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/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 CoordMapsTimeDependent {
27 template <typename Map1, typename Map2, typename Map3>
28 class ProductOf3Maps;
29 template <typename Map1, typename Map2>
30 class ProductOf2Maps;
31 } // namespace CoordMapsTimeDependent
32 
33 template <typename SourceFrame, typename TargetFrame, typename... Maps>
34 class CoordinateMap;
35 } // namespace domain
36 
37 namespace Frame {
38 struct Grid;
39 struct Inertial;
40 } // namespace Frame
41 /// \endcond
42 
43 namespace domain {
44 namespace creators {
45 namespace time_dependence {
46 /*!
47  * \brief A uniform translation in the \f$x-, y-\f$ and \f$z-\f$direction.
48  *
49  * The coordinates are adjusted according to:
50  *
51  * \f{align}{
52  * x^i \to x^i + f^i(t)
53  * \f}
54  *
55  * where \f$f^i(t)\f$ are the functions of time.
56  */
57 template <size_t MeshDim>
58 class UniformTranslation final : public TimeDependence<MeshDim> {
59  private:
61 
62  public:
63  using maps_list = tmpl::list<
68  domain::CoordinateMap<Frame::Grid, Frame::Inertial,
70  Translation, Translation, Translation>>>;
71 
72  static constexpr size_t mesh_dim = MeshDim;
73 
74  /// \brief The initial time of the functions of time.
75  struct InitialTime {
76  using type = double;
77  static constexpr OptionString help = {
78  "The initial time of the functions of time"};
79  };
80  /// \brief The \f$x\f$-, \f$y\f$-, and \f$z\f$-velocity.
81  struct Velocity {
83  static constexpr OptionString help = {"The velocity of the map."};
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 `"TranslationX", "TranslationY", "TranslationZ"`.
91  static constexpr OptionString help = {"Names of the functions of time."};
92  static type default_value() noexcept {
93  return UniformTranslation::default_function_names();
94  }
95  };
96 
97  using MapForComposition =
98  detail::generate_coordinate_map_t<tmpl::list<tmpl::conditional_t<
99  MeshDim == 1, Translation,
100  tmpl::conditional_t<MeshDim == 2,
102  Translation, Translation>,
104  Translation, Translation, Translation>>>>>;
105 
106  using options = tmpl::list<InitialTime, Velocity, FunctionOfTimeNames>;
107 
108  static constexpr OptionString help = {
109  "A spatially uniform translation initialized with a constant velocity."};
110 
111  UniformTranslation() = default;
112  ~UniformTranslation() override = default;
113  UniformTranslation(const UniformTranslation&) = delete;
114  UniformTranslation(UniformTranslation&&) noexcept = default;
115  UniformTranslation& operator=(const UniformTranslation&) = delete;
116  UniformTranslation& operator=(UniformTranslation&&) noexcept = default;
117 
118  UniformTranslation(double initial_time,
119  const std::array<double, MeshDim>& velocity,
120  std::array<std::string, MeshDim> functions_of_time_names =
121  default_function_names()) noexcept;
122 
123  auto get_clone() const noexcept
125 
126  auto block_maps(size_t number_of_blocks) const noexcept
128  Frame::Grid, Frame::Inertial, MeshDim>>> override;
129 
130  auto functions_of_time() const noexcept -> std::unordered_map<
131  std::string,
133 
134  /// Returns the map for each block to be used in a composition of
135  /// `TimeDependence`s.
136  MapForComposition map_for_composition() const noexcept;
137 
138  private:
139  static std::array<std::string, MeshDim> default_function_names() noexcept;
140 
141  template <size_t LocalDim>
142  // NOLINTNEXTLINE(readability-redundant-declaration)
143  friend bool operator==(const UniformTranslation<LocalDim>& lhs,
144  const UniformTranslation<LocalDim>& rhs) noexcept;
145 
146  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
147  std::array<double, MeshDim> velocity_{};
148  std::array<std::string, MeshDim> functions_of_time_names_{};
149 };
150 
151 template <size_t Dim>
152 bool operator==(const UniformTranslation<Dim>& lhs,
153  const UniformTranslation<Dim>& rhs) noexcept;
154 
155 template <size_t Dim>
156 bool operator!=(const UniformTranslation<Dim>& lhs,
157  const UniformTranslation<Dim>& rhs) noexcept;
158 } // namespace time_dependence
159 } // namespace creators
160 } // namespace domain
The -, -, and -velocity.
Definition: UniformTranslation.hpp:81
Definition: IndexType.hpp:43
Definition: BlockId.hpp:16
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:44
T signaling_NaN(T... args)
Defines classes and functions for making classes creatable from input files.
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:235
A uniform translation in the and direction.
Definition: UniformTranslation.hpp:58
The names of the functions of times to be added to the added to the DataBox.
Definition: UniformTranslation.hpp:89
Product of three one-dimensional CoordinateMaps.
Definition: ProductMapsTimeDep.hpp:118
The initial time of the functions of time.
Definition: UniformTranslation.hpp:75
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
Translation map defined by .
Definition: Translation.hpp:36
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)
Definition: IndexType.hpp:44
Product of two codimension=0 CoordinateMaps, where one or both must be time-dependent.
Definition: ProductMapsTimeDep.hpp:38