ShuOsherTube.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 Initial data for the Shu-Osher oscillatory shock tube \cite Shu1988439
32  *
33  * The general initial data is given by:
34  *
35  * \f{align*}{
36  * \{\rho,v^x,p\}=
37  * \left\{
38  * \begin{array}{ll}
39  * \left\{\rho_L, v^x_L, p_L\right\} &\mathrm{if} \;\;\; x<\Delta \\
40  * \left\{1+\epsilon\sin(\lambda x), v^x_R, p_R\right\} &\mathrm{if} \;\;\;
41  * x\ge \Delta
42  * \end{array}\right.
43  * \f}
44  *
45  * with the adiabatic index being 1.4.
46  *
47  * With the standard parameters given below, this is a Mach-3 shock moving into
48  * a sinusoidal density profile.
49  *
50  * \f{align*}{
51  * \{\rho,v^x,p\}=
52  * \left\{
53  * \begin{array}{ll}
54  * \left\{3.857143, 2.629369, 10.33333\right\} &\mathrm{if} \;\;\; x<-4 \\
55  * \left\{1+0.2\sin(5x), 0, 1\right\} &\mathrm{if} \;\;\; x\ge -4
56  * \end{array}\right.
57  * \f}
58  *
59  * With these values the usual final time is 1.8.
60  */
61 class ShuOsherTube : public MarkAsAnalyticData {
62  public:
65 
66  /// Initial postition of the discontinuity
67  struct JumpPosition {
68  using type = double;
69  static constexpr Options::String help = {
70  "The initial position of the discontinuity."};
71  };
72 
73  struct LeftMassDensity {
74  using type = double;
75  static constexpr Options::String help = {"The left mass density."};
76  static type lower_bound() noexcept { return 0.0; }
77  };
78 
79  struct LeftVelocity {
80  using type = double;
81  static constexpr Options::String help = {"The left velocity."};
82  };
83 
84  struct LeftPressure {
85  using type = double;
86  static constexpr Options::String help = {"The left pressure."};
87  static type lower_bound() noexcept { return 0.0; }
88  };
89 
90  struct RightVelocity {
91  using type = double;
92  static constexpr Options::String help = {"The right velocity."};
93  };
94 
95  struct RightPressure {
96  using type = double;
97  static constexpr Options::String help = {"The right pressure."};
98  static type lower_bound() noexcept { return 0.0; }
99  };
100 
101  struct Epsilon {
102  using type = double;
103  static constexpr Options::String help = {"Sinusoid amplitude."};
104  static type lower_bound() noexcept { return 0.0; }
105  static type upper_bound() noexcept { return 1.0; }
106  };
107 
108  struct Lambda {
109  using type = double;
110  static constexpr Options::String help = {"Sinusoid wavelength."};
111  };
112 
113  static constexpr Options::String help = {
114  "1D Shu-Osher oscillatory shock tube."};
115 
116  using options =
117  tmpl::list<JumpPosition, LeftMassDensity, LeftVelocity, LeftPressure,
118  RightVelocity, RightPressure, Epsilon, Lambda>;
119 
120  ShuOsherTube(double jump_position, double mass_density_l, double velocity_l,
121  double pressure_l, double velocity_r, double pressure_r,
122  double epsilon, double lambda) noexcept;
123  ShuOsherTube() = default;
124  ShuOsherTube(const ShuOsherTube& /*rhs*/) = delete;
125  ShuOsherTube& operator=(const ShuOsherTube& /*rhs*/) = delete;
126  ShuOsherTube(ShuOsherTube&& /*rhs*/) noexcept = default;
127  ShuOsherTube& operator=(ShuOsherTube&& /*rhs*/) noexcept = default;
128  ~ShuOsherTube() = default;
129 
130  template <typename DataType, typename... Tags>
131  tuples::TaggedTuple<Tags...> variables(
132  const tnsr::I<DataType, 1, Frame::Inertial>& x,
133  tmpl::list<Tags...> /*meta*/) const noexcept {
134  return {tuples::get<Tags>(variables(x, tmpl::list<Tags>{}))...};
135  }
136 
137  const EquationsOfState::IdealFluid<false>& equation_of_state()
138  const noexcept {
139  return equation_of_state_;
140  }
141 
142  // clang-tidy: no runtime references
143  void pup(PUP::er& p) noexcept; // NOLINT
144 
145  private:
146  template <typename DataType>
147  auto variables(const tnsr::I<DataType, 1, Frame::Inertial>& x,
148  tmpl::list<Tags::MassDensity<DataType>> /*meta*/)
149  const noexcept -> tuples::TaggedTuple<Tags::MassDensity<DataType>>;
150 
151  template <typename DataType>
152  auto variables(
153  const tnsr::I<DataType, 1, Frame::Inertial>& x,
154  tmpl::list<Tags::Velocity<DataType, 1, Frame::Inertial>> /*meta*/)
155  const noexcept
156  -> tuples::TaggedTuple<Tags::Velocity<DataType, 1, Frame::Inertial>>;
157 
158  template <typename DataType>
159  auto variables(const tnsr::I<DataType, 1, Frame::Inertial>& x,
160  tmpl::list<Tags::Pressure<DataType>> /*meta*/) const noexcept
161  -> tuples::TaggedTuple<Tags::Pressure<DataType>>;
162 
163  template <typename DataType>
164  auto variables(const tnsr::I<DataType, 1, Frame::Inertial>& x,
165  tmpl::list<Tags::SpecificInternalEnergy<DataType>> /*meta*/)
166  const noexcept
167  -> tuples::TaggedTuple<Tags::SpecificInternalEnergy<DataType>>;
168 
169  friend bool
170  operator==( // NOLINT (clang-tidy: readability-redundant-declaration)
171  const ShuOsherTube& lhs, const ShuOsherTube& rhs) noexcept;
172 
173  double mass_density_l_ = std::numeric_limits<double>::signaling_NaN();
174  double velocity_l_ = std::numeric_limits<double>::signaling_NaN();
175  double pressure_l_ = std::numeric_limits<double>::signaling_NaN();
176  double jump_position_ = std::numeric_limits<double>::signaling_NaN();
177  double epsilon_ = std::numeric_limits<double>::signaling_NaN();
178  double lambda_ = std::numeric_limits<double>::signaling_NaN();
179  double velocity_r_ = std::numeric_limits<double>::signaling_NaN();
180  double pressure_r_ = std::numeric_limits<double>::signaling_NaN();
181  double adiabatic_index_ = 1.4;
182  EquationsOfState::IdealFluid<false> equation_of_state_{adiabatic_index_};
183 };
184 
185 bool operator!=(const ShuOsherTube& lhs, const ShuOsherTube& rhs) noexcept;
186 } // namespace NewtonianEuler::AnalyticData
NewtonianEuler::AnalyticData::ShuOsherTube::LeftVelocity
Definition: ShuOsherTube.hpp:79
EquationsOfState
Contains all equations of state, including base class.
Definition: DarkEnergyFluid.hpp:26
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::AnalyticData::ShuOsherTube::Epsilon
Definition: ShuOsherTube.hpp:101
NewtonianEuler::AnalyticData
Holds classes implementing analytic data for the NewtonianEuler system.
Definition: EvolveNewtonianEulerFwd.hpp:9
NewtonianEuler::AnalyticData::ShuOsherTube
Initial data for the Shu-Osher oscillatory shock tube .
Definition: ShuOsherTube.hpp:61
NewtonianEuler::AnalyticData::ShuOsherTube::RightVelocity
Definition: ShuOsherTube.hpp:90
NewtonianEuler::AnalyticData::ShuOsherTube::Lambda
Definition: ShuOsherTube.hpp:108
cstddef
EquationsOfState::IdealFluid< false >
array
NewtonianEuler::AnalyticData::ShuOsherTube::LeftMassDensity
Definition: ShuOsherTube.hpp:73
NewtonianEuler::AnalyticData::ShuOsherTube::JumpPosition
Initial postition of the discontinuity.
Definition: ShuOsherTube.hpp:67
NewtonianEuler::AnalyticData::ShuOsherTube::LeftPressure
Definition: ShuOsherTube.hpp:84
tnsr
Type aliases to construct common Tensors.
Definition: TypeAliases.hpp:31
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::ShuOsherTube::RightPressure
Definition: ShuOsherTube.hpp:95
TMPL.hpp