SphericalCompression.hpp
1 // 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 
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/Options.hpp"
22 #include "Utilities/TMPL.hpp"
23 
24 /// \cond
25 namespace domain {
26 namespace FunctionsOfTime {
27 class FunctionOfTime;
28 } // namespace FunctionsOfTime
29 namespace CoordinateMaps::TimeDependent {
30 template <bool InertiorMap>
31 class SphericalCompression;
32 } // namespace CoordinateMaps::TimeDependent
33 template <typename SourceFrame, typename TargetFrame, typename... Maps>
34 class CoordinateMap;
35 } // namespace domain
36 
37 namespace Frame {
38 struct Grid;
39 struct Inertial;
40 } // namespace Frame
41 /// \endcond
42 
44 /*!
45  * \brief A spherical compression about some center, as given by
46  * domain::CoordinateMaps::TimeDependent::SphericalCompression<false>.
47  *
48  * \details This TimeDependence is suitable for use on a spherical shell,
49  * where MinRadius and MaxRadius are the inner and outer radii of the shell,
50  * respectively.
51  */
52 class SphericalCompression final : public TimeDependence<3> {
53  private:
56 
57  public:
58  using maps_list =
61 
62  static constexpr size_t mesh_dim = 3;
63 
64  /// \brief The initial time of the function of time.
65  struct InitialTime {
66  using type = double;
67  static constexpr Options::String help = {
68  "The initial time of the function of time"};
69  };
70  /// \brief The time interval for updates of the functions of time.
73  static constexpr Options::String help = {
74  "The initial time interval for updates of the functions of time. If "
75  "Auto, then the functions of time do not expire, nor can they be "
76  "updated."};
77  };
78  /// \brief Minimum radius for the SphericalCompression map
79  struct MinRadius {
80  using type = double;
81  static constexpr Options::String help = {
82  "Min radius for SphericalCompression map."};
83  };
84  /// \brief Maximum radius for the SphericalCompression map
85  struct MaxRadius {
86  using type = double;
87  static constexpr Options::String help = {
88  "Max radius for SphericalCompression map."};
89  };
90  /// \brief Center for the SphericalCompression map
91  struct Center {
93  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  struct InitialValue {
98  using type = double;
99  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
105  using type = double;
106  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
112  using type = double;
113  static constexpr Options::String help = {
114  "Spherical compression initial radial acceleration."};
115  };
116  /// \brief The name of the functions of time to be added to the added to the
117  /// DataBox for the spherical compression
119  using type = std::string;
120  static constexpr Options::String help = {
121  "Names of SphericalCompression function of time."};
122  };
123 
124  using MapForComposition =
125  detail::generate_coordinate_map_t<tmpl::list<SphericalCompressionMap>>;
126 
127  using options = tmpl::list<InitialTime, InitialExpirationDeltaT, MinRadius,
130 
131  static constexpr Options::String help = {"A spherical compression."};
132 
133  SphericalCompression() = default;
134  ~SphericalCompression() override = default;
136  SphericalCompression(SphericalCompression&&) noexcept = default;
137  SphericalCompression& operator=(const SphericalCompression&) = delete;
138  SphericalCompression& operator=(SphericalCompression&&) noexcept = default;
139 
140  SphericalCompression(double initial_time,
141  std::optional<double> initial_expiration_delta_t,
142  double min_radius, double max_radius,
143  std::array<double, 3> center, double initial_value,
144  double initial_velocity, double initial_acceleration,
145  std::string function_of_time_name = "LambdaFactorA0",
146  const Options::Context& context = {});
147 
148  auto get_clone() const noexcept
149  -> std::unique_ptr<TimeDependence<mesh_dim>> override;
150 
151  auto block_maps(size_t number_of_blocks) const noexcept
152  -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
153  Frame::Grid, Frame::Inertial, mesh_dim>>> override;
154 
155  auto functions_of_time() const noexcept -> std::unordered_map<
156  std::string,
157  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
158 
159  /// Returns the map for each block to be used in a composition of
160  /// `TimeDependence`s.
161  MapForComposition map_for_composition() const noexcept;
162 
163  private:
164  // NOLINTNEXTLINE(readability-redundant-declaration)
165  friend bool operator==(const SphericalCompression& lhs,
166  const SphericalCompression& rhs) noexcept;
167 
168  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
169  std::optional<double> initial_expiration_delta_t_{};
170  double min_radius_{std::numeric_limits<double>::signaling_NaN()};
171  double max_radius_{std::numeric_limits<double>::signaling_NaN()};
172  std::array<double, 3> center_{};
173  double initial_value_{std::numeric_limits<double>::signaling_NaN()};
174  double initial_velocity_{std::numeric_limits<double>::signaling_NaN()};
175  double initial_acceleration_{std::numeric_limits<double>::signaling_NaN()};
176  std::string function_of_time_name_{};
177 };
178 
179 bool operator!=(const SphericalCompression& lhs,
180  const SphericalCompression& rhs) noexcept;
181 } // namespace domain::creators::time_dependence
std::string
domain::creators::time_dependence::SphericalCompression::MinRadius
Minimum radius for the SphericalCompression map.
Definition: SphericalCompression.hpp:79
Frame::Inertial
Definition: IndexType.hpp:44
domain::creators::time_dependence::SphericalCompression::MaxRadius
Maximum radius for the SphericalCompression map.
Definition: SphericalCompression.hpp:85
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
Frame::Grid
Definition: IndexType.hpp:43
std::rel_ops::operator!=
T operator!=(T... args)
Options.hpp
domain::creators::time_dependence::SphericalCompression::InitialValue
Initial value for function of time for the spherical compression.
Definition: SphericalCompression.hpp:97
vector
domain::creators::time_dependence::SphericalCompression::InitialTime
The initial time of the function of time.
Definition: SphericalCompression.hpp:65
CoordinateMap.hpp
domain::creators::time_dependence::SphericalCompression::InitialExpirationDeltaT
The time interval for updates of the functions of time.
Definition: SphericalCompression.hpp:71
domain::creators::time_dependence::SphericalCompression
A spherical compression about some center, as given by domain::CoordinateMaps::TimeDependent::Spheric...
Definition: SphericalCompression.hpp:52
Options
Utilities for parsing input files.
Definition: MinmodType.hpp:8
domain::creators::time_dependence::SphericalCompression::Center
Center for the SphericalCompression map.
Definition: SphericalCompression.hpp:91
cstddef
Assert.hpp
domain::creators::time_dependence::TimeDependence
The abstract base class off of which specific classes for adding time dependence into a domain creato...
Definition: TimeDependence.hpp:56
array
domain::creators::time_dependence::SphericalCompression::InitialVelocity
Initial radial velocity for the function of time for the spherical compression.
Definition: SphericalCompression.hpp:104
domain::CoordinateMaps::TimeDependent::SphericalCompression
Time-dependent compression of a finite 3D spherical volume.
Definition: SphericalCompression.hpp:252
std::numeric_limits::signaling_NaN
T signaling_NaN(T... args)
memory
Options::Auto
A class indicating that a parsed value can be automatically computed instead of specified.
Definition: Auto.hpp:36
limits
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
optional
domain::creators::time_dependence::SphericalCompression::block_maps
auto block_maps(size_t number_of_blocks) const noexcept -> std::vector< std::unique_ptr< domain::CoordinateMapBase< Frame::Grid, Frame::Inertial, mesh_dim >>> override
Returns the coordinate maps from the Frame::Grid to the Frame::Inertial frame for each block.
domain::creators::time_dependence::SphericalCompression::map_for_composition
MapForComposition map_for_composition() const noexcept
Returns the map for each block to be used in a composition of TimeDependences.
domain::creators::time_dependence::SphericalCompression::FunctionOfTimeName
The name of the functions of time to be added to the added to the DataBox for the spherical compressi...
Definition: SphericalCompression.hpp:118
unordered_map
domain::creators::time_dependence::SphericalCompression::InitialAcceleration
Initial radial acceleration for the function of time for the spherical compression.
Definition: SphericalCompression.hpp:111
TMPL.hpp
domain::creators::time_dependence
Classes and functions for adding time dependence to a domain.
Definition: Composition.hpp:24
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:240
string