UniformTranslation.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/Translation.hpp"
17 #include "Domain/Creators/TimeDependence/GenerateCoordinateMap.hpp"
18 #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
19 #include "Options/Auto.hpp"
20 #include "Options/Options.hpp"
21 #include "Utilities/TMPL.hpp"
22
23 /// \cond
24 namespace domain {
25 namespace FunctionsOfTime {
26 class FunctionOfTime;
27 } // namespace FunctionsOfTime
28 namespace CoordinateMaps {
29 namespace TimeDependent {
30 template <typename Map1, typename Map2, typename Map3>
31 class ProductOf3Maps;
32 template <typename Map1, typename Map2>
33 class ProductOf2Maps;
34 } // namespace TimeDependent
35 } // namespace CoordinateMaps
36
37 template <typename SourceFrame, typename TargetFrame, typename... Maps>
38 class CoordinateMap;
39 } // namespace domain
40
41 namespace Frame {
42 struct Grid;
43 struct Inertial;
44 } // namespace Frame
45 /// \endcond
46
47 namespace domain {
48 namespace creators {
49 namespace time_dependence {
50 /*!
51  * \brief A uniform translation in the \f$x-, y-\f$ and \f$z-\f$direction.
52  *
53  * The coordinates are adjusted according to:
54  *
55  * \f{align}{
56  * x^i \to x^i + f^i(t)
57  * \f}
58  *
59  * where \f$f^i(t)\f$ are the functions of time.
60  */
61 template <size_t MeshDim>
62 class UniformTranslation final : public TimeDependence<MeshDim> {
63  private:
65
66  public:
67  using maps_list = tmpl::list<
75
76  static constexpr size_t mesh_dim = MeshDim;
77
78  /// \brief The initial time of the functions of time.
79  struct InitialTime {
80  using type = double;
81  static constexpr Options::String help = {
82  "The initial time of the functions of time"};
83  };
84  /// \brief The time interval for updates of the functions of time.
87  static constexpr Options::String help = {
88  "The time interval for updates of the functions of time. If "
89  "Auto, then the functions of time do not expire, nor can they be "
90  "updated."};
91  };
92  /// \brief The \f$x\f$-, \f$y\f$-, and \f$z\f$-velocity.
93  struct Velocity {
95  static constexpr Options::String help = {"The velocity of the map."};
96  };
97  /// \brief The names of the functions of times to be added to the added to the
98  /// DataBox.
101  static constexpr Options::String help = {"Names of the functions of time."};
102  };
103
104  using MapForComposition =
105  detail::generate_coordinate_map_t<tmpl::list<tmpl::conditional_t<
106  MeshDim == 1, Translation,
107  tmpl::conditional_t<
108  MeshDim == 2,
113
114  using options = tmpl::list<InitialTime, InitialExpirationDeltaT, Velocity,
116
117  static constexpr Options::String help = {
118  "A spatially uniform translation initialized with a constant velocity."};
119
120  UniformTranslation() = default;
121  ~UniformTranslation() override = default;
122  UniformTranslation(const UniformTranslation&) = delete;
123  UniformTranslation(UniformTranslation&&) noexcept = default;
124  UniformTranslation& operator=(const UniformTranslation&) = delete;
125  UniformTranslation& operator=(UniformTranslation&&) noexcept = default;
126
127  UniformTranslation(double initial_time,
128  std::optional<double> initial_expiration_delta_t,
129  const std::array<double, MeshDim>& velocity,
130  std::array<std::string, MeshDim> functions_of_time_names =
131  default_function_names()) noexcept;
132
133  auto get_clone() const noexcept
134  -> std::unique_ptr<TimeDependence<MeshDim>> override;
135
136  auto block_maps(size_t number_of_blocks) const noexcept
137  -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
138  Frame::Grid, Frame::Inertial, MeshDim>>> override;
139
140  auto functions_of_time() const noexcept -> std::unordered_map<
141  std::string,
142  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
143
144  /// Returns the map for each block to be used in a composition of
145  /// TimeDependences.
146  MapForComposition map_for_composition() const noexcept;
147
148  private:
149  static std::array<std::string, MeshDim> default_function_names() noexcept;
150
151  template <size_t LocalDim>
153  friend bool operator==(const UniformTranslation<LocalDim>& lhs,
154  const UniformTranslation<LocalDim>& rhs) noexcept;
155
156  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
157  std::optional<double> initial_expiration_delta_t_{};
158  std::array<double, MeshDim> velocity_{};
159  std::array<std::string, MeshDim> functions_of_time_names_{};
160 };
161
162 template <size_t Dim>
163 bool operator==(const UniformTranslation<Dim>& lhs,
164  const UniformTranslation<Dim>& rhs) noexcept;
165
166 template <size_t Dim>
167 bool operator!=(const UniformTranslation<Dim>& lhs,
168  const UniformTranslation<Dim>& rhs) noexcept;
169 } // namespace time_dependence
170 } // namespace creators
171 } // namespace domain
domain::creators::time_dependence::UniformTranslation::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::UniformTranslation::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.
Frame::Inertial
Definition: IndexType.hpp:44
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
Frame::Grid
Definition: IndexType.hpp:43
std::rel_ops::operator!=
T operator!=(T... args)
domain::creators::time_dependence::UniformTranslation::Velocity
The -, -, and -velocity.
Definition: UniformTranslation.hpp:93
Options.hpp
vector
domain::CoordinateMaps::TimeDependent::ProductOf2Maps
Product of two codimension=0 CoordinateMaps, where one or both must be time-dependent.
Definition: ProductMaps.hpp:39
domain::creators::time_dependence::UniformTranslation::InitialTime
The initial time of the functions of time.
Definition: UniformTranslation.hpp:79
CoordinateMap.hpp
domain::creators::time_dependence::UniformTranslation
A uniform translation in the and direction.
Definition: UniformTranslation.hpp:62
domain::CoordinateMaps::TimeDependent::Translation
Translation map defined by .
Definition: Translation.hpp:37
cstddef
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:56
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:36
domain::creators::time_dependence::UniformTranslation::map_for_composition
MapForComposition map_for_composition() const noexcept
Returns the map for each block to be used in a composition of TimeDependences.
domain::creators::time_dependence::UniformTranslation::InitialExpirationDeltaT
The time interval for updates of the functions of time.
Definition: UniformTranslation.hpp:85
limits
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
domain::CoordinateMaps::TimeDependent::ProductOf3Maps
Product of three one-dimensional CoordinateMaps.
Definition: ProductMaps.hpp:123
Frame
Definition: IndexType.hpp:36
optional
domain::creators::time_dependence::UniformTranslation::FunctionOfTimeNames
The names of the functions of times to be added to the added to the DataBox.
Definition: UniformTranslation.hpp:99
unordered_map
domain::creators::time_dependence::UniformTranslation::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.
TMPL.hpp
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:240
string