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>
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>
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>
64  gsl::not_null<tnsr::a<DataVector, 3, Frame::Inertial>*> char_speeds,
65  const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
66  const tnsr::I<DataVector, SpatialDim, Frame::Inertial>& shift,
67  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
68  unit_normal_one_form) noexcept;
69 
70 template <size_t SpatialDim>
74  using return_type = typename base::type;
75  using argument_tags = tmpl::list<
79 
80  static constexpr void function(
81  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_1,
83  const tnsr::I<DataVector, SpatialDim, Frame::Inertial>& shift,
84  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
85  unit_normal_one_form) noexcept {
86  characteristic_speeds<SpatialDim>(result, gamma_1, lapse, shift,
88  }
89 };
90 /// @}
91 
92 /// @{
93 /*!
94  * \brief Computes characteristic fields from evolved fields
95  *
96  * \ref CharacteristicFieldsCompute and
97  * \ref EvolvedFieldsFromCharacteristicFieldsCompute convert between
98  * characteristic and evolved fields for the scalar-wave system in curved
99  * spacetime.
100  *
101  * \ref CharacteristicFieldsCompute computes
102  * characteristic fields as described in "Optimal constraint projection for
103  * hyperbolic evolution systems" by Holst et. al \cite Holst2004wt .
104  * Their names used here differ from this paper:
105  *
106  * \f{align*}
107  * \mathrm{SpECTRE} && \mathrm{Holst} \\
108  * v^{\hat \psi} && Z^1 \\
109  * v^{\hat 0}_{i} && Z^{2}_{i} \\
110  * v^{\hat \pm} && u^{1\pm}
111  * \f}
112  *
113  * The characteristic fields \f$u\f$ are given in terms of the evolved fields by
114  * Eq. (33) - (35) of \cite Holst2004wt, respectively:
115  *
116  * \f{align*}
117  * v^{\hat \psi} =& \psi \\
118  * v^{\hat 0}_{i} =& (\delta^k_i - n_i n^k) \Phi_{k} := P^k_i \Phi_{k} \\
119  * v^{\hat \pm} =& \Pi \pm n^i \Phi_{i} - \gamma_2\psi
120  * \f}
121  *
122  * where \f$\psi\f$ is the scalar field, \f$\Pi\f$ and \f$\Phi_{i}\f$ are
123  * evolved fields introduced by first derivatives of \f$\psi\f$, \f$\gamma_2\f$
124  * is a constraint damping parameter, and \f$n_k\f$ is the unit normal to the
125  * surface.
126  *
127  * \ref EvolvedFieldsFromCharacteristicFieldsCompute computes evolved fields
128  * \f$w\f$ in terms of the characteristic fields. This uses the inverse of
129  * above relations (c.f. Eq. (36) - (38) of \cite Holst2004wt ):
130  *
131  * \f{align*}
132  * \psi =& v^{\hat \psi}, \\
133  * \Pi =& \frac{1}{2}(v^{\hat +} + v^{\hat -}) + \gamma_2 v^{\hat \psi}, \\
134  * \Phi_{i} =& \frac{1}{2}(v^{\hat +} - v^{\hat -}) n_i + v^{\hat 0}_{i}.
135  * \f}
136  *
137  * The corresponding characteristic speeds \f$\lambda\f$ are computed by
138  * \ref CharacteristicSpeedsCompute .
139  */
140 template <size_t SpatialDim>
141 Variables<
142  tmpl::list<Tags::VPsi, Tags::VZero<SpatialDim>, Tags::VPlus, Tags::VMinus>>
144  const Scalar<DataVector>& gamma_2,
145  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
146  inverse_spatial_metric,
147  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
148  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
149  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
150  unit_normal_one_form) noexcept;
151 
152 template <size_t SpatialDim>
154  gsl::not_null<Variables<tmpl::list<Tags::VPsi, Tags::VZero<SpatialDim>,
156  char_fields,
157  const Scalar<DataVector>& gamma_2,
158  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
159  inverse_spatial_metric,
160  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
161  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
162  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
163  unit_normal_one_form) noexcept;
164 
165 template <size_t SpatialDim>
169  using return_type = typename base::type;
170  using argument_tags = tmpl::list<
175 
176  static constexpr void function(
177  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_2,
178  const tnsr::II<DataVector, SpatialDim, Frame::Inertial>&
179  inverse_spatial_metric,
180  const Scalar<DataVector>& psi, const Scalar<DataVector>& pi,
181  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi,
182  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
183  unit_normal_one_form) noexcept {
184  characteristic_fields<SpatialDim>(result, gamma_2, inverse_spatial_metric,
185  psi, pi, phi, unit_normal_one_form);
186  }
187 };
188 /// @}
189 
190 /// @{
191 /*!
192  * \brief For expressions used here to compute evolved fields from
193  * characteristic ones, see \ref CharacteristicFieldsCompute.
194  */
195 template <size_t SpatialDim>
196 Variables<tmpl::list<Psi, Pi, Phi<SpatialDim>>>
198  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
199  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
200  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
201  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
202  unit_normal_one_form) noexcept;
203 
204 template <size_t SpatialDim>
206  gsl::not_null<Variables<tmpl::list<Psi, Pi, Phi<SpatialDim>>>*>
207  evolved_fields,
208  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
209  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
210  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
211  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
212  unit_normal_one_form) noexcept;
213 
214 template <size_t SpatialDim>
219  using return_type = typename base::type;
220  using argument_tags = tmpl::list<
222  Tags::VMinus,
224 
225  static constexpr void function(
226  gsl::not_null<return_type*> result, const Scalar<DataVector>& gamma_2,
227  const Scalar<DataVector>& v_psi,
228  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& v_zero,
229  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
230  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&
231  unit_normal_one_form) noexcept {
232  evolved_fields_from_characteristic_fields<SpatialDim>(
233  result, gamma_2, v_psi, v_zero, v_plus, v_minus, unit_normal_one_form);
234  }
235 };
236 /// @}
237 
238 namespace Tags {
239 /*!
240  * \brief Computes the largest magnitude of the characteristic speeds.
241  *
242  * \details Returns the magnitude of the largest characteristic speed
243  * along any direction at a given point in space, considering all
244  * characteristic fields. This is useful, for e.g., in computing the
245  * Courant factor. The coordinate characteristic speeds for this system are
246  * \f$\{-(1+\gamma_1)n_k N^k, -n_k N^k, -n_k N^k \pm N\}\f$. At any point
247  * in space, these are maximized when the normal vector is parallel to the
248  * shift vector, i.e. \f$ n^j = N^j / \sqrt{N^i N_i}\f$, and \f$ n_k N^k
249  * = g_{jk} N^j N^k / \sqrt{N^i N_i} = \sqrt{N^i N_i} =\f$
250  * `magnitude(shift, spatial_metric)`. The maximum characteristic speed
251  * is therefore calculated as \f$ \rm{max}(\vert 1+\gamma_1\vert\sqrt{N^i
252  * N_i},\, \sqrt{N^i N_i}+\vert N\vert) \f$.
253  */
254 template <size_t SpatialDim>
257  using argument_tags = tmpl::list<
261  using return_type = double;
263  static void function(
264  const gsl::not_null<double*> max_speed, const Scalar<DataVector>& gamma_1,
265  const Scalar<DataVector>& lapse,
266  const tnsr::I<DataVector, SpatialDim, Frame::Inertial>& shift,
267  const tnsr::ii<DataVector, SpatialDim, Frame::Inertial>&
268  spatial_metric) noexcept;
269 };
270 } // namespace Tags
271 } // namespace CurvedScalarWave
db::ComputeTag
Mark a struct as a compute tag by inheriting from this.
Definition: Tag.hpp:157
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::Tags::ComputeLargestCharacteristicSpeed
Computes the largest magnitude of the characteristic speeds.
Definition: Characteristics.hpp:255
gr::Tags::SpatialMetric
Definition: Tags.hpp:26
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::LargestCharacteristicSpeed
Definition: Tags.hpp:94
CurvedScalarWave::Tags::VPlus
Definition: Tags.hpp:81
CurvedScalarWave::CharacteristicFieldsCompute
Definition: Characteristics.hpp:166
CurvedScalarWave::characteristic_speeds
std::array< DataVector, 4 > characteristic_speeds(const Scalar< DataVector > &gamma_1, const Scalar< DataVector > &lapse, const tnsr::I< DataVector, SpatialDim, Frame::Inertial > &shift, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &unit_normal_one_form) noexcept
Compute the characteristic speeds for the scalar wave system in curved spacetime.
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:137
CurvedScalarWave::Tags::EvolvedFieldsFromCharacteristicFields
Definition: Tags.hpp:104
cstddef
std::array
CurvedScalarWave::Tags::VMinus
Definition: Tags.hpp:84
CurvedScalarWave::evolved_fields_from_characteristic_fields
Variables< tmpl::list< Psi, Pi, Phi< SpatialDim > > > evolved_fields_from_characteristic_fields(const Scalar< DataVector > &gamma_2, const Scalar< DataVector > &v_psi, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &v_zero, const Scalar< DataVector > &v_plus, const Scalar< DataVector > &v_minus, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &unit_normal_one_form) noexcept
For expressions used here to compute evolved fields from characteristic ones, see CharacteristicField...
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:99
Variables.hpp
CurvedScalarWave::EvolvedFieldsFromCharacteristicFieldsCompute
Definition: Characteristics.hpp:215
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:71
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::spatial_metric
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
gr::Tags::Lapse
Definition: Tags.hpp:52
TMPL.hpp
CurvedScalarWave::characteristic_fields
Variables< tmpl::list< Tags::VPsi, Tags::VZero< SpatialDim >, Tags::VPlus, Tags::VMinus > > characteristic_fields(const Scalar< DataVector > &gamma_2, const tnsr::II< DataVector, SpatialDim, Frame::Inertial > &inverse_spatial_metric, const Scalar< DataVector > &psi, const Scalar< DataVector > &pi, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &phi, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &unit_normal_one_form) noexcept
Computes characteristic fields from evolved fields.
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: BoundaryCorrection.hpp:13
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13
CurvedScalarWave::Tags::CharacteristicSpeeds
Definition: Tags.hpp:90