SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/Hydro/EquationsOfState - IdealFluid.hpp Hit Total Coverage
Commit: 37c384043430860f87787999aa7399d01bb3d213 Lines: 8 30 26.7 %
Date: 2024-04-20 02:24:02
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 <boost/preprocessor/arithmetic/dec.hpp>
       7             : #include <boost/preprocessor/arithmetic/inc.hpp>
       8             : #include <boost/preprocessor/control/expr_iif.hpp>
       9             : #include <boost/preprocessor/list/adt.hpp>
      10             : #include <boost/preprocessor/repetition/for.hpp>
      11             : #include <boost/preprocessor/repetition/repeat.hpp>
      12             : #include <boost/preprocessor/tuple/to_list.hpp>
      13             : #include <limits>
      14             : #include <pup.h>
      15             : 
      16             : #include "DataStructures/Tensor/TypeAliases.hpp"
      17             : #include "Options/String.hpp"
      18             : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"  // IWYU pragma: keep
      19             : #include "PointwiseFunctions/Hydro/Units.hpp"
      20             : #include "Utilities/Serialization/CharmPupable.hpp"
      21             : #include "Utilities/TMPL.hpp"
      22             : 
      23             : /// \cond
      24             : class DataVector;
      25             : /// \endcond
      26             : 
      27             : namespace EquationsOfState {
      28             : /*!
      29             :  * \ingroup EquationsOfStateGroup
      30             :  * \brief Equation of state for an ideal fluid
      31             :  *
      32             :  * An ideal fluid equation of state:
      33             :  *
      34             :  * \f[
      35             :  * p = \rho \epsilon(\gamma-1)
      36             :  * \f]
      37             :  *
      38             :  * where \f$\rho\f$ is the rest mass density, \f$\epsilon\f$ is the specific
      39             :  * internal energy, and \f$\gamma\f$ is the adiabatic index.
      40             :  *
      41             :  * The temperature \f$T\f$ is defined as
      42             :  *
      43             :  * \f[
      44             :  * T = (\gamma - 1) \epsilon
      45             :  * \f]
      46             :  */
      47             : template <bool IsRelativistic>
      48           1 : class IdealFluid : public EquationOfState<IsRelativistic, 2> {
      49             :  public:
      50           0 :   static constexpr size_t thermodynamic_dim = 2;
      51           0 :   static constexpr bool is_relativistic = IsRelativistic;
      52             : 
      53           0 :   struct AdiabaticIndex {
      54           0 :     using type = double;
      55           0 :     static constexpr Options::String help = {"Adiabatic index gamma"};
      56             :   };
      57             : 
      58           0 :   static constexpr Options::String help = {
      59             :       "An ideal fluid equation of state.\n"
      60             :       "The pressure is related to the rest mass density by p = rho * epsilon * "
      61             :       "(gamma - 1), where p is the pressure, rho is the rest mass density, "
      62             :       "epsilon is the specific internal energy, and gamma is the adiabatic "
      63             :       "index.\n"
      64             :       "The temperature T is defined as T=epsilon."};
      65             : 
      66           0 :   using options = tmpl::list<AdiabaticIndex>;
      67             : 
      68           0 :   IdealFluid() = default;
      69           0 :   IdealFluid(const IdealFluid&) = default;
      70           0 :   IdealFluid& operator=(const IdealFluid&) = default;
      71           0 :   IdealFluid(IdealFluid&&) = default;
      72           0 :   IdealFluid& operator=(IdealFluid&&) = default;
      73           0 :   ~IdealFluid() override = default;
      74             : 
      75           0 :   explicit IdealFluid(double adiabatic_index);
      76             : 
      77             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(IdealFluid, 2)
      78             : 
      79           0 :   std::unique_ptr<EquationOfState<IsRelativistic, 2>> get_clone()
      80             :       const override;
      81             : 
      82           0 :   std::unique_ptr<EquationOfState<IsRelativistic, 3>> promote_to_3d_eos()
      83             :       const override;
      84             : 
      85             :   /// \brief Returns `true` if the EOS is barotropic
      86           1 :   bool is_barotropic() const override { return false; }
      87             : 
      88           0 :   bool operator==(const IdealFluid<IsRelativistic>& rhs) const;
      89             : 
      90           0 :   bool operator!=(const IdealFluid<IsRelativistic>& rhs) const;
      91             : 
      92           0 :   bool is_equal(const EquationOfState<IsRelativistic, 2>& rhs) const override;
      93             : 
      94           0 :   WRAPPED_PUPable_decl_base_template(  // NOLINT
      95             :       SINGLE_ARG(EquationOfState<IsRelativistic, 2>), IdealFluid);
      96             : 
      97             :   /// The lower bound of the rest mass density that is valid for this EOS
      98           1 :   double rest_mass_density_lower_bound() const override { return 0.0; }
      99             : 
     100             :   /// The upper bound of the rest mass density that is valid for this EOS
     101           1 :   double rest_mass_density_upper_bound() const override {
     102             :     return std::numeric_limits<double>::max();
     103             :   }
     104             : 
     105             :   /// The lower bound of the specific internal energy that is valid for this EOS
     106             :   /// at the given rest mass density \f$\rho\f$
     107           1 :   double specific_internal_energy_lower_bound(
     108             :       const double /* rest_mass_density */) const override {
     109             :     return 0.0;
     110             :   }
     111             : 
     112             :   /// The upper bound of the specific internal energy that is valid for this EOS
     113             :   /// at the given rest mass density \f$\rho\f$
     114           1 :   double specific_internal_energy_upper_bound(
     115             :       double rest_mass_density) const override;
     116             : 
     117             :   /// The lower bound of the specific enthalpy that is valid for this EOS
     118           1 :   double specific_enthalpy_lower_bound() const override {
     119             :     return IsRelativistic ? 1.0 : 0.0;
     120             :   }
     121             : 
     122             :   /// The vacuum baryon mass for this EoS
     123           1 :   double baryon_mass() const override {
     124             :     return hydro::units::geometric::default_baryon_mass;
     125             :   }
     126             : 
     127             :  private:
     128             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(2)
     129             : 
     130           0 :   double adiabatic_index_ = std::numeric_limits<double>::signaling_NaN();
     131             : };
     132             : 
     133             : /// \cond
     134             : template <bool IsRelativistic>
     135             : PUP::able::PUP_ID EquationsOfState::IdealFluid<IsRelativistic>::my_PUP_ID = 0;
     136             : /// \endcond
     137             : }  // namespace EquationsOfState

Generated by: LCOV version 1.14