UniformRotationAboutZAxis.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 
16 #include "Domain/CoordinateMaps/TimeDependent/Rotation.hpp"
17 #include "Domain/Creators/TimeDependence/GenerateCoordinateMap.hpp"
18 #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
19 #include "ErrorHandling/Assert.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>
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 rotation about the \f$z\f$ axis:
50  * \f{eqnarray*}
51  * x &\to& x \cos \alpha(t) - y \sin \alpha(t)\text{,} \\
52  * y &\to& x \sin \alpha(t) + y \cos \alpha(t)\text{,}
53  * \f}
54  * where \f$\alpha(t)\f$ is a `domain::FunctionsOfTime::FunctionOfTime`. For 3
55  * spatial dimensions, \f$z \to z\f$, and the rotation is implemented as a
56  * product of the 2D rotation and an identity map. The rotation is undefined
57  * (and therefore unimplemented here) for 1 spatial dimension.
58  */
59 template <size_t MeshDim>
60 class UniformRotationAboutZAxis final : public TimeDependence<MeshDim> {
61  static_assert(
62  MeshDim > 1,
63  "UniformRotationAboutZAxis<MeshDim> undefined for MeshDim == 1");
64 
65  private:
68 
69  public:
70  using maps_list = tmpl::list<
75 
76  static constexpr size_t mesh_dim = MeshDim;
77 
78  /// \brief The initial time of the function of time.
79  struct InitialTime {
80  using type = double;
81  static constexpr OptionString help = {
82  "The initial time of the function of time"};
83  };
84  /// \brief The \f$x\f$-, \f$y\f$-, and \f$z\f$-velocity.
85  struct AngularVelocity {
86  using type = double;
87  static constexpr OptionString help = {"The angular velocity of the map."};
88  };
89  /// \brief The name of the function of time to be added to the DataBox.
90  ///
91  /// The default is `"RotationAngle"`.
93  using type = std::string;
94  static constexpr OptionString help = {
95  "Name of the rotation angle function of time."};
96  static type default_value() noexcept {
97  return std::string{"RotationAngle"};
98  }
99  };
100 
101  using MapForComposition = detail::generate_coordinate_map_t<
102  tmpl::list<tmpl::conditional_t<MeshDim == 2, Rotation,
103  domain::CoordinateMaps::TimeDependent::
104  ProductOf2Maps<Rotation, Identity>>>>;
105 
106  using options = tmpl::list<InitialTime, AngularVelocity, FunctionOfTimeName>;
107 
108  static constexpr OptionString help = {
109  "A spatially uniform rotation about the z axis initialized with a "
110  "constant angular velocity."};
111 
112  UniformRotationAboutZAxis() = default;
113  ~UniformRotationAboutZAxis() override = default;
117  delete;
119  default;
120 
122  double initial_time, double angular_velocity,
123  std::string function_of_time_name = "RotationAngle") noexcept;
124 
125  auto get_clone() const noexcept
126  -> std::unique_ptr<TimeDependence<MeshDim>> override;
127 
128  auto block_maps(size_t number_of_blocks) const noexcept
129  -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
130  Frame::Grid, Frame::Inertial, MeshDim>>> override;
131 
132  auto functions_of_time() const noexcept -> std::unordered_map<
133  std::string,
134  std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
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==(
144  const UniformRotationAboutZAxis<LocalDim>& lhs,
145  const UniformRotationAboutZAxis<LocalDim>& rhs) noexcept;
146 
147  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
148  double angular_velocity_{std::numeric_limits<double>::signaling_NaN()};
149  std::string function_of_time_name_{};
150 };
151 
152 template <size_t Dim>
153 bool operator==(const UniformRotationAboutZAxis<Dim>& lhs,
154  const UniformRotationAboutZAxis<Dim>& rhs) noexcept;
155 
156 template <size_t Dim>
157 bool operator!=(const UniformRotationAboutZAxis<Dim>& lhs,
158  const UniformRotationAboutZAxis<Dim>& rhs) noexcept;
159 } // namespace time_dependence
160 } // namespace creators
161 } // namespace domain
Identity.hpp
domain::creators::time_dependence::UniformRotationAboutZAxis
A uniform rotation about the axis:
Definition: UniformRotationAboutZAxis.hpp:60
std::string
domain::creators::time_dependence::UniformRotationAboutZAxis::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: UniformRotationAboutZAxis.cpp:41
Frame::Inertial
Definition: IndexType.hpp:44
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:46
domain::creators::time_dependence::UniformRotationAboutZAxis::InitialTime
The initial time of the function of time.
Definition: UniformRotationAboutZAxis.hpp:79
Frame::Grid
Definition: IndexType.hpp:43
std::rel_ops::operator!=
T operator!=(T... args)
Options.hpp
domain::CoordinateMaps::TimeDependent::Rotation< 2 >
Time-dependent spatial rotation in two dimensions.
Definition: Rotation.hpp:57
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::UniformRotationAboutZAxis::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: UniformRotationAboutZAxis.cpp:49
CoordinateMap.hpp
cstddef
Assert.hpp
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::UniformRotationAboutZAxis::FunctionOfTimeName
The name of the function of time to be added to the DataBox.
Definition: UniformRotationAboutZAxis.hpp:92
domain::creators::time_dependence::UniformRotationAboutZAxis::AngularVelocity
The -, -, and -velocity.
Definition: UniformRotationAboutZAxis.hpp:85
limits
domain::CoordinateMaps::Identity
Definition: Identity.hpp:28
Frame
Definition: IndexType.hpp:36
unordered_map
domain::creators::time_dependence::UniformRotationAboutZAxis::map_for_composition
MapForComposition map_for_composition() const noexcept
Returns the map for each block to be used in a composition of TimeDependences.
OptionString
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
TMPL.hpp
domain::creators::time_dependence::UniformRotationAboutZAxis::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: UniformRotationAboutZAxis.cpp:65
domain::CoordinateMap
A coordinate map or composition of coordinate maps.
Definition: CoordinateMap.hpp:237
string