Line data Source code
1 1 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : ///\file
5 : /// Declares function templates to calculate the Ricci tensor
6 :
7 : #pragma once
8 :
9 : #include <cstddef>
10 :
11 : #include "DataStructures/DataBox/Tag.hpp"
12 : #include "DataStructures/Tensor/TypeAliases.hpp"
13 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
14 :
15 : /// \cond
16 : namespace gsl {
17 : template <typename>
18 : struct not_null;
19 : } // namespace gsl
20 : /// \endcond
21 :
22 : namespace gr {
23 :
24 : /// @{
25 : /*!
26 : * \ingroup GeneralRelativityGroup
27 : * \brief Computes Ricci tensor from the (spatial or spacetime)
28 : * Christoffel symbol of the second kind and its derivative.
29 : *
30 : * \details Computes Ricci tensor \f$R_{ab}\f$ as:
31 : * \f$ R_{ab} = \partial_c \Gamma^{c}_{ab} - \partial_{(b} \Gamma^{c}_{a)c}
32 : * + \Gamma^{d}_{ab}\Gamma^{c}_{cd} - \Gamma^{d}_{ac} \Gamma^{c}_{bd} \f$
33 : * where \f$\Gamma^{a}_{bc}\f$ is the Christoffel symbol of the second kind.
34 : */
35 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
36 1 : void ricci_tensor(
37 : gsl::not_null<tnsr::aa<DataType, SpatialDim, Frame, Index>*> result,
38 : const tnsr::Abb<DataType, SpatialDim, Frame, Index>& christoffel_2nd_kind,
39 : const tnsr::aBcc<DataType, SpatialDim, Frame, Index>&
40 : d_christoffel_2nd_kind);
41 :
42 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
43 1 : tnsr::aa<DataType, SpatialDim, Frame, Index> ricci_tensor(
44 : const tnsr::Abb<DataType, SpatialDim, Frame, Index>& christoffel_2nd_kind,
45 : const tnsr::aBcc<DataType, SpatialDim, Frame, Index>&
46 : d_christoffel_2nd_kind);
47 : /// @}
48 :
49 : /// @{
50 : /*!
51 : * \ingroup GeneralRelativityGroup
52 : * \brief Computes the Ricci Scalar from the (spatial or spacetime) Ricci Tensor
53 : * and inverse metrics.
54 : *
55 : * \details Computes Ricci scalar using the inverse metric (spatial or
56 : * spacetime) and Ricci tensor \f$R = g^{ab}R_{ab}\f$
57 : */
58 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
59 1 : void ricci_scalar(
60 : const gsl::not_null<Scalar<DataType>*> ricci_scalar_result,
61 : const tnsr::aa<DataType, SpatialDim, Frame, Index>& ricci_tensor,
62 : const tnsr::AA<DataType, SpatialDim, Frame, Index>& inverse_metric);
63 :
64 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
65 1 : Scalar<DataType> ricci_scalar(
66 : const tnsr::aa<DataType, SpatialDim, Frame, Index>& ricci_tensor,
67 : const tnsr::AA<DataType, SpatialDim, Frame, Index>& inverse_metric);
68 : /// @}
69 :
70 : namespace Tags {
71 : /// Compute item for spatial Ricci tensor \f$R_{ij}\f$
72 : /// computed from SpatialChristoffelSecondKind and its spatial derivatives.
73 : ///
74 : /// Can be retrieved using `gr::Tags::SpatialRicci`
75 : template <typename DataType, size_t SpatialDim, typename Frame>
76 1 : struct SpatialRicciCompute : SpatialRicci<DataType, SpatialDim, Frame>,
77 : db::ComputeTag {
78 0 : using argument_tags = tmpl::list<
79 : gr::Tags::SpatialChristoffelSecondKind<DataType, SpatialDim, Frame>,
80 : ::Tags::deriv<
81 : gr::Tags::SpatialChristoffelSecondKind<DataType, SpatialDim, Frame>,
82 : tmpl::size_t<SpatialDim>, Frame>>;
83 :
84 0 : using return_type = tnsr::ii<DataType, SpatialDim, Frame>;
85 :
86 0 : static constexpr auto function = static_cast<void (*)(
87 : gsl::not_null<tnsr::ii<DataType, SpatialDim, Frame>*>,
88 : const tnsr::Ijj<DataType, SpatialDim, Frame>&,
89 : const tnsr::iJkk<DataType, SpatialDim, Frame>&)>(
90 : &ricci_tensor<SpatialDim, Frame, IndexType::Spatial, DataType>);
91 :
92 0 : using base = SpatialRicci<DataType, SpatialDim, Frame>;
93 : };
94 :
95 : /// Computes the spatial Ricci scalar using the spatial Ricci tensor and the
96 : /// inverse spatial metric.
97 : ///
98 : /// Can be retrieved using `gr::Tags::SpatialRicciScalar`
99 : template <typename DataType, size_t SpatialDim, typename Frame>
100 1 : struct SpatialRicciScalarCompute : SpatialRicciScalar<DataType>,
101 : db::ComputeTag {
102 0 : using argument_tags =
103 : tmpl::list<gr::Tags::SpatialRicci<DataType, SpatialDim, Frame>,
104 : gr::Tags::InverseSpatialMetric<DataType, SpatialDim, Frame>>;
105 :
106 0 : using return_type = Scalar<DataType>;
107 :
108 0 : static constexpr auto function =
109 : static_cast<void (*)(gsl::not_null<Scalar<DataType>*>,
110 : const tnsr::ii<DataType, SpatialDim, Frame>&,
111 : const tnsr::II<DataType, SpatialDim, Frame>&)>(
112 : &ricci_scalar<SpatialDim, Frame, IndexType::Spatial, DataType>);
113 :
114 0 : using base = SpatialRicciScalar<DataType>;
115 : };
116 : } // namespace Tags
117 : } // namespace gr
|