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/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::CoordMapsTimeDependent::CubicScale` map. A linear radial
42 /// scaling can be used by specifying the two functions of time to have the same
43 /// name.
44 template <size_t MeshDim>
45 class CubicScale final : public TimeDependence<MeshDim> {
46  private:
48 
49  public:
50  using maps_list =
51  tmpl::list<CoordinateMap<Frame::Grid, Frame::Inertial, CubicScaleMap>>;
52 
53  static constexpr size_t mesh_dim = MeshDim;
54 
55  /// \brief The initial time of the functions of time.
56  struct InitialTime {
57  using type = double;
58  static constexpr OptionString help = {
59  "The initial time of the functions of time"};
60  };
61  /// \brief The outer boundary or pivot point of the
62  /// `domain::CoordMapsTimeDependent::CubicScale` map
63  struct OuterBoundary {
64  using type = double;
65  static constexpr OptionString help = {
66  "Outer boundary or pivot point of the map"};
67  };
68  /// \brief The initial values of the expansion factors.
71  static constexpr OptionString help = {"Expansion values at initial time."};
72  };
73  /// \brief The velocity of the expansion factors.
74  struct Velocity {
76  static constexpr OptionString help = {"The rate of expansion."};
77  };
78  /// \brief The acceleration of the expansion factors.
79  struct Acceleration {
81  static constexpr OptionString help = {"The acceleration of expansion."};
82  };
83  /// \brief The names of the functions of times to be added to the added to the
84  /// DataBox.
85  ///
86  /// The defaults are `"ExpansionA", "ExpansionB"`.
87  ///
88  /// If the two names are same then a linear radial scaling is used instead of
89  /// a cubic scaling.
92  static constexpr OptionString help = {"Names of the functions of time."};
93  static type default_value() noexcept {
94  return {{"ExpansionA", "ExpansionB"}};
95  }
96  };
97 
98  using options = tmpl::list<InitialTime, OuterBoundary, FunctionOfTimeNames,
100 
101  static constexpr OptionString help = {
102  "A spatial radial scaling either based on a cubic scaling or a simple\n"
103  "linear scaling.\n"
104  "\n"
105  "If the two functions of time have the same name then the scaling is a\n"
106  "linear radial scaling."};
107 
108  using MapForComposition =
110 
111  CubicScale() = default;
112  ~CubicScale() override = default;
113  CubicScale(const CubicScale&) = delete;
114  CubicScale(CubicScale&&) noexcept = default;
115  CubicScale& operator=(const CubicScale&) = delete;
116  CubicScale& operator=(CubicScale&&) noexcept = default;
117 
118  CubicScale(double initial_time,
119  double outer_boundary,
120  std::array<std::string, 2> functions_of_time_names,
121  const std::array<double, 2>& initial_expansion,
122  const std::array<double, 2>& velocity,
123  const std::array<double, 2>& acceleration) noexcept;
124 
125  auto get_clone() const noexcept
127 
128  auto block_maps(size_t number_of_blocks) const noexcept
130  Frame::Grid, Frame::Inertial, MeshDim>>> override;
131 
132  auto functions_of_time() const noexcept -> std::unordered_map<
133  std::string,
135 
136  /// Returns the map for each block to be used in a composition of
137  /// `TimeDependence`s.
138  MapForComposition map_for_composition() const noexcept;
139 
140  private:
141  template <size_t LocalDim>
142  // NOLINTNEXTLINE(readability-redundant-declaration)
143  friend bool operator==(const CubicScale<LocalDim>& lhs,
144  const CubicScale<LocalDim>& rhs) noexcept;
145 
146  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
147  double outer_boundary_{std::numeric_limits<double>::signaling_NaN()};
148  std::array<std::string, 2> functions_of_time_names_{};
149  std::array<double, 2> initial_expansion_{};
150  std::array<double, 2> velocity_{};
151  std::array<double, 2> acceleration_{};
152 };
153 
154 template <size_t Dim>
155 bool operator==(const CubicScale<Dim>& lhs,
156  const CubicScale<Dim>& rhs) noexcept;
157 
158 template <size_t Dim>
159 bool operator!=(const CubicScale<Dim>& lhs,
160  const CubicScale<Dim>& rhs) noexcept;
161 } // namespace time_dependence
162 } // namespace creators
163 } // namespace domain
The velocity of the expansion factors.
Definition: CubicScale.hpp:74
Definition: IndexType.hpp:43
Definition: BlockId.hpp:16
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:44
T signaling_NaN(T... args)
A linear or cubic radial scaling time dependence.
Definition: CubicScale.hpp:45
The initial time of the functions of time.
Definition: CubicScale.hpp:56
The names of the functions of times to be added to the added to the DataBox.
Definition: CubicScale.hpp:90
Defines classes and functions for making classes creatable from input files.
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:235
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
The abstract base class off of which specific classes for adding time dependence into a domain creato...
Definition: TimeDependence.hpp:53
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Defines class CoordinateMap.
Wraps the template metaprogramming library used (brigand)
The initial values of the expansion factors.
Definition: CubicScale.hpp:69
Definition: IndexType.hpp:44
The acceleration of the expansion factors.
Definition: CubicScale.hpp:79
Maps the radius as where is the radius of the source coordinates.
Definition: CubicScale.hpp:98
The outer boundary or pivot point of the domain::CoordMapsTimeDependent::CubicScale map...
Definition: CubicScale.hpp:63