Line data Source code
1 0 : // 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"
9 : #include "DataStructures/TaggedTuple.hpp"
10 : #include "DataStructures/Tensor/TypeAliases.hpp"
11 : #include "Evolution/Systems/Burgers/Tags.hpp"
12 : #include "Options/String.hpp"
13 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
14 : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
15 : #include "Utilities/Serialization/CharmPupable.hpp"
16 : #include "Utilities/TMPL.hpp"
17 :
18 : /// \cond
19 : class DataVector;
20 :
21 : namespace PUP {
22 : class er;
23 : } // namespace PUP
24 : /// \endcond
25 :
26 1 : namespace Burgers::Solutions {
27 : /*!
28 : * \brief A solution resembling a bump.
29 : *
30 : * At \f$t=0\f$, the solution is a parabola:
31 : * \f{equation*}
32 : * u(x, t) = h \left(1 - \left(\frac{x - c}{w}\right)^2\right),
33 : * \f}
34 : * where \f$h\f$ is the height, \f$c\f$ is the center, and \f$w\f$ is
35 : * the distance from the center to the zeros. A shock propagates in
36 : * from infinity and reaches one of the zeros at \f$t = \frac{w}{2
37 : * h}\f$.
38 : */
39 1 : class Bump : public evolution::initial_data::InitialData,
40 : public MarkAsAnalyticSolution {
41 : public:
42 0 : struct HalfWidth {
43 0 : using type = double;
44 0 : static constexpr Options::String help{
45 : "The distance from the center to the zero of the bump"};
46 0 : static type lower_bound() { return 0.; }
47 : };
48 :
49 0 : struct Height {
50 0 : using type = double;
51 0 : static constexpr Options::String help{"The height of the bump"};
52 : };
53 :
54 0 : struct Center {
55 0 : using type = double;
56 0 : static constexpr Options::String help{"The center of the bump"};
57 : };
58 :
59 0 : using options = tmpl::list<HalfWidth, Height, Center>;
60 0 : static constexpr Options::String help{"A bump solution"};
61 :
62 0 : Bump() = default;
63 0 : Bump(const Bump&) = default;
64 0 : Bump& operator=(const Bump&) = default;
65 0 : Bump(Bump&&) = default;
66 0 : Bump& operator=(Bump&&) = default;
67 0 : ~Bump() override = default;
68 :
69 0 : Bump(double half_width, double height, double center = 0.);
70 :
71 0 : auto get_clone() const
72 : -> std::unique_ptr<evolution::initial_data::InitialData> override;
73 :
74 : /// \cond
75 : explicit Bump(CkMigrateMessage* msg);
76 : using PUP::able::register_constructor;
77 : WRAPPED_PUPable_decl_template(Bump);
78 : /// \endcond
79 :
80 : template <typename T>
81 0 : Scalar<T> u(const tnsr::I<T, 1>& x, double t) const;
82 :
83 : template <typename T>
84 0 : Scalar<T> du_dt(const tnsr::I<T, 1>& x, double t) const;
85 :
86 0 : tuples::TaggedTuple<Tags::U> variables(const tnsr::I<DataVector, 1>& x,
87 : double t,
88 : tmpl::list<Tags::U> /*meta*/) const;
89 :
90 0 : tuples::TaggedTuple<::Tags::dt<Burgers::Tags::U>> variables(
91 : const tnsr::I<DataVector, 1>& x, double t,
92 : tmpl::list<::Tags::dt<Tags::U>> /*meta*/) const;
93 :
94 : // NOLINTNEXTLINE(google-runtime-references)
95 0 : void pup(PUP::er& p) override;
96 :
97 : private:
98 0 : double half_width_ = std::numeric_limits<double>::signaling_NaN();
99 0 : double height_ = std::numeric_limits<double>::signaling_NaN();
100 0 : double center_ = std::numeric_limits<double>::signaling_NaN();
101 : };
102 : } // namespace Burgers::Solutions
|