Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cmath>
7 : #include <cstddef>
8 : #include <cstdint>
9 : #include <utility>
10 :
11 : #include "DataStructures/DataBox/Prefixes.hpp"
12 : #include "DataStructures/DataBox/Tag.hpp"
13 : #include "DataStructures/Tensor/Tensor.hpp"
14 : #include "DataStructures/VariablesTag.hpp"
15 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
16 : #include "Utilities/ContainerHelpers.hpp"
17 : #include "Utilities/Gsl.hpp"
18 : #include "Utilities/TMPL.hpp"
19 : #include "Utilities/TaggedTuple.hpp"
20 :
21 : namespace gr {
22 : /// @{
23 : /*!
24 : * \ingroup GeneralRelativityGroup
25 : * \brief Computes the spacetime metric from the spatial metric, lapse, and
26 : * shift.
27 : * \details The spacetime metric \f$ g_{ab} \f$ is calculated as
28 : * \f{align}{
29 : * g_{tt} &= - \alpha^2 + \beta^m \beta^n \gamma_{mn} \\
30 : * g_{ti} &= \gamma_{mi} \beta^m \\
31 : * g_{ij} &= \gamma_{ij}
32 : * \f}
33 : * where \f$ \alpha, \beta^i\f$ and \f$ \gamma_{ij}\f$ are the lapse, shift and
34 : * spatial metric respectively
35 : */
36 : template <typename DataType, size_t Dim, typename Frame>
37 1 : void spacetime_metric(
38 : gsl::not_null<tnsr::aa<DataType, Dim, Frame>*> spacetime_metric,
39 : const Scalar<DataType>& lapse, const tnsr::I<DataType, Dim, Frame>& shift,
40 : const tnsr::ii<DataType, Dim, Frame>& spatial_metric);
41 :
42 : template <typename DataType, size_t SpatialDim, typename Frame>
43 1 : tnsr::aa<DataType, SpatialDim, Frame> spacetime_metric(
44 : const Scalar<DataType>& lapse,
45 : const tnsr::I<DataType, SpatialDim, Frame>& shift,
46 : const tnsr::ii<DataType, SpatialDim, Frame>& spatial_metric);
47 : /// @}
48 :
49 : namespace Tags {
50 : /*!
51 : * \brief Compute item for spacetime metric \f$g_{ab}\f$ from the lapse
52 : * \f$\alpha\f$, shift \f$\beta^i\f$, and spatial metric \f$\gamma_{ij}\f$.
53 : *
54 : * \details Can be retrieved using `gr::Tags::SpacetimeMetric`.
55 : */
56 : template <typename DataType, size_t SpatialDim, typename Frame>
57 1 : struct SpacetimeMetricCompute : SpacetimeMetric<DataType, SpatialDim, Frame>,
58 : db::ComputeTag {
59 0 : using argument_tags =
60 : tmpl::list<Lapse<DataType>, Shift<DataType, SpatialDim, Frame>,
61 : SpatialMetric<DataType, SpatialDim, Frame>>;
62 :
63 0 : using return_type = tnsr::aa<DataType, SpatialDim, Frame>;
64 :
65 0 : static constexpr auto function = static_cast<void (*)(
66 : gsl::not_null<tnsr::aa<DataType, SpatialDim, Frame>*>,
67 : const Scalar<DataType>&, const tnsr::I<DataType, SpatialDim, Frame>&,
68 : const tnsr::ii<DataType, SpatialDim, Frame>&)>(
69 : &spacetime_metric<DataType, SpatialDim, Frame>);
70 :
71 0 : using base = SpacetimeMetric<DataType, SpatialDim, Frame>;
72 : };
73 : } // namespace Tags
74 : } // namespace gr
|