SpacetimeMetric.hpp
1 // 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 
12 #include "DataStructures/DataBox/Tag.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$ \psi_{ab} \f$ is calculated as
28  * \f{align}{
29  * \psi_{tt} &= - N^2 + N^m N^n g_{mn} \\
30  * \psi_{ti} &= g_{mi} N^m \\
31  * \psi_{ij} &= g_{ij}
32  * \f}
33  * where \f$ N, N^i\f$ and \f$ g_{ij}\f$ are the lapse, shift and spatial metric
34  * respectively
35  */
36 template <size_t Dim, typename Frame, typename DataType>
37 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) noexcept;
41 
42 template <size_t SpatialDim, typename Frame, typename DataType>
43 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) noexcept;
47 // @}
48 
49 namespace Tags {
50 /*!
51  * \brief Compute item for spacetime metric \f$\psi_{ab}\f$ from the
52  * lapse \f$N\f$, shift \f$N^i\f$, and spatial metric \f$g_{ij}\f$.
53  *
54  * \details Can be retrieved using `gr::Tags::SpacetimeMetric`.
55  */
56 template <size_t SpatialDim, typename Frame, typename DataType>
57 struct SpacetimeMetricCompute : SpacetimeMetric<SpatialDim, Frame, DataType>,
59  using argument_tags =
60  tmpl::list<Lapse<DataType>, Shift<SpatialDim, Frame, DataType>,
62 
63  using return_type = tnsr::aa<DataType, SpatialDim, Frame>;
64 
65  static constexpr auto function = static_cast<void (*)(
67  const Scalar<DataType>&, const tnsr::I<DataType, SpatialDim, Frame>&,
68  const tnsr::ii<DataType, SpatialDim, Frame>&) noexcept>(
69  &spacetime_metric<SpatialDim, Frame, DataType>);
70 
72 };
73 } // namespace Tags
74 } // namespace gr
db::ComputeTag
Marks a DataBoxTag as being a compute item that executes a function.
Definition: Tag.hpp:109
utility
gr::Tags::SpatialMetric< SpatialDim, Frame, DataType >
cmath
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
cstdint
gr::Tags::SpacetimeMetric
Definition: Tags.hpp:17
gr::Tags::Shift< SpatialDim, Frame, DataType >
gr::shift
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute shift from spacetime metric and inverse spatial metric.
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
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.
gr
Definition: GaugeWave.hpp:27
Tensor.hpp
gr::spatial_metric
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
gr::Tags::SpacetimeMetricCompute
Compute item for spacetime metric from the lapse , shift , and spatial metric .
Definition: SpacetimeMetric.hpp:57
Prefixes.hpp
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183