Rotation.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <array>
7 #include <boost/optional.hpp>
8 #include <cstddef>
9 #include <memory>
10 #include <string>
11 #include <unordered_map>
12
14 #include "Utilities/TypeTraits/RemoveReferenceWrapper.hpp"
15
16 /// \cond
17 namespace domain {
18 namespace FunctionsOfTime {
19 class FunctionOfTime;
20 } // namespace FunctionsOfTime
21 } // namespace domain
22 namespace PUP {
23 class er;
24 } // namespace PUP
25 /// \endcond
26
27 namespace domain {
28 namespace CoordinateMaps {
29 namespace TimeDependent {
30
31 /// \cond HIDDEN_SYMBOLS
32 template <size_t Dim>
33 class Rotation;
34 /// \endcond
35
36 /*!
37  * \ingroup CoordMapsTimeDependentGroup
38  * \brief Time-dependent spatial rotation in two dimensions.
39  *
40  * Let \f$(R,\Phi)\f$ be the polar coordinates associated with
41  * \f$(\xi,\eta)\f$, where \f$\xi\f$ and \f$\eta\f$ are the unmapped
42  * coordiantes. Let \f$(r,\phi)\f$ be the polar coordinates associated with
43  * \f$(x,y)\f$, where \f$x\f$ and \f$y\f$ are the mapped coordinates.
44  * This map applies the spatial rotation \f$\phi = \Phi + \alpha(t)\f$.
45  *
46  * The formula for the mapping is:
47  *\f{eqnarray*}
48  x &=& \xi \cos \alpha(t) - \eta \sin \alpha(t), \\
49  y &=& \xi \sin \alpha(t) + \eta \cos \alpha(t).
50  \f}
51  *
52  * \note Currently, only a rotation in two-dimensional space is implemented
53  * here. In the future, this class should be extended to also support
54  * three-dimensional rotations using quaternions.
55  */
56 template <>
57 class Rotation<2> {
58  public:
59  static constexpr size_t dim = 2;
60
61  explicit Rotation(std::string function_of_time_name) noexcept;
62  Rotation() = default;
63
64  template <typename T>
66  const std::array<T, 2>& source_coords, double time,
67  const std::unordered_map<
70  functions_of_time) const noexcept;
71
72  boost::optional<std::array<double, 2>> inverse(
73  const std::array<double, 2>& target_coords, double time,
74  const std::unordered_map<
77  functions_of_time) const noexcept;
78
79  template <typename T>
80  std::array<tt::remove_cvref_wrap_t<T>, 2> frame_velocity(
81  const std::array<T, 2>& source_coords, double time,
82  const std::unordered_map<
85  functions_of_time) const noexcept;
86
87  template <typename T>
88  tnsr::Ij<tt::remove_cvref_wrap_t<T>, 2, Frame::NoFrame> jacobian(
89  const std::array<T, 2>& source_coords, double time,
90  const std::unordered_map<
93  functions_of_time) const noexcept;
94
95  template <typename T>
96  tnsr::Ij<tt::remove_cvref_wrap_t<T>, 2, Frame::NoFrame> inv_jacobian(
97  const std::array<T, 2>& source_coords, double time,
98  const std::unordered_map<
101  functions_of_time) const noexcept;
102
103  void pup(PUP::er& p) noexcept; // NOLINT
104
105  static bool is_identity() noexcept { return false; }
106
107  private:
108  friend bool operator==(const Rotation<2>& lhs,
109  const Rotation<2>& rhs) noexcept;
110  std::string f_of_t_name_;
111 };
112
113 bool operator!=(const Rotation<2>& lhs, const Rotation<2>& rhs) noexcept;
114
115 } // namespace TimeDependent
116 } // namespace CoordinateMaps
117 } // namespace domain
std::string
domain::CoordinateMaps::TimeDependent::Rotation< 2 >
Time-dependent spatial rotation in two dimensions.
Definition: Rotation.hpp:57
Frame::NoFrame
Represents an index that is not in a known frame, e.g. some internal intermediate frame that is irrel...
Definition: IndexType.hpp:48
cstddef
array
memory
TypeAliases.hpp
std::unique_ptr
unordered_map
string