CubicScale.hpp
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/CubicScale.hpp"
17 #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
18 #include "Options/Auto.hpp"
19 #include "Options/Options.hpp"
20 #include "Utilities/TMPL.hpp"
21
22 /// \cond
23 namespace domain {
24 namespace FunctionsOfTime {
25 class FunctionOfTime;
26 } // namespace FunctionsOfTime
27
28 template <typename SourceFrame, typename TargetFrame, typename... Maps>
29 class CoordinateMap;
30 } // namespace domain
31
32 namespace Frame {
33 struct Grid;
34 struct Inertial;
35 } // namespace Frame
36 /// \endcond
37
38 namespace domain {
39 namespace creators {
40 namespace time_dependence {
41 /// \brief A linear or cubic radial scaling time dependence.
42 ///
43 /// Adds the domain::CoordinateMaps::TimeDependent::CubicScale map. A linear
44 /// radial scaling can be used by specifying the two functions of time to have
45 /// the same name.
46 template <size_t MeshDim>
47 class CubicScale final : public TimeDependence<MeshDim> {
48  private:
49  using CubicScaleMap =
51
52  public:
53  using maps_list =
54  tmpl::list<CoordinateMap<Frame::Grid, Frame::Inertial, CubicScaleMap>>;
55
56  static constexpr size_t mesh_dim = MeshDim;
57
58  /// \brief The initial time of the functions of time.
59  struct InitialTime {
60  using type = double;
61  static constexpr Options::String help = {
62  "The initial time of the functions of time"};
63  };
64  /// \brief The initial time interval for updates of the functions of time.
67  static constexpr Options::String help = {
68  "The initial time interval for updates of the functions of time. If "
69  "Auto, then the functions of time do not expire, nor can they be "
70  "updated."};
71  };
72  /// \brief The outer boundary or pivot point of the
73  /// domain::CoordinateMaps::TimeDependent::CubicScale map
74  struct OuterBoundary {
75  using type = double;
76  static constexpr Options::String help = {
77  "Outer boundary or pivot point of the map"};
78  };
79  /// \brief The initial values of the expansion factors.
82  static constexpr Options::String help = {
83  "Expansion values at initial time."};
84  };
85  /// \brief The velocity of the expansion factors.
86  struct Velocity {
88  static constexpr Options::String help = {"The rate of expansion."};
89  };
90  /// \brief The acceleration of the expansion factors.
91  struct Acceleration {
93  static constexpr Options::String help = {"The acceleration of expansion."};
94  };
95  /// \brief The names of the functions of times to be added to the added to the
96  /// DataBox.
97  ///
98  /// If the two names are same then a linear radial scaling is used instead of
99  /// a cubic scaling.
102  static constexpr Options::String help = {"Names of the functions of time."};
103  };
104
105  using options =
108
109  static constexpr Options::String help = {
110  "A spatial radial scaling either based on a cubic scaling or a simple\n"
111  "linear scaling.\n"
112  "\n"
113  "If the two functions of time have the same name then the scaling is a\n"
115
116  using MapForComposition =
118
119  CubicScale() = default;
120  ~CubicScale() override = default;
121  CubicScale(const CubicScale&) = delete;
122  CubicScale(CubicScale&&) noexcept = default;
123  CubicScale& operator=(const CubicScale&) = delete;
124  CubicScale& operator=(CubicScale&&) noexcept = default;
125
126  CubicScale(double initial_time,
127  std::optional<double> initial_expiration_delta_t,
128  double outer_boundary,
129  std::array<std::string, 2> functions_of_time_names,
130  const std::array<double, 2>& initial_expansion,
131  const std::array<double, 2>& velocity,
132  const std::array<double, 2>& acceleration) noexcept;
133
134  auto get_clone() const noexcept
135  -> std::unique_ptr<TimeDependence<MeshDim>> override;
136
137  auto block_maps(size_t number_of_blocks) const noexcept
138  -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
139  Frame::Grid, Frame::Inertial, MeshDim>>> override;
140
141  auto functions_of_time() const noexcept -> std::unordered_map<
142  std::string,
143  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
144
145  /// Returns the map for each block to be used in a composition of
146  /// TimeDependences.
147  MapForComposition map_for_composition() const noexcept;
148
149  private:
150  template <size_t LocalDim>
152  friend bool operator==(const CubicScale<LocalDim>& lhs,
153  const CubicScale<LocalDim>& rhs) noexcept;
154
155  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
156  std::optional<double> initial_expiration_delta_t_{};
157  double outer_boundary_{std::numeric_limits<double>::signaling_NaN()};
158  std::array<std::string, 2> functions_of_time_names_{};
159  std::array<double, 2> initial_expansion_{};
160  std::array<double, 2> velocity_{};
161  std::array<double, 2> acceleration_{};
162 };
163
164 template <size_t Dim>
165 bool operator==(const CubicScale<Dim>& lhs,
166  const CubicScale<Dim>& rhs) noexcept;
167
168 template <size_t Dim>
169 bool operator!=(const CubicScale<Dim>& lhs,
170  const CubicScale<Dim>& rhs) noexcept;
171 } // namespace time_dependence
172 } // namespace creators
173 } // namespace domain
domain::creators::time_dependence::CubicScale::FunctionOfTimeNames
The names of the functions of times to be added to the added to the DataBox.
Definition: CubicScale.hpp:100
domain::creators::time_dependence::CubicScale::block_maps
auto block_maps(size_t number_of_blocks) const noexcept -> std::vector< std::unique_ptr< domain::CoordinateMapBase< Frame::Grid, Frame::Inertial, MeshDim >>> override
Returns the coordinate maps from the Frame::Grid to the Frame::Inertial frame for each block.
domain::creators::time_dependence::CubicScale::functions_of_time
auto functions_of_time() const noexcept -> std::unordered_map< std::string, std::unique_ptr< domain::FunctionsOfTime::FunctionOfTime >> override
Returns the functions of time for the domain.
domain::creators::time_dependence::CubicScale::OuterBoundary
The outer boundary or pivot point of the domain::CoordinateMaps::TimeDependent::CubicScale map.
Definition: CubicScale.hpp:74
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
std::rel_ops::operator!=
T operator!=(T... args)
Options.hpp
domain::creators::time_dependence::CubicScale::InitialExpirationDeltaT
The initial time interval for updates of the functions of time.
Definition: CubicScale.hpp:65
vector
domain::creators::time_dependence::CubicScale::get_clone
auto get_clone() const noexcept -> std::unique_ptr< TimeDependence< MeshDim >> override
Returns a std::unique_ptr pointing to a copy of the TimeDependence.
domain::creators::time_dependence::CubicScale::InitialExpansion
The initial values of the expansion factors.
Definition: CubicScale.hpp:80
CoordinateMap.hpp
domain::creators::time_dependence::CubicScale::Velocity
The velocity of the expansion factors.
Definition: CubicScale.hpp:86
domain::creators::time_dependence::CubicScale::map_for_composition
MapForComposition map_for_composition() const noexcept
Returns the map for each block to be used in a composition of TimeDependences.
cstddef
domain::CoordinateMaps::TimeDependent::CubicScale
Maps the radius as where is the radius of the source coordinates.
Definition: CubicScale.hpp:99
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:60
array
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:33
domain::creators::time_dependence::CubicScale::InitialTime
The initial time of the functions of time.
Definition: CubicScale.hpp:59
limits
domain::creators::time_dependence::CubicScale
A linear or cubic radial scaling time dependence.
Definition: CubicScale.hpp:47
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
optional
unordered_map
TMPL.hpp
domain::creators::time_dependence::CubicScale::Acceleration
The acceleration of the expansion factors.
Definition: CubicScale.hpp:91
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:240
string