Bump.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 /*!
26  * \brief A solution resembling a bump.
27  *
28  * At \f$t=0\f$, the solution is a parabola:
29  * \f{equation*}
30  * u(x, t) = h \left(1 - \left(\frac{x - c}{w}\right)^2\right),
31  * \f}
32  * where \f$h\f$ is the height, \f$c\f$ is the center, and \f$w\f$ is
33  * the distance from the center to the zeros. A shock propagates in
34  * from infinity and reaches one of the zeros at \f$t = \frac{w}{2
35  * h}\f$.
36  */
37 class Bump {
38  public:
39  struct HalfWidth {
40  using type = double;
41  static constexpr OptionString help{
42  "The distance from the center to the zero of the bump"};
43  static type lower_bound() noexcept { return 0.; }
44  };
45 
46  struct Height {
47  using type = double;
48  static constexpr OptionString help{"The height of the bump"};
49  };
50 
51  struct Center {
52  using type = double;
53  static constexpr OptionString help{"The center of the bump"};
54  static type default_value() noexcept { return 0.; }
55  };
56 
57  using options = tmpl::list<HalfWidth, Height, Center>;
58  static constexpr OptionString help{"A bump solution"};
59 
60  Bump() = default;
61  Bump(const Bump&) noexcept = delete;
62  Bump& operator=(const Bump&) noexcept = delete;
63  Bump(Bump&&) noexcept = default;
64  Bump& operator=(Bump&&) noexcept = default;
65  ~Bump() noexcept = default;
66 
67  Bump(double half_width, double height, double center = 0.) noexcept;
68 
69  template <typename T>
70  Scalar<T> u(const tnsr::I<T, 1>& x, double t) const noexcept;
71 
72  template <typename T>
73  Scalar<T> du_dt(const tnsr::I<T, 1>& x, double t) const noexcept;
74 
76  const tnsr::I<DataVector, 1>& x, double t,
77  tmpl::list<Tags::U> /*meta*/) const noexcept;
78 
80  const tnsr::I<DataVector, 1>& x, double t,
81  tmpl::list<::Tags::dt<Tags::U>> /*meta*/) const noexcept;
82 
83  // clang-tidy: no pass by reference
84  void pup(PUP::er& p) noexcept; // NOLINT
85 
86  private:
87  double half_width_ = std::numeric_limits<double>::signaling_NaN();
90 };
91 } // namespace Solutions
92 } // 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:26
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Definition: Bump.hpp:51
Defines a list of useful type aliases for tensors.
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
Definition: Bump.hpp:46
Items related to evolving the Burgers equation .
Definition: Equations.cpp:20
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
A solution resembling a bump.
Definition: Bump.hpp:37