Characteristics.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
8 #include "DataStructures/DataBox/Tag.hpp"
9 #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
12 #include "Domain/FaceNormal.hpp"
14 #include "Evolution/Systems/CurvedScalarWave/TagsDeclarations.hpp"
15 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 namespace CurvedScalarWave {
19 // @{
20 /*!
21  * \brief Compute the characteristic speeds for the scalar wave system in curved
22  * spacetime.
23  *
24  * Computes the speeds as described in "Optimal constraint projection for
25  * hyperbolic evolution systems" by Holst et. al \cite Holst2004wt
26  * [see text following Eq. (32)]. The characteristic fields' names used here
27  * are similar to the paper:
28  *
29  * \f{align*}
30  * \mathrm{SpECTRE} && \mathrm{Holst} \\
31  * v^{\hat \psi} && Z^1 \\
32  * v^{\hat 0}_{i} && Z^{2}_{i} \\
33  * v^{\hat \pm} && u^{1\pm}
34  * \f}
35  *
36  * The corresponding characteristic speeds \f$\lambda\f$ are given in the text
37  * following Eq. (38) of \cite Holst2004wt :
38  *
39  * \f{align*}
40  * \lambda_{\hat \psi} =& -(1 + \gamma_1) n_k N^k \\
41  * \lambda_{\hat 0} =& -n_k N^k \\
42  * \lambda_{\hat \pm} =& -n_k N^k \pm N
43  * \f}
44  *
45  * where \f$n_k\f$ is the unit normal to the surface.
46  */
47 template <size_t SpatialDim>
48 std::array<DataVector, 4> characteristic_speeds(
49  const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
50  const tnsr::I<DataVector, SpatialDim, Frame::Inertial>& shift,
51  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
52  unit_normal_one_form) noexcept;
53 
54 template <size_t SpatialDim>
55 void characteristic_speeds(
57  const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
58  const tnsr::I<DataVector, SpatialDim, Frame::Inertial>& shift,
59  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
60  unit_normal_one_form) noexcept;
61 
62 template <size_t SpatialDim>
66  using return_type = typename base::type;
67  using argument_tags = tmpl::list<
71 
72  static constexpr void function(
73  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_1,
75  const tnsr::I<DataVector, SpatialDim, Frame::Inertial>& shift,
76  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
77  unit_normal_one_form) noexcept {
78  characteristic_speeds<SpatialDim>(result, gamma_1, lapse, shift,
80  }
81 };
82 // @}
83 
84 // @{
85 /*!
86  * \brief Computes characteristic fields from evolved fields
87  *
88  * \ref CharacteristicFieldsCompute and
89  * \ref EvolvedFieldsFromCharacteristicFieldsCompute convert between
90  * characteristic and evolved fields for the scalar-wave system in curved
91  * spacetime.
92  *
93  * \ref CharacteristicFieldsCompute computes
94  * characteristic fields as described in "Optimal constraint projection for
95  * hyperbolic evolution systems" by Holst et. al \cite Holst2004wt .
96  * Their names used here differ from this paper:
97  *
98  * \f{align*}
99  * \mathrm{SpECTRE} && \mathrm{Holst} \\
100  * v^{\hat \psi} && Z^1 \\
101  * v^{\hat 0}_{i} && Z^{2}_{i} \\
102  * v^{\hat \pm} && u^{1\pm}
103  * \f}
104  *
105  * The characteristic fields \f$u\f$ are given in terms of the evolved fields by
106  * Eq. (33) - (35) of \cite Holst2004wt, respectively:
107  *
108  * \f{align*}
109  * v^{\hat \psi} =& \psi \\
110  * v^{\hat 0}_{i} =& (\delta^k_i - n_i n^k) \Phi_{k} := P^k_i \Phi_{k} \\
111  * v^{\hat \pm} =& \Pi \pm n^i \Phi_{i} - \gamma_2\psi
112  * \f}
113  *
114  * where \f$\psi\f$ is the scalar field, \f$\Pi\f$ and \f$\Phi_{i}\f$ are
115  * evolved fields introduced by first derivatives of \f$\psi\f$, \f$\gamma_2\f$
116  * is a constraint damping parameter, and \f$n_k\f$ is the unit normal to the
117  * surface.
118  *
119  * \ref EvolvedFieldsFromCharacteristicFieldsCompute computes evolved fields
120  * \f$w\f$ in terms of the characteristic fields. This uses the inverse of
121  * above relations (c.f. Eq. (36) - (38) of \cite Holst2004wt ):
122  *
123  * \f{align*}
124  * \psi =& v^{\hat \psi}, \\
125  * \Pi =& \frac{1}{2}(v^{\hat +} + v^{\hat -}) + \gamma_2 v^{\hat \psi}, \\
126  * \Phi_{i} =& \frac{1}{2}(v^{\hat +} - v^{\hat -}) n_i + v^{\hat 0}_{i}.
127  * \f}
128  *
129  * The corresponding characteristic speeds \f$\lambda\f$ are computed by
130  * \ref CharacteristicSpeedsCompute .
131  */
132 template <size_t SpatialDim>
133 Variables<
134  tmpl::list<Tags::VPsi, Tags::VZero<SpatialDim>, Tags::VPlus, Tags::VMinus>>
135 characteristic_fields(
136  const Scalar<DataVector>& gamma_2,
137  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
138  inverse_spatial_metric,
139  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
140  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
141  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
142  unit_normal_one_form) noexcept;
143 
144 template <size_t SpatialDim>
145 void characteristic_fields(
146  gsl::not_null<Variables<tmpl::list<Tags::VPsi, Tags::VZero<SpatialDim>,
148  char_fields,
149  const Scalar<DataVector>& gamma_2,
150  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
151  inverse_spatial_metric,
152  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
153  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
154  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
155  unit_normal_one_form) noexcept;
156 
157 template <size_t SpatialDim>
161  using return_type = typename base::type;
162  using argument_tags = tmpl::list<
167 
168  static constexpr void function(
169  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_2,
170  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
171  inverse_spatial_metric,
172  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
173  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
174  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
175  unit_normal_one_form) noexcept {
176  characteristic_fields<SpatialDim>(result, gamma_2, inverse_spatial_metric,
177  psi, pi, phi, unit_normal_one_form);
178  }
179 };
180 // @}
181 
182 // @{
183 /*!
184  * \brief For expressions used here to compute evolved fields from
185  * characteristic ones, see \ref CharacteristicFieldsCompute.
186  */
187 template <size_t SpatialDim>
188 Variables<tmpl::list<Psi, Pi, Phi<SpatialDim>>>
189 evolved_fields_from_characteristic_fields(
190  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
191  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
192  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
193  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
194  unit_normal_one_form) noexcept;
195 
196 template <size_t SpatialDim>
197 void evolved_fields_from_characteristic_fields(
198  gsl::not_null<Variables<tmpl::list<Psi, Pi, Phi<SpatialDim>>>*>
199  evolved_fields,
200  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
201  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
202  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
203  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
204  unit_normal_one_form) noexcept;
205 
206 template <size_t SpatialDim>
211  using return_type = typename base::type;
212  using argument_tags = tmpl::list<
214  Tags::VMinus,
216 
217  static constexpr void function(
218  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_2,
219  const Scalar<DataVector>& v_psi,
220  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
221  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
222  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
223  unit_normal_one_form) noexcept {
224  evolved_fields_from_characteristic_fields<SpatialDim>(
225  result, gamma_2, v_psi, v_zero, v_plus, v_minus, unit_normal_one_form);
226  }
227 };
228 // @}
229 
230 /*!
231  * \brief Computes the largest magnitude of the characteristic speeds.
232  */
233 template <size_t SpatialDim>
235  using argument_tags = tmpl::list<Tags::CharacteristicSpeeds<SpatialDim>>;
236  static double apply(const std::array<DataVector, 4>& char_speeds) noexcept;
237 };
238 } // namespace CurvedScalarWave
db::ComputeTag
Marks a DataBoxTag as being a compute item that executes a function.
Definition: Tag.hpp:109
GeneralizedHarmonic::pi
void pi(gsl::not_null< 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 .
CurvedScalarWave::ComputeLargestCharacteristicSpeed
Computes the largest magnitude of the characteristic speeds.
Definition: Characteristics.hpp:234
CurvedScalarWave::Tags::ConstraintGamma1
Definition: Tags.hpp:37
FaceNormal.hpp
CurvedScalarWave::Tags::VPsi
Tags corresponding to the characteristic fields of the scalar-wave system in curved spacetime.
Definition: Tags.hpp:74
CurvedScalarWave::Tags::VPlus
Definition: Tags.hpp:81
CurvedScalarWave::CharacteristicFieldsCompute
Definition: Characteristics.hpp:158
CurvedScalarWave::Tags::ConstraintGamma2
Definition: Tags.hpp:41
Constraints.hpp
CurvedScalarWave::Phi
Definition: Tags.hpp:32
gr::lapse
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.
Tags::Normalized
Definition: Magnitude.hpp:138
CurvedScalarWave::Tags::EvolvedFieldsFromCharacteristicFields
Definition: Tags.hpp:100
cstddef
std::array
CurvedScalarWave::Tags::VMinus
Definition: Tags.hpp:84
CurvedScalarWave::Pi
Definition: Tags.hpp:27
GeneralizedHarmonic::phi
void phi(gsl::not_null< 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's equations...
CurvedScalarWave::Psi
Definition: Tags.hpp:23
gr::Tags::Shift
Definition: Tags.hpp:48
CurvedScalarWave::Tags::CharacteristicFields
Definition: Tags.hpp:95
Variables.hpp
CurvedScalarWave::EvolvedFieldsFromCharacteristicFieldsCompute
Definition: Characteristics.hpp:207
gr::shift
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.
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
CurvedScalarWave::CharacteristicSpeedsCompute
Definition: Characteristics.hpp:63
CurvedScalarWave::Tags::VZero
Definition: Tags.hpp:78
Tensor.hpp
StrahlkorperGr::unit_normal_one_form
void unit_normal_one_form(gsl::not_null< tnsr::i< DataVector, 3, Frame > * > result, 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.
gr::Tags::Lapse
Definition: Tags.hpp:52
TMPL.hpp
gr::Tags::InverseSpatialMetric
Inverse of the spatial metric.
Definition: Tags.hpp:33
CurvedScalarWave
Items related to evolving a scalar wave on a curved background.
Definition: Characteristics.cpp:18
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
CurvedScalarWave::Tags::CharacteristicSpeeds
Definition: Tags.hpp:90