SodExplosion.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <cstddef>
8 #include <limits>
9 
10 #include "DataStructures/DataVector.hpp"
13 #include "Evolution/Systems/NewtonianEuler/Sources/NoSource.hpp"
14 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
15 #include "Options/Options.hpp"
16 #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
17 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
18 #include "PointwiseFunctions/Hydro/EquationsOfState/IdealFluid.hpp"
19 #include "Utilities/MakeArray.hpp"
20 #include "Utilities/TMPL.hpp"
21 #include "Utilities/TaggedTuple.hpp"
22 
23 /// \cond
24 namespace PUP {
25 class er; // IWYU pragma: keep
26 } // namespace PUP
27 /// \endcond
28 
30 /*!
31  * \brief A cylindrical or spherical Sod explosion \cite Toro2009 \cite Sod19781
32  *
33  * Common initial conditions are:
34  *
35  * \f{align*}{
36  * (\rho, v^i, p) =
37  * &\left\{
38  * \begin{array}{ll}
39  * (1 ,0, 1) & \mathrm{if} \; r \le 0.5 \\
40  * (0.125 ,0, 0.1) & \mathrm{if} \; r > 0.5
41  * \end{array}\right.
42  * \f}
43  *
44  * where \f$r\f$ is the cylindrical (2d) or spherical (3d) radius. This test
45  * problem uses an adiabatic index of 1.4. A reference solution can be computed
46  * in 1d by solving the Newtonian Euler equations in cylindrical or spherical
47  * symmetry. Note that the inner and outer density and pressure, as well as
48  * where the initial discontinuity is can be chosen arbitrarily.
49  */
50 template <size_t Dim>
51 class SodExplosion : public MarkAsAnalyticData {
52  public:
53  static_assert(Dim > 1, "Sod explosion is a 2d and 3d problem.");
56 
57  /// Initial radius of the discontinuity
58  struct InitialRadius {
59  using type = double;
60  static constexpr Options::String help = {
61  "The initial radius of the discontinuity."};
62  static type lower_bound() noexcept { return 0.0; }
63  };
64 
66  using type = double;
67  static constexpr Options::String help = {"The inner mass density."};
68  static type lower_bound() noexcept { return 0.0; }
69  };
70 
71  struct InnerPressure {
72  using type = double;
73  static constexpr Options::String help = {"The inner pressure."};
74  static type lower_bound() noexcept { return 0.0; }
75  };
76 
78  using type = double;
79  static constexpr Options::String help = {"The outer mass density."};
80  static type lower_bound() noexcept { return 0.0; }
81  };
82 
83  struct OuterPressure {
84  using type = double;
85  static constexpr Options::String help = {"The outer pressure."};
86  static type lower_bound() noexcept { return 0.0; }
87  };
88 
89  using options = tmpl::list<InitialRadius, InnerMassDensity, InnerPressure,
91 
92  static constexpr Options::String help = {
93  "Cylindrical or spherical Sod explosion."};
94 
95  SodExplosion() = default;
96  SodExplosion(const SodExplosion& /*rhs*/) = delete;
97  SodExplosion& operator=(const SodExplosion& /*rhs*/) = delete;
98  SodExplosion(SodExplosion&& /*rhs*/) noexcept = default;
99  SodExplosion& operator=(SodExplosion&& /*rhs*/) noexcept = default;
100  ~SodExplosion() = default;
101 
102  SodExplosion(double initial_radius, double inner_mass_density,
103  double inner_pressure, double outer_mass_density,
104  double outer_pressure, const Options::Context& context = {});
105 
106  /// Retrieve a collection of hydrodynamic variables at position x
107  template <typename... Tags>
109  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
110  tmpl::list<Tags...> /*meta*/) const noexcept {
111  return {tuples::get<Tags>(variables(x, tmpl::list<Tags>{}))...};
112  }
113 
114  const equation_of_state_type& equation_of_state() const noexcept {
115  return equation_of_state_;
116  }
117 
118  // clang-tidy: no runtime references
119  void pup(PUP::er& /*p*/) noexcept; // NOLINT
120 
121  private:
123  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
124  tmpl::list<Tags::MassDensity<DataVector>> /*meta*/) const noexcept;
125 
126  tuples::TaggedTuple<Tags::Velocity<DataVector, Dim, Frame::Inertial>>
127  variables(
128  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
129  tmpl::list<Tags::Velocity<DataVector, Dim, Frame::Inertial>> /*meta*/)
130  const noexcept;
131 
132  tuples::TaggedTuple<Tags::Pressure<DataVector>> variables(
133  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
134  tmpl::list<Tags::Pressure<DataVector>> /*meta*/) const noexcept;
135 
136  tuples::TaggedTuple<Tags::SpecificInternalEnergy<DataVector>> variables(
137  const tnsr::I<DataVector, Dim, Frame::Inertial>& x,
138  tmpl::list<Tags::SpecificInternalEnergy<DataVector>> /*meta*/)
139  const noexcept;
140 
141  template <size_t SpatialDim>
142  friend bool
143  operator==( // NOLINT (clang-tidy: readability-redundant-declaration)
144  const SodExplosion<SpatialDim>& lhs,
145  const SodExplosion<SpatialDim>& rhs) noexcept;
146 
147  double initial_radius_ = std::numeric_limits<double>::signaling_NaN();
148  double inner_mass_density_ = std::numeric_limits<double>::signaling_NaN();
149  double inner_pressure_ = std::numeric_limits<double>::signaling_NaN();
150  double outer_mass_density_ = std::numeric_limits<double>::signaling_NaN();
151  double outer_pressure_ = std::numeric_limits<double>::signaling_NaN();
152  equation_of_state_type equation_of_state_{};
153 };
154 
155 template <size_t Dim>
156 bool operator!=(const SodExplosion<Dim>& lhs,
157  const SodExplosion<Dim>& rhs) noexcept;
158 } // namespace NewtonianEuler::AnalyticData
NewtonianEuler::AnalyticData::SodExplosion::InnerMassDensity
Definition: SodExplosion.hpp:65
std::rel_ops::operator!=
T operator!=(T... args)
NewtonianEuler::Sources::NoSource
Used to mark that the initial data do not require source terms in the evolution equations.
Definition: NoSource.hpp:21
Options.hpp
MakeArray.hpp
NewtonianEuler::Tags::MassDensity
The mass density of the fluid.
Definition: Tags.hpp:26
NewtonianEuler::AnalyticData
Holds classes implementing analytic data for the NewtonianEuler system.
Definition: EvolveNewtonianEulerFwd.hpp:9
Options
Utilities for parsing input files.
Definition: MinmodType.hpp:8
cstddef
NewtonianEuler::AnalyticData::SodExplosion::OuterMassDensity
Definition: SodExplosion.hpp:77
EquationsOfState::IdealFluid< false >
array
NewtonianEuler::AnalyticData::SodExplosion
A cylindrical or spherical Sod explosion .
Definition: SodExplosion.hpp:51
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
NewtonianEuler::AnalyticData::SodExplosion::InitialRadius
Initial radius of the discontinuity.
Definition: SodExplosion.hpp:58
NewtonianEuler::AnalyticData::SodExplosion::variables
tuples::TaggedTuple< Tags... > variables(const tnsr::I< DataVector, Dim, Frame::Inertial > &x, tmpl::list< Tags... >) const noexcept
Retrieve a collection of hydrodynamic variables at position x.
Definition: SodExplosion.hpp:108
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
NewtonianEuler::AnalyticData::SodExplosion::OuterPressure
Definition: SodExplosion.hpp:83
limits
TypeAliases.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
Tensor.hpp
NewtonianEuler::AnalyticData::SodExplosion::InnerPressure
Definition: SodExplosion.hpp:71
TMPL.hpp