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  /// The defaults are "ExpansionA", "ExpansionB".
99  ///
100  /// If the two names are same then a linear radial scaling is used instead of
101  /// a cubic scaling.
104  static constexpr Options::String help = {"Names of the functions of time."};
105  static type default_value() noexcept {
106  return {{"ExpansionA", "ExpansionB"}};
107  }
108  };
109
110  using options =
113
114  static constexpr Options::String help = {
115  "A spatial radial scaling either based on a cubic scaling or a simple\n"
116  "linear scaling.\n"
117  "\n"
118  "If the two functions of time have the same name then the scaling is a\n"
120
121  using MapForComposition =
123
124  CubicScale() = default;
125  ~CubicScale() override = default;
126  CubicScale(const CubicScale&) = delete;
127  CubicScale(CubicScale&&) noexcept = default;
128  CubicScale& operator=(const CubicScale&) = delete;
129  CubicScale& operator=(CubicScale&&) noexcept = default;
130
131  CubicScale(double initial_time,
132  std::optional<double> initial_expiration_delta_t,
133  double outer_boundary,
134  std::array<std::string, 2> functions_of_time_names,
135  const std::array<double, 2>& initial_expansion,
136  const std::array<double, 2>& velocity,
137  const std::array<double, 2>& acceleration) noexcept;
138
139  auto get_clone() const noexcept
140  -> std::unique_ptr<TimeDependence<MeshDim>> override;
141
142  auto block_maps(size_t number_of_blocks) const noexcept
143  -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
144  Frame::Grid, Frame::Inertial, MeshDim>>> override;
145
146  auto functions_of_time() const noexcept -> std::unordered_map<
147  std::string,
148  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
149
150  /// Returns the map for each block to be used in a composition of
151  /// TimeDependences.
152  MapForComposition map_for_composition() const noexcept;
153
154  private:
155  template <size_t LocalDim>
157  friend bool operator==(const CubicScale<LocalDim>& lhs,
158  const CubicScale<LocalDim>& rhs) noexcept;
159
160  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
161  std::optional<double> initial_expiration_delta_t_{};
162  double outer_boundary_{std::numeric_limits<double>::signaling_NaN()};
163  std::array<std::string, 2> functions_of_time_names_{};
164  std::array<double, 2> initial_expansion_{};
165  std::array<double, 2> velocity_{};
166  std::array<double, 2> acceleration_{};
167 };
168
169 template <size_t Dim>
170 bool operator==(const CubicScale<Dim>& lhs,
171  const CubicScale<Dim>& rhs) noexcept;
172
173 template <size_t Dim>
174 bool operator!=(const CubicScale<Dim>& lhs,
175  const CubicScale<Dim>& rhs) noexcept;
176 } // namespace time_dependence
177 } // namespace creators
178 } // 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:102
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::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.
Definition: CubicScale.cpp:57
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
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::CubicScale::map_for_composition
MapForComposition map_for_composition() const noexcept
Returns the map for each block to be used in a composition of TimeDependences.
Definition: CubicScale.cpp:102
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:27
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
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.
Definition: CubicScale.cpp:47
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.
Definition: CubicScale.cpp:72
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:236
string