Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/PDE/Riemann/AUSMMultiSpecies.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 : : for multi-species fluid dynamics.
10 : : \details This file implements the Advection Upstream Splitting Method (AUSM)
11 : : Riemann solver, with the all-speed corrections.
12 : : Ref. Liou, M. S. (2006). A sequel to AUSM, Part II: AUSM+-up for
13 : : all speeds. Journal of computational physics, 214(1), 137-170.
14 : : */
15 : : // *****************************************************************************
16 : : #ifndef AUSMMultiSpecies_h
17 : : #define AUSMMultiSpecies_h
18 : :
19 : : #include <vector>
20 : :
21 : : #include "Fields.hpp"
22 : : #include "SplitMachFns.hpp"
23 : : #include "FunctionPrototypes.hpp"
24 : : #include "Inciter/Options/Flux.hpp"
25 : : #include "EoS/EOS.hpp"
26 : : #include "MultiSpecies/MultiSpeciesIndexing.hpp"
27 : : #include "MultiSpecies/Mixture/Mixture.hpp"
28 : :
29 : : namespace inciter {
30 : :
31 : : //! AUSMMultiSpecies+up approximate Riemann solver
32 : : struct AUSMMultiSpecies {
33 : :
34 : : //! AUSM+up approximate Riemann solver flux function for multi-species flow
35 : : //! \param[in] fn Face/Surface normal
36 : : //! \param[in] u Left and right unknown/state vector
37 : : //! \return Riemann flux solution according to AUSM+up, appended by Riemann
38 : : //! velocities and volume-fractions.
39 : : //! \note The function signature must follow tk::RiemannFluxFn
40 : : static tk::RiemannFluxFn::result_type
41 : 1752300 : flux( const std::vector< EOS >& mat_blk,
42 : : const std::array< tk::real, 3 >& fn,
43 : : const std::array< std::vector< tk::real >, 2 >& u,
44 : : const std::vector< std::array< tk::real, 3 > >& = {} )
45 : : {
46 : 1752300 : auto nspec = g_inputdeck.get< tag::multispecies, tag::nspec >();
47 : 1752300 : auto k_p = g_inputdeck.get< tag::lowspeed_kp >();
48 : :
49 : 1752300 : auto ncomp = u[0].size();
50 [ + - ]: 1752300 : std::vector< tk::real > flx( ncomp, 0 );
51 : :
52 : : tk::real rhol(0.0), rhor(0.0), pl(0.0), pr(0.0), hl(0.0), hr(0.0),
53 : : al(0.0), ar(0.0), a12(0.0), rho12(0.0);
54 : :
55 : : // initialize mixtures
56 : : Mixture mixl(nspec, u[0], mat_blk);
57 [ + - ]: 1752300 : Mixture mixr(nspec, u[1], mat_blk);
58 : :
59 : : // Mixture densities
60 : 1752300 : rhol = mixl.get_mix_density();
61 : 1752300 : rhor = mixr.get_mix_density();
62 : :
63 : : // Velocities
64 [ + - ]: 1752300 : auto ul = u[0][multispecies::momentumIdx(nspec, 0)]/rhol;
65 : 1752300 : auto vl = u[0][multispecies::momentumIdx(nspec, 1)]/rhol;
66 : 1752300 : auto wl = u[0][multispecies::momentumIdx(nspec, 2)]/rhol;
67 : 1752300 : auto ur = u[1][multispecies::momentumIdx(nspec, 0)]/rhor;
68 : 1752300 : auto vr = u[1][multispecies::momentumIdx(nspec, 1)]/rhor;
69 [ + - ]: 1752300 : auto wr = u[1][multispecies::momentumIdx(nspec, 2)]/rhor;
70 : :
71 [ + - ]: 1752300 : pl = mixl.pressure( rhol, ul, vl, wl,
72 : : u[0][multispecies::energyIdx(nspec, 0)], mat_blk );
73 [ + - ]: 1752300 : hl = u[0][multispecies::energyIdx(nspec, 0)] + pl;
74 [ + - ]: 1752300 : al = mixl.frozen_soundspeed( rhol, pl, mat_blk );
75 : :
76 [ + - ]: 1752300 : pr = mixr.pressure (rhor, ur, vr, wr,
77 [ + - ]: 1752300 : u[1][multispecies::energyIdx(nspec, 0)], mat_blk );
78 [ + - ]: 1752300 : hr = u[1][multispecies::energyIdx(nspec, 0)] + pr;
79 [ + - ]: 1752300 : ar = mixr.frozen_soundspeed( rhor, pr, mat_blk );
80 : :
81 : : // Average states for mixture speed of sound
82 : 1752300 : a12 = 0.5*(al+ar);
83 : 1752300 : rho12 = 0.5*(rhol+rhor);
84 : :
85 : : // Face-normal velocities from advective velocities
86 : 1752300 : auto vnl = ul*fn[0] + vl*fn[1] + wl*fn[2];
87 : 1752300 : auto vnr = ur*fn[0] + vr*fn[1] + wr*fn[2];
88 : :
89 : : // Mach numbers
90 : 1752300 : auto ml = vnl/a12;
91 : 1752300 : auto mr = vnr/a12;
92 : :
93 : : // All-speed parameters
94 : : // These parameters control the amount of all-speed diffusion necessary for
95 : : // low-Mach flows. Setting k_u and k_p to zero does not add any all-speed
96 : : // diffusion, whereas setting k_u and k_p to 1 adds maximum recommended
97 : : // all-speed diffusion. See "Liou, M. S. (2006). A sequel to AUSM, Part II:
98 : : // AUSM+-up for all speeds. Journal of computational physics, 214(1),
99 : : // 137-170" for more mathematical explanation. k_u is the velocity diffusion
100 : : // term and k_p is the pressure diffusion term. These two terms reduce
101 : : // pressure-velocity decoupling (chequerboarding/odd-even oscillations).
102 : : tk::real k_u(1.0), f_a(1.0);
103 : :
104 : : // Split Mach polynomials
105 : 1752300 : auto msl = splitmach_ausm( ml, f_a );
106 : 1752300 : auto msr = splitmach_ausm( mr, f_a );
107 : :
108 : : // Riemann Mach number
109 : 1752300 : auto m0 = 1.0 - (0.5*(vnl*vnl + vnr*vnr)/(a12*a12));
110 [ + + ]: 1752300 : auto mp = -k_p* std::max(m0, 0.0) * (pr-pl) / (f_a*rho12*a12*a12);
111 : 1752300 : auto m12 = msl[0] + msr[1] + mp;
112 : 1752300 : auto vriem = a12 * m12;
113 : :
114 : : // Riemann pressure
115 : 1752300 : auto pu = -k_u* msl[2] * msr[3] * f_a * rho12 * a12 * (vnr-vnl);
116 : 1752300 : auto p12 = msl[2]*pl + msr[3]*pr + pu;
117 : :
118 : : // Flux vector splitting
119 : 1752300 : auto l_plus = 0.5 * (vriem + std::fabs(vriem));
120 : 1752300 : auto l_minus = 0.5 * (vriem - std::fabs(vriem));
121 : :
122 : : // Conservative fluxes
123 [ + + ]: 4380750 : for (std::size_t k=0; k<nspec; ++k)
124 : : {
125 : 2628450 : flx[multispecies::densityIdx(nspec, k)] =
126 : 2628450 : l_plus *u[0][multispecies::densityIdx(nspec, k)] +
127 : 2628450 : l_minus*u[1][multispecies::densityIdx(nspec, k)];
128 : : }
129 : :
130 : 1752300 : flx[multispecies::energyIdx(nspec, 0)] = l_plus*hl + l_minus*hr;
131 : :
132 [ + + ]: 7009200 : for (std::size_t idir=0; idir<3; ++idir)
133 : : {
134 : 5256900 : flx[multispecies::momentumIdx(nspec, idir)] =
135 : 5256900 : l_plus *u[0][multispecies::momentumIdx(nspec, idir)] +
136 : 5256900 : l_minus*u[1][multispecies::momentumIdx(nspec, idir)] + p12*fn[idir];
137 : : }
138 : :
139 : 1752300 : return flx;
140 : : }
141 : :
142 : : //! Flux type accessor
143 : : //! \return Flux type
144 : : static ctr::FluxType type() noexcept { return ctr::FluxType::AUSM; }
145 : : };
146 : :
147 : : } // inciter::
148 : :
149 : : #endif // AUSMMultiSpecies_h
|