7#ifndef FVSYSEQNEEGAS_H_
8#define FVSYSEQNEEGAS_H_
29 template <MInt stencil = AUSM>
31 const MFloat*
const rightVars,
const MFloat*
const NotUsed(srfcCoeff),
MFloat*
const flux);
37 template <MInt stencil>
44 TERMM(1,
"Viscous Flux Scheme not implemented.");
49 template <MInt stencil>
55 TERMM(1,
"Three point viscous Flux Scheme not implemented for SysEqnEEGas.");
57 TERMM(1,
"Viscous Flux Scheme not implemented.");
66 const MFloat*
const avarsCell);
69 const MFloat*
const NotUsed(avarsCell));
72 const MFloat*
const cvarsCell,
73 const MFloat*
const avarsCell,
74 const MFloat*
const slopesCell);
121 static const MInt Segfault = std::numeric_limits<MInt>::min();
124 static constexpr MInt noVariables = nDim + 1;
127 static constexpr MInt A_RHO_U = 0;
128 static constexpr MInt A_RHO_V = 1;
129 static constexpr MInt A_RHO_W = nDim == 3 ? 2 : Segfault;
131 static constexpr MInt A_RHO = nDim;
134 static constexpr MInt RHO_U = 0;
135 static constexpr MInt RHO_V = 1;
136 static constexpr MInt RHO_W = nDim == 3 ? 2 : Segfault;
138 static constexpr MInt RHO_E = Segfault;
139 static constexpr MInt RHO = nDim;
141 static constexpr MInt RHO_Y[1] = {nDim};
151 static constexpr std::array<MInt, nDim> P_RHO_VV = [] {
152 IF_CONSTEXPR(nDim == 2) {
169 static const MInt Segfault = std::numeric_limits<MInt>::min();
171 static constexpr MInt noVariables = nDim + 3;
175 static constexpr MInt W = nDim == 3 ? 2 : Segfault;
177 static constexpr MInt RHO = nDim;
178 static constexpr MInt P = nDim + 1;
181 static constexpr MInt A = nDim + 2;
182 static constexpr MInt Y[1] = {A};
184 const std::array<MString, nDim + 3> varNames = [] {
185 IF_CONSTEXPR(nDim == 2) {
186 std::array<MString, nDim + 3>
a = {
"u",
"v",
"rho",
"p",
"alpha"};
190 std::array<MString, nDim + 3>
a = {
"u",
"v",
"w",
"rho",
"p",
"alpha"};
195 for(
MInt i = 0; i < noVariables; i++) {
196 names[i] = varNames[i];
204 static constexpr MInt noVariables = 1;
210template <MInt stencil>
212 const MFloat*
const leftVars,
const MFloat*
const rightVars,
213 const MFloat*
const NotUsed(srfcCoeff),
MFloat*
const flux) {
216 const MFloat RHOL = leftVars[PV->RHO];
217 const MFloat PL = leftVars[PV->P];
218 const MFloat AL = sqrt(m_gamma *
mMax(MFloatEps, PL /
mMax(MFloatEps, RHOL)));
219 const MFloat ML = leftVars[orientation] / AL;
223 const MFloat RHOR = rightVars[PV->RHO];
224 const MFloat PR = rightVars[PV->P];
225 const MFloat AR = sqrt(m_gamma *
mMax(MFloatEps, PR /
mMax(MFloatEps, RHOR)));
226 const MFloat MR = rightVars[orientation] / AR;
231 const MFloat MLR = 0.5 * (ML + MR);
232 const MFloat PLR = PL * (0.5 + upwindCoefficient * ML) + PR * (0.5 - upwindCoefficient * MR);
234 const MFloat ALPHALR = 0.5 * (ALPHAL + ALPHAR);
237 const MFloat RHO_AL = RHOL * AL;
238 const MFloat RHO_AR = RHOR * AR;
241 const MFloat RHO_U2 = 0.25 * (MLR * (RHO_AL + RHO_AR) + fabs(MLR) * (RHO_AL - RHO_AR));
242 const MFloat AbsRHO_U2 = fabs(RHO_U2);
244 std::array<MFloat, nDim> pFactor{};
245 pFactor[orientation] = 1.0;
247 for(
MUint n = 0; n < nDim; n++) {
248 flux[FV->A_RHO_VV[n]] = ALPHALR
249 * (RHO_U2 * (leftVars[PV->VV[n]] + rightVars[PV->VV[n]])
250 + AbsRHO_U2 * (leftVars[PV->VV[n]] - rightVars[PV->VV[n]]))
252 flux[FV->P_RHO_VV[n]] = PLR * pFactor[n] * A;
255 flux[FV->A_RHO] = ALPHALR * 2.0 * RHO_U2 * A;
262 for(
MInt n = 0; n < nDim; n++) {
263 flux[FV->A_RHO_VV[n]] = F0;
265 flux[FV->A_RHO] = F0;
271 const MFloat*
const slope1,
272 const MFloat*
const NotUsed(srfcCoeff),
const MFloat f0,
274 static const MFloat F1BRe0 = F1 / m_Re0;
276 const MFloat rho = F1B2 * (vars0[PV->RHO] + vars1[PV->RHO]);
277 const MFloat F1Brho = F1 / rho;
278 const MFloat p = F1B2 * (vars0[PV->P] + vars1[PV->P]);
279 const MFloat alpha = F1B2 * (vars0[PV->A] + vars1[PV->A]);
282 const MFloat T = m_gamma * p * F1Brho;
285 const MUint id0 = orientation;
286 const MUint id1 = index0[orientation];
287 const MUint id2 = index1[orientation];
290 const MFloat dAOverRe = A * F1BRe0;
293 const MFloat mue = (T * sqrt(T) * m_sutherlandPlusOne) / (T + m_sutherlandConstant);
296 const MUint s00 = id0 * nDim + id0;
297 const MUint s01 = id0 * nDim + id1;
298 const MUint s10 = id1 * nDim + id0;
299 const MUint s11 = id1 * nDim + id1;
301 std::array<MFloat, nDim> tau{};
304 mue * alpha * (f0 * (F4B3 * slope0[s00] - F2B3 * slope0[s11]) + f1 * (F4B3 * slope1[s00] - F2B3 * slope1[s11]));
305 tau[id1] = mue * alpha * (f0 * (slope0[s01] + slope0[s10]) + f1 * (slope1[s01] + slope1[s10]));
306 }
else if(nDim == 3) {
307 const MUint s22 = id2 * nDim + id2;
308 const MUint s02 = id0 * nDim + id2;
309 const MUint s20 = id2 * nDim + id0;
310 tau[id0] = mue * alpha
311 * (f0 * (F4B3 * slope0[s00] - F2B3 * (slope0[s11] + slope0[s22]))
312 + f1 * (F4B3 * slope1[s00] - F2B3 * (slope1[s11] + slope1[s22])));
313 tau[id1] = mue * alpha * (f0 * (slope0[s01] + slope0[s10]) + f1 * (slope1[s01] + slope1[s10]));
314 tau[id2] = mue * alpha * (f0 * (slope0[s02] + slope0[s20]) + f1 * (slope1[s02] + slope1[s20]));
318 for(
MUint n = 0; n < nDim; n++) {
319 flux[FV->A_RHO_VV[n]] -= dAOverRe * tau[n];
325 const MFloat*
const avarsCell) {
327 if(cvarsCell[CV->A_RHO] > -m_EEGasEps) {
328 fRhoAlpha = F1 /
mMax(cvarsCell[CV->A_RHO], m_EEGasEps);
330 fRhoAlpha = F1 / cvarsCell[CV->A_RHO];
333 for(
MInt vel = 0; vel < nDim; ++vel) {
334 pvarsCell[PV->VV[vel]] = cvarsCell[CV->A_RHO_VV[vel]] * fRhoAlpha;
336 pvarsCell[PV->RHO] = pvarsCell[PV->P] * m_gamma + avarsCell[AV->DC];
338 pvarsCell[PV->A] = cvarsCell[CV->A_RHO] / pvarsCell[PV->RHO];
344 const MFloat*
const NotUsed(avarsCell)) {
345 cvarsCell[CV->A_RHO] = pvarsCell[PV->RHO] * pvarsCell[PV->A];
346 for(
MInt vel = 0; vel < nDim; vel++) {
347 cvarsCell[CV->A_RHO_VV[vel]] = cvarsCell[CV->A_RHO] * pvarsCell[PV->VV[vel]];
352inline std::vector<std::vector<MFloat>>
354 const MFloat*
const NotUsed(avarsCell),
355 const MFloat*
const NotUsed(slopesCell)) {
357 "SysEqnEEGas has not been tested with adaptation. The computation of the conservative variables should be "
358 "adjusted. Terminating.");
359 std::vector<std::vector<MFloat>> dQ(CV->noVariables, std::vector<MFloat>(nDim));
static constexpr std::array< MInt, nDim > getArray012()
static constexpr MBool hasSC
void Ausm(const MInt orientation, const MFloat upwindCoefficient, const MFloat A, const MFloat *const leftVars, const MFloat *const rightVars, const MFloat *const NotUsed(srfcCoeff), MFloat *const flux)
void viscousFlux(const MInt orientation, const MFloat A, const MFloat *const vars0, const MFloat *const vars1, const MFloat *const slope0, const MFloat *const slope1, const MFloat *const srfcCoeff, const MFloat f0, const MFloat f1, MFloat *const flux)
void AusmBndryCorrection(const MInt orientation, const MFloat A, const MFloat *const leftVars, const MFloat *const rightVars, MFloat *const flux)
ConservativeVariables * CV
void viscousFlux(const MInt, const MFloat, const MBool, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat *const, const MFloat, const MFloat, MFloat *const)
std::vector< std::vector< MFloat > > conservativeSlopes(const MFloat *const pvarsCell, const MFloat *const cvarsCell, const MFloat *const avarsCell, const MFloat *const slopesCell)
void viscousFluxFivePoint(const MInt orientation, const MFloat A, const MFloat *const vars0, const MFloat *const vars1, const MFloat *const slope0, const MFloat *const slope1, const MFloat *const srfcCoeff, const MFloat f0, const MFloat f1, MFloat *const flux)
void computePrimitiveVariables(const MFloat *const cvarsCell, MFloat *const pvarsCell, const MFloat *const avarsCell)
static constexpr MBool hasAV
void computeConservativeVariables(const MFloat *const pvarsCell, MFloat *const cvarsCell, const MFloat *const NotUsed(avarsCell))
MFloat m_sutherlandConstant
static constexpr std::array< MInt, nDim > getArray012()
MFloat m_sutherlandPlusOneThermal
MFloat m_sutherlandPlusOne
MFloat m_referenceTemperature
MFloat m_F1BGammaMinusOne
static const MUint index1[nDim]
static const MUint index0[nDim]
MFloat m_sutherlandConstantThermal
void mTerm(const MInt errorCode, const MString &location, const MString &message)
constexpr T mMin(const T &x, const T &y)
constexpr T mMax(const T &x, const T &y)
std::basic_string< char > MString
Static indices for accessing additional variables.
Static indices for accessing conservative variables in nDim spatial dimensions.
static constexpr MInt noVariables
static const MInt Segfault
Static indices for accessing flux variables.
Static indices for accessing primitive variables in nDim spatial dimensions.
void getPrimitiveVariableNames(MString *names)