Step.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <limits>
7 
8 #include "DataStructures/DataBox/Prefixes.hpp" // IWYU pragma: keep
10 #include "Evolution/Systems/Burgers/Tags.hpp" // IWYU pragma: keep
11 #include "Options/Options.hpp"
12 #include "Utilities/TMPL.hpp"
14 
15 /// \cond
16 class DataVector;
17 // IWYU pragma: no_forward_declare Tensor
18 namespace PUP {
19 class er;
20 } // namespace PUP
21 /// \endcond
22 
23 namespace Burgers {
24 namespace Solutions {
25 /// \brief A propagating shock between two constant states
26 ///
27 /// The shock propagates left-to-right, with profile
28 /// \f$U(x, t) = U_R + (U_L - U_R) H(-(x - x_0 - v t))\f$.
29 /// Here \f$U_L\f$ and \f$U_R\f$ are the left and right constant states,
30 /// satisfying \f$U_L > U_R\f$; \f$H\f$ is the Heaviside function; \f$x_0\f$ is
31 /// the initial (i.e., \f$t=0\f$) position of the shock; and
32 /// \f$v = 0.5 (U_L + U_R)\f$ is the speed of the shock.
33 ///
34 /// \note At the shock, where \f$x = x_0 + vt\f$, we have \f$U(x, t) = U_L\f$.
35 /// (This is inherited from the Heaviside implementation `step_function`.)
36 /// Additionally, the time derivative \f$\partial_t u0\f$ is zero, rather than
37 /// the correct delta function.
38 class Step {
39  public:
40  struct LeftValue {
41  using type = double;
42  static type lower_bound() noexcept { return 0.0; }
43  static type default_value() noexcept { return 2.0; }
44  static constexpr OptionString help{"The value of U, left of the shock"};
45  };
46  struct RightValue {
47  using type = double;
48  static type lower_bound() noexcept { return 0.0; }
49  static type default_value() noexcept { return 1.0; }
50  static constexpr OptionString help{"The value of U, right of the shock"};
51  };
52  struct InitialPosition {
53  using type = double;
54  static constexpr OptionString help{"The shock's position at t==0"};
55  };
56 
57  using options = tmpl::list<LeftValue, RightValue, InitialPosition>;
58  static constexpr OptionString help{"A propagating shock solution"};
59 
60  Step(double left_value, double right_value, double initial_shock_position,
61  const OptionContext& context = {});
62 
63  Step() = default;
64  Step(const Step&) noexcept = default;
65  Step& operator=(const Step&) noexcept = default;
66  Step(Step&&) noexcept = default;
67  Step& operator=(Step&&) noexcept = default;
68  ~Step() noexcept = default;
69 
70  template <typename T>
71  Scalar<T> u(const tnsr::I<T, 1>& x, double t) const noexcept;
72 
73  template <typename T>
74  Scalar<T> du_dt(const tnsr::I<T, 1>& x, double t) const noexcept;
75 
76  tuples::TaggedTuple<Tags::U> variables(const tnsr::I<DataVector, 1>& x,
77  double t,
78  tmpl::list<Tags::U> /*meta*/) const
79  noexcept;
80 
82  const tnsr::I<DataVector, 1>& x, double t,
83  tmpl::list<::Tags::dt<Tags::U>> /*meta*/) const noexcept;
84 
85  // clang-tidy: no pass by reference
86  void pup(PUP::er& p) noexcept; // NOLINT
87 
88  private:
89  double left_value_ = std::numeric_limits<double>::signaling_NaN();
90  double right_value_ = std::numeric_limits<double>::signaling_NaN();
91  double initial_shock_position_ = std::numeric_limits<double>::signaling_NaN();
92 };
93 } // namespace Solutions
94 } // namespace Burgers
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
T signaling_NaN(T... args)
Defines classes and functions for making classes creatable from input files.
Define prefixes for DataBox tags.
Prefix indicating a time derivative.
Definition: Prefixes.hpp:28
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
A propagating shock between two constant states.
Definition: Step.hpp:38
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines a list of useful type aliases for tensors.
Stores a collection of function values.
Definition: DataVector.hpp:46
Information about the nested operations being performed by the parser, for use in printing errors...
Definition: Options.hpp:36
Wraps the template metaprogramming library used (brigand)
Items related to evolving the Burgers equation .
Definition: Equations.cpp:20
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21