Sources.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "DataStructures/Tensor/TypeAliases.hpp" // IWYU pragma: keep
7 #include "Evolution/Systems/GrMhd/ValenciaDivClean/TagsDeclarations.hpp" // IWYU pragma: keep
9 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
10 #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp" // IWYU pragma: keep
11 #include "Utilities/TMPL.hpp"
12 
13 // IWYU pragma: no_include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
14 // IWYU pragma: no_include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
15 // IWYU pragma: no_include "PointwiseFunctions/Hydro/Tags.hpp"
16 // IWYU pragma: no_include "Utilities/Gsl.hpp"
17 
18 // IWYU pragma: no_forward_declare Tensor
19 // IWYU pragma: no_forward_declare Tags::deriv
20 
21 /// \cond
22 class DataVector;
23 
24 namespace Tags {
25 template <typename>
26 struct Source;
27 } // namespace Tags
28 /// \endcond
29 
30 namespace grmhd {
31 namespace ValenciaDivClean {
32 
33 /*!
34  * \brief Compute the source terms for the flux-conservative Valencia
35  * formulation of GRMHD with divergence cleaning.
36  *
37  *
38  * A flux-conservative system has the generic form:
39  * \f[
40  * \partial_t U_i + \partial_m F^m(U_i) = S(U_i)
41  * \f]
42  *
43  * where \f$F^a()\f$ denotes the flux of a conserved variable \f$U_i\f$ and
44  * \f$S()\f$ denotes the source term for the conserved variable.
45  *
46  * For the Valencia formulation:
47  * \f{align*}
48  * S({\tilde D}) = & 0\\
49  * S({\tilde S}_i) = & \frac{1}{2} \alpha {\tilde S}^{mn} \partial_i \gamma_{mn}
50  * + {\tilde S}_m \partial_i \beta^m - ({\tilde D} + {\tilde \tau}) \partial_i
51  * \alpha \\
52  * S({\tilde \tau}) = & \alpha {\tilde S}^{mn} K_{mn} - {\tilde S}^m \partial_m
53  * \alpha \\
54  * S({\tilde B}^i) = & -{\tilde B}^m \partial_m \beta^i + {\tilde \Phi}
55  * \gamma^{im} \partial_m \alpha + \alpha {\tilde \Phi} \left( \frac{1}{2}
56  * \gamma^{il} \gamma^{jk} - \gamma^{ij} \gamma^{lk} \right) \partial_l
57  * \gamma_{jk} \\ S({\tilde \Phi}) = & {\tilde B}^k \partial_k \alpha - \alpha K
58  * {\tilde \Phi}
59  * - \alpha \kappa {\tilde \Phi}
60  * \f}
61  *
62  * where
63  * \f{align*}
64  * {\tilde S}^i = & {\tilde S}_m \gamma^{im} \\
65  * {\tilde S}^{ij} = & \sqrt{\gamma} \left[ \left(h \rho W^2 + B^n B_n \right)
66  * v^i v^j + \left(p + p_m \right) \gamma^{ij} - B^n v_n \left( B^i v^j + B^j
67  * v^i \right) - \frac{B^i B^j}{W^2} \right]
68  * \f}
69  *
70  * where \f${\tilde D}\f$, \f${\tilde S}_i\f$, \f${\tilde \tau}\f$, \f${\tilde
71  * B}^i\f$, and \f${\tilde \Phi}\f$ are a generalized mass-energy density,
72  * momentum density, specific internal energy density, magnetic field, and
73  * divergence cleaning field. Furthermore, \f$\gamma\f$ is the determinant of
74  * the spatial metric \f$\gamma_{ij}\f$, \f$\rho\f$ is the rest mass density,
75  * \f$W\f$ is the Lorentz factor, \f$h\f$ is the specific enthalpy, \f$v^i\f$ is
76  * the spatial velocity, \f$B^k\f$ is the magnetic field, \f$p\f$ is the
77  * pressure, \f$p_m = \frac{1}{2} \left[ \left( B^n v_n \right)^2 + B^n B_n /
78  * W^2 \right]\f$ is the magnetic pressure, \f$\alpha\f$ is the lapse,
79  * \f$\beta^i\f$ is the shift, \f$K\f$ is the trace of the extrinsic curvature
80  * \f$K_{ij}\f$, and \f$\kappa\f$ is a damping parameter that damps violations
81  * of the divergence-free (no-monopole) condition \f$\Phi = \partial_i {\tilde
82  * B}^i = 0\f$ .
83  */
85  using return_tags =
86  tmpl::list<::Tags::Source<grmhd::ValenciaDivClean::Tags::TildeTau>,
90 
91  using argument_tags = tmpl::list<
103  ::Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<3>,
105  ::Tags::deriv<gr::Tags::Shift<3, Frame::Inertial, DataVector>,
106  tmpl::size_t<3>, Frame::Inertial>,
108  ::Tags::deriv<gr::Tags::SpatialMetric<3, Frame::Inertial, DataVector>,
109  tmpl::size_t<3>, Frame::Inertial>,
113 
114  static void apply(
115  gsl::not_null<Scalar<DataVector>*> source_tilde_tau,
116  gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> source_tilde_s,
117  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> source_tilde_b,
118  gsl::not_null<Scalar<DataVector>*> source_tilde_phi,
119  const Scalar<DataVector>& tilde_d, const Scalar<DataVector>& tilde_tau,
120  const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
121  const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b,
122  const Scalar<DataVector>& tilde_phi,
123  const tnsr::I<DataVector, 3, Frame::Inertial>& spatial_velocity,
124  const tnsr::I<DataVector, 3, Frame::Inertial>& magnetic_field,
125  const Scalar<DataVector>& rest_mass_density,
127  const Scalar<DataVector>& lorentz_factor,
128  const Scalar<DataVector>& pressure, const Scalar<DataVector>& lapse,
129  const tnsr::i<DataVector, 3, Frame::Inertial>& d_lapse,
130  const tnsr::iJ<DataVector, 3, Frame::Inertial>& d_shift,
131  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
132  const tnsr::ijj<DataVector, 3, Frame::Inertial>& d_spatial_metric,
133  const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric,
134  const Scalar<DataVector>& sqrt_det_spatial_metric,
135  const tnsr::ii<DataVector, 3, Frame::Inertial>& extrinsic_curvature,
136  double constraint_damping_parameter) noexcept;
137 };
138 } // namespace ValenciaDivClean
139 } // namespace grmhd
Prefix indicating a source term.
Definition: Prefixes.hpp:66
The spatial velocity of the fluid, where . Here is the spatial part of the 4-velocity of the fluid...
Definition: Tags.hpp:156
The fluid pressure .
Definition: Tags.hpp:130
Definition: Tags.hpp:36
The densitized divergence-cleaning field .
Definition: Tags.hpp:70
Definition: Tags.hpp:46
Definition: Tags.hpp:31
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
Definition: ComputeSpacetimeQuantities.cpp:62
Scalar< DataType > specific_enthalpy(const Scalar< DataType > &rest_mass_density, const Scalar< DataType > &specific_internal_energy, const Scalar< DataType > &pressure) noexcept
Computes the relativistic specific enthalpy as: where is the specific internal energy...
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1609
The magnetic field measured by an Eulerian observer, where is the normal to the spatial hypersurfac...
Definition: Tags.hpp:86
tnsr::ii< DataVector, 3, Frame > extrinsic_curvature(const tnsr::ii< DataVector, 3, Frame > &grad_normal, const tnsr::i< DataVector, 3, Frame > &unit_normal_one_form, const tnsr::I< DataVector, 3, Frame > &unit_normal_vector) noexcept
Extrinsic curvature of a 2D Strahlkorper embedded in a 3D space.
The densitized energy density .
Definition: Tags.hpp:50
The densitized momentum density .
Definition: Tags.hpp:57
The densitized magnetic field .
Definition: Tags.hpp:64
Definition: Tags.hpp:26
Defines functions computing partial derivatives.
The Lorentz factor , where is the spatial velocity of the fluid.
Definition: Tags.hpp:68
Definition: DataBoxTag.hpp:29
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.
Definition: ComputeSpacetimeQuantities.cpp:117
Defines a list of useful type aliases for tensors.
The densitized rest-mass density .
Definition: Tags.hpp:44
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
Compute the source terms for the flux-conservative Valencia formulation of GRMHD with divergence clea...
Definition: Sources.hpp:84
The rest-mass density .
Definition: Tags.hpp:137
Definition: IndexType.hpp:44
The specific enthalpy .
Definition: Tags.hpp:182
Items related to general relativistic magnetohydrodynamics (GRMHD)
Definition: Characteristics.hpp:34
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
The constraint damping parameter for divergence cleaning.
Definition: Tags.hpp:38
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Definition: Tags.hpp:96