Characteristics.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
10 #include "Domain/FaceNormal.hpp"
11 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
12 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
13 #include "Utilities/TMPL.hpp"
14 
15 /// \cond
16 class DataVector;
17 namespace gsl {
18 template <class T>
19 class not_null;
20 } // namespace gsl
21 namespace Tags {
22 template <typename Tag>
23 struct Normalized;
24 } // namespace Tags
25 /// \endcond
26 
27 // IWYU pragma: no_forward_declare Tensor
28 
29 namespace GeneralizedHarmonic {
30 // @{
31 /*!
32  * \ingroup GeneralizedHarmonic
33  * \brief Compute the characteristic speeds for the generalized harmonic system.
34  *
35  * Computes the speeds as described in "A New Generalized Harmonic
36  * Evolution System" by Lindblom et. al \cite Lindblom2005qh
37  * [see text following Eq.(34)]. The characteristic fields' names used here
38  * differ from this paper:
39  *
40  * \f{align*}
41  * \mathrm{SpECTRE} && \mathrm{Lindblom} \\
42  * u^{\psi}_{ab} && u^\hat{0}_{ab} \\
43  * u^0_{iab} && u^\hat{2}_{iab} \\
44  * u^{\pm}_{ab} && u^{\hat{1}\pm}_{ab}
45  * \f}
46  *
47  * The corresponding characteristic speeds \f$v\f$ are given in the text between
48  * Eq.(34) and Eq.(35) of \cite Lindblom2005qh :
49  *
50  * \f{align*}
51  * v_{\psi} =& -(1 + \gamma_1) n_k N^k \\
52  * v_{0} =& -n_k N^k \\
53  * v_{\pm} =& -n_k N^k \pm N
54  * \f}
55  *
56  * where \f$N, N^k\f$ are the lapse and shift respectively, \f$\gamma_1\f$ is a
57  * constraint damping parameter, and \f$n_k\f$ is the unit normal to the
58  * surface.
59  */
60 template <size_t Dim, typename Frame>
62  using argument_tags = tmpl::list<
66 
67  static typename Tags::CharacteristicSpeeds<Dim, Frame>::type function(
68  const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
69  const tnsr::I<DataVector, Dim, Frame>& shift,
70  const tnsr::i<DataVector, Dim, Frame>& normal) noexcept;
71 };
72 
73 template <size_t Dim, typename Frame>
74 void compute_characteristic_speeds(
75  gsl::not_null<typename Tags::CharacteristicSpeeds<Dim, Frame>::type*>
76  char_speeds,
77  const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
78  const tnsr::I<DataVector, Dim, Frame>& shift,
79  const tnsr::i<DataVector, Dim, Frame>& normal) noexcept;
80 // @}
81 
82 // @{
83 /*!
84  * \ingroup GeneralizedHarmonic
85  * \brief Computes characteristic fields from evolved fields
86  *
87  * \ref CharacteristicFieldsCompute and
88  * \ref EvolvedFieldsFromCharacteristicFieldsCompute convert between
89  * characteristic and evolved fields for the generalized harmonic system.
90  *
91  * \ref CharacteristicFieldsCompute computes
92  * characteristic fields as described in "A New Generalized Harmonic
93  * Evolution System" by Lindblom et. al \cite Lindblom2005qh .
94  * Their names used here differ from this paper:
95  *
96  * \f{align*}
97  * \mathrm{SpECTRE} && \mathrm{Lindblom} \\
98  * u^{\psi}_{ab} && u^\hat{0}_{ab} \\
99  * u^0_{iab} && u^\hat{2}_{iab} \\
100  * u^{\pm}_{ab} && u^{\hat{1}\pm}_{ab}
101  * \f}
102  *
103  * The characteristic fields \f$u\f$ are given in terms of the evolved fields by
104  * Eq.(32) - (34) of \cite Lindblom2005qh, respectively:
105  * \f{align*}
106  * u^{\psi}_{ab} =& \psi_{ab} \\
107  * u^0_{iab} =& (\delta^k_i - n_i n^k) \Phi_{kab} := P^k_i \Phi_{kab} \\
108  * u^{\pm}_{ab} =& \Pi_{ab} \pm n^i \Phi_{iab} - \gamma_2\psi_{ab}
109  * \f}
110  *
111  * where \f$\psi_{ab}\f$ is the spacetime metric, \f$\Pi_{ab}\f$ and
112  * \f$\Phi_{iab}\f$ are evolved generalized harmonic fields introduced by first
113  * derivatives of \f$\psi_{ab}\f$, \f$\gamma_2\f$ is a constraint damping
114  * parameter, and \f$n_k\f$ is the unit normal to the surface.
115  *
116  * \ref EvolvedFieldsFromCharacteristicFieldsCompute computes evolved fields
117  * \f$w\f$ in terms of the characteristic fields. This uses the inverse of
118  * above relations:
119  *
120  * \f{align*}
121  * \psi_{ab} =& u^{\psi}_{ab}, \\
122  * \Pi_{ab} =& \frac{1}{2}(u^{+}_{ab} + u^{-}_{ab}) + \gamma_2 u^{\psi}_{ab}, \\
123  * \Phi_{iab} =& \frac{1}{2}(u^{+}_{ab} - u^{-}_{ab}) n_i + u^0_{iab}.
124  * \f}
125  *
126  * The corresponding characteristic speeds \f$v\f$ are computed by
127  * \ref CharacteristicSpeedsCompute .
128  */
129 template <size_t Dim, typename Frame>
131  using argument_tags = tmpl::list<
136 
137  static typename Tags::CharacteristicFields<Dim, Frame>::type function(
138  const Scalar<DataVector>& gamma_2,
139  const tnsr::aa<DataVector, Dim, Frame>& spacetime_metric,
140  const tnsr::aa<DataVector, Dim, Frame>& pi,
141  const tnsr::iaa<DataVector, Dim, Frame>& phi,
142  const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form,
143  const tnsr::I<DataVector, Dim, Frame>& unit_normal_vector) noexcept;
144 };
145 
146 template <size_t Dim, typename Frame>
147 void compute_characteristic_fields(
148  gsl::not_null<typename Tags::CharacteristicFields<Dim, Frame>::type*>
149  char_fields,
150  const Scalar<DataVector>& gamma_2,
151  const tnsr::aa<DataVector, Dim, Frame>& spacetime_metric,
152  const tnsr::aa<DataVector, Dim, Frame>& pi,
153  const tnsr::iaa<DataVector, Dim, Frame>& phi,
154  const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form,
155  const tnsr::I<DataVector, Dim, Frame>& unit_normal_vector) noexcept;
156 // @}
157 
158 // @{
159 /*!
160  * \ingroup GeneralizedHarmonic
161  * \brief For expressions used here to compute evolved fields from
162  * characteristic ones, see \ref CharacteristicFieldsCompute.
163  */
164 template <size_t Dim, typename Frame>
166  using argument_tags = tmpl::list<
170 
171  static typename Tags::EvolvedFieldsFromCharacteristicFields<Dim, Frame>::type
172  function(
173  const Scalar<DataVector>& gamma_2,
174  const tnsr::aa<DataVector, Dim, Frame>& u_psi,
175  const tnsr::iaa<DataVector, Dim, Frame>& u_zero,
176  const tnsr::aa<DataVector, Dim, Frame>& u_plus,
177  const tnsr::aa<DataVector, Dim, Frame>& u_minus,
178  const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form) noexcept;
179 };
180 
181 template <size_t Dim, typename Frame>
182 void compute_evolved_fields_from_characteristic_fields(
184  typename Tags::EvolvedFieldsFromCharacteristicFields<Dim, Frame>::type*>
185  evolved_fields,
186  const Scalar<DataVector>& gamma_2,
187  const tnsr::aa<DataVector, Dim, Frame>& u_psi,
188  const tnsr::iaa<DataVector, Dim, Frame>& u_zero,
189  const tnsr::aa<DataVector, Dim, Frame>& u_plus,
190  const tnsr::aa<DataVector, Dim, Frame>& u_minus,
191  const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form) noexcept;
192 
193 // @}
194 } // namespace GeneralizedHarmonic
Auxiliary variable which is analytically the spatial derivative of the spacetime metric.
Definition: Tags.hpp:39
Compute the characteristic speeds for the generalized harmonic system.
Definition: Characteristics.hpp:61
Conjugate momentum to the spacetime metric.
Definition: Tags.hpp:27
Implementations from the Guideline Support Library.
Definition: ConservativeFromPrimitive.hpp:10
Definition: Tags.hpp:15
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:93
tnsr::i< DataVector, 3, Frame > unit_normal_one_form(const tnsr::i< DataVector, 3, Frame > &normal_one_form, const DataVector &one_over_one_form_magnitude) noexcept
Computes normalized unit normal one-form to a Strahlkorper.
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:155
For expressions used here to compute evolved fields from characteristic ones, see CharacteristicField...
Definition: Characteristics.hpp:165
Definition: Tags.hpp:46
Definition: Tags.hpp:90
Definition: Tags.hpp:31
tnsr::aa< DataType, SpatialDim, Frame > pi(const Scalar< DataType > &lapse, const Scalar< DataType > &dt_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::I< DataType, SpatialDim, Frame > &dt_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ii< DataType, SpatialDim, Frame > &dt_spatial_metric, const tnsr::iaa< DataType, SpatialDim, Frame > &phi) noexcept
Computes the conjugate momentum of the spacetime metric .
Definition: ComputeGhQuantities.cpp:58
Definition: Tags.hpp:85
Computes characteristic fields from evolved fields.
Definition: Characteristics.hpp:130
tnsr::aa< DataType, SpatialDim, Frame > spacetime_metric(const Scalar< DataType > &lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric) noexcept
Computes the spacetime metric from the spatial metric, lapse, and shift.
tnsr::iaa< DataType, SpatialDim, Frame > phi(const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric) noexcept
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein&#39;s equations...
Definition: ComputeGhQuantities.cpp:22
Items related to evolving the first-order generalized harmonic system.
Definition: Characteristics.cpp:25
Definition: Tags.hpp:80
Definition: Tags.hpp:41
Definition: DataBoxTag.hpp:29
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.
Definition: ComputeSpacetimeQuantities.cpp:98
Defines a list of useful type aliases for tensors.
Declares function unnormalized_face_normal.
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.
Definition: ComputeSpacetimeQuantities.cpp:82
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
Tags corresponding to the characteristic fields of the generalized harmonic system.
Definition: Tags.hpp:75
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12