Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/Physics/EOS.hpp
4 : : \copyright 2012-2015 J. Bakosi,
5 : : 2016-2018 Los Alamos National Security, LLC.,
6 : : 2019-2021 Triad National Security, LLC.,
7 : : 2022-2025 J. Bakosi
8 : : All rights reserved. See the LICENSE file for details.
9 : : \brief Equation of state functions
10 : : */
11 : : // *****************************************************************************
12 : : #pragma once
13 : :
14 : : #include "InciterConfig.hpp"
15 : :
16 : : namespace inciter {
17 : :
18 : : extern ctr::Config g_cfg;
19 : :
20 : : } // ::inciter
21 : :
22 : : namespace eos {
23 : :
24 : : using inciter::g_cfg;
25 : :
26 : : //! Compute pressure
27 : : //! \param[in] re Specific internal energy times density
28 : : //! \return Pressure from the ideal gas equation of state
29 : : inline double
30 : : pressure( double re ) {
31 : 54016989 : auto g = g_cfg.get< tag::mat_spec_heat_ratio >();
32 [ + + ][ + + ]: 62054484 : return re * (g-1.0);
[ + + ][ + + ]
[ + - ]
33 : : }
34 : :
35 : : //! Compute speed of sound from density and pressure
36 : : //! \param[in] r Density
37 : : //! \param[in] p Pressure
38 : : //! \return Speed of sound from the ideal gas equation of state
39 : : inline double
40 : : soundspeed( double r, double p ) {
41 : 49692686 : auto g = g_cfg.get< tag::mat_spec_heat_ratio >();
42 [ + + ][ + + ]: 69975120 : return std::sqrt( g * p / r );
43 : : }
44 : :
45 : : //! Compute specific total energy from density, momentum, and pressure
46 : : //! \param[in] r Density
47 : : //! \param[in] u X-velocity
48 : : //! \param[in] v Y-velocity
49 : : //! \param[in] w Z-velocity
50 : : //! \param[in] p Pressure
51 : : //! \return Specific total energy from the ideal gas equation of state
52 : : inline double
53 : : totalenergy( double r, double u, double v, double w, double p ) {
54 : 5899198 : auto g = g_cfg.get< tag::mat_spec_heat_ratio >();
55 : 5925916 : return p / (g-1.0) + 0.5 * r * (u*u + v*v + w*w);
56 : : }
57 : :
58 : : } // eos::
|