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