Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/DataBox/Prefixes.hpp"
9 : #include "DataStructures/DataBox/Tag.hpp"
10 : #include "DataStructures/Tensor/TypeAliases.hpp"
11 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
12 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
13 : #include "Utilities/Gsl.hpp"
14 : #include "Utilities/TMPL.hpp"
15 :
16 : /// \cond
17 : class DataVector;
18 : /// \endcond
19 :
20 : namespace gh {
21 : /// @{
22 : /*!
23 : * \ingroup GeneralRelativityGroup
24 : * \brief Computes generalized harmonic gauge source function.
25 : * \details If \f$\alpha, \beta^i, \gamma_{ij}, \Gamma_{ijk}, K\f$ are the
26 : * lapse, shift, spatial metric, spatial Christoffel symbols, and trace of the
27 : * extrinsic curvature, then we compute
28 : * \f{align}
29 : * H_l &=
30 : * \alpha^{-2} \gamma_{il}(\partial_t \beta^i - \beta^k \partial_k \beta^i)
31 : * + \alpha^{-1} \partial_l \alpha - \gamma^{km}\Gamma_{lkm} \\
32 : * H_0 &= -\alpha^{-1} \partial_t \alpha + \alpha^{-1} \beta^k\partial_k \alpha
33 : * + \beta^k H_k - \alpha K
34 : * \f}
35 : * See Eqs. 8 and 9 of \cite Lindblom2005qh
36 : */
37 : template <typename DataType, size_t SpatialDim, typename Frame>
38 1 : void gauge_source(
39 : gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> gauge_source_h,
40 : const Scalar<DataType>& lapse, const Scalar<DataType>& dt_lapse,
41 : const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
42 : const tnsr::I<DataType, SpatialDim, Frame>& shift,
43 : const tnsr::I<DataType, SpatialDim, Frame>& dt_shift,
44 : const tnsr::iJ<DataType, SpatialDim, Frame>& deriv_shift,
45 : const tnsr::ii<DataType, SpatialDim, Frame>& spatial_metric,
46 : const Scalar<DataType>& trace_extrinsic_curvature,
47 : const tnsr::i<DataType, SpatialDim, Frame>& trace_christoffel_last_indices);
48 :
49 : template <typename DataType, size_t SpatialDim, typename Frame>
50 1 : tnsr::a<DataType, SpatialDim, Frame> gauge_source(
51 : const Scalar<DataType>& lapse, const Scalar<DataType>& dt_lapse,
52 : const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
53 : const tnsr::I<DataType, SpatialDim, Frame>& shift,
54 : const tnsr::I<DataType, SpatialDim, Frame>& dt_shift,
55 : const tnsr::iJ<DataType, SpatialDim, Frame>& deriv_shift,
56 : const tnsr::ii<DataType, SpatialDim, Frame>& spatial_metric,
57 : const Scalar<DataType>& trace_extrinsic_curvature,
58 : const tnsr::i<DataType, SpatialDim, Frame>& trace_christoffel_last_indices);
59 : /// @}
60 :
61 : namespace Tags {
62 : /*!
63 : * \brief Compute item to get the implicit gauge source function from 3 + 1
64 : * quantities.
65 : *
66 : * \details See `gauge_source()`. Can be retrieved using
67 : * `gh::Tags::GaugeH`.
68 : */
69 : template <size_t SpatialDim, typename Frame>
70 1 : struct GaugeHImplicitFrom3p1QuantitiesCompute
71 : : GaugeH<DataVector, SpatialDim, Frame>,
72 : db::ComputeTag {
73 0 : using argument_tags =
74 : tmpl::list<gr::Tags::Lapse<DataVector>,
75 : ::Tags::dt<gr::Tags::Lapse<DataVector>>,
76 : ::Tags::deriv<gr::Tags::Lapse<DataVector>,
77 : tmpl::size_t<SpatialDim>, Frame>,
78 : gr::Tags::Shift<DataVector, SpatialDim, Frame>,
79 : ::Tags::dt<gr::Tags::Shift<DataVector, SpatialDim, Frame>>,
80 : ::Tags::deriv<gr::Tags::Shift<DataVector, SpatialDim, Frame>,
81 : tmpl::size_t<SpatialDim>, Frame>,
82 : gr::Tags::SpatialMetric<DataVector, SpatialDim, Frame>,
83 : gr::Tags::TraceExtrinsicCurvature<DataVector>,
84 : gr::Tags::TraceSpatialChristoffelFirstKind<DataVector,
85 : SpatialDim, Frame>>;
86 :
87 0 : using return_type = tnsr::a<DataVector, SpatialDim, Frame>;
88 :
89 0 : static constexpr auto function = static_cast<void (*)(
90 : gsl::not_null<tnsr::a<DataVector, SpatialDim, Frame>*>,
91 : const Scalar<DataVector>&, const Scalar<DataVector>&,
92 : const tnsr::i<DataVector, SpatialDim, Frame>&,
93 : const tnsr::I<DataVector, SpatialDim, Frame>&,
94 : const tnsr::I<DataVector, SpatialDim, Frame>&,
95 : const tnsr::iJ<DataVector, SpatialDim, Frame>&,
96 : const tnsr::ii<DataVector, SpatialDim, Frame>&, const Scalar<DataVector>&,
97 : const tnsr::i<DataVector, SpatialDim, Frame>&)>(
98 : &gauge_source<DataVector, SpatialDim, Frame>);
99 :
100 0 : using base = GaugeH<DataVector, SpatialDim, Frame>;
101 : };
102 :
103 : /*!
104 : * \brief Compute item to get spacetime derivative of the gauge source function
105 : * from its spatial and time derivatives.
106 : *
107 : * \details Can be retrieved using
108 : * `gh::Tags::SpacetimeDerivGaugeH`.
109 : */
110 : template <size_t SpatialDim, typename Frame>
111 1 : struct SpacetimeDerivGaugeHCompute
112 : : SpacetimeDerivGaugeH<DataVector, SpatialDim, Frame>,
113 : db::ComputeTag {
114 0 : using argument_tags =
115 : tmpl::list<::Tags::dt<gh::Tags::GaugeH<DataVector, SpatialDim, Frame>>,
116 : ::Tags::deriv<gh::Tags::GaugeH<DataVector, SpatialDim, Frame>,
117 : tmpl::size_t<SpatialDim>, Frame>>;
118 :
119 0 : using return_type = tnsr::ab<DataVector, SpatialDim, Frame>;
120 :
121 0 : static constexpr void function(
122 : const gsl::not_null<tnsr::ab<DataVector, SpatialDim, Frame>*>
123 : spacetime_deriv_gauge_source,
124 : const tnsr::a<DataVector, SpatialDim, Frame>& time_deriv_gauge_source,
125 : const tnsr::ia<DataVector, SpatialDim, Frame>& deriv_gauge_source) {
126 : for (size_t b = 0; b < SpatialDim + 1; ++b) {
127 : spacetime_deriv_gauge_source->get(0, b) = time_deriv_gauge_source.get(b);
128 : for (size_t a = 1; a < SpatialDim + 1; ++a) {
129 : spacetime_deriv_gauge_source->get(a, b) =
130 : deriv_gauge_source.get(a - 1, b);
131 : }
132 : }
133 : }
134 :
135 0 : using base = SpacetimeDerivGaugeH<DataVector, SpatialDim, Frame>;
136 : };
137 : } // namespace Tags
138 : } // namespace gh
|