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 Pfaffian transformation from spherical to Cartesian coordinates.
24 : *
25 : * \note This map is designed to be used together with Spherepack! Spherepack
26 : * expects a Pfaffian transformation of the derivatives.
27 : *
28 : * \details This is a Pfaffian mapping from \f$(r,\theta,\phi) \rightarrow
29 : * (x,y,z) \f$.
30 : *
31 : * The formula for the mapping is...
32 : * \f{eqnarray*}
33 : * x &=& r \sin\theta \cos\phi \\
34 : * y &=& r \sin\theta \sin\phi \\
35 : * z &=& r \cos\theta
36 : * \f}
37 : *
38 : * The Pfaffian basis vectors
39 : * \f$ (e_{\hat r}, e_{\hat \theta}, e_{\hat \phi})\f$
40 : * are related to the coordinate basis vectors
41 : * \f$ (e_r, e_{\theta}, e_{\phi})\f$
42 : * by...
43 : * \f{eqnarray*}
44 : * e_{\hat r} &=& e_r \\
45 : * e_{\hat \theta} &=& e_{\theta} \\
46 : * e_{\hat \phi} &=& \frac{1}{\sin \theta} e_{\phi}
47 : * \f}
48 : */
49 1 : class SphericalToCartesianPfaffian {
50 : public:
51 0 : static constexpr size_t dim = 3;
52 0 : SphericalToCartesianPfaffian();
53 0 : ~SphericalToCartesianPfaffian() = default;
54 0 : SphericalToCartesianPfaffian(SphericalToCartesianPfaffian&&);
55 0 : SphericalToCartesianPfaffian(const SphericalToCartesianPfaffian&);
56 0 : SphericalToCartesianPfaffian& operator=(const SphericalToCartesianPfaffian&);
57 0 : SphericalToCartesianPfaffian& operator=(SphericalToCartesianPfaffian&&);
58 :
59 : template <typename T>
60 0 : std::array<T, 3> operator()(const std::array<T, 3>& source_coords) const;
61 :
62 : // NOLINTNEXTLINE(readability-convert-member-functions-to-static)
63 0 : std::optional<std::array<double, 3>> inverse(
64 : const std::array<double, 3>& target_coords) const;
65 :
66 : template <typename T>
67 0 : tnsr::Ij<T, 3, Frame::NoFrame> jacobian(
68 : const std::array<T, 3>& source_coords) const;
69 :
70 : template <typename T>
71 0 : tnsr::Ij<T, 3, Frame::NoFrame> inv_jacobian(
72 : const std::array<T, 3>& source_coords) const;
73 :
74 : // NOLINTNEXTLINE(google-runtime-references)
75 0 : void pup(PUP::er& p);
76 :
77 0 : static constexpr bool is_identity() { return false; }
78 :
79 0 : static constexpr bool supports_hessian{false};
80 : };
81 :
82 0 : bool operator==(const SphericalToCartesianPfaffian& lhs,
83 : const SphericalToCartesianPfaffian& rhs);
84 :
85 0 : bool operator!=(const SphericalToCartesianPfaffian& lhs,
86 : const SphericalToCartesianPfaffian& rhs);
87 : } // namespace domain::CoordinateMaps
|