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/Tensor/EagerMath/Magnitude.hpp"
11 #include "Domain/FaceNormal.hpp"
13 #include "Evolution/Systems/CurvedScalarWave/TagsDeclarations.hpp"
14 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
15 #include "Utilities/TMPL.hpp"
16 
17 namespace CurvedScalarWave {
18 // @{
19 /*!
20  * \ingroup CurvedScalarWave
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  * \ingroup CurvedScalarWave
87  * \brief Computes characteristic fields from evolved fields
88  *
89  * \ref CharacteristicFieldsCompute and
90  * \ref EvolvedFieldsFromCharacteristicFieldsCompute convert between
91  * characteristic and evolved fields for the scalar-wave system in curved
92  * spacetime.
93  *
94  * \ref CharacteristicFieldsCompute computes
95  * characteristic fields as described in "Optimal constraint projection for
96  * hyperbolic evolution systems" by Holst et. al \cite Holst2004wt .
97  * Their names used here differ from this paper:
98  *
99  * \f{align*}
100  * \mathrm{SpECTRE} && \mathrm{Holst} \\
101  * v^{\hat \psi} && Z^1 \\
102  * v^{\hat 0}_{i} && Z^{2}_{i} \\
103  * v^{\hat \pm} && u^{1\pm}
104  * \f}
105  *
106  * The characteristic fields \f$u\f$ are given in terms of the evolved fields by
107  * Eq. (33) - (35) of \cite Holst2004wt, respectively:
108  *
109  * \f{align*}
110  * v^{\hat \psi} =& \psi \\
111  * v^{\hat 0}_{i} =& (\delta^k_i - n_i n^k) \Phi_{k} := P^k_i \Phi_{k} \\
112  * v^{\hat \pm} =& \Pi \pm n^i \Phi_{i} - \gamma_2\psi
113  * \f}
114  *
115  * where \f$\psi\f$ is the scalar field, \f$\Pi\f$ and \f$\Phi_{i}\f$ are
116  * evolved fields introduced by first derivatives of \f$\psi\f$, \f$\gamma_2\f$
117  * is a constraint damping parameter, and \f$n_k\f$ is the unit normal to the
118  * surface.
119  *
120  * \ref EvolvedFieldsFromCharacteristicFieldsCompute computes evolved fields
121  * \f$w\f$ in terms of the characteristic fields. This uses the inverse of
122  * above relations (c.f. Eq. (36) - (38) of \cite Holst2004wt ):
123  *
124  * \f{align*}
125  * \psi =& v^{\hat \psi}, \\
126  * \Pi =& \frac{1}{2}(v^{\hat +} + v^{\hat -}) + \gamma_2 v^{\hat \psi}, \\
127  * \Phi_{i} =& \frac{1}{2}(v^{\hat +} - v^{\hat -}) n_i + v^{\hat 0}_{i}.
128  * \f}
129  *
130  * The corresponding characteristic speeds \f$\lambda\f$ are computed by
131  * \ref CharacteristicSpeedsCompute .
132  */
133 template <size_t SpatialDim>
134 Variables<
135  tmpl::list<Tags::VPsi, Tags::VZero<SpatialDim>, Tags::VPlus, Tags::VMinus>>
136 characteristic_fields(
137  const Scalar<DataVector>& gamma_2,
138  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
139  inverse_spatial_metric,
140  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
141  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
142  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
143  unit_normal_one_form) noexcept;
144 
145 template <size_t SpatialDim>
146 void characteristic_fields(
147  gsl::not_null<Variables<tmpl::list<Tags::VPsi, Tags::VZero<SpatialDim>,
148  Tags::VPlus, Tags::VMinus>>*>
149  char_fields,
150  const Scalar<DataVector>& gamma_2,
151  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
152  inverse_spatial_metric,
153  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
154  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
155  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
156  unit_normal_one_form) noexcept;
157 
158 template <size_t SpatialDim>
162  using return_type = typename base::type;
163  using argument_tags = tmpl::list<
168 
169  static constexpr void function(
170  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_2,
171  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
172  inverse_spatial_metric,
173  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
174  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
175  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
176  unit_normal_one_form) noexcept {
177  characteristic_fields<SpatialDim>(result, gamma_2, inverse_spatial_metric,
178  psi, pi, phi, unit_normal_one_form);
179  }
180 };
181 // @}
182 
183 // @{
184 /*!
185  * \ingroup CurvedScalarWave
186  * \brief For expressions used here to compute evolved fields from
187  * characteristic ones, see \ref CharacteristicFieldsCompute.
188  */
189 template <size_t SpatialDim>
190 Variables<tmpl::list<Psi, Pi, Phi<SpatialDim>>>
191 evolved_fields_from_characteristic_fields(
192  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
193  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
194  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
195  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
196  unit_normal_one_form) noexcept;
197 
198 template <size_t SpatialDim>
199 void evolved_fields_from_characteristic_fields(
200  gsl::not_null<Variables<tmpl::list<Psi, Pi, Phi<SpatialDim>>>*>
201  evolved_fields,
202  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
203  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
204  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
205  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
206  unit_normal_one_form) noexcept;
207 
208 template <size_t SpatialDim>
213  using return_type = typename base::type;
214  using argument_tags = tmpl::list<
216  Tags::VMinus,
218 
219  static constexpr void function(
220  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_2,
221  const Scalar<DataVector>& v_psi,
222  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
223  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
224  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
225  unit_normal_one_form) noexcept {
226  evolved_fields_from_characteristic_fields<SpatialDim>(
227  result, gamma_2, v_psi, v_zero, v_plus, v_minus, unit_normal_one_form);
228  }
229 };
230 // @}
231 
232 /*!
233  * \ingroup CurvedScalarWave
234  * \brief Computes the largest magnitude of the characteristic speeds.
235  */
236 template <size_t SpatialDim>
238  using argument_tags = tmpl::list<Tags::CharacteristicSpeeds<SpatialDim>>;
239  static double apply(const std::array<DataVector, 4>& char_speeds) noexcept;
240 };
241 } // namespace CurvedScalarWave
Definition: Characteristics.hpp:63
Defines functions to calculate the scalar wave constraints in curved spacetime.
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:119
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.
Tags corresponding to the characteristic fields of the scalar-wave system in curved spacetime...
Definition: Tags.hpp:77
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:154
Definition: Tags.hpp:28
Definition: Characteristics.hpp:159
Definition: Tags.hpp:59
Inverse of the spatial metric.
Definition: Tags.hpp:36
Definition: Tags.hpp:81
Definition: Tags.hpp:87
Definition: Tags.hpp:84
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:120
Definition: Tags.hpp:34
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:59
Defines class Variables.
Definition: Tags.hpp:54
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:137
Defines classes for Tensor.
Declares function unnormalized_face_normal.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1628
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:110
Definition: Tags.hpp:23
Wraps the template metaprogramming library used (brigand)
Items related to evolving a scalar wave on a curved background.
Definition: Characteristics.cpp:18
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182
Computes the largest magnitude of the characteristic speeds.
Definition: Characteristics.hpp:237