ConservativeFromPrimitive.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
7 #include "Evolution/Systems/GrMhd/ValenciaDivClean/TagsDeclarations.hpp" // IWYU pragma: keep
8 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
9 #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp" // IWYU pragma: keep
10 #include "Utilities/TMPL.hpp"
11
12 // IWYU pragma: no_include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
13 // IWYU pragma: no_include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
14 // IWYU pragma: no_include "PointwiseFunctions/Hydro/Tags.hpp"
15
16 /// \cond
17 namespace gsl {
18 template <typename T>
19 class not_null;
20 } // namespace gsl
21
22 class DataVector;
23 /// \endcond
24
25 // IWYU pragma: no_forward_declare Tensor
26
27 namespace grmhd {
29
30 /*!
31  * \brief Compute the conservative variables from primitive variables
32  *
33  * \f{align*}
34  * {\tilde D} = & \sqrt{\gamma} \rho W \\
35  * {\tilde S}_i = & \sqrt{\gamma} \left( \rho h W^2 v_i + B^m B_m v_i - B^m v_m
36  * B_i \right) \\
37  * {\tilde \tau} = & \sqrt{\gamma} \left[ \rho h W^2 - p - \rho W - \frac{1}{2}
38  * (B^m v_m)^2 + \frac{1}{2} B^m B_m \left( 1 + v^m v_m \right) \right] \\
39  * {\tilde B}^i = & \sqrt{\gamma} B^i \\
40  * {\tilde \Phi} = & \sqrt{\gamma} \Phi
41  * \f}
42  *
43  * where the conserved variables \f${\tilde D}\f$, \f${\tilde S}_i\f$,
44  * \f${\tilde \tau}\f$, \f${\tilde B}^i\f$, and \f${\tilde \Phi}\f$ are a
45  * generalized mass-energy density, momentum density, specific internal energy
46  * density, magnetic field, and divergence cleaning field. Furthermore
47  * \f$\gamma\f$ is the determinant of the spatial metric, \f$\rho\f$ is the rest
48  * mass density, \f$W = 1/\sqrt{1-v_i v^i}\f$ is the Lorentz factor, \f$h = 1 + 49 * \epsilon + \frac{p}{\rho}\f$ is the specific enthalpy, \f$v^i\f$ is the
50  * spatial velocity, \f$\epsilon\f$ is the specific internal energy, \f$p\f$ is
51  * the pressure, \f$B^i\f$ is the spatial magnetic field measured by an Eulerian
52  * observer, and \f$\Phi\f$ is a divergence cleaning field.
53  *
54  * The quantity \f${\tilde \tau}\f$ is rewritten as in RelativisticEuler
55  * to avoid cancellation error in the non-relativistic limit:
56  * \f[
57  * \left( \rho h W^2 - p - \rho W \right) \longrightarrow
58  * W^2 \left[ \rho \left( \epsilon + v^2
59  * \frac{W}{W + 1} \right) + p v^2 \right] .\f]
60  */
67
68  using argument_tags =
69  tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
78
79  static void apply(
82  gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> tilde_s,
83  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_b,
85  const Scalar<DataVector>& rest_mass_density,
86  const Scalar<DataVector>& specific_internal_energy,
88  const Scalar<DataVector>& pressure,
89  const tnsr::I<DataVector, 3, Frame::Inertial>& spatial_velocity,
90  const Scalar<DataVector>& lorentz_factor,
91  const tnsr::I<DataVector, 3, Frame::Inertial>& magnetic_field,
92  const Scalar<DataVector>& sqrt_det_spatial_metric,
93  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
94  const Scalar<DataVector>& divergence_cleaning_field) noexcept;
95 };
97 } // namespace grmhd
Implementations from the Guideline Support Library.
Definition: ConservativeFromPrimitive.hpp:10
The spatial velocity .
Definition: Tags.hpp:144
The fluid pressure .
Definition: Tags.hpp:123
The specific internal energy .
Definition: Tags.hpp:176
Definition: Tags.hpp:36
The densitized divergence-cleaning field .
Definition: Tags.hpp:70
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:43
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:1595
The magnetic field measured by an Eulerian observer, where is the normal to the spatial hypersurfac...
Definition: Tags.hpp:80
The divergence-cleaning field .
Definition: Tags.hpp:47
The densitized energy density .
Definition: Tags.hpp:50
Compute the conservative variables from primitive variables.
Definition: ConservativeFromPrimitive.hpp:61
The densitized momentum density .
Definition: Tags.hpp:57
The densitized magnetic field .
Definition: Tags.hpp:64
Definition: Tags.hpp:26
The Lorentz factor .
Definition: Tags.hpp:64
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:46
Wraps the template metaprogramming library used (brigand)
The specific enthalpy .
Definition: Tags.hpp:169
Items related to general relativistic magnetohydrodynamics (GRMHD)
Definition: Characteristics.hpp:34
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12