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/GodunovRomenskiAluminum.hpp"
23 : : #include "EoS/ThermallyPerfectGas.hpp"
24 : :
25 : : namespace inciter {
26 : :
27 : : //! Equation types
28 : : enum class EqType : uint8_t { compflow
29 : : , multimat
30 : : , multispecies
31 : : };
32 : :
33 : : //! Base class for generic forwarding interface to eos types
34 [ - - ]: 789 : class EOS {
35 : :
36 : : private:
37 : : //! Variant type listing all eos types modeling the same concept
38 : : std::variant< StiffenedGas
39 : : , JWL
40 : : , SmallShearSolid
41 : : , GodunovRomenskiAluminum
42 : : , ThermallyPerfectGas
43 : : > m_material;
44 : :
45 : : public:
46 : : //! Empty constructor for Charm++
47 : : explicit EOS() {}
48 : :
49 : : //! Constructor
50 : : explicit EOS( ctr::MaterialType mattype, EqType eq, std::size_t k );
51 : :
52 : : //! Entry method tags for specific EOS classes to use with compute()
53 : : struct density {};
54 : : struct pressure {};
55 : : struct soundspeed {};
56 : : struct shearspeed {};
57 : : struct totalenergy {};
58 : : struct temperature {};
59 : : struct min_eff_pressure {};
60 : : struct refDensity {};
61 : : struct refPressure {};
62 : : struct rho0 {};
63 : : //! Call EOS function
64 : : //! \tparam Fn Function tag identifying the function to call
65 : : //! \tparam Args Types of arguments to pass to function
66 : : //! \param[in] args Arguments to member function to be called
67 : : //! \details This function issues a call to a member function of the
68 : : //! EOS vector and is thus equivalent to mat_blk[imat].Fn(...).
69 : : template< typename Fn, typename... Args >
70 : : tk::real compute( Args&&... args ) const {
71 [ + + ][ + + ]: 651929690 : return std::visit( [&]( const auto& m )-> tk::real {
[ + + ][ + + ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ - + ][ - + ]
[ + - ][ + - ]
[ - - ][ + - ]
[ + + ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ - + ][ + - ]
[ - - ][ - - ]
[ - + ][ + + ]
[ + - ][ + + ]
[ - - ][ - - ]
[ - - ][ - + ]
[ + - ][ - + ]
[ - + ][ - - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - + ][ - + ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - + ]
[ - + ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - + ][ - + ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - + ]
[ - + ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ + + ][ + - ]
[ + + ][ - - ]
[ + - ][ + + ]
[ + - ][ + + ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ + + ][ + - ]
[ + + ][ - - ]
[ + - ][ + + ]
[ + - ][ + + ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ]
72 : : if constexpr( std::is_same_v< Fn, density > )
73 : 2388384 : return m.density( std::forward< Args >( args )... );
74 : :
75 : : else if constexpr( std::is_same_v< Fn, pressure > )
76 : 171700835 : return m.pressure( std::forward< Args >( args )... );
77 : :
78 : : else if constexpr( std::is_same_v< Fn, soundspeed > )
79 : 169010575 : return m.soundspeed( std::forward< Args >( args )... );
80 : :
81 : : else if constexpr( std::is_same_v< Fn, shearspeed > )
82 : : return m.shearspeed( std::forward< Args >( args )... );
83 : :
84 : : else if constexpr( std::is_same_v< Fn, totalenergy > )
85 : 14099488 : return m.totalenergy( std::forward< Args >( args )... );
86 : :
87 : : else if constexpr( std::is_same_v< Fn, temperature > )
88 : 2365840 : return m.temperature( std::forward< Args >( args )... );
89 : :
90 : : else if constexpr( std::is_same_v< Fn, min_eff_pressure > )
91 : 92086930 : return m.min_eff_pressure( std::forward< Args >( args )... );
92 : :
93 : : else if constexpr( std::is_same_v< Fn, refDensity > )
94 : : return m.refDensity( std::forward< Args >( args )... );
95 : :
96 : : else if constexpr( std::is_same_v< Fn, refPressure > )
97 : : return m.refPressure( std::forward< Args >( args )... );
98 : :
99 : : else if constexpr( std::is_same_v< Fn, rho0 > )
100 : 0 : return m.rho0( std::forward< Args >( args )... );
101 [ + - ][ + - ]: 294752952 : }, m_material );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ + - ][ - - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ - - ][ + - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ + - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ + - ][ + - ]
[ + - ][ - - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ + - ][ + - ]
[ + - ][ - - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ + - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
102 : : }
103 : :
104 : : //! Entry method tags for specific EOS classes to use with computeTensor()
105 : : struct CauchyStress {};
106 : : //! Call EOS function returning a tensor
107 : : //! \tparam Fn Function tag identifying the function to call
108 : : //! \tparam Args Types of arguments to pass to function
109 : : //! \param[in] args Arguments to member function to be called
110 : : //! \details This function issues a call to a member function of the
111 : : //! EOS vector and is thus equivalent to mat_blk[imat].Fn(...).
112 : : template< typename Fn, typename... Args >
113 : : std::array< std::array< tk::real, 3 >, 3 > computeTensor( Args&&... args )
114 : : const {
115 : 0 : return std::visit( [&]( const auto& m )->
116 : : std::array< std::array< tk::real, 3 >, 3 > {
117 : : if constexpr( std::is_same_v< Fn, CauchyStress > )
118 : 0 : return m.CauchyStress( std::forward< Args >( args )... );
119 : :
120 [ - - ][ - - ]: 0 : }, m_material );
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
[ - - ][ - - ]
121 : : }
122 : :
123 : : //! Entry method tags for specific EOS classes to use with set()
124 : : struct setRho0 {};
125 : : //! Call EOS function
126 : : //! \tparam Fn Function tag identifying the function to call
127 : : //! \tparam Args Types of arguments to pass to function
128 : : //! \param[in] args Arguments to member function to be called
129 : : //! \details This function issues a call to a member function of the
130 : : //! EOS vector and is thus equivalent to mat_blk[imat].Fn(...).
131 : : template< typename Fn, typename... Args >
132 : : void set( Args&&... args ) {
133 : 539 : std::visit( [&]( auto& m )-> void {
134 : : if constexpr( std::is_same_v< Fn, setRho0 > )
135 : 0 : m.setRho0( std::forward< Args >( args )... );
136 [ + - ]: 539 : }, m_material );
137 : : }
138 : :
139 : : /** @name Charm++ pack/unpack serializer member functions */
140 : : ///@{
141 : : //! \brief Pack/Unpack serialize member function
142 : : //! \param[in,out] p Charm++'s PUP::er serializer object reference
143 : : void pup( PUP::er &p ) {
144 : : p | m_material;
145 : : }
146 : : //! \brief Pack/Unpack serialize operator|
147 : : //! \param[in,out] p Charm++'s PUP::er serializer object reference
148 : : //! \param[in,out] s EOS object reference
149 : : friend void operator|( PUP::er& p, EOS& s ) { s.pup(p); }
150 : : //@}
151 : : };
152 : :
153 : : } // inciter::
154 : :
155 : : #endif // EOS_h
|