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