UniformTranslation.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/Translation.hpp"
16 #include "Domain/Creators/TimeDependence/GenerateCoordinateMap.hpp"
17 #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
18 #include "Options/Options.hpp"
19 #include "Utilities/TMPL.hpp"
20 
21 /// \cond
22 namespace domain {
23 namespace FunctionsOfTime {
24 class FunctionOfTime;
25 } // namespace FunctionsOfTime
26 namespace CoordinateMaps {
27 namespace TimeDependent {
28 template <typename Map1, typename Map2, typename Map3>
29 class ProductOf3Maps;
30 template <typename Map1, typename Map2>
31 class ProductOf2Maps;
32 } // namespace TimeDependent
33 } // namespace CoordinateMaps
34 
35 template <typename SourceFrame, typename TargetFrame, typename... Maps>
36 class CoordinateMap;
37 } // namespace domain
38 
39 namespace Frame {
40 struct Grid;
41 struct Inertial;
42 } // namespace Frame
43 /// \endcond
44 
45 namespace domain {
46 namespace creators {
47 namespace time_dependence {
48 /*!
49  * \brief A uniform translation in the \f$x-, y-\f$ and \f$z-\f$direction.
50  *
51  * The coordinates are adjusted according to:
52  *
53  * \f{align}{
54  * x^i \to x^i + f^i(t)
55  * \f}
56  *
57  * where \f$f^i(t)\f$ are the functions of time.
58  */
59 template <size_t MeshDim>
60 class UniformTranslation final : public TimeDependence<MeshDim> {
61  private:
63 
64  public:
65  using maps_list = tmpl::list<
73 
74  static constexpr size_t mesh_dim = MeshDim;
75 
76  /// \brief The initial time of the functions of time.
77  struct InitialTime {
78  using type = double;
79  static constexpr OptionString help = {
80  "The initial time of the functions of time"};
81  };
82  /// \brief The \f$x\f$-, \f$y\f$-, and \f$z\f$-velocity.
83  struct Velocity {
85  static constexpr OptionString help = {"The velocity of the map."};
86  };
87  /// \brief The names of the functions of times to be added to the added to the
88  /// DataBox.
89  ///
90  /// The defaults are `"TranslationX", "TranslationY", "TranslationZ"`.
93  static constexpr OptionString help = {"Names of the functions of time."};
94  static type default_value() noexcept {
95  return UniformTranslation::default_function_names();
96  }
97  };
98 
99  using MapForComposition =
100  detail::generate_coordinate_map_t<tmpl::list<tmpl::conditional_t<
101  MeshDim == 1, Translation,
102  tmpl::conditional_t<
103  MeshDim == 2,
108 
109  using options = tmpl::list<InitialTime, Velocity, FunctionOfTimeNames>;
110 
111  static constexpr OptionString help = {
112  "A spatially uniform translation initialized with a constant velocity."};
113 
114  UniformTranslation() = default;
115  ~UniformTranslation() override = default;
116  UniformTranslation(const UniformTranslation&) = delete;
117  UniformTranslation(UniformTranslation&&) noexcept = default;
118  UniformTranslation& operator=(const UniformTranslation&) = delete;
119  UniformTranslation& operator=(UniformTranslation&&) noexcept = default;
120 
121  UniformTranslation(double initial_time,
122  const std::array<double, MeshDim>& velocity,
123  std::array<std::string, MeshDim> functions_of_time_names =
124  default_function_names()) 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  static std::array<std::string, MeshDim> default_function_names() noexcept;
143 
144  template <size_t LocalDim>
145  // NOLINTNEXTLINE(readability-redundant-declaration)
146  friend bool operator==(const UniformTranslation<LocalDim>& lhs,
147  const UniformTranslation<LocalDim>& rhs) noexcept;
148 
149  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
150  std::array<double, MeshDim> velocity_{};
151  std::array<std::string, MeshDim> functions_of_time_names_{};
152 };
153 
154 template <size_t Dim>
155 bool operator==(const UniformTranslation<Dim>& lhs,
156  const UniformTranslation<Dim>& rhs) noexcept;
157 
158 template <size_t Dim>
159 bool operator!=(const UniformTranslation<Dim>& lhs,
160  const UniformTranslation<Dim>& rhs) noexcept;
161 } // namespace time_dependence
162 } // namespace creators
163 } // 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.
Definition: UniformTranslation.cpp:45
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.
Definition: UniformTranslation.cpp:53
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:83
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::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: UniformTranslation.cpp:69
domain::creators::time_dependence::UniformTranslation::InitialTime
The initial time of the functions of time.
Definition: UniformTranslation.hpp:77
CoordinateMap.hpp
domain::creators::time_dependence::UniformTranslation
A uniform translation in the and direction.
Definition: UniformTranslation.hpp:60
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:55
array
std::numeric_limits::signaling_NaN
T signaling_NaN(T... args)
memory
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.
limits
domain::CoordinateMaps::TimeDependent::ProductOf3Maps
Product of three one-dimensional CoordinateMaps.
Definition: ProductMaps.hpp:119
Frame
Definition: IndexType.hpp:36
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:91
unordered_map
OptionString
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
TMPL.hpp
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:236
string