Line data Source code
1 1 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : ///\file
5 : /// Defines functions to calculate Christoffel symbols
6 :
7 : #pragma once
8 :
9 : #include <cstddef>
10 :
11 : #include "DataStructures/DataBox/Prefixes.hpp"
12 : #include "DataStructures/DataBox/Tag.hpp"
13 : #include "DataStructures/Tensor/EagerMath/RaiseOrLowerIndex.hpp"
14 : #include "DataStructures/Tensor/EagerMath/Trace.hpp"
15 : #include "DataStructures/Tensor/IndexType.hpp"
16 : #include "DataStructures/Tensor/TypeAliases.hpp"
17 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
18 :
19 : /// \cond
20 : namespace gsl {
21 : template <class>
22 : class not_null;
23 : } // namespace gsl
24 : /// \endcond
25 :
26 : namespace gr {
27 : /// @{
28 : /*!
29 : * \ingroup GeneralRelativityGroup
30 : * \brief Computes Christoffel symbol of the first kind from derivative of
31 : * metric
32 : *
33 : * \details Computes Christoffel symbol \f$\Gamma_{abc}\f$ as:
34 : * \f$ \Gamma_{cab} = \frac{1}{2} ( \partial_a g_{bc} + \partial_b g_{ac}
35 : * - \partial_c g_{ab}) \f$
36 : * where \f$g_{bc}\f$ is either a spatial or spacetime metric
37 : */
38 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
39 1 : void christoffel_first_kind(
40 : gsl::not_null<tnsr::abb<DataType, SpatialDim, Frame, Index>*> christoffel,
41 : const tnsr::abb<DataType, SpatialDim, Frame, Index>& d_metric);
42 :
43 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
44 1 : tnsr::abb<DataType, SpatialDim, Frame, Index> christoffel_first_kind(
45 : const tnsr::abb<DataType, SpatialDim, Frame, Index>& d_metric);
46 : /// @}
47 :
48 : /// @{
49 : /*!
50 : * \ingroup GeneralRelativityGroup
51 : * \brief Computes Christoffel symbol of the second kind from derivative of
52 : * metric and the inverse metric.
53 : *
54 : * \details Computes Christoffel symbol \f$\Gamma^a_{bc}\f$ as:
55 : * \f$ \Gamma^d_{ab} = \frac{1}{2} g^{cd} (\partial_a g_{bc} + \partial_b g_{ac}
56 : * - \partial_c g_{ab}) \f$
57 : * where \f$g_{bc}\f$ is either a spatial or spacetime metric.
58 : *
59 : * Avoids the extra memory allocation that occurs by computing the
60 : * Christoffel symbol of the first kind and then raising the index.
61 : */
62 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
63 1 : void christoffel_second_kind(
64 : gsl::not_null<tnsr::Abb<DataType, SpatialDim, Frame, Index>*> christoffel,
65 : const tnsr::abb<DataType, SpatialDim, Frame, Index>& d_metric,
66 : const tnsr::AA<DataType, SpatialDim, Frame, Index>& inverse_metric);
67 :
68 : template <size_t SpatialDim, typename Frame, IndexType Index, typename DataType>
69 1 : auto christoffel_second_kind(
70 : const tnsr::abb<DataType, SpatialDim, Frame, Index>& d_metric,
71 : const tnsr::AA<DataType, SpatialDim, Frame, Index>& inverse_metric)
72 : -> tnsr::Abb<DataType, SpatialDim, Frame, Index>;
73 : /// @}
74 :
75 0 : namespace Tags {
76 : /// Compute item for spatial Christoffel symbols of the first kind
77 : /// \f$\Gamma_{ijk}\f$ computed from the first derivative of the
78 : /// spatial metric.
79 : ///
80 : /// Can be retrieved using `gr::Tags::SpatialChristoffelFirstKind`
81 : template <typename DataType, size_t SpatialDim, typename Frame>
82 1 : struct SpatialChristoffelFirstKindCompute
83 : : SpatialChristoffelFirstKind<DataType, SpatialDim, Frame>,
84 : db::ComputeTag {
85 0 : using argument_tags = tmpl::list<
86 : ::Tags::deriv<gr::Tags::SpatialMetric<DataType, SpatialDim, Frame>,
87 : tmpl::size_t<SpatialDim>, Frame>>;
88 :
89 0 : using return_type = tnsr::ijj<DataType, SpatialDim, Frame>;
90 :
91 0 : static constexpr auto function = static_cast<void (*)(
92 : gsl::not_null<
93 : tnsr::abb<DataType, SpatialDim, Frame, IndexType::Spatial>*>,
94 : const tnsr::ijj<DataType, SpatialDim, Frame>&)>(
95 : &christoffel_first_kind<SpatialDim, Frame, IndexType::Spatial, DataType>);
96 :
97 0 : using base = SpatialChristoffelFirstKind<DataType, SpatialDim, Frame>;
98 : };
99 :
100 : /// Compute item for spatial Christoffel symbols of the second kind
101 : /// \f$\Gamma^i_{jk}\f$ computed from the Christoffel symbols of the
102 : /// first kind and the inverse spatial metric.
103 : ///
104 : /// Can be retrieved using `gr::Tags::SpatialChristoffelSecondKind`
105 : template <typename DataType, size_t SpatialDim, typename Frame>
106 1 : struct SpatialChristoffelSecondKindCompute
107 : : SpatialChristoffelSecondKind<DataType, SpatialDim, Frame>,
108 : db::ComputeTag {
109 0 : using argument_tags =
110 : tmpl::list<SpatialChristoffelFirstKind<DataType, SpatialDim, Frame>,
111 : InverseSpatialMetric<DataType, SpatialDim, Frame>>;
112 :
113 0 : using return_type = tnsr::Ijj<DataType, SpatialDim, Frame>;
114 :
115 0 : static constexpr auto function = static_cast<void (*)(
116 : gsl::not_null<tnsr::Ijj<DataType, SpatialDim, Frame>*>,
117 : const tnsr::ijj<DataType, SpatialDim, Frame>&,
118 : const tnsr::II<DataType, SpatialDim, Frame>&)>(
119 : &raise_or_lower_first_index<DataType,
120 : SpatialIndex<SpatialDim, UpLo::Lo, Frame>,
121 : SpatialIndex<SpatialDim, UpLo::Lo, Frame>>);
122 :
123 0 : using base = SpatialChristoffelSecondKind<DataType, SpatialDim, Frame>;
124 : };
125 :
126 : /// Compute item for the trace of the spatial Christoffel symbols
127 : /// of the first kind
128 : /// \f$\Gamma_{i} = \Gamma_{ijk}\gamma^{jk}\f$ computed from the
129 : /// Christoffel symbols of the first kind and the inverse spatial metric.
130 : ///
131 : /// Can be retrieved using `gr::Tags::TraceSpatialChristoffelFirstKind`
132 : template <typename DataType, size_t SpatialDim, typename Frame>
133 1 : struct TraceSpatialChristoffelFirstKindCompute
134 : : TraceSpatialChristoffelFirstKind<DataType, SpatialDim, Frame>,
135 : db::ComputeTag {
136 0 : using argument_tags =
137 : tmpl::list<SpatialChristoffelFirstKind<DataType, SpatialDim, Frame>,
138 : InverseSpatialMetric<DataType, SpatialDim, Frame>>;
139 :
140 0 : using return_type = tnsr::i<DataType, SpatialDim, Frame>;
141 :
142 0 : static constexpr auto function = static_cast<void (*)(
143 : gsl::not_null<tnsr::i<DataType, SpatialDim, Frame>*>,
144 : const tnsr::ijj<DataType, SpatialDim, Frame>&,
145 : const tnsr::II<DataType, SpatialDim, Frame>&)>(
146 : &trace_last_indices<DataType, SpatialIndex<SpatialDim, UpLo::Lo, Frame>,
147 : SpatialIndex<SpatialDim, UpLo::Lo, Frame>>);
148 :
149 0 : using base = TraceSpatialChristoffelFirstKind<DataType, SpatialDim, Frame>;
150 : };
151 :
152 : /// Compute item for the trace of the spatial Christoffel symbols
153 : /// of the second kind
154 : /// \f$\Gamma^{i} = \Gamma^{i}_{jk}\gamma^{jk}\f$ computed from the
155 : /// Christoffel symbols of the second kind and the inverse spatial metric.
156 : ///
157 : /// Can be retrieved using `gr::Tags::TraceSpatialChristoffelSecondKind`
158 : template <typename DataType, size_t SpatialDim, typename Frame>
159 1 : struct TraceSpatialChristoffelSecondKindCompute
160 : : TraceSpatialChristoffelSecondKind<DataType, SpatialDim, Frame>,
161 : db::ComputeTag {
162 0 : using argument_tags =
163 : tmpl::list<SpatialChristoffelSecondKind<DataType, SpatialDim, Frame>,
164 : InverseSpatialMetric<DataType, SpatialDim, Frame>>;
165 :
166 0 : using return_type = tnsr::I<DataType, SpatialDim, Frame>;
167 :
168 0 : static constexpr auto function = static_cast<void (*)(
169 : gsl::not_null<tnsr::I<DataType, SpatialDim, Frame>*>,
170 : const tnsr::Ijj<DataType, SpatialDim, Frame>&,
171 : const tnsr::II<DataType, SpatialDim, Frame>&)>(
172 : &trace_last_indices<DataType, SpatialIndex<SpatialDim, UpLo::Up, Frame>,
173 : SpatialIndex<SpatialDim, UpLo::Lo, Frame>>);
174 :
175 0 : using base = TraceSpatialChristoffelSecondKind<DataType, SpatialDim, Frame>;
176 : };
177 :
178 : /// Compute item for spacetime Christoffel symbols of the first kind
179 : /// \f$\Gamma_{abc}\f$ computed from the first derivative of the
180 : /// spacetime metric.
181 : ///
182 : /// Can be retrieved using `gr::Tags::SpacetimeChristoffelFirstKind`
183 : template <typename DataType, size_t SpatialDim, typename Frame>
184 1 : struct SpacetimeChristoffelFirstKindCompute
185 : : SpacetimeChristoffelFirstKind<DataType, SpatialDim, Frame>,
186 : db::ComputeTag {
187 0 : using argument_tags =
188 : tmpl::list<DerivativesOfSpacetimeMetric<DataType, SpatialDim, Frame>>;
189 :
190 0 : using return_type =
191 : tnsr::abb<DataType, SpatialDim, Frame, IndexType::Spacetime>;
192 :
193 0 : static constexpr auto function = static_cast<void (*)(
194 : gsl::not_null<
195 : tnsr::abb<DataType, SpatialDim, Frame, IndexType::Spacetime>*>,
196 : const tnsr::abb<DataType, SpatialDim, Frame, IndexType::Spacetime>&)>(
197 : &christoffel_first_kind<SpatialDim, Frame, IndexType::Spacetime,
198 : DataType>);
199 :
200 0 : using base = SpacetimeChristoffelFirstKind<DataType, SpatialDim, Frame>;
201 : };
202 :
203 : /// Compute item for spacetime Christoffel symbols of the second kind
204 : /// \f$\Gamma^a_{bc}\f$ computed from the Christoffel symbols of the
205 : /// first kind and the inverse spacetime metric.
206 : ///
207 : /// Can be retrieved using `gr::Tags::SpacetimeChristoffelSecondKind`
208 : template <typename DataType, size_t SpatialDim, typename Frame>
209 1 : struct SpacetimeChristoffelSecondKindCompute
210 : : SpacetimeChristoffelSecondKind<DataType, SpatialDim, Frame>,
211 : db::ComputeTag {
212 0 : using argument_tags =
213 : tmpl::list<SpacetimeChristoffelFirstKind<DataType, SpatialDim, Frame>,
214 : InverseSpacetimeMetric<DataType, SpatialDim, Frame>>;
215 :
216 0 : using return_type = tnsr::Abb<DataType, SpatialDim, Frame>;
217 :
218 0 : static constexpr auto function = static_cast<void (*)(
219 : gsl::not_null<tnsr::Abb<DataType, SpatialDim, Frame>*>,
220 : const tnsr::abb<DataType, SpatialDim, Frame>&,
221 : const tnsr::AA<DataType, SpatialDim, Frame>&)>(
222 : &raise_or_lower_first_index<DataType,
223 : SpacetimeIndex<SpatialDim, UpLo::Lo, Frame>,
224 : SpacetimeIndex<SpatialDim, UpLo::Lo, Frame>>);
225 :
226 0 : using base = SpacetimeChristoffelSecondKind<DataType, SpatialDim, Frame>;
227 : };
228 :
229 : /// Compute item for the trace of the spacetime Christoffel symbols
230 : /// of the first kind
231 : /// \f$\Gamma_{a} = \Gamma_{abc}g^{bc}\f$ computed from the
232 : /// Christoffel symbols of the first kind and the inverse spacetime metric.
233 : ///
234 : /// Can be retrieved using `gr::Tags::TraceSpacetimeChristoffelFirstKind`
235 : template <typename DataType, size_t SpatialDim, typename Frame>
236 1 : struct TraceSpacetimeChristoffelFirstKindCompute
237 : : TraceSpacetimeChristoffelFirstKind<DataType, SpatialDim, Frame>,
238 : db::ComputeTag {
239 0 : using argument_tags =
240 : tmpl::list<SpacetimeChristoffelFirstKind<DataType, SpatialDim, Frame>,
241 : InverseSpacetimeMetric<DataType, SpatialDim, Frame>>;
242 :
243 0 : using return_type = tnsr::a<DataType, SpatialDim, Frame>;
244 :
245 0 : static constexpr auto function = static_cast<void (*)(
246 : gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*>,
247 : const tnsr::abb<DataType, SpatialDim, Frame>&,
248 : const tnsr::AA<DataType, SpatialDim, Frame>&)>(
249 : &trace_last_indices<DataType, SpacetimeIndex<SpatialDim, UpLo::Lo, Frame>,
250 : SpacetimeIndex<SpatialDim, UpLo::Lo, Frame>>);
251 :
252 0 : using base = TraceSpacetimeChristoffelFirstKind<DataType, SpatialDim, Frame>;
253 : };
254 : } // namespace Tags
255 : } // namespace gr
|