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 <limits>
9 : #include <memory>
10 : #include <optional>
11 : #include <string>
12 : #include <unordered_map>
13 : #include <vector>
14 :
15 : #include "Domain/CoordinateMaps/CoordinateMap.hpp"
16 : #include "Domain/CoordinateMaps/TimeDependent/SphericalCompression.hpp"
17 : #include "Domain/Creators/TimeDependence/GenerateCoordinateMap.hpp"
18 : #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
19 : #include "Options/Auto.hpp"
20 : #include "Options/Context.hpp"
21 : #include "Options/String.hpp"
22 : #include "Utilities/ErrorHandling/Assert.hpp"
23 : #include "Utilities/TMPL.hpp"
24 :
25 : /// \cond
26 : namespace domain::FunctionsOfTime {
27 : class FunctionOfTime;
28 : } // namespace domain::FunctionsOfTime
29 : namespace domain::CoordinateMaps::TimeDependent {
30 : template <bool InertiorMap>
31 : class SphericalCompression;
32 : } // namespace domain::CoordinateMaps::TimeDependent
33 : namespace domain {
34 : template <typename SourceFrame, typename TargetFrame, typename... Maps>
35 : class CoordinateMap;
36 : } // namespace domain
37 :
38 : namespace Frame {
39 : struct Distorted;
40 : struct Grid;
41 : struct Inertial;
42 : } // namespace Frame
43 : /// \endcond
44 :
45 : namespace domain::creators::time_dependence {
46 : /*!
47 : * \brief A spherical compression about some center, as given by
48 : * domain::CoordinateMaps::TimeDependent::SphericalCompression<false>.
49 : *
50 : * \details This TimeDependence is suitable for use on a spherical shell,
51 : * where MinRadius and MaxRadius are the inner and outer radii of the shell,
52 : * respectively.
53 : *
54 : * \note The quantity stored in the FunctionOfTime is really
55 : * the spherical-harmonic coefficient \f$\lambda_{00}(t)\f$. This is
56 : * different from the Shape map, which stores ylm::Spherepack coefficients
57 : * \f$a_{lm}(t)\f$ and \f$b_{lm}(t)\f$ instead of \f$\lambda_{lm}(t)\f$.
58 : * See domain::CoordinateMaps::TimeDependent::Shape for more details.
59 : */
60 1 : class SphericalCompression final : public TimeDependence<3> {
61 : private:
62 0 : using SphericalCompressionMap =
63 : domain::CoordinateMaps::TimeDependent::SphericalCompression<false>;
64 :
65 : public:
66 0 : using maps_list =
67 : tmpl::list<domain::CoordinateMap<Frame::Grid, Frame::Inertial,
68 : SphericalCompressionMap>>;
69 :
70 0 : static constexpr size_t mesh_dim = 3;
71 :
72 : /// \brief The initial time of the function of time.
73 1 : struct InitialTime {
74 0 : using type = double;
75 0 : static constexpr Options::String help = {
76 : "The initial time of the function of time"};
77 : };
78 : /// \brief Minimum radius for the SphericalCompression map
79 1 : struct MinRadius {
80 0 : using type = double;
81 0 : static constexpr Options::String help = {
82 : "Min radius for SphericalCompression map."};
83 : };
84 : /// \brief Maximum radius for the SphericalCompression map
85 1 : struct MaxRadius {
86 0 : using type = double;
87 0 : static constexpr Options::String help = {
88 : "Max radius for SphericalCompression map."};
89 : };
90 : /// \brief Center for the SphericalCompression map
91 1 : struct Center {
92 0 : using type = std::array<double, 3>;
93 0 : static constexpr Options::String help = {
94 : "Center for the SphericalCompression map."};
95 : };
96 : /// \brief Initial value for function of time for the spherical compression
97 1 : struct InitialValue {
98 0 : using type = double;
99 0 : static constexpr Options::String help = {
100 : "Spherical compression value at initial time."};
101 : };
102 : /// \brief Initial radial velocity for the function of time for the spherical
103 : /// compression
104 1 : struct InitialVelocity {
105 0 : using type = double;
106 0 : static constexpr Options::String help = {
107 : "Spherical compression initial radial velocity."};
108 : };
109 : /// \brief Initial radial acceleration for the function of time for the
110 : /// spherical compression
111 1 : struct InitialAcceleration {
112 0 : using type = double;
113 0 : static constexpr Options::String help = {
114 : "Spherical compression initial radial acceleration."};
115 : };
116 :
117 0 : using GridToInertialMap =
118 : detail::generate_coordinate_map_t<Frame::Grid, Frame::Inertial,
119 : tmpl::list<SphericalCompressionMap>>;
120 :
121 0 : using options =
122 : tmpl::list<InitialTime, MinRadius, MaxRadius, Center, InitialValue,
123 : InitialVelocity, InitialAcceleration>;
124 :
125 0 : static constexpr Options::String help = {"A spherical compression."};
126 :
127 0 : SphericalCompression() = default;
128 0 : ~SphericalCompression() override = default;
129 0 : SphericalCompression(const SphericalCompression&) = delete;
130 0 : SphericalCompression(SphericalCompression&&) = default;
131 0 : SphericalCompression& operator=(const SphericalCompression&) = delete;
132 0 : SphericalCompression& operator=(SphericalCompression&&) = default;
133 :
134 0 : SphericalCompression(double initial_time, double min_radius,
135 : double max_radius, std::array<double, 3> center,
136 : double initial_value, double initial_velocity,
137 : double initial_acceleration,
138 : const Options::Context& context = {});
139 :
140 1 : auto get_clone() const -> std::unique_ptr<TimeDependence<mesh_dim>> override;
141 :
142 1 : auto block_maps_grid_to_inertial(size_t number_of_blocks) const
143 : -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
144 : Frame::Grid, Frame::Inertial, mesh_dim>>> override;
145 :
146 1 : auto block_maps_grid_to_distorted(size_t number_of_blocks) const
147 : -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
148 : Frame::Grid, Frame::Distorted, mesh_dim>>> override {
149 : using ptr_type =
150 : domain::CoordinateMapBase<Frame::Grid, Frame::Distorted, mesh_dim>;
151 : return std::vector<std::unique_ptr<ptr_type>>(number_of_blocks);
152 : }
153 :
154 1 : auto block_maps_distorted_to_inertial(size_t number_of_blocks) const
155 : -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
156 : Frame::Distorted, Frame::Inertial, mesh_dim>>> override {
157 : using ptr_type =
158 : domain::CoordinateMapBase<Frame::Distorted, Frame::Inertial, mesh_dim>;
159 : return std::vector<std::unique_ptr<ptr_type>>(number_of_blocks);
160 : }
161 :
162 1 : auto functions_of_time(const std::unordered_map<std::string, double>&
163 : initial_expiration_times = {}) const
164 : -> std::unordered_map<
165 : std::string,
166 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
167 :
168 : private:
169 : // NOLINTNEXTLINE(readability-redundant-declaration)
170 0 : friend bool operator==(const SphericalCompression& lhs,
171 : const SphericalCompression& rhs);
172 :
173 0 : GridToInertialMap grid_to_inertial_map() const;
174 :
175 0 : double initial_time_{std::numeric_limits<double>::signaling_NaN()};
176 0 : double min_radius_{std::numeric_limits<double>::signaling_NaN()};
177 0 : double max_radius_{std::numeric_limits<double>::signaling_NaN()};
178 0 : std::array<double, 3> center_{};
179 0 : double initial_value_{std::numeric_limits<double>::signaling_NaN()};
180 0 : double initial_velocity_{std::numeric_limits<double>::signaling_NaN()};
181 0 : double initial_acceleration_{std::numeric_limits<double>::signaling_NaN()};
182 0 : inline static const std::string function_of_time_name_{"Size"};
183 : };
184 :
185 0 : bool operator!=(const SphericalCompression& lhs,
186 : const SphericalCompression& rhs);
187 : } // namespace domain::creators::time_dependence
|