Quinoa all test code coverage report
Current view: top level - PDE/EoS - EOS.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 14 20 70.0 %
Date: 2025-04-30 15:23:38 Functions: 25 221 11.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 166 1034 16.1 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/EoS/EOS.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Polymorphic variant-style implementation for equations of state,
       9                 :            :     where children implement specific EOS functions.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef EOS_h
      13                 :            : #define EOS_h
      14                 :            : 
      15                 :            : #include <variant>
      16                 :            : 
      17                 :            : #include "PUPUtil.hpp"
      18                 :            : #include "Inciter/Options/Material.hpp"
      19                 :            : #include "EoS/StiffenedGas.hpp"
      20                 :            : #include "EoS/JWL.hpp"
      21                 :            : #include "EoS/SmallShearSolid.hpp"
      22                 :            : #include "EoS/WilkinsAluminum.hpp"
      23                 :            : #include "EoS/GodunovRomenski.hpp"
      24                 :            : #include "EoS/ThermallyPerfectGas.hpp"
      25                 :            : 
      26                 :            : namespace inciter {
      27                 :            : 
      28                 :            : //! Equation types
      29                 :            : enum class EqType : uint8_t { compflow
      30                 :            :                             , multimat
      31                 :            :                             , multispecies
      32                 :            :                             };
      33                 :            : 
      34                 :            : //! Base class for generic forwarding interface to eos types
      35         [ -  - ]:        786 : class EOS {
      36                 :            : 
      37                 :            :   private:
      38                 :            :     //! Variant type listing all eos types modeling the same concept
      39                 :            :     std::variant< StiffenedGas
      40                 :            :                 , JWL
      41                 :            :                 , SmallShearSolid
      42                 :            :                 , WilkinsAluminum
      43                 :            :                 , GodunovRomenski
      44                 :            :                 , ThermallyPerfectGas
      45                 :            :                 > m_material;
      46                 :            : 
      47                 :            :   public:
      48                 :            :     //! Empty constructor for Charm++
      49                 :            :     explicit EOS() {}
      50                 :            : 
      51                 :            :     //! Constructor
      52                 :            :     explicit EOS( ctr::MaterialType mattype, EqType eq, std::size_t k );
      53                 :            : 
      54                 :            :     //! Entry method tags for specific EOS classes to use with compute()
      55                 :            :     struct density {};
      56                 :            :     struct pressure {};
      57                 :            :     struct pressure_coldcompr {};
      58                 :            :     struct soundspeed {};
      59                 :            :     struct shearspeed {};
      60                 :            :     struct totalenergy {};
      61                 :            :     struct temperature {};
      62                 :            :     struct min_eff_pressure {};
      63                 :            :     struct refDensity {};
      64                 :            :     struct refPressure {};
      65                 :            :     struct rho0 {};
      66                 :            :     struct gas_constant {};
      67                 :            :     struct internalenergy {};
      68                 :            :     struct cv {};
      69                 :            :     //! Call EOS function
      70                 :            :     //! \tparam Fn Function tag identifying the function to call
      71                 :            :     //! \tparam Args Types of arguments to pass to function
      72                 :            :     //! \param[in] args Arguments to member function to be called
      73                 :            :     //! \details This function issues a call to a member function of the
      74                 :            :     //!   EOS vector and is thus equivalent to mat_blk[imat].Fn(...).
      75                 :            :     template< typename Fn, typename... Args >
      76                 :            :     tk::real compute( Args&&... args ) const {
      77 [ +  + ][ +  + ]:  626638826 :       return std::visit( [&]( const auto& m )-> tk::real {
         [ +  + ][ +  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ +  - ][ +  - ]
         [ -  - ][ +  - ]
         [ +  + ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ -  + ][ +  - ]
         [ -  - ][ -  - ]
         [ -  + ][ +  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  + ]
         [ +  - ][ -  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  + ][ +  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  + ][ -  - ]
         [ +  - ][ +  + ]
         [ +  - ][ +  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  + ][ -  - ]
         [ +  - ][ +  + ]
         [ +  - ][ +  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  + ]
      78                 :            :           if constexpr( std::is_same_v< Fn, density > )
      79                 :    2147340 :             return m.density( std::forward< Args >( args )... );
      80                 :            : 
      81                 :            :           else if constexpr( std::is_same_v< Fn, pressure > )
      82                 :  150798511 :             return m.pressure( std::forward< Args >( args )... );
      83                 :            : 
      84                 :            :           else if constexpr( std::is_same_v< Fn, pressure_coldcompr > )
      85                 :            :             return m.pressure_coldcompr( std::forward< Args >( args )... );
      86                 :            : 
      87                 :            :           else if constexpr( std::is_same_v< Fn, soundspeed > )
      88                 :  149977855 :             return m.soundspeed( std::forward< Args >( args )... );
      89                 :            : 
      90                 :            :           else if constexpr( std::is_same_v< Fn, shearspeed > )
      91                 :          0 :             return m.shearspeed( std::forward< Args >( args )... );
      92                 :            : 
      93                 :            :           else if constexpr( std::is_same_v< Fn, totalenergy > )
      94                 :   13809909 :             return m.totalenergy( std::forward< Args >( args )... );
      95                 :            : 
      96                 :            :           else if constexpr( std::is_same_v< Fn, temperature > )
      97                 :    2365840 :             return m.temperature( std::forward< Args >( args )... );
      98                 :            : 
      99                 :            :           else if constexpr( std::is_same_v< Fn, min_eff_pressure > )
     100                 :   92086930 :             return m.min_eff_pressure( std::forward< Args >( args )... );
     101                 :            : 
     102                 :            :           else if constexpr( std::is_same_v< Fn, refDensity > )
     103                 :            :             return m.refDensity( std::forward< Args >( args )... );
     104                 :            : 
     105                 :            :           else if constexpr( std::is_same_v< Fn, refPressure > )
     106                 :            :             return m.refPressure( std::forward< Args >( args )... );
     107                 :            : 
     108                 :            :           else if constexpr( std::is_same_v< Fn, rho0 > )
     109                 :          0 :             return m.rho0( std::forward< Args >( args )... );
     110                 :            : 
     111                 :            :           else if constexpr( std::is_same_v< Fn, gas_constant > )
     112                 :    5620716 :             return m.gas_constant( std::forward< Args >( args )... );
     113                 :            : 
     114                 :            :           else if constexpr( std::is_same_v< Fn, internalenergy > )
     115                 :   15240329 :             return m.internalenergy( std::forward< Args >( args )... );
     116                 :            : 
     117                 :            :           else if constexpr( std::is_same_v< Fn, cv > )
     118                 :   20133413 :             return m.cv( std::forward< Args >( args )... );
     119 [ +  - ][ +  - ]:  309686711 :         }, m_material );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ +  - ][ -  - ]
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ -  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     120                 :            :     }
     121                 :            : 
     122                 :            :     //! Entry method tags for specific EOS classes to use with computeTensor()
     123                 :            :     struct CauchyStress {};
     124                 :            :     //! Call EOS function returning a tensor
     125                 :            :     //! \tparam Fn Function tag identifying the function to call
     126                 :            :     //! \tparam Args Types of arguments to pass to function
     127                 :            :     //! \param[in] args Arguments to member function to be called
     128                 :            :     //! \details This function issues a call to a member function of the
     129                 :            :     //!   EOS vector and is thus equivalent to mat_blk[imat].Fn(...).
     130                 :            :     template< typename Fn, typename... Args >
     131                 :            :     std::array< std::array< tk::real, 3 >, 3 > computeTensor( Args&&... args )
     132                 :            :     const {
     133                 :          0 :       return std::visit( [&]( const auto& m )->
     134                 :            :         std::array< std::array< tk::real, 3 >, 3 > {
     135                 :            :           if constexpr( std::is_same_v< Fn, CauchyStress > )
     136                 :          0 :             return m.CauchyStress( std::forward< Args >( args )... );
     137                 :            : 
     138 [ -  - ][ -  - ]:          0 :         }, m_material );
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
     139                 :            :     }
     140                 :            : 
     141                 :            :     //! Entry method tags for specific EOS classes to use with set()
     142                 :            :     struct setRho0 {};
     143                 :            :     //! Call EOS function
     144                 :            :     //! \tparam Fn Function tag identifying the function to call
     145                 :            :     //! \tparam Args Types of arguments to pass to function
     146                 :            :     //! \param[in] args Arguments to member function to be called
     147                 :            :     //! \details This function issues a call to a member function of the
     148                 :            :     //!   EOS vector and is thus equivalent to mat_blk[imat].Fn(...).
     149                 :            :     template< typename Fn, typename... Args >
     150                 :            :     void set( Args&&... args ) {
     151                 :        539 :       std::visit( [&]( auto& m )-> void {
     152                 :            :           if constexpr( std::is_same_v< Fn, setRho0 > )
     153                 :          0 :             m.setRho0( std::forward< Args >( args )... );
     154         [ +  - ]:        539 :         }, m_material );
     155                 :            :     }
     156                 :            : 
     157                 :            :     /** @name Charm++ pack/unpack serializer member functions */
     158                 :            :     ///@{
     159                 :            :     //! \brief Pack/Unpack serialize member function
     160                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     161                 :            :     void pup( PUP::er &p ) {
     162                 :            :       p | m_material;
     163                 :            :     }
     164                 :            :     //! \brief Pack/Unpack serialize operator|
     165                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     166                 :            :     //! \param[in,out] s EOS object reference
     167                 :            :     friend void operator|( PUP::er& p, EOS& s ) { s.pup(p); }
     168                 :            :     //@}
     169                 :            : };
     170                 :            : 
     171                 :            : } // inciter::
     172                 :            : 
     173                 :            : #endif // EOS_h

Generated by: LCOV version 1.14