Quinoa all test code coverage report
Current view: top level - PDE/EoS - ThermallyPerfectGas.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 13 19 68.4 %
Date: 2025-02-13 15:54:38 Functions: 1 4 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 26 46.2 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/EoS/ThermallyPerfectGas.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     Thermally perfect gas equation of state
       9                 :            :   \details   This file declares functions for the thermally perfect gas equation
      10                 :            :              of state for the compressible flow equations.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef ThermallyPerfectGas_h
      14                 :            : #define ThermallyPerfectGas_h
      15                 :            : 
      16                 :            : #include "Data.hpp"
      17                 :            : 
      18                 :            : namespace inciter {
      19                 :            : 
      20                 :            : class ThermallyPerfectGas {
      21                 :            : 
      22                 :            :   private:
      23                 :            :     tk::real m_gamma;
      24                 :            :     tk::real m_R;
      25                 :            :     std::vector< std::vector< tk::real > > m_cp_coeff{3, std::vector< tk::real >(8)};
      26                 :            :     std::vector< tk::real > m_t_range{std::vector< tk::real >(4)};
      27                 :            :     tk::real m_dH_ref;
      28                 :            : 
      29                 :   11614657 :     std::size_t get_t_range(tk::real temp) const
      30                 :            :     // *************************************************************************
      31                 :            :     //! Check what temperature range, if any, the given temperature is in
      32                 :            :     //! \param[in] temp Given temperature to be checked for range
      33                 :            :     //! \return Index of temperature range the given temperature is in
      34                 :            :     // *************************************************************************
      35                 :            :     {
      36                 :   11614657 :       tk::real fdg = 0.1; // Fudge factor to accomodate numerical overshoot
      37 [ +  - ][ -  + ]:   11614657 :       if (temp < m_t_range[0] * (1 - fdg) || temp > m_t_range.back() * (1 + fdg)) {
                 [ -  + ]
      38 [ -  - ][ -  - ]:          0 :         Throw("ThermallyPerfectGas totalenergy temperature outside t_range bounds: "
         [ -  - ][ -  - ]
      39                 :            :         + std::to_string(temp));
      40                 :            :       }
      41                 :            : 
      42                 :   11614657 :       std::size_t t_rng_idx(0);
      43         [ +  - ]:   17790610 :       for (std::size_t k = 0; k < m_t_range.size() - 1; k++) {
      44                 :            :         // Apply fudge factor to max/min bounds
      45                 :   17790610 :         tk::real fdgl = 1., fdgu = 1.;
      46         [ +  + ]:   17790610 :         if (k == 0) {
      47                 :   11614657 :             fdgl = 1 - fdg;
      48         [ -  + ]:    6175953 :         } else if (k == m_t_range.size() - 2) {
      49                 :          0 :             fdgu = 1 + fdg;
      50                 :            :         }
      51 [ +  - ][ +  + ]:   17790610 :         if (temp >= m_t_range[k] * fdgl && temp < m_t_range[k+1] * fdgu) {
                 [ +  + ]
      52                 :   11614657 :           t_rng_idx = k;
      53                 :   11614657 :           break;
      54                 :            :         }
      55                 :            :       }
      56                 :   11614657 :       return t_rng_idx;
      57                 :            :     }
      58                 :            : 
      59                 :            : 
      60                 :            :   public:
      61                 :            :     //! Default constructor
      62                 :            :     ThermallyPerfectGas() = default;
      63                 :            : 
      64                 :            :     //! Constructor
      65                 :            :     ThermallyPerfectGas(
      66                 :            :       tk::real gamma,
      67                 :            :       tk::real R,
      68                 :            :       std::vector< std::vector< tk::real > > cp_coeff,
      69                 :            :       std::vector< tk::real > t_range,
      70                 :            :       tk::real dH_ref);
      71                 :            : 
      72                 :            :     //! Set rho0 EOS parameter. No-op.
      73                 :          0 :     void setRho0(tk::real) {}
      74                 :            : 
      75                 :            :     //! Calculate density from the material pressure and temperature
      76                 :            :     tk::real density( tk::real pr,
      77                 :            :                       tk::real temp ) const;
      78                 :            : 
      79                 :            :     //! Calculate pressure from the material density, momentum and total energy
      80                 :            :     tk::real pressure( tk::real rho,
      81                 :            :                        tk::real u,
      82                 :            :                        tk::real v,
      83                 :            :                        tk::real w,
      84                 :            :                        tk::real rhoE,
      85                 :            :                        tk::real alpha=1.0,
      86                 :            :                        std::size_t imat=0,
      87                 :            :       const std::array< std::array< tk::real, 3 >, 3 >& defgrad={{}}) const;
      88                 :            : 
      89                 :            :     //! \brief Calculate the Cauchy stress tensor from the material density,
      90                 :            :     //!   momentum, and total energy
      91                 :            :     std::array< std::array< tk::real, 3 >, 3 >
      92                 :            :     CauchyStress(
      93                 :            :       tk::real,
      94                 :            :       tk::real,
      95                 :            :       tk::real,
      96                 :            :       tk::real,
      97                 :            :       tk::real,
      98                 :            :       tk::real,
      99                 :            :       std::size_t,
     100                 :            :       const std::array< std::array< tk::real, 3 >, 3 >& adefgrad={{}} ) const;
     101                 :            : 
     102                 :            :     //! Calculate speed of sound from the material density and material pressure
     103                 :            :     tk::real soundspeed( tk::real rho,
     104                 :            :                          tk::real pr,
     105                 :            :                          tk::real alpha=1.0,
     106                 :            :                          std::size_t imat=0,
     107                 :            :       const std::array< std::array< tk::real, 3 >, 3 >& adefgrad={{}},
     108                 :            :       const std::array< tk::real, 3 >& asigman={{}} ) const;
     109                 :            : 
     110                 :            :     //! Calculate speed of shear waves
     111                 :            :     tk::real shearspeed(
     112                 :            :       tk::real,
     113                 :            :       tk::real,
     114                 :            :       std::size_t ) const { return 0.0; }
     115                 :            : 
     116                 :            :     //! \brief Calculate material specific total energy from the material
     117                 :            :     //!   density, momentum and material pressure
     118                 :            :     tk::real totalenergy( tk::real rho,
     119                 :            :                           tk::real u,
     120                 :            :                           tk::real v,
     121                 :            :                           tk::real w,
     122                 :            :                           tk::real pr,
     123                 :            :       const std::array< std::array< tk::real, 3 >, 3 >& defgrad={{}} ) const;
     124                 :            : 
     125                 :            :     //! \brief Calculate material temperature from the material density, and
     126                 :            :     //!   material specific total energy
     127                 :            :     tk::real temperature( tk::real rho,
     128                 :            :                           tk::real u,
     129                 :            :                           tk::real v,
     130                 :            :                           tk::real w,
     131                 :            :                           tk::real rhoE,
     132                 :            :                           tk::real alpha=1.0,
     133                 :            :       const std::array< std::array< tk::real, 3 >, 3 >& defgrad={{}} ) const;
     134                 :            : 
     135                 :            :     //! Compute the minimum allowed pressure
     136                 :          0 :     tk::real min_eff_pressure(
     137                 :            :       tk::real min,
     138                 :            :       tk::real,
     139                 :            :       tk::real ) const
     140                 :          0 :     { return min; }
     141                 :            : 
     142                 :            :     //! Compute the reference density
     143                 :            :     tk::real refDensity() const { return density(refPressure(), 300.0); }
     144                 :            : 
     145                 :            :     //! Compute the reference pressure
     146                 :            :     tk::real refPressure() const { return 1.0e5; }
     147                 :            : 
     148                 :            :     //! Return initial density
     149                 :          0 :     tk::real rho0() const { return density(1.0e5, 300.0); }
     150                 :            : 
     151                 :            :     /** @name Charm++ pack/unpack serializer member functions */
     152                 :            :     ///@{
     153                 :            :     //! \brief Pack/Unpack serialize member function
     154                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     155                 :            :     void pup( PUP::er &p ) /*override*/ {
     156                 :            :       p | m_gamma;
     157                 :            :       p | m_R;
     158                 :            :       p | m_cp_coeff;
     159                 :            :       p | m_t_range;
     160                 :            :       p | m_dH_ref;
     161                 :            :     }
     162                 :            :     //! \brief Pack/Unpack serialize operator|
     163                 :            :     //! \param[in,out] p Charm++'s PUP::er serializer object reference
     164                 :            :     //! \param[in,out] i ThermallyPerfectGas object reference
     165                 :            :     friend void operator|( PUP::er& p, ThermallyPerfectGas& i ) { i.pup(p); }
     166                 :            :     //@}
     167                 :            : };
     168                 :            : 
     169                 :            : } //inciter::
     170                 :            : 
     171                 :            : #endif // ThermallyPerfectGas_h

Generated by: LCOV version 1.14