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