Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/DataBox/Prefixes.hpp"
9 : #include "DataStructures/DataBox/Tag.hpp"
10 : #include "DataStructures/DataVector.hpp"
11 : #include "DataStructures/Tensor/Tensor.hpp"
12 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
13 : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
14 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
15 : #include "Utilities/ContainerHelpers.hpp"
16 : #include "Utilities/Gsl.hpp"
17 : #include "Utilities/TMPL.hpp"
18 :
19 : // IWYU pragma: no_forward_declare Tags::deriv
20 :
21 : /// \cond
22 : namespace domain {
23 : namespace Tags {
24 : template <size_t Dim, typename Frame>
25 : struct Coordinates;
26 : } // namespace Tags
27 : } // namespace domain
28 : class DataVector;
29 : template <typename X, typename Symm, typename IndexList>
30 : class Tensor;
31 : /// \endcond
32 :
33 : namespace gh {
34 : /// @{
35 : /*!
36 : * \ingroup GeneralRelativityGroup
37 : * \brief Computes spatial derivatives of lapse (\f$\alpha\f$) from the
38 : * generalized harmonic variables and spacetime unit normal 1-form.
39 : *
40 : * \details If the generalized harmonic conjugate momentum and spatial
41 : * derivative variables are \f$\Pi_{ab} = -n^c \partial_c g_{ab} \f$ and
42 : * \f$\Phi_{iab} = \partial_i g_{ab} \f$, the spatial derivatives of
43 : * \f$\alpha\f$ can be obtained from:
44 : *
45 : * \f{align*}
46 : * n^a n^b \Phi_{iab} =
47 : * -\frac{1}{2\alpha} [\partial_i (-\alpha^2 + \beta_j\beta^j)-
48 : * 2 \beta^j \partial_i \beta_j
49 : * + \beta^j \beta^k \partial_i \gamma_{jk}]
50 : * = -\frac{2}{\alpha} \partial_i \alpha,
51 : * \f}
52 : *
53 : * since
54 : *
55 : * \f[
56 : * \partial_i (\beta_j\beta^j) =
57 : * 2\beta^j \partial_i \beta_j - \beta^j \beta^k \partial_i \gamma_{jk}.
58 : * \f]
59 : *
60 : * \f[
61 : * \Longrightarrow \partial_i \alpha = -(\alpha/2) n^a \Phi_{iab} n^b
62 : * \f]
63 : */
64 : template <typename DataType, size_t SpatialDim, typename Frame>
65 1 : void spatial_deriv_of_lapse(
66 : gsl::not_null<tnsr::i<DataType, SpatialDim, Frame>*> deriv_lapse,
67 : const Scalar<DataType>& lapse,
68 : const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
69 : const tnsr::iaa<DataType, SpatialDim, Frame>& phi);
70 :
71 : template <typename DataType, size_t SpatialDim, typename Frame>
72 1 : tnsr::i<DataType, SpatialDim, Frame> spatial_deriv_of_lapse(
73 : const Scalar<DataType>& lapse,
74 : const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
75 : const tnsr::iaa<DataType, SpatialDim, Frame>& phi);
76 : /// @}
77 :
78 : namespace Tags {
79 : /*!
80 : * \brief Compute item to get spatial derivatives of lapse from the
81 : * generalized harmonic variables and spacetime unit normal one-form.
82 : *
83 : * \details See `spatial_deriv_of_lapse()`. Can be retrieved using
84 : * `gr::Tags::Lapse` wrapped in `::Tags::deriv`.
85 : */
86 : template <size_t SpatialDim, typename Frame>
87 1 : struct DerivLapseCompute : ::Tags::deriv<gr::Tags::Lapse<DataVector>,
88 : tmpl::size_t<SpatialDim>, Frame>,
89 : db::ComputeTag {
90 0 : using argument_tags =
91 : tmpl::list<gr::Tags::Lapse<DataVector>,
92 : gr::Tags::SpacetimeNormalVector<DataVector, SpatialDim, Frame>,
93 : Phi<DataVector, SpatialDim, Frame>>;
94 :
95 0 : using return_type = tnsr::i<DataVector, SpatialDim, Frame>;
96 :
97 0 : static constexpr auto function = static_cast<void (*)(
98 : gsl::not_null<tnsr::i<DataVector, SpatialDim, Frame>*>,
99 : const Scalar<DataVector>&, const tnsr::A<DataVector, SpatialDim, Frame>&,
100 : const tnsr::iaa<DataVector, SpatialDim, Frame>&)>(
101 : &spatial_deriv_of_lapse<DataVector, SpatialDim, Frame>);
102 :
103 0 : using base = ::Tags::deriv<gr::Tags::Lapse<DataVector>,
104 : tmpl::size_t<SpatialDim>, Frame>;
105 : };
106 : } // namespace Tags
107 : } // namespace gh
|