Constraints.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 ///\file
5 /// Defines functions to calculate the scalar wave constraints in
6 /// curved spacetime
7 
8 #pragma once
9 
10 #include <cstddef>
11 
15 #include "Utilities/Gsl.hpp"
17 #include "Utilities/TMPL.hpp"
18 
19 namespace CurvedScalarWave {
20 namespace Tags {
21 /*!
22  * \brief Compute items to compute constraint damping parameters.
23  *
24  * \details For the evolution system with constraint damping parameters
25  * to be symmetric-hyperbolic, we need \f$\gamma_1 \gamma_2 = 0\f$. When
26  * \f$\gamma_1 = 0\f$, Ref. \cite Holst2004wt shows that the one-index
27  * constraint decays exponentially on a time-scale \f$ 1/\gamma_2\f$.
28  * Conversely, they also show that using \f$\gamma_2 > 0\f$ leads to
29  * exponential suppression of constraint violations.
30  *
31  * Can be retrieved using `CurvedScalarWave::Tags::ConstraintGamma1`
32  * and `CurvedScalarWave::Tags::ConstraintGamma2`.
33  */
35  using argument_tags = tmpl::list<Psi>;
36  static auto function(const Scalar<DataVector>& used_for_size) noexcept {
37  return make_with_value<type>(used_for_size, 0.);
38  }
39  using base = ConstraintGamma1;
40 };
41 /// \copydoc ConstraintGamma1Compute
43  using argument_tags = tmpl::list<Psi>;
44  static auto function(const Scalar<DataVector>& used_for_size) noexcept {
45  return make_with_value<type>(used_for_size, 1.);
46  }
47  using base = ConstraintGamma2;
48 };
49 } // namespace Tags
50 
51 // @{
52 /*!
53  * \brief Computes the scalar-wave one-index constraint.
54  *
55  * \details Computes the scalar-wave one-index constraint,
56  * \f$C_{i} = \partial_i\psi - \Phi_{i},\f$ which is
57  * given by Eq. (19) of \cite Holst2004wt
58  */
59 template <size_t SpatialDim>
60 tnsr::i<DataVector, SpatialDim, Frame::Inertial> one_index_constraint(
61  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& d_psi,
62  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi) noexcept;
63 
64 template <size_t SpatialDim>
66  gsl::not_null<tnsr::i<DataVector, SpatialDim, Frame::Inertial>*> constraint,
67  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& d_psi,
68  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi) noexcept;
69 // @}
70 
71 // @{
72 /*!
73  * \brief Computes the scalar-wave 2-index constraint.
74  *
75  * \details Computes the scalar-wave 2-index FOSH constraint
76  * [Eq. (20) of \cite Holst2004wt],
77  *
78  * \f{eqnarray}{
79  * C_{ij} &\equiv& \partial_i \Phi_j - \partial_j \Phi_i
80  * \f}
81  *
82  * where \f$\Phi_{i} = \partial_i\psi\f$; and \f$\psi\f$ is the scalar field.
83  */
84 template <size_t SpatialDim>
85 tnsr::ij<DataVector, SpatialDim, Frame::Inertial> two_index_constraint(
86  const tnsr::ij<DataVector, SpatialDim, Frame::Inertial>& d_phi) noexcept;
87 
88 template <size_t SpatialDim>
90  gsl::not_null<tnsr::ij<DataVector, SpatialDim, Frame::Inertial>*>
91  constraint,
92  const tnsr::ij<DataVector, SpatialDim, Frame::Inertial>& d_phi) noexcept;
93 // @}
94 
95 namespace Tags {
96 /*!
97  * \brief Compute item to get the one-index constraint for the scalar-wave
98  * evolution system.
99  *
100  * \details See `one_index_constraint()`. Can be retrieved using
101  * `CurvedScalarWave::Tags::OneIndexConstraint`.
102  */
103 template <size_t SpatialDim>
106  using argument_tags =
107  tmpl::list<::Tags::deriv<Psi, tmpl::size_t<SpatialDim>, Frame::Inertial>,
109  using return_type = tnsr::i<DataVector, SpatialDim, Frame::Inertial>;
110  static constexpr void (*function)(
111  const gsl::not_null<return_type*> result,
112  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&,
113  const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&) =
114  &one_index_constraint<SpatialDim>;
116 };
117 
118 /*!
119  * \brief Compute item to get the two-index constraint for the scalar-wave
120  * evolution system.
121  *
122  * \details See `two_index_constraint()`. Can be retrieved using
123  * `CurvedScalarWave::Tags::TwoIndexConstraint`.
124  */
125 template <size_t SpatialDim>
128  using argument_tags =
129  tmpl::list<::Tags::deriv<Phi<SpatialDim>, tmpl::size_t<SpatialDim>,
130  Frame::Inertial>>;
131  using return_type = tnsr::ij<DataVector, SpatialDim, Frame::Inertial>;
132  static constexpr void (*function)(
133  const gsl::not_null<return_type*> result,
134  const tnsr::ij<DataVector, SpatialDim, Frame::Inertial>&) =
135  &two_index_constraint<SpatialDim>;
137 };
138 } // namespace Tags
139 } // namespace CurvedScalarWave
Compute item to get the two-index constraint for the scalar-wave evolution system.
Definition: Constraints.hpp:126
Tag for the two-index constraint of the scalar wave system in curved spacetime.
Definition: Tags.hpp:67
Tag for the one-index constraint of the scalar wave system in curved spacetime.
Definition: Tags.hpp:56
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:154
Compute items to compute constraint damping parameters.
Definition: Constraints.hpp:42
tnsr::ij< DataVector, SpatialDim, Frame::Inertial > two_index_constraint(const tnsr::ij< DataVector, SpatialDim, Frame::Inertial > &d_phi) noexcept
Computes the scalar-wave 2-index constraint.
Definition: Constraints.cpp:47
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 functions computing partial derivatives.
Definition: DataBoxTag.hpp:29
Defines classes for Tensor.
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
Definition: IndexType.hpp:44
Items related to evolving a scalar wave on a curved background.
Definition: Characteristics.cpp:18
Compute items to compute constraint damping parameters.
Definition: Constraints.hpp:34
Defines DataBox tags for the curved scalar wave system.
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182
tnsr::i< DataVector, SpatialDim, Frame::Inertial > one_index_constraint(const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &d_psi, const tnsr::i< DataVector, SpatialDim, Frame::Inertial > &phi) noexcept
Computes the scalar-wave one-index constraint.
Definition: Constraints.cpp:16
Defines make_with_value.
Compute item to get the one-index constraint for the scalar-wave evolution system.
Definition: Constraints.hpp:104