NewmanHamlin.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <boost/optional.hpp>
7 #include <cstddef>
8 #include <string>
9 
10 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
11 
12 // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState
13 
14 namespace grmhd {
15 namespace ValenciaDivClean {
16 namespace PrimitiveRecoverySchemes {
17 
18 /// \cond
20 /// \endcond
21 
22 /*!
23  * \brief Compute the primitive variables from the conservative variables using
24  * the scheme of [Newman and Hamlin, SIAM J. Sci. Comput., 36(4)
25  * B661-B683 (2014)](https://epubs.siam.org/doi/10.1137/140956749).
26  *
27  * In the Newman and Hamlin paper, `total_energy_density` is \f$e\f$,
28  * `momentum_density_squared` is\f${\cal M}^2\f$,
29  * `momentum_density_dot_magnetic_field` is \f${\cal T}\f$,
30  * `magnetic_field_squared` is \f${\cal B}^2\f$, and
31  * `rest_mass_density_times_lorentz_factor` is \f${\tilde \rho}\f$.
32  * Furthermore, the returned `PrimitiveRecoveryData.rho_h_w_squared` is \f${\cal
33  * L}\f$.
34  *
35  * In terms of the conservative variables (in our notation):
36  * \f{align}
37  * e = & \frac{{\tilde D} + {\tilde \tau}}{\sqrt{\gamma}} \\
38  * {\cal M}^2 = & \frac{\gamma^{mn} {\tilde S}_m {\tilde S}_n}{\gamma} \\
39  * {\cal T} = & \frac{{\tilde B}^m {\tilde S}_m}{\gamma} \\
40  * {\cal B}^2 = & \frac{\gamma_{mn} {\tilde B}^m {\tilde B}^n}{\gamma} \\
41  * {\tilde \rho} = & \frac{\tilde D}{\sqrt{\gamma}}
42  * \f}
43  *
44  * where the conserved variables \f${\tilde D}\f$, \f${\tilde S}_i\f$,
45  * \f${\tilde \tau}\f$, and \f${\tilde B}^i\f$ are a generalized mass-energy
46  * density, momentum density, specific internal energy density, and magnetic
47  * field, and \f$\gamma\f$ and \f$\gamma^{mn}\f$ are the determinant and inverse
48  * of the spatial metric \f$\gamma_{mn}\f$.
49  */
50 class NewmanHamlin {
51  public:
52  template <size_t ThermodynamicDim>
53  static boost::optional<PrimitiveRecoveryData> apply(
54  double initial_guess_for_pressure, double total_energy_density,
55  double momentum_density_squared,
56  double momentum_density_dot_magnetic_field, double magnetic_field_squared,
57  double rest_mass_density_times_lorentz_factor,
59  equation_of_state) noexcept;
60 
61  static const std::string name() noexcept { return "Newman Hamlin"; }
62 
63  private:
64  static constexpr size_t max_iterations_ = 50;
65  static constexpr double relative_tolerance_ = 1.e-10;
66 };
67 } // namespace PrimitiveRecoverySchemes
68 } // namespace ValenciaDivClean
69 } // namespace grmhd
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
Compute the primitive variables from the conservative variables using the scheme of Newman and Hamlin...
Definition: NewmanHamlin.hpp:50
Items related to general relativistic magnetohydrodynamics (GRMHD)
Definition: Characteristics.hpp:34
Data determined by PrimitiveRecoverySchemes at a single grid point.
Definition: PrimitiveRecoveryData.hpp:19