Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/PDE/ConfigureCompFlow.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 Register and compile configuration for compressible flow PDE
9 : : \details Register and compile configuration for compressible flow PDE.
10 : : */
11 : : // *****************************************************************************
12 : : #ifndef ConfigureCompFlow_h
13 : : #define ConfigureCompFlow_h
14 : :
15 : : #include <set>
16 : : #include <map>
17 : : #include <vector>
18 : :
19 : : #include "PDEFactory.hpp"
20 : : #include "SystemComponents.hpp"
21 : : #include "Inciter/Options/PDE.hpp"
22 : : #include "FunctionPrototypes.hpp"
23 : : #include "ContainerUtil.hpp"
24 : : #include "EoS/EoS.hpp"
25 : :
26 : : namespace inciter {
27 : :
28 : : extern ctr::InputDeck g_inputdeck;
29 : :
30 : : //! Register compressible flow PDEs into PDE factory
31 : : void
32 : : registerCompFlow( CGFactory& cf,
33 : : DGFactory& df,
34 : : std::set< ctr::PDEType >& cgt,
35 : : std::set< ctr::PDEType >& dgt );
36 : :
37 : : //! Return information on the compressible flow PDE
38 : : std::vector< std::pair< std::string, std::string > >
39 : : infoCompFlow( std::map< ctr::PDEType, tk::ctr::ncomp_t >& cnt );
40 : :
41 : : //! \brief Assign function that computes physics variables from the
42 : : //! numerical solution for CompFlow
43 : : void
44 : : assignCompFlowGetVars( const std::string& name, tk::GetVarFn& f );
45 : :
46 : : /** @name Functions that compute physics variables from the numerical solution for CompFlow */
47 : : ///@{
48 : :
49 : : #if defined(__clang__)
50 : : #pragma clang diagnostic push
51 : : #pragma clang diagnostic ignored "-Wunused-function"
52 : : #endif
53 : :
54 : : namespace compflow {
55 : :
56 : : //! Compute density for output to file
57 : : //! \note Must follow the signature in tk::GetVarFn
58 : : //! \param[in] U Numerical solution
59 : : //! \param[in] offset System offset specifying the position of the CompFlow
60 : : //! equation system among other systems
61 : : //! \return Fluid density ready to be output to file
62 : : static tk::GetVarFn::result_type
63 : 3327 : densityOutVar( const tk::Fields& U, tk::ctr::ncomp_t offset, std::size_t )
64 : : {
65 : 3327 : return U.extract( 0, offset );
66 : : }
67 : :
68 : : //! Compute velocity component for output to file
69 : : //! \note Must follow the signature in tk::GetVarFn
70 : : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z
71 : : //! \param[in] U Numerical solution
72 : : //! \param[in] offset System offset specifying the position of the CompFlow
73 : : //! equation system among other systems
74 : : //! \param[in] rdof Number of reconstructed solution DOFs
75 : : //! \return Velocity component ready to be output to file
76 : : template< tk::ctr::ncomp_t dir >
77 : : tk::GetVarFn::result_type
78 : 9921 : velocityOutVar( const tk::Fields& U, tk::ctr::ncomp_t offset, std::size_t rdof )
79 : : {
80 : : using tk::operator/=;
81 [ + - ][ + - ]: 19842 : auto r = U.extract( 0, offset ), u = U.extract( (dir+1)*rdof, offset );
82 [ + - ]: 9921 : u /= r;
83 : 19842 : return u;
84 : : }
85 : :
86 : : //! Compute volumetric total energy (energy per unit volume) for output to file
87 : : //! \note Must follow the signature in tk::GetVarFn
88 : : //! \param[in] U Numerical solution
89 : : //! \param[in] offset System offset specifying the position of the CompFlow
90 : : //! equation system among other systems
91 : : //! \param[in] rdof Number of reconstructed solution DOFs
92 : : //! \return Volumetric total energy ready to be output to file
93 : : static tk::GetVarFn::result_type
94 : 0 : volumetricTotalEnergyOutVar( const tk::Fields& U, tk::ctr::ncomp_t offset,
95 : : std::size_t rdof )
96 : : {
97 : 0 : return U.extract( 4*rdof, offset );
98 : : }
99 : :
100 : : //! Compute specific total energy (energy per unit mass) for output to file
101 : : //! \note Must follow the signature in tk::GetVarFn
102 : : //! \param[in] U Numerical solution
103 : : //! \param[in] offset System offset specifying the position of the CompFlow
104 : : //! equation system among other systems
105 : : //! \param[in] rdof Number of reconstructed solution DOFs
106 : : //! \return Specific total energy ready to be output to file
107 : : static tk::GetVarFn::result_type
108 : 3327 : specificTotalEnergyOutVar( const tk::Fields& U, tk::ctr::ncomp_t offset,
109 : : std::size_t rdof )
110 : : {
111 : : using tk::operator/=;
112 [ + - ][ + - ]: 6654 : auto r = U.extract( 0, offset ), e = U.extract( 4*rdof, offset );
113 [ + - ]: 3327 : e /= r;
114 : 6654 : return e;
115 : : }
116 : :
117 : : //! Compute momentum component for output to file
118 : : //! \note Must follow the signature in tk::GetVarFn
119 : : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z
120 : : //! \param[in] U Numerical solution
121 : : //! \param[in] offset System offset specifying the position of the CompFlow
122 : : //! equation system among other systems
123 : : //! \param[in] rdof Number of reconstructed solution DOFs
124 : : //! \return Momentum component ready to be output to file
125 : : template< tk::ctr::ncomp_t dir >
126 : : tk::GetVarFn::result_type
127 : 0 : momentumOutVar( const tk::Fields& U, tk::ctr::ncomp_t offset, std::size_t rdof )
128 : : {
129 : 0 : return U.extract( (dir+1)*rdof, offset );
130 : : }
131 : :
132 : : //! Compute pressure for output to file
133 : : //! \note Must follow the signature in tk::GetVarFn
134 : : //! \param[in] U Numerical solution
135 : : //! \param[in] offset System offset specifying the position of the CompFlow
136 : : //! equation system among other systems
137 : : //! \param[in] rdof Number of reconstructed solution DOFs
138 : : //! \return Pressure ready to be output to file
139 : : static tk::GetVarFn::result_type
140 : 3327 : pressureOutVar( const tk::Fields& U, tk::ctr::ncomp_t offset, std::size_t rdof )
141 : : {
142 : : using tk::operator/=;
143 [ + - ]: 6654 : auto r = U.extract( 0, offset ),
144 [ + - ]: 6654 : u = U.extract( 1*rdof, offset ),
145 [ + - ]: 6654 : v = U.extract( 2*rdof, offset ),
146 [ + - ]: 6654 : w = U.extract( 3*rdof, offset ),
147 [ + - ]: 6654 : re = U.extract( 4*rdof, offset );
148 [ + - ]: 3327 : u /= r;
149 [ + - ]: 3327 : v /= r;
150 [ + - ]: 3327 : w /= r;
151 [ + - ]: 3327 : auto p = r;
152 [ + - ]: 3327 : auto sys = tk::cref_find( g_inputdeck.get< tag::sys >(), offset );
153 [ + + ]: 743113 : for (std::size_t i=0; i<U.nunk(); ++i)
154 [ + - ]: 739786 : p[i] = eos_pressure<tag::compflow>( sys, r[i], u[i], v[i], w[i], re[i] );
155 : 6654 : return p;
156 : : }
157 : :
158 : : } // compflow::
159 : :
160 : : #if defined(__clang__)
161 : : #pragma clang diagnostic pop
162 : : #endif
163 : :
164 : : //@}
165 : :
166 : : } // inciter::
167 : :
168 : : #endif // ConfigureCompFlow_h
|