Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <array>
7 : #include <cstddef>
8 : #include <optional>
9 :
10 : #include "DataStructures/Tensor/TypeAliases.hpp"
11 :
12 : /// \cond
13 : namespace PUP {
14 : class er;
15 : } // namespace PUP
16 : /// \endcond
17 :
18 : namespace domain::CoordinateMaps {
19 :
20 : /*!
21 : * \ingroup CoordinateMapsGroup
22 : *
23 : * \brief Transformation from polar to Cartesian coordinates.
24 : *
25 : * \details This is a mapping from \f$(r,\phi) \rightarrow (x,y) \f$.
26 : *
27 : * The formula for the mapping is...
28 : * \f{eqnarray*}
29 : * x &=& r \cos\phi \\
30 : * y &=& r \sin\phi
31 : * \f}
32 : */
33 1 : class PolarToCartesian {
34 : public:
35 0 : static constexpr size_t dim = 2;
36 0 : PolarToCartesian();
37 0 : ~PolarToCartesian() = default;
38 0 : PolarToCartesian(PolarToCartesian&&);
39 0 : PolarToCartesian(const PolarToCartesian&);
40 0 : PolarToCartesian& operator=(const PolarToCartesian&);
41 0 : PolarToCartesian& operator=(PolarToCartesian&&);
42 :
43 : template <typename T>
44 0 : std::array<T, 2> operator()(const std::array<T, 2>& source_coords) const;
45 :
46 : // NOLINTNEXTLINE(readability-convert-member-functions-to-static)
47 0 : std::optional<std::array<double, 2>> inverse(
48 : const std::array<double, 2>& target_coords) const;
49 :
50 : template <typename T>
51 0 : tnsr::Ij<T, 2, Frame::NoFrame> jacobian(
52 : const std::array<T, 2>& source_coords) const;
53 :
54 : template <typename T>
55 0 : tnsr::Ij<T, 2, Frame::NoFrame> inv_jacobian(
56 : const std::array<T, 2>& source_coords) const;
57 :
58 : // NOLINTNEXTLINE(google-runtime-references)
59 0 : void pup(PUP::er& p);
60 :
61 0 : static constexpr bool is_identity() { return false; }
62 :
63 0 : static constexpr bool supports_hessian{false};
64 : };
65 :
66 0 : bool operator==(const PolarToCartesian& lhs, const PolarToCartesian& rhs);
67 :
68 0 : bool operator!=(const PolarToCartesian& lhs, const PolarToCartesian& rhs);
69 : } // namespace domain::CoordinateMaps
|