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 Options::String 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 Options::String help = {
67  "Outer boundary or pivot point of the map"};
68  };
69  /// \brief The initial values of the expansion factors.
72  static constexpr Options::String help = {
73  "Expansion values at initial time."};
74  };
75  /// \brief The velocity of the expansion factors.
76  struct Velocity {
78  static constexpr Options::String help = {"The rate of expansion."};
79  };
80  /// \brief The acceleration of the expansion factors.
81  struct Acceleration {
83  static constexpr Options::String help = {"The acceleration of expansion."};
84  };
85  /// \brief The names of the functions of times to be added to the added to the
86  /// DataBox.
87  ///
88  /// The defaults are `"ExpansionA", "ExpansionB"`.
89  ///
90  /// If the two names are same then a linear radial scaling is used instead of
91  /// a cubic scaling.
94  static constexpr Options::String help = {"Names of the functions of time."};
95  static type default_value() noexcept {
96  return {{"ExpansionA", "ExpansionB"}};
97  }
98  };
99 
100  using options = tmpl::list<InitialTime, OuterBoundary, FunctionOfTimeNames,
102 
103  static constexpr Options::String help = {
104  "A spatial radial scaling either based on a cubic scaling or a simple\n"
105  "linear scaling.\n"
106  "\n"
107  "If the two functions of time have the same name then the scaling is a\n"
108  "linear radial scaling."};
109 
110  using MapForComposition =
112 
113  CubicScale() = default;
114  ~CubicScale() override = default;
115  CubicScale(const CubicScale&) = delete;
116  CubicScale(CubicScale&&) noexcept = default;
117  CubicScale& operator=(const CubicScale&) = delete;
118  CubicScale& operator=(CubicScale&&) noexcept = default;
119 
120  CubicScale(double initial_time,
121  double outer_boundary,
122  std::array<std::string, 2> functions_of_time_names,
123  const std::array<double, 2>& initial_expansion,
124  const std::array<double, 2>& velocity,
125  const std::array<double, 2>& acceleration) noexcept;
126 
127  auto get_clone() const noexcept
128  -> std::unique_ptr<TimeDependence<MeshDim>> override;
129 
130  auto block_maps(size_t number_of_blocks) const noexcept
131  -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
132  Frame::Grid, Frame::Inertial, MeshDim>>> override;
133 
134  auto functions_of_time() const noexcept -> std::unordered_map<
135  std::string,
136  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
137 
138  /// Returns the map for each block to be used in a composition of
139  /// `TimeDependence`s.
140  MapForComposition map_for_composition() const noexcept;
141 
142  private:
143  template <size_t LocalDim>
144  // NOLINTNEXTLINE(readability-redundant-declaration)
145  friend bool operator==(const CubicScale<LocalDim>& lhs,
146  const CubicScale<LocalDim>& rhs) noexcept;
147 
148  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
149  double outer_boundary_{std::numeric_limits<double>::signaling_NaN()};
150  std::array<std::string, 2> functions_of_time_names_{};
151  std::array<double, 2> initial_expansion_{};
152  std::array<double, 2> velocity_{};
153  std::array<double, 2> acceleration_{};
154 };
155 
156 template <size_t Dim>
157 bool operator==(const CubicScale<Dim>& lhs,
158  const CubicScale<Dim>& rhs) noexcept;
159 
160 template <size_t Dim>
161 bool operator!=(const CubicScale<Dim>& lhs,
162  const CubicScale<Dim>& rhs) noexcept;
163 } // namespace time_dependence
164 } // namespace creators
165 } // 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:92
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:45
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:76
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:60
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
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
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
TMPL.hpp
domain::creators::time_dependence::CubicScale::Acceleration
The acceleration of the expansion factors.
Definition: CubicScale.hpp:81
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:236
string