Characteristics.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <cstddef>
8 
10 #include "DataStructures/DataVector.hpp"
12 #include "Domain/FaceNormal.hpp"
14 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 template <typename>
20 class Variables;
21 
22 namespace Tags {
23 template <typename Tag>
24 struct Normalized;
25 } // namespace Tags
26 /// \endcond
27 
28 namespace ScalarWave {
29 namespace Tags {
31  using argument_tags = tmpl::list<Psi>;
32  static auto function(const Scalar<DataVector>& psi) noexcept {
33  return make_with_value<type>(psi, 0.);
34  }
35  using base = ConstraintGamma2;
36 };
37 } // namespace Tags
38 
39 // @{
40 /*!
41  * \ingroup ScalarWave
42  * \brief Compute the characteristic speeds for the scalar wave system.
43  *
44  * Computes the speeds as described in "Optimal constraint projection for
45  * hyperbolic evolution systems" by Holst et al. \cite Holst2004wt
46  * [see text following Eq.(32)]. The characteristic fields' names used here
47  * differ from this paper:
48  *
49  * \f{align*}
50  * \mathrm{SpECTRE} && \mathrm{Holst} \\
51  * v^{\hat \psi} && Z^1 \\
52  * v^{\hat 0}_{i} && Z^{2}_{i} \\
53  * v^{\hat \pm} && u^{1\pm}
54  * \f}
55  *
56  * The corresponding characteristic speeds \f$\lambda_{\hat \alpha}\f$ are given
57  * in the text following Eq.(38) of \cite Holst2004wt :
58  *
59  * \f{align*}
60  * \lambda_{\hat \psi} =& 0 \\
61  * \lambda_{\hat 0} =& 0 \\
62  * \lambda_{\hat \pm} =& \pm 1.
63  * \f}
64  */
65 template <size_t Dim>
66 std::array<DataVector, 4> characteristic_speeds(
67  const tnsr::i<DataVector, Dim, Frame::Inertial>&
68  unit_normal_one_form) noexcept;
69 
70 template <size_t Dim>
71 void characteristic_speeds(
73  const tnsr::i<DataVector, Dim, Frame::Inertial>&
74  unit_normal_one_form) noexcept;
75 
76 template <size_t Dim>
80  using type = typename base::type;
81  using argument_tags =
82  tmpl::list<::Tags::Normalized<::Tags::UnnormalizedFaceNormal<Dim>>>;
83 
84  static typename Tags::CharacteristicSpeeds<Dim>::type function(
85  const tnsr::i<DataVector, Dim, Frame::Inertial>&
86  unit_normal_one_form) noexcept {
87  return characteristic_speeds(unit_normal_one_form);
88  };
89 };
90 // @}
91 
92 // @{
93 /*!
94  * \ingroup ScalarWave
95  * \brief Computes characteristic fields from evolved fields
96  *
97  * \ref CharacteristicFieldsCompute and
98  * \ref EvolvedFieldsFromCharacteristicFieldsCompute convert between
99  * characteristic and evolved fields for the scalar-wave system.
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${v}^{\hat \alpha}\f$ are given in terms of
114  * the evolved fields by 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$\Phi_{i}=\partial_i \psi\f$ is an
123  * auxiliary variable, \f$\Pi\f$ is a conjugate momentum, \f$\gamma_2\f$
124  * is a constraint damping parameter, and \f$n_k\f$ is the unit normal to the
125  * surface along which the characteristic fields are defined.
126  *
127  * \ref EvolvedFieldsFromCharacteristicFieldsCompute computes evolved fields
128  * \f$u_\alpha\f$ in terms of the characteristic fields. This uses the inverse
129  * of above relations:
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_{\hat \alpha}\f$
138  * are computed by \ref CharacteristicSpeedsCompute .
139  */
140 template <size_t Dim>
141 Variables<tmpl::list<Tags::VPsi, Tags::VZero<Dim>, Tags::VPlus, Tags::VMinus>>
142 characteristic_fields(const Scalar<DataVector>& gamma_2,
143  const Scalar<DataVector>& psi,
144  const Scalar<DataVector>& pi,
145  const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
146  const tnsr::i<DataVector, Dim, Frame::Inertial>&
147  unit_normal_one_form) noexcept;
148 
149 template <size_t Dim>
150 void characteristic_fields(
151  gsl::not_null<Variables<
152  tmpl::list<Tags::VPsi, Tags::VZero<Dim>, Tags::VPlus, Tags::VMinus>>*>
153  char_fields,
154  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& psi,
155  const Scalar<DataVector>& pi,
156  const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
157  const tnsr::i<DataVector, Dim, Frame::Inertial>&
158  unit_normal_one_form) noexcept;
159 
160 template <size_t Dim>
164  using type = typename base::type;
165  using argument_tags =
166  tmpl::list<Tags::ConstraintGamma2, Psi, Pi, Phi<Dim>,
168 
169  static typename Tags::CharacteristicFields<Dim>::type function(
170  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& psi,
171  const Scalar<DataVector>& pi,
172  const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
173  const tnsr::i<DataVector, Dim, Frame::Inertial>&
174  unit_normal_one_form) noexcept {
175  return characteristic_fields(gamma_2, psi, pi, phi, unit_normal_one_form);
176  };
177 };
178 // @}
179 
180 // @{
181 /*!
182  * \ingroup ScalarWave
183  * \brief Compute evolved fields from characteristic fields.
184  *
185  * For expressions used here to compute evolved fields from characteristic ones,
186  * see \ref CharacteristicFieldsCompute.
187  */
188 template <size_t Dim>
189 Variables<tmpl::list<Psi, Pi, Phi<Dim>>>
190 evolved_fields_from_characteristic_fields(
191  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
192  const tnsr::i<DataVector, Dim, Frame::Inertial>& v_zero,
193  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
194  const tnsr::i<DataVector, Dim, Frame::Inertial>&
195  unit_normal_one_form) noexcept;
196 
197 template <size_t Dim>
198 void evolved_fields_from_characteristic_fields(
199  gsl::not_null<Variables<tmpl::list<Psi, Pi, Phi<Dim>>>*> evolved_fields,
200  const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
201  const tnsr::i<DataVector, Dim, Frame::Inertial>& v_zero,
202  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
203  const tnsr::i<DataVector, Dim, Frame::Inertial>&
204  unit_normal_one_form) noexcept;
205 
206 template <size_t Dim>
211  using type = typename base::type;
212  using argument_tags =
213  tmpl::list<Tags::ConstraintGamma2, Tags::VPsi, Tags::VZero<Dim>,
214  Tags::VPlus, Tags::VMinus,
216 
217  static typename Tags::EvolvedFieldsFromCharacteristicFields<Dim>::type
218  function(const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
219  const tnsr::i<DataVector, Dim, Frame::Inertial>& v_zero,
220  const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
221  const tnsr::i<DataVector, Dim, Frame::Inertial>&
222  unit_normal_one_form) noexcept {
223  return evolved_fields_from_characteristic_fields(
224  gamma_2, v_psi, v_zero, v_plus, v_minus, unit_normal_one_form);
225  };
226 };
227 // @}
228 } // namespace ScalarWave
Definition: Tags.hpp:37
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:119
Definition: Characteristics.hpp:30
Definition: Tags.hpp:31
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:154
Definition: Characteristics.hpp:161
Definition: Characteristics.hpp:77
Definition: Tags.hpp:78
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
Defines DataBox tags for scalar wave system.
Items related to evolving the scalar wave equation.
Definition: Characteristics.cpp:16
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
Definition: DataBoxTag.hpp:29
Defines classes for Tensor.
Declares function unnormalized_face_normal.
Tags corresponding to the characteristic fields of the flat-spacetime scalar-wave system...
Definition: Tags.hpp:69
Wraps the template metaprogramming library used (brigand)
Definition: Tags.hpp:82
Defines functions and classes from the GSL.
Definition: Tags.hpp:20
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Definition: Tags.hpp:25
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Definition: Tags.hpp:74
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182
Defines make_with_value.