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 : /// \cond
20 : namespace domain {
21 : namespace Tags {
22 : template <size_t Dim, typename Frame>
23 : struct Coordinates;
24 : } // namespace Tags
25 : } // namespace domain
26 : class DataVector;
27 : template <typename X, typename Symm, typename IndexList>
28 : class Tensor;
29 : /// \endcond
30 :
31 : namespace gh {
32 : /// @{
33 : /*!
34 : * \ingroup GeneralRelativityGroup
35 : * \brief Computes spatial derivatives of the shift vector from
36 : * the generalized harmonic and geometric variables
37 : *
38 : * \details Spatial derivatives of the shift vector \f$\beta^i\f$ can be derived
39 : * from the following steps:
40 : * \f{align*}
41 : * \partial_i \beta^j
42 : * =& \gamma^{jl} \gamma_{kl} \partial_i \beta^k \\
43 : * =& \gamma^{jl} (\beta^k \partial_i \gamma_{lk}
44 : * + \gamma_{kl}\partial_i \beta^k - \beta^k \partial_i \gamma_{kl}) \\
45 : * =& \gamma^{jl} (\partial_i \beta_l - \beta^k \partial_i \gamma_{lk})
46 : * (\because \gamma^{j0} = 0) \\
47 : * =& \gamma^{ja} (\partial_i g_{a0} - \beta^k \partial _i g_{ak}) \\
48 : * =& \alpha \gamma^{ja} n^b \partial_i g_{ab} \\
49 : * =& (\gamma^{ja} - n^j n^a) \alpha n^b \Phi_{iab}
50 : * - 2 n^j \partial_i \alpha \\
51 : * =& g^{ja} \alpha n^b \Phi_{iab} - 2 n^j \partial_i \alpha \\
52 : * =& \alpha (g^{ja} + n^j n^a) n^b \Phi_{iab}.
53 : * \f}
54 : * where we used the equation from spatial_deriv_of_lapse() for
55 : * \f$\partial_i \alpha\f$.
56 : */
57 : template <typename DataType, size_t SpatialDim, typename Frame>
58 1 : void spatial_deriv_of_shift(
59 : gsl::not_null<tnsr::iJ<DataType, SpatialDim, Frame>*> deriv_shift,
60 : const Scalar<DataType>& lapse,
61 : const tnsr::AA<DataType, SpatialDim, Frame>& inverse_spacetime_metric,
62 : const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
63 : const tnsr::iaa<DataType, SpatialDim, Frame>& phi);
64 :
65 : template <typename DataType, size_t SpatialDim, typename Frame>
66 1 : tnsr::iJ<DataType, SpatialDim, Frame> spatial_deriv_of_shift(
67 : const Scalar<DataType>& lapse,
68 : const tnsr::AA<DataType, SpatialDim, Frame>& inverse_spacetime_metric,
69 : const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
70 : const tnsr::iaa<DataType, SpatialDim, Frame>& phi);
71 : /// @}
72 :
73 : namespace Tags {
74 : /*!
75 : * \brief Compute item to get spatial derivatives of the shift vector from
76 : * generalized harmonic and geometric variables
77 : *
78 : * \details See `spatial_deriv_of_shift()`. Can be retrieved using
79 : * `gr::Tags::Shift` wrapped in `::Tags::deriv`.
80 : */
81 : template <size_t SpatialDim, typename Frame>
82 1 : struct DerivShiftCompute
83 : : ::Tags::deriv<gr::Tags::Shift<DataVector, SpatialDim, Frame>,
84 : tmpl::size_t<SpatialDim>, Frame>,
85 : db::ComputeTag {
86 0 : using argument_tags = tmpl::list<
87 : gr::Tags::Lapse<DataVector>,
88 : gr::Tags::InverseSpacetimeMetric<DataVector, SpatialDim, Frame>,
89 : gr::Tags::SpacetimeNormalVector<DataVector, SpatialDim, Frame>,
90 : Phi<DataVector, SpatialDim, Frame>>;
91 :
92 0 : using return_type = tnsr::iJ<DataVector, SpatialDim, Frame>;
93 :
94 0 : static constexpr auto function = static_cast<void (*)(
95 : gsl::not_null<tnsr::iJ<DataVector, SpatialDim, Frame>*>,
96 : const Scalar<DataVector>&, const tnsr::AA<DataVector, SpatialDim, Frame>&,
97 : const tnsr::A<DataVector, SpatialDim, Frame>&,
98 : const tnsr::iaa<DataVector, SpatialDim, Frame>&)>(
99 : &spatial_deriv_of_shift<DataVector, SpatialDim, Frame>);
100 :
101 0 : using base = ::Tags::deriv<gr::Tags::Shift<DataVector, SpatialDim, Frame>,
102 : tmpl::size_t<SpatialDim>, Frame>;
103 : };
104 : } // namespace Tags
105 : } // namespace gh
|