SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/ValenciaDivClean - PrimitiveFromConservative.hpp Hit Total Coverage
Commit: 664546099c4dbf27a1b708fac45e39c82dd743d2 Lines: 1 7 14.3 %
Date: 2024-04-19 16:28:01
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : 
       8             : #include "DataStructures/Tensor/TypeAliases.hpp"
       9             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/PrimitiveFromConservativeOptions.hpp"
      10             : #include "Evolution/Systems/GrMhd/ValenciaDivClean/TagsDeclarations.hpp"
      11             : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
      12             : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
      13             : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"
      14             : #include "Utilities/TMPL.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 EquationsOfState::EquationOfState
      26             : // IWYU pragma: no_forward_declare Tensor
      27             : 
      28             : namespace grmhd {
      29             : namespace ValenciaDivClean {
      30             : /*!
      31             :  * \brief Compute the primitive variables from the conservative variables
      32             :  *
      33             :  * For the Valencia formulation of the GRMHD system with divergence cleaning,
      34             :  * the conversion of the evolved conserved variables to the primitive variables
      35             :  * cannot be expressed in closed analytic form and requires a root find.
      36             :  *
      37             :  * [Siegel {\em et al}, The Astrophysical Journal 859:71(2018)]
      38             :  * (http://iopscience.iop.org/article/10.3847/1538-4357/aabcc5/meta)
      39             :  * compares several inversion methods.
      40             :  *
      41             :  * If `ErrorOnFailure` is `false` then the returned `bool` will be `false` if
      42             :  * recovery failed and `true` if it succeeded.
      43             :  *
      44             :  * If `EnforcePhysicality` is `false` then the hydrodynamic inversion will
      45             :  * return with an error if the input conservatives are unphysical, i.e., if no
      46             :  * solution exits. The exact behavior is governed by `ErrorOnFailure`.
      47             :  */
      48             : template <typename OrderedListOfPrimitiveRecoverySchemes,
      49             :           bool ErrorOnFailure = true>
      50           1 : struct PrimitiveFromConservative {
      51           0 :   using return_tags =
      52             :       tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
      53             :                  hydro::Tags::ElectronFraction<DataVector>,
      54             :                  hydro::Tags::SpecificInternalEnergy<DataVector>,
      55             :                  hydro::Tags::SpatialVelocity<DataVector, 3>,
      56             :                  hydro::Tags::MagneticField<DataVector, 3>,
      57             :                  hydro::Tags::DivergenceCleaningField<DataVector>,
      58             :                  hydro::Tags::LorentzFactor<DataVector>,
      59             :                  hydro::Tags::Pressure<DataVector>,
      60             :                  hydro::Tags::Temperature<DataVector>>;
      61             : 
      62           0 :   using argument_tags = tmpl::list<
      63             :       grmhd::ValenciaDivClean::Tags::TildeD,
      64             :       grmhd::ValenciaDivClean::Tags::TildeYe,
      65             :       grmhd::ValenciaDivClean::Tags::TildeTau,
      66             :       grmhd::ValenciaDivClean::Tags::TildeS<>,
      67             :       grmhd::ValenciaDivClean::Tags::TildeB<>,
      68             :       grmhd::ValenciaDivClean::Tags::TildePhi,
      69             :       gr::Tags::SpatialMetric<DataVector, 3>,
      70             :       gr::Tags::InverseSpatialMetric<DataVector, 3>,
      71             :       gr::Tags::SqrtDetSpatialMetric<DataVector>,
      72             :       hydro::Tags::GrmhdEquationOfState,
      73             :       grmhd::ValenciaDivClean::Tags::PrimitiveFromConservativeOptions>;
      74             : 
      75             :   template <bool EnforcePhysicality = true>
      76           0 :   static bool apply(
      77             :       gsl::not_null<Scalar<DataVector>*> rest_mass_density,
      78             :       gsl::not_null<Scalar<DataVector>*> electron_fraction,
      79             :       gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
      80             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
      81             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
      82             :       gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
      83             :       gsl::not_null<Scalar<DataVector>*> lorentz_factor,
      84             :       gsl::not_null<Scalar<DataVector>*> pressure,
      85             :       gsl::not_null<Scalar<DataVector>*> temperature,
      86             :       const Scalar<DataVector>& tilde_d, const Scalar<DataVector>& tilde_ye,
      87             :       const Scalar<DataVector>& tilde_tau,
      88             :       const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
      89             :       const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b,
      90             :       const Scalar<DataVector>& tilde_phi,
      91             :       const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
      92             :       const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric,
      93             :       const Scalar<DataVector>& sqrt_det_spatial_metric,
      94             :       const EquationsOfState::EquationOfState<true, 3>& equation_of_state,
      95             :       const grmhd::ValenciaDivClean::PrimitiveFromConservativeOptions&
      96             :           primitive_from_conservative_options);
      97             : 
      98             :  private:
      99             :   template <bool EnforcePhysicality, typename EosType>
     100           0 :   static bool impl(
     101             :       gsl::not_null<Scalar<DataVector>*> rest_mass_density,
     102             :       gsl::not_null<Scalar<DataVector>*> electron_fraction,
     103             :       gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
     104             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> spatial_velocity,
     105             :       gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> magnetic_field,
     106             :       gsl::not_null<Scalar<DataVector>*> divergence_cleaning_field,
     107             :       gsl::not_null<Scalar<DataVector>*> lorentz_factor,
     108             :       gsl::not_null<Scalar<DataVector>*> pressure,
     109             :       gsl::not_null<Scalar<DataVector>*> temperature,
     110             :       const Scalar<DataVector>& tilde_d, const Scalar<DataVector>& tilde_ye,
     111             :       const Scalar<DataVector>& tilde_tau,
     112             :       const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
     113             :       const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b,
     114             :       const Scalar<DataVector>& tilde_phi,
     115             :       const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
     116             :       const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric,
     117             :       const Scalar<DataVector>& sqrt_det_spatial_metric,
     118             :       const EosType& equation_of_state,
     119             :       const grmhd::ValenciaDivClean::PrimitiveFromConservativeOptions&
     120             :           primitive_from_conservative_options);
     121             : 
     122             :   // Use Kastaun hydro inversion if B is dynamically unimportant
     123           0 :   static constexpr bool use_hydro_optimization = true;
     124             : };
     125             : }  // namespace ValenciaDivClean
     126             : }  // namespace grmhd

Generated by: LCOV version 1.14