Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <cstddef>
8 : #include <pup.h>
9 :
10 : #include "Options/Context.hpp"
11 : #include "Options/String.hpp"
12 : #include "Utilities/Serialization/CharmPupable.hpp"
13 : #include "Utilities/TMPL.hpp"
14 :
15 : /// \cond
16 : namespace PUP {
17 : class er;
18 : } // namespace PUP
19 : /// \endcond
20 :
21 : namespace ylm {
22 : template <typename Frame>
23 : class Strahlkorper;
24 :
25 : /*!
26 : * \ingroup SurfacesGroup
27 : * \brief Base class for constructing initial Strahlkorper shapes.
28 : * \details When constructing a Stahlkorper from options (such as the
29 : * initial guess for an apparent horizon), the user can specify a resolution
30 : * and a shape (such as spherical, or read from file).
31 : */
32 : template <typename Frame>
33 1 : class InitialShape : public PUP::able {
34 : protected:
35 : /// \cond
36 : InitialShape() = default;
37 : InitialShape(const InitialShape&) = default;
38 : InitialShape(InitialShape&&) = default;
39 : InitialShape& operator=(const InitialShape&) = default;
40 : InitialShape& operator=(InitialShape&&) = default;
41 : /// \endcond
42 :
43 : public:
44 0 : ~InitialShape() override = default;
45 0 : explicit InitialShape(CkMigrateMessage* msg) : PUP::able(msg) {}
46 :
47 0 : WRAPPED_PUPable_abstract(InitialShape);
48 :
49 : /// Construct a Strahlkorper with both `l_max` and `m_max` set to `l_max`.
50 : /// The `context` is used to report option-parsing errors.
51 1 : virtual Strahlkorper<Frame> strahlkorper(
52 : size_t l_max, const Options::Context& context) const = 0;
53 : };
54 :
55 0 : namespace InitialShapes {
56 : /*!
57 : * \ingroup SurfacesGroup
58 : * \brief A spherical initial Strahlkorper shape.
59 : */
60 : template <typename Frame>
61 1 : class Sphere : public InitialShape<Frame> {
62 : public:
63 0 : struct Center {
64 0 : using type = std::array<double, 3>;
65 0 : static constexpr Options::String help = {
66 : "Center of the Strahlkorper expansion"};
67 : };
68 0 : struct Radius {
69 0 : using type = double;
70 0 : static constexpr Options::String help = {
71 : "Radius of spherical Strahlkorper"};
72 : };
73 :
74 0 : using options = tmpl::list<Center, Radius>;
75 0 : static constexpr Options::String help = {
76 : "Construct a spherical Strahlkorper."};
77 0 : static std::string name() { return "Sphere"; }
78 :
79 0 : Sphere() = default;
80 0 : Sphere(std::array<double, 3> center, double radius);
81 :
82 : /// \cond
83 : explicit Sphere(CkMigrateMessage* msg);
84 : using PUP::able::register_constructor;
85 : WRAPPED_PUPable_decl_template(Sphere); // NOLINT
86 : /// \endcond
87 :
88 1 : Strahlkorper<Frame> strahlkorper(
89 : size_t l_max, const Options::Context& context) const override;
90 :
91 0 : void pup(PUP::er& p) override;
92 :
93 : private:
94 0 : std::array<double, 3> center_{};
95 0 : double radius_{};
96 : };
97 :
98 : } // namespace InitialShapes
99 : } // namespace ylm
|