Characteristics.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <cstddef>
8 
11 #include "Domain/FaceNormal.hpp"
12 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
13 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
14 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp" // IWYU pragma: keep
15 #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp" // IWYU pragma: keep
16 #include "Utilities/Gsl.hpp"
17 #include "Utilities/TMPL.hpp"
18 
19 // IWYU pragma: no_include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
20 // IWYU pragma: no_include "PointwiseFunctions/Hydro/Tags.hpp"
21 
22 /// \cond
23 class DataVector;
24 namespace Tags {
25 template <typename Tag>
26 struct Normalized;
27 } // namespace Tags
28 /// \endcond
29 
30 // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState
31 // IWYU pragma: no_forward_declare EquationsOfSTate::IdealFluid
32 // IWYU pragma: no_forward_declare Tensor
33 
34 namespace grmhd {
35 namespace ValenciaDivClean {
36 
37 // @{
38 /*!
39  * \brief Compute the characteristic speeds for the Valencia formulation of
40  * GRMHD with divergence cleaning.
41  *
42  * Obtaining the exact form of the characteristic speeds involves the solution
43  * of a nontrivial quartic equation for the fast and slow modes. Here we make
44  * use of a common approximation in the literature (e.g. \cite Gammie2003)
45  * where the resulting characteristic speeds are analogous to those of the
46  * Valencia formulation of the 3-D relativistic Euler system
47  * (see RelativisticEuler::Valencia::characteristic_speeds),
48  *
49  * \f{align*}
50  * \lambda_2 &= \alpha \Lambda^- - \beta_n,\\
51  * \lambda_{3, 4, 5, 6, 7} &= \alpha v_n - \beta_n,\\
52  * \lambda_{8} &= \alpha \Lambda^+ - \beta_n,
53  * \f}
54  *
55  * with the substitution
56  *
57  * \f{align*}
58  * c_s^2 \longrightarrow c_s^2 + v_A^2(1 - c_s^2)
59  * \f}
60  *
61  * in the definition of \f$\Lambda^\pm\f$. Here \f$v_A\f$ is the Alfvén
62  * speed. In addition, two more speeds corresponding to the divergence cleaning
63  * mode and the longitudinal magnetic field are added,
64  *
65  * \f{align*}
66  * \lambda_1 = -\alpha - \beta_n,\\
67  * \lambda_9 = \alpha - \beta_n.
68  * \f}
69  *
70  * \note The ordering assumed here is such that, in the Newtonian limit,
71  * the exact expressions for \f$\lambda_{2, 8}\f$, \f$\lambda_{3, 7}\f$,
72  * and \f$\lambda_{4, 6}\f$ should reduce to the
73  * corresponding fast modes, Alfvén modes, and slow modes, respectively.
74  * See \cite Dedner2002 for a detailed description of the hyperbolic
75  * characterization of Newtonian MHD. In terms of the primitive variables:
76  *
77  * \f{align*}
78  * v^2 &= \gamma_{mn} v^m v^n \\
79  * c_s^2 &= \frac{1}{h} \left[ \left( \frac{\partial p}{\partial \rho}
80  * \right)_\epsilon +
81  * \frac{p}{\rho^2} \left(\frac{\partial p}{\partial \epsilon}
82  * \right)_\rho \right] \\
83  * v_A^2 &= \frac{b^2}{b^2 + \rho h} \\
84  * b^2 &= \frac{1}{W^2} \gamma_{mn} B^m B^n + \left( \gamma_{mn} B^m v^n
85  * \right)^2
86  * \f}
87  *
88  * where \f$\gamma_{mn}\f$ is the spatial metric, \f$\rho\f$ is the rest
89  * mass density, \f$W = 1/\sqrt{1-v_i v^i}\f$ is the Lorentz factor, \f$h = 1 +
90  * \epsilon + \frac{p}{\rho}\f$ is the specific enthalpy, \f$v^i\f$ is the
91  * spatial velocity, \f$\epsilon\f$ is the specific internal energy, \f$p\f$ is
92  * the pressure, and \f$B^i\f$ is the spatial magnetic field measured by an
93  * Eulerian observer.
94  */
95 template <size_t ThermodynamicDim>
97  const Scalar<DataVector>& rest_mass_density,
98  const Scalar<DataVector>& specific_internal_energy,
100  const tnsr::I<DataVector, 3, Frame::Inertial>& spatial_velocity,
101  const Scalar<DataVector>& lorentz_factor,
102  const tnsr::I<DataVector, 3, Frame::Inertial>& magnetic_field,
103  const Scalar<DataVector>& lapse, const tnsr::I<DataVector, 3>& shift,
104  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
105  const tnsr::i<DataVector, 3>& unit_normal,
107  equation_of_state) noexcept;
108 
109 template <size_t ThermodynamicDim>
112  const Scalar<DataVector>& rest_mass_density,
113  const Scalar<DataVector>& specific_internal_energy,
114  const Scalar<DataVector>& specific_enthalpy,
115  const tnsr::I<DataVector, 3, Frame::Inertial>& spatial_velocity,
116  const Scalar<DataVector>& lorentz_factor,
117  const tnsr::I<DataVector, 3, Frame::Inertial>& magnetic_field,
118  const Scalar<DataVector>& lapse, const tnsr::I<DataVector, 3>& shift,
119  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
120  const tnsr::i<DataVector, 3>& unit_normal,
122  equation_of_state) noexcept;
123 // @}
124 
125 namespace Tags {
126 /// \brief Compute the characteristic speeds for the Valencia formulation of
127 /// GRMHD with divergence cleaning.
128 ///
129 /// \details see grmhd::ValenciaDivClean::characteristic_speeds
130 template <typename EquationOfStateType>
133  using argument_tags =
134  tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
143 
144  using volume_tags =
145  tmpl::list<hydro::Tags::EquationOfState<EquationOfStateType>>;
146 
148 
149  static constexpr void function(
150  const gsl::not_null<return_type*> result,
151  const Scalar<DataVector>& rest_mass_density,
152  const Scalar<DataVector>& specific_internal_energy,
154  const tnsr::I<DataVector, 3, Frame::Inertial>& spatial_velocity,
155  const Scalar<DataVector>& lorentz_factor,
156  const tnsr::I<DataVector, 3, Frame::Inertial>& magnetic_field,
157  const Scalar<DataVector>& lapse, const tnsr::I<DataVector, 3>& shift,
158  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
159  const tnsr::i<DataVector, 3>& unit_normal,
161  true, EquationOfStateType::thermodynamic_dim>&
162  equation_of_state) noexcept {
163  characteristic_speeds<EquationOfStateType::thermodynamic_dim>(
164  result, rest_mass_density, specific_internal_energy, specific_enthalpy,
165  spatial_velocity, lorentz_factor, magnetic_field, lapse, shift,
166  spatial_metric, unit_normal, equation_of_state);
167  }
168 };
169 } // namespace Tags
170 
172  using argument_tags = tmpl::list<>;
173  static double apply() noexcept { return 1.0; }
174 };
175 
176 } // namespace ValenciaDivClean
177 } // namespace grmhd
The spatial velocity .
Definition: Tags.hpp:144
std::array< DataVector, 9 > characteristic_speeds(const Scalar< DataVector > &rest_mass_density, const Scalar< DataVector > &specific_internal_energy, const Scalar< DataVector > &specific_enthalpy, const tnsr::I< DataVector, 3, Frame::Inertial > &spatial_velocity, const Scalar< DataVector > &lorentz_factor, const tnsr::I< DataVector, 3, Frame::Inertial > &magnetic_field, const Scalar< DataVector > &lapse, const tnsr::I< DataVector, 3 > &shift, const tnsr::ii< DataVector, 3, Frame::Inertial > &spatial_metric, const tnsr::i< DataVector, 3 > &unit_normal, const EquationsOfState::EquationOfState< true, ThermodynamicDim > &equation_of_state) noexcept
Compute the characteristic speeds for the Valencia formulation of GRMHD with divergence cleaning...
The normalized (co)vector represented by Tag.
Definition: Magnitude.hpp:93
The specific internal energy .
Definition: Tags.hpp:176
Base class for equations of state depending on whether or not the system is relativistic, and the number of independent thermodynamic variables (ThermodynamicDim) needed to determine the pressure.
Definition: EquationOfState.hpp:63
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:155
Definition: Tags.hpp:46
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
Definition: Tags.hpp:26
The Lorentz factor .
Definition: Tags.hpp:64
Definition: Tags.hpp:41
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:98
Defines a list of useful type aliases for tensors.
Declares function unnormalized_face_normal.
Compute the characteristic speeds for the Valencia formulation of GRMHD with divergence cleaning...
Definition: Characteristics.hpp:131
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.
Definition: ComputeSpacetimeQuantities.cpp:82
Stores a collection of function values.
Definition: DataVector.hpp:46
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
The characteristic speeds.
Definition: Tags.hpp:32
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
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
The equation of state.
Definition: Tags.hpp:57