Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <boost/functional/hash.hpp>
8 : #include <cstddef>
9 : #include <limits>
10 : #include <memory>
11 : #include <utility>
12 :
13 : #include "DataStructures/DataBox/Prefixes.hpp"
14 : #include "DataStructures/FixedHashMap.hpp"
15 : #include "DataStructures/Tensor/TypeAliases.hpp"
16 : #include "Domain/Structure/MaxNumberOfNeighbors.hpp"
17 : #include "Domain/Tags.hpp"
18 : #include "Evolution/DgSubcell/Tags/GhostDataForReconstruction.hpp"
19 : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
20 : #include "Evolution/Systems/ScalarAdvection/FiniteDifference/Reconstructor.hpp"
21 : #include "Evolution/Systems/ScalarAdvection/Tags.hpp"
22 : #include "Options/String.hpp"
23 : #include "Utilities/TMPL.hpp"
24 :
25 : /// \cond
26 : class DataVector;
27 : template <size_t Dim>
28 : class Direction;
29 : template <size_t Dim>
30 : class Element;
31 : template <size_t Dim>
32 : class ElementId;
33 : template <size_t Dim>
34 : class Mesh;
35 : template <typename TagsList>
36 : class Variables;
37 : namespace gsl {
38 : template <typename>
39 : class not_null;
40 : } // namespace gsl
41 : namespace Tags {
42 : template <typename TagsList>
43 : class Variables;
44 : } // namespace Tags
45 : namespace PUP {
46 : class er;
47 : } // namespace PUP
48 : namespace evolution::dg::subcell {
49 : class GhostData;
50 : } // namespace evolution::dg::subcell
51 : /// \endcond
52 :
53 1 : namespace ScalarAdvection::fd {
54 : /*!
55 : * \brief Adaptive-order WENO reconstruction hybridizing orders 5 and 3. See
56 : * ::fd::reconstruction::aoweno_53() for details.
57 : */
58 : template <size_t Dim>
59 1 : class AoWeno53 : public Reconstructor<Dim> {
60 : private:
61 0 : using face_vars_tags =
62 : tmpl::list<Tags::U,
63 : ::Tags::Flux<Tags::U, tmpl::size_t<Dim>, Frame::Inertial>>;
64 0 : using volume_vars_tags = tmpl::list<Tags::U>;
65 :
66 : public:
67 0 : struct GammaHi {
68 0 : using type = double;
69 0 : static constexpr Options::String help = {
70 : "The linear weight for the 5th-order stencil."};
71 : };
72 0 : struct GammaLo {
73 0 : using type = double;
74 0 : static constexpr Options::String help = {
75 : "The linear weight for the central 3rd-order stencil."};
76 : };
77 0 : struct Epsilon {
78 0 : using type = double;
79 0 : static constexpr Options::String help = {
80 : "The parameter added to the oscillation indicators to avoid division "
81 : "by zero"};
82 : };
83 0 : struct NonlinearWeightExponent {
84 0 : using type = size_t;
85 0 : static constexpr Options::String help = {
86 : "The exponent q to which the oscillation indicators are raised"};
87 : };
88 :
89 0 : using options =
90 : tmpl::list<GammaHi, GammaLo, Epsilon, NonlinearWeightExponent>;
91 0 : static constexpr Options::String help{
92 : "Adaptive-order WENO reconstruction hybridizing orders 5 and 3."};
93 :
94 0 : AoWeno53() = default;
95 0 : AoWeno53(AoWeno53&&) = default;
96 0 : AoWeno53& operator=(AoWeno53&&) = default;
97 0 : AoWeno53(const AoWeno53&) = default;
98 0 : AoWeno53& operator=(const AoWeno53&) = default;
99 0 : ~AoWeno53() override = default;
100 :
101 0 : AoWeno53(double gamma_hi, double gamma_lo, double epsilon,
102 : size_t nonlinear_weight_exponent);
103 :
104 0 : explicit AoWeno53(CkMigrateMessage* msg);
105 :
106 0 : WRAPPED_PUPable_decl_base_template(Reconstructor<Dim>, AoWeno53);
107 :
108 0 : auto get_clone() const -> std::unique_ptr<Reconstructor<Dim>> override;
109 :
110 0 : void pup(PUP::er& p) override;
111 :
112 0 : size_t ghost_zone_size() const override { return 3; }
113 :
114 0 : using reconstruction_argument_tags =
115 : tmpl::list<::Tags::Variables<volume_vars_tags>,
116 : domain::Tags::Element<Dim>,
117 : evolution::dg::subcell::Tags::GhostDataForReconstruction<Dim>,
118 : evolution::dg::subcell::Tags::Mesh<Dim>>;
119 :
120 : template <typename TagsList>
121 0 : void reconstruct(
122 : gsl::not_null<std::array<Variables<TagsList>, Dim>*> vars_on_lower_face,
123 : gsl::not_null<std::array<Variables<TagsList>, Dim>*> vars_on_upper_face,
124 : const Variables<tmpl::list<Tags::U>>& volume_vars,
125 : const Element<Dim>& element,
126 : const FixedHashMap<
127 : maximum_number_of_neighbors(Dim),
128 : std::pair<Direction<Dim>, ElementId<Dim>>,
129 : evolution::dg::subcell::GhostData,
130 : boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>& ghost_data,
131 : const Mesh<Dim>& subcell_mesh) const;
132 :
133 : template <typename TagsList>
134 0 : void reconstruct_fd_neighbor(
135 : gsl::not_null<Variables<TagsList>*> vars_on_face,
136 : const Variables<tmpl::list<Tags::U>>& volume_vars,
137 : const Element<Dim>& element,
138 : const FixedHashMap<
139 : maximum_number_of_neighbors(Dim),
140 : std::pair<Direction<Dim>, ElementId<Dim>>,
141 : evolution::dg::subcell::GhostData,
142 : boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>& ghost_data,
143 : const Mesh<Dim>& subcell_mesh,
144 : const Direction<Dim> direction_to_reconstruct) const;
145 :
146 : private:
147 : template <size_t LocalDim>
148 : // NOLINTNEXTLINE(readability-redundant-declaration)
149 0 : friend bool operator==(const AoWeno53<LocalDim>& lhs,
150 : const AoWeno53<LocalDim>& rhs);
151 :
152 0 : double gamma_hi_ = std::numeric_limits<double>::signaling_NaN();
153 0 : double gamma_lo_ = std::numeric_limits<double>::signaling_NaN();
154 0 : double epsilon_ = std::numeric_limits<double>::signaling_NaN();
155 0 : size_t nonlinear_weight_exponent_ = 0;
156 :
157 0 : void (*reconstruct_)(gsl::not_null<std::array<gsl::span<double>, Dim>*>,
158 : gsl::not_null<std::array<gsl::span<double>, Dim>*>,
159 : const gsl::span<const double>&,
160 : const DirectionMap<Dim, gsl::span<const double>>&,
161 : const Index<Dim>&, size_t, double, double, double);
162 0 : void (*reconstruct_lower_neighbor_)(gsl::not_null<DataVector*>,
163 : const DataVector&, const DataVector&,
164 : const Index<Dim>&, const Index<Dim>&,
165 : const Direction<Dim>&, const double&,
166 : const double&, const double&);
167 0 : void (*reconstruct_upper_neighbor_)(gsl::not_null<DataVector*>,
168 : const DataVector&, const DataVector&,
169 : const Index<Dim>&, const Index<Dim>&,
170 : const Direction<Dim>&, const double&,
171 : const double&, const double&);
172 : };
173 :
174 : template <size_t Dim>
175 0 : bool operator==(const AoWeno53<Dim>& lhs, const AoWeno53<Dim>& rhs);
176 :
177 : template <size_t Dim>
178 0 : bool operator!=(const AoWeno53<Dim>& lhs, const AoWeno53<Dim>& rhs);
179 : } // namespace ScalarAdvection::fd
|