AoWeno.hpp
1 // 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 
12 #include "DataStructures/DataBox/PrefixHelpers.hpp"
14 #include "DataStructures/FixedHashMap.hpp"
16 #include "Domain/Structure/MaxNumberOfNeighbors.hpp"
17 #include "Domain/Tags.hpp"
18 #include "Evolution/DgSubcell/Tags/Mesh.hpp"
19 #include "Evolution/DgSubcell/Tags/NeighborData.hpp"
20 #include "Evolution/Systems/NewtonianEuler/FiniteDifference/Reconstructor.hpp"
21 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
22 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
23 #include "PointwiseFunctions/Hydro/Tags.hpp"
24 
25 namespace NewtonianEuler::fd {
26 /*!
27  * \brief Adaptive-order WENO reconstruction hybridizing orders 5 and 3. See
28  * ::fd::reconstruction::aoweno_53() for details.
29  */
30 template <size_t Dim>
31 class AoWeno53Prim : public Reconstructor<Dim> {
32  private:
33  // Conservative vars tags
37 
38  // Primitive vars tags
43 
44  using prims_tags =
45  tmpl::list<MassDensity, Velocity, SpecificInternalEnergy, Pressure>;
46  using cons_tags = tmpl::list<MassDensityCons, MomentumDensity, EnergyDensity>;
49  using prim_tags_for_reconstruction =
50  tmpl::list<MassDensity, Velocity, Pressure>;
51 
52  public:
53  struct GammaHi {
54  using type = double;
55  static constexpr Options::String help = {
56  "The linear weight for the 5th-order stencil."};
57  };
58  struct GammaLo {
59  using type = double;
60  static constexpr Options::String help = {
61  "The linear weight for the central 3rd-order stencil."};
62  };
63  struct Epsilon {
64  using type = double;
65  static constexpr Options::String help = {
66  "The parameter added to the oscillation indicators to avoid division "
67  "by zero"};
68  };
70  using type = size_t;
71  static constexpr Options::String help = {
72  "The exponent q to which the oscillation indicators are raised"};
73  };
74 
75  using options =
76  tmpl::list<GammaHi, GammaLo, Epsilon, NonlinearWeightExponent>;
77  static constexpr Options::String help{
78  "Monotised central reconstruction scheme using primitive variables."};
79 
80  AoWeno53Prim() = default;
81  AoWeno53Prim(AoWeno53Prim&&) noexcept = default;
82  AoWeno53Prim& operator=(AoWeno53Prim&&) noexcept = default;
83  AoWeno53Prim(const AoWeno53Prim&) = default;
84  AoWeno53Prim& operator=(const AoWeno53Prim&) = default;
85  ~AoWeno53Prim() override = default;
86 
87  AoWeno53Prim(double gamma_hi, double gamma_lo, double epsilon,
88  size_t nonlinear_weight_exponent) noexcept;
89 
90  explicit AoWeno53Prim(CkMigrateMessage* msg) noexcept;
91 
92  WRAPPED_PUPable_decl_base_template(Reconstructor<Dim>, AoWeno53Prim);
93 
94  auto get_clone() const noexcept
95  -> std::unique_ptr<Reconstructor<Dim>> override;
96 
97  void pup(PUP::er& p) override;
98 
99  size_t ghost_zone_size() const noexcept override { return 3; }
100 
101  using reconstruction_argument_tags =
102  tmpl::list<::Tags::Variables<prims_tags>,
104  evolution::dg::subcell::Tags::
105  NeighborDataForReconstructionAndRdmpTci<Dim>,
107 
108  template <size_t ThermodynamicDim, typename TagsList>
109  void reconstruct(
110  gsl::not_null<std::array<Variables<TagsList>, Dim>*> vars_on_lower_face,
111  gsl::not_null<std::array<Variables<TagsList>, Dim>*> vars_on_upper_face,
112  const Variables<prims_tags>& volume_prims,
114  const Element<Dim>& element,
115  const FixedHashMap<
119  boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>&
120  neighbor_data,
121  const Mesh<Dim>& subcell_mesh) const noexcept;
122 
123  /// Called by an element doing DG when the neighbor is doing subcell.
124  template <size_t ThermodynamicDim, typename TagsList>
126  gsl::not_null<Variables<TagsList>*> vars_on_face,
127  const Variables<prims_tags>& subcell_volume_prims,
129  const Element<Dim>& element,
130  const FixedHashMap<
134  boost::hash<std::pair<Direction<Dim>, ElementId<Dim>>>>&
135  neighbor_data,
136  const Mesh<Dim>& subcell_mesh,
137  const Direction<Dim> direction_to_reconstruct) const noexcept;
138 
139  private:
140  template <size_t LocalDim>
141  // NOLINTNEXTLINE(readability-redundant-declaration)
142  friend bool operator==(const AoWeno53Prim<LocalDim>& lhs,
143  const AoWeno53Prim<LocalDim>& rhs) noexcept;
144 
145  double gamma_hi_ = std::numeric_limits<double>::signaling_NaN();
146  double gamma_lo_ = std::numeric_limits<double>::signaling_NaN();
147  double epsilon_ = std::numeric_limits<double>::signaling_NaN();
148  size_t nonlinear_weight_exponent_ = 0;
149 
150  void (*reconstruct_)(gsl::not_null<std::array<gsl::span<double>, Dim>*>,
154  const Index<Dim>&, size_t, double, double,
155  double) noexcept;
156  void (*reconstruct_lower_neighbor_)(gsl::not_null<DataVector*>,
157  const DataVector&, const DataVector&,
158  const Index<Dim>&, const Index<Dim>&,
159  const Direction<Dim>&, const double&,
160  const double&, const double&) noexcept;
161  void (*reconstruct_upper_neighbor_)(gsl::not_null<DataVector*>,
162  const DataVector&, const DataVector&,
163  const Index<Dim>&, const Index<Dim>&,
164  const Direction<Dim>&, const double&,
165  const double&, const double&) noexcept;
166 };
167 
168 template <size_t Dim>
169 bool operator!=(const AoWeno53Prim<Dim>& lhs,
170  const AoWeno53Prim<Dim>& rhs) noexcept {
171  return not(lhs == rhs);
172 }
173 } // namespace NewtonianEuler::fd
maximum_number_of_neighbors
constexpr size_t maximum_number_of_neighbors(const size_t dim)
Definition: MaxNumberOfNeighbors.hpp:15
Frame::Inertial
Definition: IndexType.hpp:44
NewtonianEuler::fd::AoWeno53Prim::GammaHi
Definition: AoWeno.hpp:53
EquationsOfState::EquationOfState
Base class for equations of state depending on whether or not the system is relativistic,...
Definition: EquationOfState.hpp:63
std::pair
Tags.hpp
domain::Tags::Element
Definition: Tags.hpp:97
NewtonianEuler::Tags::MassDensity
The mass density of the fluid.
Definition: Tags.hpp:26
NewtonianEuler::Tags::SpecificInternalEnergy
The specific internal energy of the fluid.
Definition: Tags.hpp:60
NewtonianEuler::fd::AoWeno53Prim::reconstruct_fd_neighbor
void reconstruct_fd_neighbor(gsl::not_null< Variables< TagsList > * > vars_on_face, const Variables< prims_tags > &subcell_volume_prims, const EquationsOfState::EquationOfState< false, ThermodynamicDim > &eos, const Element< Dim > &element, const FixedHashMap< maximum_number_of_neighbors(Dim)+1, std::pair< Direction< Dim >, ElementId< Dim >>, evolution::dg::subcell::NeighborData, boost::hash< std::pair< Direction< Dim >, ElementId< Dim >>>> &neighbor_data, const Mesh< Dim > &subcell_mesh, const Direction< Dim > direction_to_reconstruct) const noexcept
Called by an element doing DG when the neighbor is doing subcell.
NewtonianEuler::fd::AoWeno53Prim
Adaptive-order WENO reconstruction hybridizing orders 5 and 3. See fd::reconstruction::aoweno_53() fo...
Definition: AoWeno.hpp:31
NewtonianEuler::fd::AoWeno53Prim::GammaLo
Definition: AoWeno.hpp:58
Index
Definition: Index.hpp:31
NewtonianEuler::Tags::MassDensityCons
The mass density of the fluid (as a conservative variable).
Definition: Tags.hpp:31
NewtonianEuler::fd::AoWeno53Prim::NonlinearWeightExponent
Definition: AoWeno.hpp:69
Direction< Dim >
Element
Definition: Element.hpp:29
ElementId< Dim >
cstddef
array
NewtonianEuler::fd
Finite difference functionality for Newtonian Euler.
Definition: AoWeno.hpp:25
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
NewtonianEuler::Tags::Pressure
The fluid pressure.
Definition: Tags.hpp:66
std::numeric_limits::signaling_NaN
T signaling_NaN(T... args)
memory
NewtonianEuler::Tags::EnergyDensity
The energy density of the fluid.
Definition: Tags.hpp:45
evolution::dg::subcell::Tags::Mesh
The mesh on the subcells.
Definition: Mesh.hpp:18
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
evolution::dg::subcell::NeighborData
Holds neighbor data needed for the TCI and reconstruction.
Definition: NeighborData.hpp:24
gsl::span
Create a span/view on a range, which is cheap to copy (one pointer).
Definition: Gsl.hpp:292
DirectionMap
Definition: DirectionMap.hpp:15
NewtonianEuler::Tags::MomentumDensity
The momentum density of the fluid.
Definition: Tags.hpp:37
limits
TypeAliases.hpp
hydro::Tags::EquationOfStateBase
Base tag for the equation of state.
Definition: Tags.hpp:53
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
db::wrap_tags_in
tmpl::transform< TagList, tmpl::bind< Wrapper, tmpl::_1, tmpl::pin< Args >... > > wrap_tags_in
Create a new tmpl::list of tags by wrapping each tag in TagList in Wrapper<_, Args....
Definition: PrefixHelpers.hpp:30
NewtonianEuler::Tags::Velocity
The macroscopic or flow velocity of the fluid.
Definition: Tags.hpp:51
FixedHashMap
A hash table with a compile-time specified maximum size and ability to efficiently handle perfect has...
Definition: FixedHashMap.hpp:82
Prefixes.hpp
NewtonianEuler::fd::Reconstructor
The base class from which all reconstruction schemes must inherit.
Definition: Reconstructor.hpp:33
NewtonianEuler::fd::AoWeno53Prim::Epsilon
Definition: AoWeno.hpp:63
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13