DampedWaveHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
9 #include "Utilities/Gsl.hpp"
10 
11 namespace GeneralizedHarmonic {
12 namespace gauges {
13 namespace DampedHarmonicGauge_detail {
14 /*
15  * Spatial weight function used in the damped harmonic gauge source
16  * function.
17  *
18  * The spatial weight function is:
19  * \f{align*}{
20  * W(x^i) = \exp(- (r / \sigma_r)^2),
21  * \f}
22  *
23  * where \f$r=\sqrt{x^i\delta_{ij}x^j}\f$ is the coordinate radius, and
24  * \f$\sigma_r\f$ is the width of the Gaussian.
25  *
26  * This function can be written with an extra factor inside the exponent in
27  * literature, e.g. \cite Deppe2018uye. We absorb that in \f$\sigma_r\f$.
28  */
29 template <size_t SpatialDim, typename Frame, typename DataType>
30 void spatial_weight_function(gsl::not_null<Scalar<DataType>*> weight,
31  const tnsr::I<DataType, SpatialDim, Frame>& coords,
32  double sigma_r) noexcept;
33 
34 /*
35  * Spacetime derivatives of the spatial weight function that enters the
36  * damped harmonic gauge source function.
37  *
38  * Compute the derivatives:
39  * \f{align*}{
40  * \partial_a W(x^i)= \partial_a \exp(- (r/\sigma_r)^2)
41  * = (-2 * x^i / \sigma_r^2) * exp(-(r/\sigma_r)^2)
42  * \f}
43  *
44  * where \f$r=\sqrt{x^i\delta_{ij}x^j}\f$ is the coordinate radius, and
45  * \f$\sigma_r\f$ is the width of the Gaussian. Since the weight function is
46  * spatial, the time derivative is always zero.
47  */
48 template <size_t SpatialDim, typename Frame, typename DataType>
49 void spacetime_deriv_of_spatial_weight_function(
50  gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> d4_weight,
51  const tnsr::I<DataType, SpatialDim, Frame>& coords, double sigma_r,
52  const Scalar<DataType>& weight_function) noexcept;
53 
54 /*
55  * The log factor that appears in damped harmonic gauge source function.
56  *
57  * Calculates: \f$ logF = \mathrm{log}(g^p/N) \f$.
58  */
59 template <typename DataType>
60 void log_factor_metric_lapse(gsl::not_null<Scalar<DataType>*> logfac,
61  const Scalar<DataType>& lapse,
62  const Scalar<DataType>& sqrt_det_spatial_metric,
63  double exponent) noexcept;
64 
65 template <typename DataType>
66 Scalar<DataType> log_factor_metric_lapse(
67  const Scalar<DataType>& lapse,
68  const Scalar<DataType>& sqrt_det_spatial_metric, double exponent) noexcept;
69 
70 /*
71  * Spacetime derivatives of the log factor that appears in the
72  * damped harmonic gauge source function.
73  *
74  * Computes the spacetime derivatives:
75  * \f{align*}{
76  * \partial_a logF = (p/g)\partial_a g - (1/N)\partial_a N
77  * \f}
78  */
79 template <size_t SpatialDim, typename Frame, typename DataType>
80 void spacetime_deriv_of_log_factor_metric_lapse(
81  gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> d4_logfac,
82  const Scalar<DataType>& lapse,
83  const tnsr::I<DataType, SpatialDim, Frame>& shift,
84  const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
85  const tnsr::II<DataType, SpatialDim, Frame>& inverse_spatial_metric,
86  const Scalar<DataType>& sqrt_det_spatial_metric,
87  const tnsr::ii<DataType, SpatialDim, Frame>& dt_spatial_metric,
88  const tnsr::aa<DataType, SpatialDim, Frame>& pi,
89  const tnsr::iaa<DataType, SpatialDim, Frame>& phi,
90  double exponent) noexcept;
91 
92 template <size_t SpatialDim, typename Frame, typename DataType>
93 tnsr::a<DataType, SpatialDim, Frame> spacetime_deriv_of_log_factor_metric_lapse(
94  const Scalar<DataType>& lapse,
95  const tnsr::I<DataType, SpatialDim, Frame>& shift,
96  const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
97  const tnsr::II<DataType, SpatialDim, Frame>& inverse_spatial_metric,
98  const Scalar<DataType>& sqrt_det_spatial_metric,
99  const tnsr::ii<DataType, SpatialDim, Frame>& dt_spatial_metric,
100  const tnsr::aa<DataType, SpatialDim, Frame>& pi,
101  const tnsr::iaa<DataType, SpatialDim, Frame>& phi,
102  double exponent) noexcept;
103 
104 /*
105  * Spacetime derivatives of the log factor (that appears in
106  * damped harmonic gauge source function), raised to an exponent.
107  *
108  * Computes the spacetime derivatives:
109  * \f{align*}{
110  * \partial_a (logF)^q = q (logF)^{q-1} \partial_a (logF)
111  * \f}
112  */
113 template <size_t SpatialDim, typename Frame, typename DataType>
114 void spacetime_deriv_of_power_log_factor_metric_lapse(
115  gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> d4_powlogfac,
116  const Scalar<DataType>& lapse,
117  const tnsr::I<DataType, SpatialDim, Frame>& shift,
118  const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
119  const tnsr::II<DataType, SpatialDim, Frame>& inverse_spatial_metric,
120  const Scalar<DataType>& sqrt_det_spatial_metric,
121  const tnsr::ii<DataType, SpatialDim, Frame>& dt_spatial_metric,
122  const tnsr::aa<DataType, SpatialDim, Frame>& pi,
123  const tnsr::iaa<DataType, SpatialDim, Frame>& phi, double g_exponent,
124  int exponent) noexcept;
125 
126 template <size_t SpatialDim, typename Frame, typename DataType>
127 tnsr::a<DataType, SpatialDim, Frame>
128 spacetime_deriv_of_power_log_factor_metric_lapse(
129  const Scalar<DataType>& lapse,
130  const tnsr::I<DataType, SpatialDim, Frame>& shift,
131  const tnsr::A<DataType, SpatialDim, Frame>& spacetime_unit_normal,
132  const tnsr::II<DataType, SpatialDim, Frame>& inverse_spatial_metric,
133  const Scalar<DataType>& sqrt_det_spatial_metric,
134  const tnsr::ii<DataType, SpatialDim, Frame>& dt_spatial_metric,
135  const tnsr::aa<DataType, SpatialDim, Frame>& pi,
136  const tnsr::iaa<DataType, SpatialDim, Frame>& phi, double g_exponent,
137  int exponent) noexcept;
138 
139 } // namespace DampedHarmonicGauge_detail
140 } // namespace gauges
141 } // namespace GeneralizedHarmonic
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 .
GeneralizedHarmonic
Items related to evolving the first-order generalized harmonic system.
Definition: Characteristics.cpp:21
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.
cstddef
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...
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
Gsl.hpp
TypeAliases.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183