Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/PDE/Riemann/AUSM.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 Advection Upstream Splitting Method (AUSM+) Riemann flux function
9 : : \details This file implements the Advection Upstream Splitting Method (AUSM)
10 : : Riemann solver, with the all-speed corrections.
11 : : Ref. Liou, M. S. (2006). A sequel to AUSM, Part II: AUSM+-up for
12 : : all speeds. Journal of computational physics, 214(1), 137-170.
13 : : */
14 : : // *****************************************************************************
15 : : #ifndef AUSM_h
16 : : #define AUSM_h
17 : :
18 : : #include <vector>
19 : :
20 : : #include "Fields.hpp"
21 : : #include "FunctionPrototypes.hpp"
22 : : #include "Inciter/Options/Flux.hpp"
23 : : #include "SplitMachFns.hpp"
24 : : #include "EoS/EOS.hpp"
25 : : #include "MultiMat/MultiMatIndexing.hpp"
26 : :
27 : : namespace inciter {
28 : :
29 : : //! AUSM+up approximate Riemann solver
30 : : struct AUSM {
31 : :
32 : : //! AUSM+up approximate Riemann solver flux function
33 : : //! \param[in] fn Face/Surface normal
34 : : //! \param[in] u Left and right unknown/state vector
35 : : //! \return Riemann flux solution according to AUSM+up, appended by Riemann
36 : : //! velocities and volume-fractions.
37 : : //! \note The function signature must follow tk::RiemannFluxFn
38 : : static tk::RiemannFluxFn::result_type
39 : 7722741 : flux( const std::vector< EOS >& mat_blk,
40 : : const std::array< tk::real, 3 >& fn,
41 : : const std::array< std::vector< tk::real >, 2 >& u,
42 : : const std::vector< std::array< tk::real, 3 > >& = {} )
43 : : {
44 : 7722741 : auto nmat = g_inputdeck.get< tag::multimat, tag::nmat >();
45 : :
46 : : // All-speed parameters
47 : : // These parameters control the amount of all-speed diffusion necessary for
48 : : // low-Mach flows. Setting k_u and k_p to zero does not add any all-speed
49 : : // diffusion, whereas setting k_u and k_p to 1 adds maximum recommended
50 : : // all-speed diffusion. See "Liou, M. S. (2006). A sequel to AUSM, Part II:
51 : : // AUSM+-up for all speeds. Journal of computational physics, 214(1),
52 : : // 137-170" for more mathematical explanation. k_u is the velocity diffusion
53 : : // term and k_p is the pressure diffusion term. These two terms reduce
54 : : // pressure-velocity decoupling (chequerboarding/odd-even oscillations).
55 : 7722741 : auto k_u = g_inputdeck.get< tag::lowspeed_ku >();
56 : 7722741 : auto k_p = g_inputdeck.get< tag::lowspeed_kp >();
57 : :
58 : 7722741 : auto ncomp = u[0].size()-(3+nmat);
59 [ + - ]: 7722741 : std::vector< tk::real > flx( ncomp, 0 );
60 : :
61 : : // Primitive variables
62 : 7722741 : tk::real rhol(0.0), rhor(0.0);
63 [ + + ]: 25863289 : for (std::size_t k=0; k<nmat; ++k)
64 : : {
65 : 18140548 : rhol += u[0][densityIdx(nmat, k)];
66 : 18140548 : rhor += u[1][densityIdx(nmat, k)];
67 : : }
68 : :
69 : 7722741 : tk::real pl(0.0), pr(0.0), amatl(0.0), amatr(0.0);
70 [ + - ][ + - ]: 15445482 : std::vector< tk::real > al_l(nmat, 0.0), al_r(nmat, 0.0),
71 [ + - ][ + - ]: 15445482 : hml(nmat, 0.0), hmr(nmat, 0.0),
72 [ + - ][ + - ]: 15445482 : pml(nmat, 0.0), pmr(nmat, 0.0),
73 [ + - ]: 15445482 : arhom12(nmat, 0.0),
74 [ + - ]: 15445482 : amat12(nmat, 0.0);
75 [ + + ]: 25863289 : for (std::size_t k=0; k<nmat; ++k)
76 : : {
77 : 18140548 : al_l[k] = u[0][volfracIdx(nmat, k)];
78 : 18140548 : pml[k] = u[0][ncomp+pressureIdx(nmat, k)];
79 : 18140548 : pl += pml[k];
80 : 18140548 : hml[k] = u[0][energyIdx(nmat, k)] + pml[k];
81 [ + - ]: 36281096 : amatl = mat_blk[k].compute< EOS::soundspeed >(
82 : 18140548 : u[0][densityIdx(nmat, k)], pml[k], al_l[k], k );
83 : :
84 : 18140548 : al_r[k] = u[1][volfracIdx(nmat, k)];
85 : 18140548 : pmr[k] = u[1][ncomp+pressureIdx(nmat, k)];
86 : 18140548 : pr += pmr[k];
87 : 18140548 : hmr[k] = u[1][energyIdx(nmat, k)] + pmr[k];
88 [ + - ]: 36281096 : amatr = mat_blk[k].compute< EOS::soundspeed >(
89 : 18140548 : u[1][densityIdx(nmat, k)], pmr[k], al_r[k], k );
90 : :
91 : : // Average states for mixture speed of sound
92 : 18140548 : arhom12[k] = 0.5*(u[0][densityIdx(nmat, k)] + u[1][densityIdx(nmat, k)]);
93 : 18140548 : amat12[k] = 0.5*(amatl+amatr);
94 : : }
95 : :
96 : 7722741 : auto rho12 = 0.5*(rhol+rhor);
97 : :
98 : : // mixture speed of sound
99 : 7722741 : tk::real ac12(0.0);
100 [ + + ]: 25863289 : for (std::size_t k=0; k<nmat; ++k)
101 : : {
102 : 18140548 : ac12 += (arhom12[k]*amat12[k]*amat12[k]);
103 : : }
104 : 7722741 : ac12 = std::sqrt( ac12/rho12 );
105 : :
106 : : // Independently limited velocities for advection
107 : 7722741 : auto ul = u[0][ncomp+velocityIdx(nmat, 0)];
108 : 7722741 : auto vl = u[0][ncomp+velocityIdx(nmat, 1)];
109 : 7722741 : auto wl = u[0][ncomp+velocityIdx(nmat, 2)];
110 : 7722741 : auto ur = u[1][ncomp+velocityIdx(nmat, 0)];
111 : 7722741 : auto vr = u[1][ncomp+velocityIdx(nmat, 1)];
112 : 7722741 : auto wr = u[1][ncomp+velocityIdx(nmat, 2)];
113 : :
114 : : // Face-normal velocities from advective velocities
115 : 7722741 : auto vnl = ul*fn[0] + vl*fn[1] + wl*fn[2];
116 : 7722741 : auto vnr = ur*fn[0] + vr*fn[1] + wr*fn[2];
117 : :
118 : : // Mach numbers
119 : 7722741 : auto ml = vnl/ac12;
120 : 7722741 : auto mr = vnr/ac12;
121 : :
122 : 7722741 : tk::real f_a(1.0);
123 : :
124 : : // Split Mach polynomials
125 : 7722741 : auto msl = splitmach_ausm( ml, f_a );
126 : 7722741 : auto msr = splitmach_ausm( mr, f_a );
127 : :
128 : : // Riemann Mach number
129 : 7722741 : auto m0 = 1.0 - (0.5*(vnl*vnl + vnr*vnr)/(ac12*ac12));
130 : 7722741 : auto mp = -k_p* std::max(m0, 0.0) * (pr-pl) / (f_a*rho12*ac12*ac12);
131 : 7722741 : auto m12 = msl[0] + msr[1] + mp;
132 : 7722741 : auto vriem = ac12 * m12;
133 : :
134 : : // Riemann pressure
135 : 7722741 : auto pu = -k_u* msl[2] * msr[3] * f_a * rho12 * ac12 * (vnr-vnl);
136 : 7722741 : auto p12 = msl[2]*pl + msr[3]*pr + pu;
137 : :
138 : 7722741 : auto md = 0.0;
139 : : //// uncomment code below AND set k_u to zero above for AUSM-2025u/p mods.
140 : : //// Additional diffusion
141 : : //auto delta = 4.0;
142 : : ////auto md = std::max(m0, 0.0) * delta * std::sqrt(std::abs(vnl - vnr) * ac12);
143 : : //md = std::max(m0, 0.0) * delta * std::sqrt(std::abs(pl - pr) / rho12);
144 : :
145 : : // Flux vector splitting
146 : 7722741 : auto l_plus = 0.5 * (vriem + std::fabs(vriem) + 2.0*md);
147 : 7722741 : auto l_minus = 0.5 * (vriem - std::fabs(vriem) - 2.0*md);
148 : :
149 : : // Conservative fluxes
150 [ + + ]: 25863289 : for (std::size_t k=0; k<nmat; ++k)
151 : : {
152 : 18140548 : flx[volfracIdx(nmat, k)] = l_plus*al_l[k] + l_minus*al_r[k];
153 : 36281096 : flx[densityIdx(nmat, k)] = l_plus*u[0][densityIdx(nmat, k)]
154 : 18140548 : + l_minus*u[1][densityIdx(nmat, k)];
155 : 18140548 : flx[energyIdx(nmat, k)] = l_plus*hml[k] + l_minus*hmr[k];
156 : : }
157 : :
158 [ + + ]: 30890964 : for (std::size_t idir=0; idir<3; ++idir)
159 : : {
160 : 46336446 : flx[momentumIdx(nmat, idir)] = l_plus*u[0][momentumIdx(nmat, idir)]
161 : 23168223 : + l_minus*u[1][momentumIdx(nmat, idir)]
162 : 23168223 : + p12*fn[idir];
163 : : }
164 : :
165 : 7722741 : l_plus = l_plus/( vriem + std::copysign(1.0e-12,vriem) );
166 : 7722741 : l_minus = l_minus/( vriem + std::copysign(1.0e-12,vriem) );
167 : :
168 : : // Store Riemann-advected partial pressures
169 [ + + ]: 25863289 : for (std::size_t k=0; k<nmat; ++k)
170 [ + - ]: 18140548 : flx.push_back( l_plus*pml[k] + l_minus*pmr[k] );
171 : :
172 : : // Store Riemann velocity
173 [ + - ]: 7722741 : flx.push_back( vriem );
174 : :
175 [ - + ][ - - ]: 7722741 : Assert( flx.size() == (3*nmat+3+nmat+1), "Size of multi-material flux "
[ - - ][ - - ]
176 : : "vector incorrect" );
177 : :
178 : 15445482 : return flx;
179 : : }
180 : :
181 : : //! Flux type accessor
182 : : //! \return Flux type
183 : : static ctr::FluxType type() noexcept { return ctr::FluxType::AUSM; }
184 : : };
185 : :
186 : : } // inciter::
187 : :
188 : : #endif // AUSM_h
|