SphericalMetricData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
9 #include "Evolution/Systems/Cce/AnalyticSolutions/WorldtubeData.hpp"
10 #include "Evolution/Systems/Cce/BoundaryDataTags.hpp"
11 #include "Evolution/Systems/Cce/Tags.hpp"
12 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
13 #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
14 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 class DataVector;
20 /// \endcond
21 
22 namespace Cce {
23 namespace Solutions {
24 
25 /*!
26  * \brief Abstract base class for analytic worldtube data most easily derived in
27  * spherical coordinate form.
28  *
29  * \details This class provides the functions required by the `WorldtubeData`
30  * interface that convert from a spherical coordinate spacetime metric to
31  * Cartesian coordinates. Derived classes of `SphericalMetricData` need not
32  * implement the `variables_impl`s for the Cartesian quantities. Instead, the
33  * derived classes must override the protected functions:
34  * - `SphericalMetricData::spherical_metric()`
35  * - `SphericalMetricData::dr_spherical_metric()`
36  * - `SphericalMetricData::dt_spherical_metric()`
37  *
38  * Derived classes are still responsible for overriding
39  * `WorldtubeData::get_clone()`, `WorldtubeData::variables_impl()` for tag
40  * `Cce::Tags::News`, and `WorldtubeData::prepare_solution()`.
41  */
43 
44  WRAPPED_PUPable_abstract(SphericalMetricData); // NOLINT
45 
46  SphericalMetricData() noexcept = default;
47 
48  explicit SphericalMetricData(const double extraction_radius) noexcept
49  : WorldtubeData{extraction_radius} {}
50 
51  /*!
52  * Computes the Jacobian
53  * \f$\partial x_{\mathrm{Cartesian}}^j / \partial x_{\mathrm{spherical}}^i\f$
54  *
55  * \details The Jacobian (with \f$ \sin \theta \f$
56  * scaled out of \f$\phi\f$ components) in question is
57  *
58  * \f{align*}{
59  * \frac{\partial x_{\mathrm{Cartesian}}^j}{\partial x_{\mathrm{spherical}}^i}
60  * = \left[
61  * \begin{array}{ccc}
62  * \frac{\partial x}{\partial r} & \frac{\partial y}{\partial r} &
63  * \frac{\partial z}{\partial r} \\
64  * \frac{\partial x}{\partial \theta} & \frac{\partial y}{\partial \theta} &
65  * \frac{\partial z}{\partial \theta} \\
66  * \frac{\partial x}{\sin \theta \partial \phi} &
67  * \frac{\partial y}{\sin \theta \partial \phi} &
68  * \frac{\partial y}{\sin \theta \partial \phi}
69  * \end{array}
70  * \right]
71  * = \left[
72  * \begin{array}{ccc}
73  * \sin \theta \cos \phi & \sin \theta \sin \phi & \cos \theta \\
74  * r \cos \theta \cos \phi & r \cos \theta \sin \phi & -r \sin \theta \\
75  * -r \sin \phi & r \cos \phi & 0
76  * \end{array}
77  * \right]
78  * \f}
79  */
81  size_t l_max) const noexcept;
82 
83  /*!
84  * Computes the first radial derivative of the
85  * Jacobian: \f$\partial_r (\partial x_{\mathrm{Cartesian}}^j /
86  * \partial x_{\mathrm{Spherical}}^i)\f$
87  *
88  * \details The radial derivative of the Jacobian (with \f$ \sin \theta \f$
89  * scaled out of \f$\phi\f$ components) in question is
90  *
91  * \f{align*}{
92  * \frac{\partial}{\partial r}
93  * \frac{\partial x_{\mathrm{Cartesian}}^j}{\partial x_{\mathrm{spherical}}^i}
94  * = \left[
95  * \begin{array}{ccc}
96  * \frac{\partial^2 x}{(\partial r)^2} & \frac{\partial^2 y}{(\partial r)^2} &
97  * \frac{\partial^2 z}{(\partial r)^2} \\
98  * \frac{\partial^2 x}{\partial r \partial \theta} &
99  * \frac{\partial^2 y}{\partial r \partial \theta} &
100  * \frac{\partial^2 z}{\partial r \partial \theta} \\
101  * \frac{\partial^2 x}{\sin \theta \partial r \partial \phi} &
102  * \frac{\partial^2 y}{\sin \theta \partial r \partial \phi} &
103  * \frac{\partial^2 y}{\sin \theta \partial r \partial \phi}
104  * \end{array}
105  * \right]
106  * = \left[
107  * \begin{array}{ccc}
108  * 0 & 0 & 0 \\
109  * \cos \theta \cos \phi & \cos \theta \sin \phi & - \sin \theta \\
110  * - \sin \phi & \cos \phi & 0
111  * \end{array}
112  * \right]
113  * \f}
114  */
116  size_t l_max) noexcept;
117 
118  /*!
119  * Computes the Jacobian
120  * \f$\partial x_{\mathrm{spherical}}^j / \partial
121  * x_{\mathrm{Cartesian}}^i\f$
122  *
123  * \details The Jacobian (with \f$ \sin \theta \f$
124  * scaled out of \f$\phi\f$ components) in question is
125  *
126  * \f{align*}{
127  * \frac{\partial x_{\mathrm{spherical}}^j}{\partial x_{\mathrm{Cartesian}}^i}
128  * = \left[
129  * \begin{array}{ccc}
130  * \frac{\partial r}{\partial x} & \frac{\partial \theta}{\partial x} &
131  * \frac{\sin \theta \partial \phi}{\partial x} \\
132  * \frac{\partial r}{\partial y} & \frac{\partial \theta}{\partial y} &
133  * \frac{\sin \theta \partial \phi}{\partial y} \\
134  * \frac{\partial r}{\partial z} & \frac{\partial \theta}{\partial z} &
135  * \frac{\sin \theta \partial \phi}{\partial z}
136  * \end{array}
137  * \right]
138  * = \left[
139  * \begin{array}{ccc}
140  * \cos \phi \sin \theta & \frac{\cos \phi \cos \theta}{r} &
141  * - \frac{\sin \phi}{r} \\
142  * \sin \phi \sin \theta & \frac{\cos \theta \sin \phi}{r} &
143  * \frac{\cos \phi}{r} \\
144  * \cos \theta & -\frac{\sin \theta}{r} & 0
145  * \end{array}
146  * \right]
147  * \f}
148  */
150  size_t l_max) const noexcept;
151 
152  /*!
153  * Computes the first radial derivative of the
154  * Jacobian: \f$\partial_r (\partial x_{\mathrm{spherical}}^j / \partial
155  * x_{\mathrm{Cartesian}}^i)\f$
156  *
157  * \details The first radial derivative of the Jacobian (with
158  * \f$ \sin \theta \f$ scaled out of \f$\phi\f$ components) in question is
159  *
160  * \f{align*}{
161  * \frac{\partial}{\partial r}
162  * \frac{\partial x_{\mathrm{spherical}}^j}{\partial x_{\mathrm{Cartesian}}^i}
163  * = \left[
164  * \begin{array}{ccc}
165  * \frac{\partial}{\partial r} \frac{\partial r}{\partial x} &
166  * \frac{\partial}{\partial r} \frac{\partial \theta}{\partial x} &
167  * \frac{\partial}{\partial r} \frac{\sin \theta \partial \phi}{\partial x} \\
168  * \frac{\partial}{\partial r} \frac{\partial r}{\partial y} &
169  * \frac{\partial}{\partial r} \frac{\partial \theta}{\partial y} &
170  * \frac{\partial}{\partial r} \frac{\sin \theta \partial \phi}{\partial y} \\
171  * \frac{\partial}{\partial r} \frac{\partial r}{\partial z} &
172  * \frac{\partial}{\partial r} \frac{\partial \theta}{\partial z} &
173  * \frac{\partial}{\partial r} \frac{\sin \theta \partial \phi}{\partial z}
174  * \end{array}
175  * \right]
176  * = \left[
177  * \begin{array}{ccc}
178  * 0 & - \frac{\cos \phi \cos \theta}{r^2} & \frac{\sin \phi}{r^2} \\
179  * 0 & - \frac{\cos \theta \sin \phi}{r^2} & -\frac{\cos \phi}{r^2} \\
180  * 0 & \frac{\sin \theta}{r^2} & 0
181  * \end{array}
182  * \right]
183  * \f}
184  */
185  void dr_inverse_jacobian(
187  size_t l_max) const noexcept;
188 
189  void pup(PUP::er& p) noexcept override;
190 
191  protected:
192  using WorldtubeData::variables_impl;
193 
194  /*!
195  * \brief Computes the Cartesian spacetime metric from the spherical solution
196  * provided by the derived classes.
197  *
198  * \details The derived classes provide spherical metric data via the virtual
199  * function `SphericalMetricData::spherical_metric()` at a resolution
200  * determined by member variable `l_max_`. This function performs the
201  * coordinate transformation using the Jacobian computed from
202  * `SphericalMetricData::inverse_jacobian()`.
203  */
204  void variables_impl(gsl::not_null<tnsr::aa<DataVector, 3>*> spacetime_metric,
205  size_t l_max, double time,
206  tmpl::type_<gr::Tags::SpacetimeMetric<
207  3, ::Frame::Inertial, DataVector>> /*meta*/) const
208  noexcept override;
209 
210  /*!
211  * \brief Computes the time derivative of the Cartesian spacetime metric from
212  * the spherical solution provided by the derived classes.
213  *
214  * \details The derived classes provide the time derivative of the spherical
215  * metric data via the virtual function
216  * `SphericalMetricData::dt_spherical_metric()` at a resolution determined by
217  * member variable `l_max_`. This function performs the coordinate
218  * transformation using the Jacobian computed from
219  * `SphericalMetricData::inverse_jacobian()`.
220  */
221  void variables_impl(
222  gsl::not_null<tnsr::aa<DataVector, 3>*> dt_spacetime_metric, size_t l_max,
223  double time,
224  tmpl::type_<::Tags::dt<gr::Tags::SpacetimeMetric<
225  3, ::Frame::Inertial, DataVector>>> /*meta*/) const noexcept override;
226 
227  /*!
228  * \brief Computes the spatial derivatives of the Cartesian spacetime metric
229  * from the spherical solution provided by the derived classes.
230  *
231  * \details The derived classes provide the radial derivative of the spherical
232  * metric data via the virtual function
233  * `SphericalMetricData::dr_spherical_metric()` at a resolution determined by
234  * member variable `l_max_`. This function performs the additional angular
235  * derivatives necessary to assemble the full spatial derivative and performs
236  * the coordinate transformation to Cartesian coordinates via the Jacobians
237  * computed in `SphericalMetricData::inverse_jacobian()` and
238  * `SphericalMetricData::inverse_jacobian()`.
239  */
240  void variables_impl(
241  gsl::not_null<tnsr::iaa<DataVector, 3>*> d_spacetime_metric, size_t l_max,
242  double time,
243  tmpl::type_<
245  noexcept override;
246 
247  /// Must be overriden in the derived class; should compute the spacetime
248  /// metric of the analytic solution in spherical coordinates.
249  virtual void spherical_metric(
253  size_t l_max, double time) const noexcept = 0;
254 
255  /// Must be overriden in the derived class; should compute the first radial
256  /// derivative of the spacetime metric of the analytic solution in spherical
257  /// coordinates.
258  virtual void dr_spherical_metric(
262  size_t l_max, double time) const noexcept = 0;
263 
264  /// Must be overriden in the derived class; should compute the first time
265  /// derivative of the spacetime metric of the analytic solution in spherical
266  /// coordinates.
267  virtual void dt_spherical_metric(
271  size_t l_max, double time) const noexcept = 0;
272 };
273 
274 } // namespace Solutions
275 } // namespace Cce
Frame::Inertial
Definition: IndexType.hpp:44
Cce::Solutions::SphericalMetricData::inverse_jacobian
void inverse_jacobian(gsl::not_null< CartesianiSphericalJ * > inverse_jacobian, size_t l_max) const noexcept
Cce::Solutions::SphericalMetricData::dr_jacobian
static void dr_jacobian(gsl::not_null< SphericaliCartesianJ * > dr_jacobian, size_t l_max) noexcept
Cce::Solutions::SphericalMetricData::dr_spherical_metric
virtual void dr_spherical_metric(gsl::not_null< tnsr::aa< DataVector, 3, ::Frame::Spherical<::Frame::Inertial >> * > dr_spherical_metric, size_t l_max, double time) const noexcept=0
Must be overriden in the derived class; should compute the first radial derivative of the spacetime m...
Cce::Solutions::SphericalMetricData::dt_spherical_metric
virtual void dt_spherical_metric(gsl::not_null< tnsr::aa< DataVector, 3, ::Frame::Spherical<::Frame::Inertial >> * > dt_spherical_metric, size_t l_max, double time) const noexcept=0
Must be overriden in the derived class; should compute the first time derivative of the spacetime met...
Cce::Solutions::SphericalMetricData
Abstract base class for analytic worldtube data most easily derived in spherical coordinate form.
Definition: SphericalMetricData.hpp:42
Cce::Solutions::SphericalMetricData::spherical_metric
virtual void spherical_metric(gsl::not_null< tnsr::aa< DataVector, 3, ::Frame::Spherical<::Frame::Inertial >> * > spherical_metric, size_t l_max, double time) const noexcept=0
Must be overriden in the derived class; should compute the spacetime metric of the analytic solution ...
cstddef
Cce::Solutions::SphericalMetricData::variables_impl
void variables_impl(gsl::not_null< tnsr::aa< DataVector, 3 > * > spacetime_metric, size_t l_max, double time, tmpl::type_< gr::Tags::SpacetimeMetric< 3, ::Frame::Inertial, DataVector >>) const noexcept override
Computes the Cartesian spacetime metric from the spherical solution provided by the derived classes.
gr::Tags::SpacetimeMetric
Definition: Tags.hpp:17
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:42
Cce::Solutions::WorldtubeData
Abstract base class for analytic worldtube data for verifying the CCE system.
Definition: WorldtubeData.hpp:65
Frame::Spherical
Represents a spherical-coordinate frame that is associated with a Cartesian frame,...
Definition: IndexType.hpp:54
GeneralizedHarmonic::Tags::Phi
Auxiliary variable which is analytically the spatial derivative of the spacetime metric.
Definition: Tags.hpp:40
Tags::dt
Prefix indicating a time derivative.
Definition: Prefixes.hpp:32
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: BoundaryComputeAndSendToEvolution.hpp:28
Gsl.hpp
gr::spacetime_metric
void spacetime_metric(gsl::not_null< tnsr::aa< DataType, Dim, Frame > * > spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, Dim, Frame > &shift, const tnsr::ii< DataType, Dim, Frame > &spatial_metric) noexcept
Computes the spacetime metric from the spatial metric, lapse, and shift.
Tensor.hpp
Cce::Solutions::SphericalMetricData::jacobian
void jacobian(gsl::not_null< SphericaliCartesianJ * > jacobian, size_t l_max) const noexcept
Cce::Solutions::SphericalMetricData::dr_inverse_jacobian
void dr_inverse_jacobian(gsl::not_null< CartesianiSphericalJ * > dr_inverse_jacobian, size_t l_max) const noexcept
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182