RotationTimeDep.hpp
1 // Distributed under the MIT License.
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 CoordMapsTimeDependent {
29 
30 /// \cond HIDDEN_SYMBOLS
31 template <size_t Dim>
32 class Rotation;
33 /// \endcond
34 
35 /*!
36  * \ingroup CoordMapsTimeDependentGroup
37  * \brief Time-dependent spatial rotation in two dimensions.
38  *
39  * Let \f$(R,\Phi)\f$ be the polar coordinates associated with
40  * \f$(\xi,\eta)\f$, where \f$\xi\f$ and \f$\eta\f$ are the unmapped
41  * coordiantes. Let \f$(r,\phi)\f$ be the polar coordinates associated with
42  * \f$(x,y)\f$, where \f$x\f$ and \f$y\f$ are the mapped coordinates.
43  * This map applies the spatial rotation \f$\phi = \Phi + \alpha(t)\f$.
44  *
45  * The formula for the mapping is:
46  *\f{eqnarray*}
47  x &=& \xi \cos \alpha(t) - \eta \sin \alpha(t), \\
48  y &=& \xi \sin \alpha(t) + \eta \cos \alpha(t).
49  \f}
50  *
51  * \note Currently, only a rotation in two-dimensional space is implemented
52  * here. In the future, this class should be extended to also support
53  * three-dimensional rotations using quaternions.
54  */
55 template <>
56 class Rotation<2> {
57  public:
58  static constexpr size_t dim = 2;
59 
60  explicit Rotation(std::string function_of_time_name) noexcept;
61  Rotation() = default;
62 
63  template <typename T>
65  const std::array<T, 2>& source_coords, double time,
66  const std::unordered_map<
69  functions_of_time) const noexcept;
70 
71  boost::optional<std::array<double, 2>> inverse(
72  const std::array<double, 2>& target_coords, double time,
73  const std::unordered_map<
76  functions_of_time) const noexcept;
77 
78  template <typename T>
79  std::array<tt::remove_cvref_wrap_t<T>, 2> frame_velocity(
80  const std::array<T, 2>& source_coords, double time,
81  const std::unordered_map<
84  functions_of_time) const noexcept;
85 
86  template <typename T>
87  tnsr::Ij<tt::remove_cvref_wrap_t<T>, 2, Frame::NoFrame> jacobian(
88  const std::array<T, 2>& source_coords, double time,
89  const std::unordered_map<
92  functions_of_time) const noexcept;
93 
94  template <typename T>
95  tnsr::Ij<tt::remove_cvref_wrap_t<T>, 2, Frame::NoFrame> inv_jacobian(
96  const std::array<T, 2>& source_coords, double time,
97  const std::unordered_map<
100  functions_of_time) const noexcept;
101 
102  void pup(PUP::er& p) noexcept; // NOLINT
103 
104  bool is_identity() const noexcept { return false; }
105 
106  private:
107  friend bool operator==(const Rotation<2>& lhs,
108  const Rotation<2>& rhs) noexcept;
109  std::string f_of_t_name_;
110 };
111 
112 bool operator!=(const Rotation<2>& lhs, const Rotation<2>& rhs) noexcept;
113 
114 } // namespace CoordMapsTimeDependent
115 } // namespace domain
Definition: Strahlkorper.hpp:14
Definition: BlockId.hpp:16
Time-dependent spatial rotation in two dimensions.
Definition: RotationTimeDep.hpp:56
Defines a list of useful type aliases for tensors.
Represents an index that is not in a known frame, e.g. some internal intermediate frame that is irrel...
Definition: IndexType.hpp:48