SpatialDerivOfShift.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
9 #include "DataStructures/DataBox/Tag.hpp"
10 #include "DataStructures/DataVector.hpp"
12 #include "Evolution/Systems/GeneralizedHarmonic/Tags.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 GeneralizedHarmonic {
34 // @{
35 /*!
36  * \ingroup GeneralRelativityGroup
37  * \brief Computes spatial derivatives of the shift vector from
38  * the generalized harmonic and geometric variables
39  *
40  * \details Spatial derivatives of the shift vector \f$N^i\f$ can be derived
41  * from the following steps:
42  * \f{align*}
43  * \partial_i N^j
44  * =& g^{jl} g_{kl} \partial_i N^k \\
45  * =& g^{jl} (N^k \partial_i g_{lk}
46  * + g_{kl}\partial_i N^k - N^k \partial_i g_{kl}) \\
47  * =& g^{jl} (\partial_i N_l - N^k \partial_i g_{lk}) (\because g^{j0} = 0) \\
48  * =& g^{ja} (\partial_i \psi_{a0} - N^k \partial _i \psi_{ak}) \\
49  * =& N g^{ja} t^b \partial_i \psi_{ab} \\
50  * =& (g^{ja} - t^j t^a) N t^b \Phi_{iab} - 2 t^j \partial_i N \\
51  * =& \psi^{ja} N t^b \Phi_{iab} - 2 t^j \partial_i N \\
52  * =& N (\psi^{ja} + t^j t^a) t^b \Phi_{iab}.
53  * \f}
54  * where we used the equation from spatial_deriv_of_lapse() for
55  * \f$\partial_i N\f$.
56  */
57 template <size_t SpatialDim, typename Frame, typename DataType>
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) noexcept;
64 
65 template <size_t SpatialDim, typename Frame, typename DataType>
66 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) noexcept;
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>
83  : ::Tags::deriv<gr::Tags::Shift<SpatialDim, Frame, DataVector>,
84  tmpl::size_t<SpatialDim>, Frame>,
86  using argument_tags = tmpl::list<
91 
92  using return_type = tnsr::iJ<DataVector, SpatialDim, Frame>;
93 
94  static constexpr auto function = static_cast<void (*)(
96  const Scalar<DataVector>&, const tnsr::AA<DataVector, SpatialDim, Frame>&,
97  const tnsr::A<DataVector, SpatialDim, Frame>&,
98  const tnsr::iaa<DataVector, SpatialDim, Frame>&) noexcept>(
99  &spatial_deriv_of_shift<SpatialDim, Frame, DataVector>);
100 
102  tmpl::size_t<SpatialDim>, Frame>;
103 };
104 } // namespace Tags
105 } // namespace GeneralizedHarmonic
db::ComputeTag
Marks a DataBoxTag as being a compute item that executes a function.
Definition: Tag.hpp:109
GeneralizedHarmonic::spatial_deriv_of_shift
void spatial_deriv_of_shift(gsl::not_null< tnsr::iJ< DataType, SpatialDim, Frame > * > deriv_shift, const Scalar< DataType > &lapse, const tnsr::AA< DataType, SpatialDim, Frame > &inverse_spacetime_metric, const tnsr::A< DataType, SpatialDim, Frame > &spacetime_unit_normal, const tnsr::iaa< DataType, SpatialDim, Frame > &phi) noexcept
Computes spatial derivatives of the shift vector from the generalized harmonic and geometric variable...
gr::Tags::SpacetimeNormalVector
Definition: Tags.hpp:87
GeneralizedHarmonic
Items related to evolving the first-order generalized harmonic system.
Definition: Characteristics.cpp:21
gr::lapse
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
cstddef
gr::Tags::InverseSpacetimeMetric
Definition: Tags.hpp:21
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:42
GeneralizedHarmonic::phi
void phi(gsl::not_null< tnsr::iaa< DataType, SpatialDim, Frame > * > phi, const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric) noexcept
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein's equations...
GeneralizedHarmonic::Tags::DerivShiftCompute
Compute item to get spatial derivatives of the shift vector from generalized harmonic and geometric v...
Definition: SpatialDerivOfShift.hpp:82
GeneralizedHarmonic::Tags::Phi< SpatialDim, Frame >
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Gsl.hpp
Frame
Definition: IndexType.hpp:36
Tensor.hpp
Tags::deriv
Prefix indicating spatial derivatives.
Definition: PartialDerivatives.hpp:53
PartialDerivatives.hpp
Prefixes.hpp
gr::Tags::Lapse
Definition: Tags.hpp:52
gr::inverse_spacetime_metric
void inverse_spacetime_metric(gsl::not_null< tnsr::AA< DataType, SpatialDim, Frame > * > inverse_spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute inverse spacetime metric from inverse spatial metric, lapse and shift.
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183