SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/Hydro/EquationsOfState - Barotropic2D.hpp Hit Total Coverage
Commit: 8f6d7ed2ad592dd78354983fd8e5ec2be7abb468 Lines: 15 39 38.5 %
Date: 2024-05-02 15:57:06
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 <cstddef>
      14             : #include <limits>
      15             : #include <memory>
      16             : #include <pup.h>
      17             : 
      18             : #include "DataStructures/Tensor/TypeAliases.hpp"
      19             : #include "Options/String.hpp"
      20             : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
      21             : #include "PointwiseFunctions/Hydro/Units.hpp"
      22             : #include "Utilities/Serialization/CharmPupable.hpp"
      23             : #include "Utilities/TMPL.hpp"
      24             : 
      25           1 : namespace EquationsOfState {
      26             : /*!
      27             :  * \ingroup EquationsOfStateGroup
      28             :  * \brief A 2D equation of state representing a barotropic fluid.
      29             :  *
      30             :  *
      31             :  * The equation of state takes the form
      32             :  *
      33             :  * \f[
      34             :  * p = p (\rho , T, Y_e) = p(\rho, 0, Y_e= Y_{e, \beta})
      35             :  * \f]
      36             :  *
      37             :  * where \f$\rho\f$ is the rest mass density, \f$T\f$  the
      38             :  * temperature , and \f$Y_e\f$ the electron fraction. The temperature and
      39             :  * electron fraction are not used, so evaluating this EoS at any arbtirary
      40             :  * temeperature or electron fraction is equivalent to evaluating it at
      41             :  * zero temperature and in beta equalibrium.
      42             :  */
      43             : template <typename ColdEos>
      44           1 : class Barotropic2D : public EquationOfState<ColdEos::is_relativistic, 2> {
      45             :  public:
      46           0 :   static constexpr size_t thermodynamic_dim = 2;
      47           0 :   static constexpr bool is_relativistic = ColdEos::is_relativistic;
      48             : 
      49           0 :   static std::string name() {
      50             :     return "Barotropic2D(" + pretty_type::name<ColdEos>() + ")";
      51             :   }
      52           0 :   static constexpr Options::String help = {
      53             :       "A 2D EoS which is independent of electron fraction and temperature. "
      54             :       "Contains an underlying 1D EoS which is dependent only "
      55             :       "on rest mass density."};
      56           0 :   struct UnderlyingEos {
      57           0 :     using type = ColdEos;
      58           0 :     static std::string name() { return pretty_type::short_name<ColdEos>(); }
      59           0 :     static constexpr Options::String help{
      60             :         "The underlying EoS which is being represented as a 2D EoS.  Must be a "
      61             :         "1D EoS"};
      62             :   };
      63             : 
      64           0 :   using options = tmpl::list<UnderlyingEos>;
      65             : 
      66           0 :   Barotropic2D() = default;
      67           0 :   Barotropic2D(const Barotropic2D&) = default;
      68           0 :   Barotropic2D& operator=(const Barotropic2D&) = default;
      69           0 :   Barotropic2D(Barotropic2D&&) = default;
      70           0 :   Barotropic2D& operator=(Barotropic2D&&) = default;
      71           0 :   ~Barotropic2D() override = default;
      72             : 
      73           0 :   explicit Barotropic2D(const ColdEos& underlying_eos)
      74             :       : underlying_eos_(underlying_eos){};
      75             : 
      76             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(Barotropic2D, 2)
      77             : 
      78           0 :   std::unique_ptr<EquationOfState<ColdEos::is_relativistic, 2>> get_clone()
      79             :       const override;
      80             : 
      81             :   std::unique_ptr<EquationOfState<ColdEos::is_relativistic, 3>>
      82           0 :   promote_to_3d_eos() const override;
      83             : 
      84           0 :   bool is_equal(
      85             :       const EquationOfState<ColdEos::is_relativistic, 2>& rhs) const override;
      86             : 
      87             :   /// \brief Returns `true` if the EOS is barotropic
      88           1 :   bool is_barotropic() const override { return true; }
      89             : 
      90           0 :   bool operator==(const Barotropic2D<ColdEos>& rhs) const;
      91             : 
      92           0 :   bool operator!=(const Barotropic2D<ColdEos>& rhs) const;
      93             :   /// @{
      94             :   /*!
      95             :    * Computes the electron fraction in beta-equilibrium \f$Y_e^{\rm eq}\f$ from
      96             :    * the rest mass density \f$\rho\f$ and the temperature \f$T\f$.
      97             :    */
      98           1 :   Scalar<double> equilibrium_electron_fraction_from_density_temperature(
      99             :       const Scalar<double>& rest_mass_density,
     100             :       const Scalar<double>& temperature) const override {
     101             :     return underlying_eos_
     102             :         .equilibrium_electron_fraction_from_density_temperature(
     103             :             rest_mass_density, temperature);
     104             :   }
     105             : 
     106           1 :   Scalar<DataVector> equilibrium_electron_fraction_from_density_temperature(
     107             :       const Scalar<DataVector>& rest_mass_density,
     108             :       const Scalar<DataVector>& temperature) const override {
     109             :     return underlying_eos_
     110             :         .equilibrium_electron_fraction_from_density_temperature(
     111             :             rest_mass_density, temperature);
     112             :   }
     113             :   /// @}
     114             : 
     115           0 :   WRAPPED_PUPable_decl_base_template(  // NOLINT
     116             :       SINGLE_ARG(EquationOfState<ColdEos::is_relativistic, 2>), Barotropic2D);
     117             : 
     118             :   /// The lower bound of the electron fraction that is valid for this EOS
     119           1 :   double electron_fraction_lower_bound() const override { return 0.0; }
     120             : 
     121             :   /// The upper bound of the electron fraction that is valid for this EOS
     122           1 :   double electron_fraction_upper_bound() const override { return 1.0; }
     123             : 
     124             :   /// The lower bound of the rest mass density that is valid for this EOS
     125           1 :   double rest_mass_density_lower_bound() const override {
     126             :     return underlying_eos_.rest_mass_density_lower_bound();
     127             :   }
     128             : 
     129             :   /// The upper bound of the rest mass density that is valid for this EOS
     130           1 :   double rest_mass_density_upper_bound() const override {
     131             :     return underlying_eos_.rest_mass_density_upper_bound();
     132             :   }
     133             : 
     134             :   /// The lower bound of the temperature that is valid for this EOS
     135           1 :   double temperature_lower_bound() const override { return 0.0; }
     136             : 
     137             :   /// The upper bound of the temperature that is valid for this EOS
     138           1 :   double temperature_upper_bound() const override {
     139             :     return std::numeric_limits<double>::max();
     140             :   }
     141             : 
     142             :   /// The lower bound of the specific internal energy that is valid for this EOS
     143             :   /// at the given rest mass density \f$\rho\f$ and electron fraction \f$Y_e\f$
     144           1 :   double specific_internal_energy_lower_bound(
     145             :       const double rest_mass_density) const override {
     146             :     return underlying_eos_.specific_internal_energy_lower_bound(
     147             :         rest_mass_density);
     148             :   }
     149             : 
     150             :   /// The upper bound of the specific internal energy that is valid for this EOS
     151             :   /// at the given rest mass density \f$\rho\f$
     152           1 :   double specific_internal_energy_upper_bound(
     153             :       const double rest_mass_density) const override {
     154             :     return underlying_eos_.specific_internal_energy_upper_bound(
     155             :         rest_mass_density);
     156             :   }
     157             : 
     158             :   /// The lower bound of the specific enthalpy that is valid for this EOS
     159           1 :   double specific_enthalpy_lower_bound() const override {
     160             :     return underlying_eos_.specific_enthalpy_lower_bound();
     161             :   }
     162             : 
     163             :   /// The baryon mass for this EoS
     164           1 :   double baryon_mass() const override { return underlying_eos_.baryon_mass(); }
     165             : 
     166             :  private:
     167             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(2)
     168           0 :   ColdEos underlying_eos_;
     169             : };
     170             : /// \cond
     171             : template <typename ColdEos>
     172             : // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
     173             : PUP::able::PUP_ID EquationsOfState::Barotropic2D<ColdEos>::my_PUP_ID = 0;
     174             : /// \endcond
     175             : }  // namespace EquationsOfState

Generated by: LCOV version 1.14