28template <MInt nDim,
class RANSModel>
36 template <MInt stencil = AUSM>
38 const MFloat*
const rightVars,
const MFloat*
const NotUsed(srfcCoeff),
MFloat*
const flux);
44 template <MInt stencil>
51 TERMM(1,
"Viscous Flux Scheme not implemented.");
56 template <MInt stencil>
58 const MFloat*
const surfaceCoords,
const MFloat*
const coord0,
const MFloat*
const coord1,
59 const MFloat*
const cellVars0,
const MFloat*
const cellVars1,
const MFloat*
const vars0,
63 viscousFluxThreePoint(orientation, A, isBndry, surfaceCoords, coord0, coord1, cellVars0, cellVars1, vars0, vars1,
64 slope0, slope1, f0, f1, flux);
66 TERMM(1,
"Viscous Flux Scheme not implemented.");
76 const MFloat*
const surfaceCoords,
const MFloat*
const coord0,
77 const MFloat*
const coord1,
const MFloat*
const cellVars0,
83 const MFloat*
const NotUsed(avarsCell));
86 const MFloat*
const NotUsed(avarsCell));
89 const MFloat*
const cvarsCell,
90 const MFloat*
const avarsCell,
91 const MFloat*
const slopesCell);
94 const MFloat*
const slopes,
const MInt recData,
const MInt*
const recNghbr,
108 const MFloat*
const slopes,
const MInt recData,
const MInt*
const ,
111 const MFloat*
const slopes,
MInt recData,
const MInt*
const recNghbr,
165template <MInt nDim,
class RANSModel>
169 static constexpr MInt Segfault = std::numeric_limits<MInt>::min();
171 static constexpr MInt RHO_U = 0;
172 static constexpr MInt RHO_V = 1;
173 static constexpr MInt RHO_W = nDim == 3 ? 2 : Segfault;
175 static constexpr MInt RHO_E = nDim;
176 static constexpr MInt RHO = nDim + 1;
177 static constexpr MInt RHO_N = nDim + 2;
178 static constexpr MInt RHO_K = nDim + 2;
179 static constexpr MInt RHO_OMEGA = nDim + 3;
192template <MInt nDim,
class RANSModel>
199template <MInt nDim,
class RANSModel>
203 static const MInt Segfault = std::numeric_limits<MInt>::min();
207 static constexpr MInt W = nDim == 3 ? 2 : Segfault;
209 static constexpr MInt RHO = nDim;
210 static constexpr MInt P = nDim + 1;
211 static constexpr MInt T = nDim + 1;
213 static constexpr MInt N = nDim + 2;
214 static constexpr MInt K = nDim + 2;
215 static constexpr MInt OMEGA = nDim + 3;
227 void getPrimitiveVariableNames(
MString* names);
231template <MInt nDim,
class RANSModel>
232template <MInt stencil>
234 const MFloat*
const leftVars,
const MFloat*
const rightVars,
235 const MFloat*
const NotUsed(srfcCoeff),
MFloat*
const flux) {
238 const MFloat RHOL = leftVars[PV->RHO];
239 const MFloat PL = leftVars[PV->P];
240 const MFloat AL = sqrt(m_gamma *
mMax(MFloatEps, PL /
mMax(MFloatEps, RHOL)));
241 const MFloat ML = leftVars[orientation] / AL;
243 const MFloat RHOR = rightVars[PV->RHO];
244 const MFloat PR = rightVars[PV->P];
245 const MFloat AR = sqrt(m_gamma *
mMax(MFloatEps, PR /
mMax(MFloatEps, RHOR)));
246 const MFloat MR = rightVars[orientation] / AR;
249 const MFloat MLR = 0.5 * (ML + MR);
250 const MFloat PLR = PL * (0.5 + upwindCoefficient * ML) + PR * (0.5 - upwindCoefficient * MR);
253 const MFloat RHO_AL = RHOL * AL;
254 const MFloat RHO_AR = RHOR * AR;
257 const MFloat RHO_U2 = 0.25 * (MLR * (RHO_AL + RHO_AR) + fabs(MLR) * (RHO_AL - RHO_AR));
258 const MFloat AbsRHO_U2 = fabs(RHO_U2);
261 const MFloat PLfRHOL = PL / RHOL;
262 const MFloat PRfRHOR = PR / RHOR;
265 const MFloat U2L = std::inner_product(&leftVars[PV->U], &leftVars[PV->U] + nDim, &leftVars[PV->U], 0.0);
266 const MFloat U2R = std::inner_product(&rightVars[PV->U], &rightVars[PV->U] + nDim, &rightVars[PV->U], 0.0);
268 const MFloat e0 = PLfRHOL * m_F1BGammaMinusOne + 0.5 * U2L + PLfRHOL;
269 const MFloat e1 = PRfRHOR * m_F1BGammaMinusOne + 0.5 * U2R + PRfRHOR;
271 std::array<MFloat, nDim> pFactor{};
272 pFactor[orientation] = 1.0;
274 for(
MInt n = 0; n < nDim; n++) {
275 flux[FV->RHO_VV[n]] = (RHO_U2 * (leftVars[PV->VV[n]] + rightVars[PV->VV[n]])
276 + AbsRHO_U2 * (leftVars[PV->VV[n]] - rightVars[PV->VV[n]]) + PLR * pFactor[n])
280 flux[FV->RHO_E] = (RHO_U2 * (e0 + e1) + AbsRHO_U2 * (e0 - e1)) * A;
281 flux[FV->RHO] = 2.0 * RHO_U2 * A;
284 for(
MInt r = 0; r < PV->m_noRansEquations; ++r) {
285 const MFloat NL = leftVars[PV->NN[r]];
286 const MFloat NR = rightVars[PV->NN[r]];
287 flux[FV->RHO_NN[r]] = (RHO_U2 * (NL + NR) + AbsRHO_U2 * (NL - NR)) * A;
292 for(
MUint s = 0; s < PV->m_noSpecies; ++s) {
293 const MFloat YsL = leftVars[PV->Y[s]];
294 const MFloat YsR = rightVars[PV->Y[s]];
295 flux[FV->RHO_Y[s]] = (RHO_U2 * (YsL + YsR) + AbsRHO_U2 * (YsL - YsR)) * A;
299template <MInt nDim,
class RANSModel>
301 const MFloat*
const leftVars,
303 const MFloat PL = leftVars[PV->P];
304 const MFloat PR = rightVars[PV->P];
305 const MFloat PLR = 0.5 * (PR + PL);
307 std::array<MFloat, nDim> pFactor{};
308 pFactor[orientation] = 1.0;
310 for(
MInt n = 0; n < nDim; n++) {
311 flux[FV->RHO_VV[n]] = PLR * pFactor[n] * A;
314 flux[FV->RHO_E] = 0.0;
318 for(
MInt r = 0; r < PV->m_noRansEquations; ++r) {
319 flux[FV->RHO_NN[r]] = 0.0;
324 for(
MUint s = 0; s < PV->m_noSpecies; ++s) {
325 flux[FV->RHO_Y[s]] = 0.0;
329template <MInt nDim,
class RANSModel>
333 const MFloat*
const NotUsed(srfcCoeff),
const MFloat f0,
335 static const MFloat rhoUDth = m_muInfinity * m_F1BPr;
336 static const MFloat F1BRe0 = F1 / m_Re0;
339 const std::array<MFloat, nDim> velocity = [&] {
340 std::array<MFloat, nDim> tmp{};
341 for(
MUint n = 0; n < nDim; n++) {
342 tmp[n] = F1B2 * (vars0[PV->VV[n]] + vars1[PV->VV[n]]);
347 const MFloat rho = F1B2 * (vars0[PV->RHO] + vars1[PV->RHO]);
348 const MFloat Frho = F1 / rho;
349 const MFloat p = F1B2 * (vars0[PV->P] + vars1[PV->P]);
352 const MFloat T = m_gamma * p * Frho;
355 const MUint id0 = orientation;
356 const MUint id1 = index0[orientation];
357 const MUint id2 = index1[orientation];
360 const MFloat dAOverRe = A * F1BRe0;
363 const MFloat mue = (T * sqrt(T) * m_sutherlandPlusOne) / (T + m_sutherlandConstant);
369 const MFloat nuTilde = F1B2 * (vars0[PV->N] + vars1[PV->N]);
370 const MFloat nuLaminar = mue / rho;
371 const MFloat chi = nuTilde / (nuLaminar);
373 const MFloat nuTurb = fv1 * nuTilde;
375 mue_t = rho * nuTurb;
378 IF_CONSTEXPR(m_ransModel ==
RANS_FS) {
379 const MFloat nuTilde = F1B2 * (vars0[PV->N] + vars1[PV->N]);
380 const MFloat nuLaminar = mue / rho;
381 const MFloat chi = nuTilde / (nuLaminar);
383 const MFloat nuTurb = fv1 * nuTilde;
385 mue_t = rho * nuTurb;
389 const MFloat k = F1B2 * (vars0[PV->K] + vars1[PV->K]);
390 const MFloat o = F1B2 * (vars0[PV->OMEGA] + vars1[PV->OMEGA]);
391 const MFloat nuTurb = k / o;
393 mue_t = rho * nuTurb;
398 const MFloat lambda_t = mue_t / m_Pr_t;
412 const MFloat lambda = (T * sqrt(T) * m_sutherlandPlusOneThermal) / (T + m_sutherlandConstantThermal);
414 const MUint sq0 = PV->P * nDim + id0;
415 const MUint sq1 = PV->RHO * nDim + id0;
416 const MFloat q = (lambda + lambda_t) * m_gFGMOrPr * Frho
417 * ((f0 * slope0[sq0] + f1 * slope1[sq0]) - p * Frho * (f0 * slope0[sq1] + f1 * slope1[sq1]));
420 const MUint s00 = id0 * nDim + id0;
421 const MUint s01 = id0 * nDim + id1;
422 const MUint s10 = id1 * nDim + id0;
423 const MUint s11 = id1 * nDim + id1;
425 std::array<MFloat, nDim> tau{};
426 IF_CONSTEXPR(nDim == 2) {
427 tau[id0] = (mue + mue_t + mue_wm)
428 * (f0 * (F4B3 * slope0[s00] - F2B3 * slope0[s11]) + f1 * (F4B3 * slope1[s00] - F2B3 * slope1[s11]));
429 tau[id1] = (mue + mue_t + mue_wm) * (f0 * (slope0[s01] + slope0[s10]) + f1 * (slope1[s01] + slope1[s10]));
431 else IF_CONSTEXPR(nDim == 3) {
432 const MUint s22 = id2 * nDim + id2;
433 const MUint s02 = id0 * nDim + id2;
434 const MUint s20 = id2 * nDim + id0;
435 tau[id0] = (mue + mue_t + mue_wm)
436 * (f0 * (F4B3 * slope0[s00] - F2B3 * (slope0[s11] + slope0[s22]))
437 + f1 * (F4B3 * slope1[s00] - F2B3 * (slope1[s11] + slope1[s22])));
438 tau[id1] = (mue + mue_t + mue_wm) * (f0 * (slope0[s01] + slope0[s10]) + f1 * (slope1[s01] + slope1[s10]));
439 tau[id2] = (mue + mue_t + mue_wm) * (f0 * (slope0[s02] + slope0[s20]) + f1 * (slope1[s02] + slope1[s20]));
443 for(
MUint n = 0; n < nDim; n++) {
444 flux[FV->RHO_VV[n]] -= dAOverRe * tau[n];
446 flux[FV->RHO_E] -= dAOverRe * (std::inner_product(velocity.begin(), velocity.end(), tau.begin(), 0.0) + q);
449 const MUint n0 = PV->N * nDim + id0;
450 const MUint rho0 = PV->RHO * nDim + id0;
452 const MFloat nuTilde = F1B2 * (vars0[PV->N] + vars1[PV->N]);
456 * (mue * (f0 * slope0[n0] + f1 * slope1[n0])
457 + sqrt(rho) * nuTilde
458 * (sqrt(rho) * (f0 * slope0[n0] + f1 * slope1[n0])
459 + nuTilde * F1 / (F2 * sqrt(rho)) * (f0 * slope0[rho0] + f1 * slope1[rho0])));
464 flux[FV->RHO_N] -= dAOverRe * (viscflux_nu);
467 IF_CONSTEXPR(m_ransModel ==
RANS_FS) {
468 const MUint n0 = PV->N * nDim + id0;
469 const MFloat nuTilde = F1B2 * (vars0[PV->N] + vars1[PV->N]);
470 const MFloat nuLaminar = mue / rho;
471 MFloat viscflux_nu = rho * (nuLaminar +
RM_FS::fasigma * nuTilde) * (f0 * slope0[n0] + f1 * slope1[n0]);
472 flux[FV->RHO_N] -= dAOverRe * (viscflux_nu);
476 const MUint n0 = PV->N * nDim + id0;
477 const MUint rho0 = PV->RHO * nDim + id0;
479 const MFloat nuTilde = F1B2 * (vars0[PV->N] + vars1[PV->N]);
481 * (mue * (f0 * slope0[n0] + f1 * slope1[n0])
482 + sqrt(rho) * nuTilde
483 * (sqrt(rho) * (f0 * slope0[n0] + f1 * slope1[n0])
484 + nuTilde * F1 / (F2 * sqrt(rho)) * (f0 * slope0[rho0] + f1 * slope1[rho0])));
486 flux[FV->RHO_N] -= dAOverRe * (viscflux_nu);
487 const MUint nk = PV->K * nDim + id0;
488 const MUint no = PV->OMEGA * nDim + id0;
490 const MFloat k = F1B2 * (vars0[PV->K] + vars1[PV->K]);
491 const MFloat omega = F1B2 * (vars0[PV->OMEGA] + vars1[PV->OMEGA]);
492 const MFloat mueTurb = rho * k / omega;
497 flux[FV->RHO_K] -= dAOverRe * (viscflux_k);
498 flux[FV->RHO_OMEGA] -= dAOverRe * (viscflux_omega);
503 const MFloat c = dAOverRe * rhoUDth;
504 for(
MUint s = 0; s < PV->m_noSpecies; ++s) {
505 const MUint i = PV->Y[s] * nDim + id0;
506 flux[FV->RHO_Y[s]] -= c * (f0 * slope0[i] + f1 * slope1[i]);
510template <MInt nDim,
class RANSModel>
513 const MFloat*
const coord0,
const MFloat*
const coord1,
const MFloat*
const cellVars0,
516 static const MFloat rhoUDth = m_muInfinity * m_F1BPr;
517 static const MFloat F1BRe0 = F1 / m_Re0;
520 const std::array<MFloat, nDim> velocity = [&] {
521 std::array<MFloat, nDim> tmp{};
522 for(
MUint n = 0; n < nDim; n++) {
523 tmp[n] = F1B2 * (vars0[PV->VV[n]] + vars1[PV->VV[n]]);
528 const MFloat rho = F1B2 * (vars0[PV->RHO] + vars1[PV->RHO]);
529 const MFloat Frho = F1 / rho;
530 const MFloat p = F1B2 * (vars0[PV->P] + vars1[PV->P]);
533 const MFloat T = m_gamma * p * Frho;
536 const MUint id0 = orientation;
537 const MUint id1 = index0[orientation];
538 const MUint id2 = index1[orientation];
541 const MFloat dAOverRe = A * F1BRe0;
544 const MFloat mue = (T * sqrt(T) * m_sutherlandPlusOne) / (T + m_sutherlandConstant);
546 const MFloat lambda = (T * sqrt(T) * m_sutherlandPlusOneThermal) / (T + m_sutherlandConstantThermal);
549 std::vector<MFloat> slopes(PV->noVariables * nDim);
554 for(
MInt var = 0; var < PV->noVariables; var++) {
555 slopes[nDim * var + id0] =
562 + (surfaceCoords[id1] - coord1[id1]) * slope1[var * nDim + id1]
563 - (surfaceCoords[id1] - coord0[id1]) * slope0[var * nDim + id1];
564 IF_CONSTEXPR(nDim == 3) {
565 slopes[nDim * var + id0] += (surfaceCoords[id2] - coord1[id2]) * slope1[var * nDim + id2]
566 - (surfaceCoords[id2] - coord0[id2]) * slope0[var * nDim + id2];
573 slopes[nDim * var + id0] /= (coord1[id0] - coord0[id0]);
577 slopes[nDim * var + id1] = f0 * slope0[var * nDim + id1] + f1 * slope1[var * nDim + id1];
578 IF_CONSTEXPR(nDim == 3) {
579 slopes[nDim * var + id2] = f0 * slope0[var * nDim + id2] + f1 * slope1[var * nDim + id2];
582 slopes[nDim * var + id0] = f0 * slope0[var * nDim + id0] + f1 * slope1[var * nDim + id0];
586 const MUint sq0 = PV->P * nDim + id0;
587 const MUint sq1 = PV->RHO * nDim + id0;
589 const MFloat q = lambda * m_gFGMOrPr * Frho * (slopes[sq0] - p * Frho * slopes[sq1]);
592 const MUint s00 = id0 * nDim + id0;
593 const MUint s01 = id0 * nDim + id1;
594 const MUint s10 = id1 * nDim + id0;
595 const MUint s11 = id1 * nDim + id1;
597 std::array<MFloat, nDim> tau{};
598 IF_CONSTEXPR(nDim == 2) {
599 tau[id0] = mue * (F4B3 * slopes[s00] - F2B3 * slopes[s11]);
600 tau[id1] = mue * (slopes[s01] + slopes[s10]);
602 else IF_CONSTEXPR(nDim == 3) {
603 const MUint s22 = id2 * nDim + id2;
604 const MUint s02 = id0 * nDim + id2;
605 const MUint s20 = id2 * nDim + id0;
606 tau[id0] = mue * (F4B3 * slopes[s00] - F2B3 * (slopes[s11] + slopes[s22]));
607 tau[id1] = mue * (slopes[s01] + slopes[s10]);
608 tau[id2] = mue * (slopes[s02] + slopes[s20]);
612 for(
MUint n = 0; n < nDim; n++) {
613 flux[FV->RHO_VV[n]] -= dAOverRe * tau[n];
615 flux[FV->RHO_E] -= dAOverRe * (std::inner_product(velocity.begin(), velocity.end(), tau.begin(), 0.0) + q);
618 const MFloat c = dAOverRe * rhoUDth;
619 for(
MUint s = 0; s < PV->m_noSpecies; ++s) {
620 const MUint i = PV->Y[s] * nDim + id0;
621 flux[FV->RHO_Y[s]] -= c * (f0 * slope0[i] + f1 * slope1[i]);
625template <MInt nDim,
class RANSModel>
628 const MFloat*
const NotUsed(avarsCell)) {
629 const MFloat fRho = F1 / cvarsCell[CV->RHO];
631 for(
MInt n = 0; n < nDim; ++n) {
632 pvarsCell[PV->VV[n]] = cvarsCell[CV->RHO_VV[n]] * fRho;
633 velPOW2 +=
POW2(pvarsCell[PV->VV[n]]);
637 pvarsCell[PV->RHO] = cvarsCell[CV->RHO];
638 pvarsCell[PV->P] = m_gammaMinusOne * (cvarsCell[CV->RHO_E] - F1B2 * pvarsCell[PV->RHO] * velPOW2);
641 for(
MInt r = 0; r < PV->m_noRansEquations; r++) {
642 pvarsCell[PV->NN[r]] = cvarsCell[CV->RHO_NN[r]] * fRho;
646 for(
MUint s = 0; s < PV->m_noSpecies; ++s) {
647 pvarsCell[PV->Y[s]] = cvarsCell[CV->RHO_Y[s]] * fRho;
651template <MInt nDim,
class RANSModel>
654 const MFloat*
const NotUsed(avarsCell)) {
657 for(
MInt vel = 0; vel < nDim; ++vel) {
658 const MFloat v = pvarsCell[vel];
659 cvarsCell[vel] = v * pvarsCell[PV->RHO];
664 cvarsCell[CV->RHO_E] = pvarsCell[PV->P] * m_F1BGammaMinusOne + F1B2 * pvarsCell[PV->RHO] * velPOW2;
667 cvarsCell[CV->RHO] = pvarsCell[PV->RHO];
669 for(
MInt r = 0; r < PV->m_noRansEquations; r++) {
670 cvarsCell[CV->RHO_NN[r]] = pvarsCell[PV->NN[r]] * pvarsCell[PV->RHO];
674 for(
MUint s = 0; s < PV->m_noSpecies; ++s) {
675 cvarsCell[CV->RHO_Y[s]] = pvarsCell[PV->Y[s]] * pvarsCell[PV->RHO];
679template <MInt nDim,
class RANSModel>
680inline std::vector<std::vector<MFloat>>
682 const MFloat*
const NotUsed(avarsCell),
683 const MFloat*
const slopesCell) {
685 for(
MInt i = 0; i < nDim; i++) {
686 U2 +=
POW2(pvarsCell[PV->VV[i]]);
689 std::vector<std::vector<MFloat>> dQ(CV->noVariables, std::vector<MFloat>(nDim));
691 for(
MInt d = 0; d < nDim; d++) {
692 dQ[CV->RHO][d] = slopesCell[PV->RHO * nDim + d];
693 dQ[CV->RHO_E][d] = slopesCell[PV->P * nDim + d] / (m_gamma - F1) + F1B2 * U2 * slopesCell[PV->RHO * nDim + d];
695 for(
MInt j = 0; j < nDim; j++) {
696 dQ[CV->RHO_VV[j]][d] =
697 pvarsCell[PV->VV[j]] * slopesCell[PV->RHO * nDim + d] + pvarsCell[PV->RHO] * slopesCell[PV->VV[j] * nDim + d];
698 dQ[CV->RHO_E][d] += pvarsCell[PV->RHO] * pvarsCell[PV->VV[j]] * slopesCell[PV->VV[j] * nDim + d];
701 for(
MInt r = 0; r < m_noRansEquations; r++) {
702 dQ[CV->RHO_NN[r]][d] =
703 pvarsCell[PV->NN[r]] * slopesCell[PV->RHO * nDim + d] + pvarsCell[PV->RHO] * slopesCell[PV->NN[r] * nDim + d];
706 for(
MUint s = 0; s < CV->m_noSpecies; ++s) {
707 dQ[CV->RHO_Y[s]][d] =
708 pvarsCell[PV->Y[s]] * slopesCell[PV->RHO * nDim + d] + pvarsCell[PV->RHO] * slopesCell[PV->Y[s] * nDim + d];
715template <MInt nDim,
class RANSModel>
718 const MInt recData,
const MInt*
const ,
723 std::ignore = recData;
724 std::ignore = noRecNghbr;
726 const MFloat rRe = F1 / m_Re0;
727 const MFloat rho = vars[cellId * PV->noVariables + PV->RHO];
728 const MFloat p = vars[cellId * PV->noVariables + PV->P];
729 const MFloat nuTilde = vars[cellId * PV->noVariables + PV->N];
730 const MFloat T = m_gamma * p / rho;
731 const MFloat mue = (T * sqrt(T) * m_sutherlandPlusOne) / (T + m_sutherlandConstant);
732 const MFloat nuLaminar = mue / rho;
739 for(
MInt d = 0; d < nDim; d++) {
740 MInt indexRho = cellId * PV->noVariables * nDim + PV->RHO * nDim + d;
741 MInt indexNT = cellId * PV->noVariables * nDim + PV->N * nDim + d;
743 *
POW2((sqrt(rho) * slopes[indexNT] + nuTilde * slopes[indexRho] / (2 * sqrt(rho))));
750 for(
MInt d1 = 0; d1 < nDim; d1++) {
751 for(
MInt d2 = 0; d2 < nDim; d2++) {
752 MInt indexVV12 = cellId * PV->noVariables * nDim + PV->VV[d1] * nDim + d2;
753 MInt indexVV21 = cellId * PV->noVariables * nDim + PV->VV[d2] * nDim + d1;
754 MFloat wij = 0.5 * (slopes[indexVV12] - slopes[indexVV21]);
760 const MFloat chi = nuTilde / (nuLaminar);
762 const MFloat Fv2 = F1 - (chi / (F1 + chi * fv1));
765 const MFloat stilde = s + term * Fv2 * rRe;
766 const MFloat r =
mMin(10.0, rRe * term / stilde);
769 const MFloat Fw = g * pow(Fwterm, (1.0 / 6.0));
775 MFloat prodDest = rho * (P - D);
777 rhs[CV->RHO_N] -= cellVol * (prodDest + diff);
780template <MInt nDim,
class RANSModel>
783 const MInt recData,
const MInt*
const recNghbr,
784 const MFloat*
const recConst,
const MInt noRecNghbr,
786 const MFloat rRe = F1 / m_Re0;
788 const MFloat rho = vars[cellId * PV->noVariables + PV->RHO];
789 const MFloat p = vars[cellId * PV->noVariables + PV->P];
790 const MFloat nuTilde = vars[cellId * PV->noVariables + PV->N];
791 const MFloat T = m_gamma * p / rho;
792 const MFloat mue = (T * sqrt(T) * m_sutherlandPlusOne) / (T + m_sutherlandConstant);
793 const MFloat nuLaminar = mue / rho;
799 for(
MInt d1 = 0; d1 < nDim; d1++) {
800 MInt indexN1 = cellId * PV->noVariables * nDim + PV->N * nDim + d1;
801 MInt indexRHO1 = cellId * PV->noVariables * nDim + PV->RHO * nDim + d1;
802 diff2 += slopes[indexN1] * slopes[indexRHO1];
803 for(
MInt d2 = 0; d2 < nDim; d2++) {
804 MInt indexVV12 = cellId * PV->noVariables * nDim + PV->VV[d1] * nDim + d2;
805 MInt indexVV21 = cellId * PV->noVariables * nDim + PV->VV[d2] * nDim + d1;
806 MFloat sij = 0.5 * (slopes[indexVV12] + slopes[indexVV21]);
807 MFloat wij = 0.5 * (slopes[indexVV12] - slopes[indexVV21]);
809 for(
MInt d3 = 0; d3 < nDim; d3++) {
810 MInt indexVV13 = cellId * PV->noVariables * nDim + PV->VV[d1] * nDim + d3;
811 MInt indexVV31 = cellId * PV->noVariables * nDim + PV->VV[d3] * nDim + d1;
812 MInt indexVV23 = cellId * PV->noVariables * nDim + PV->VV[d2] * nDim + d3;
813 MInt indexVV32 = cellId * PV->noVariables * nDim + PV->VV[d3] * nDim + d2;
814 MFloat ski = 0.5 * (slopes[indexVV13] + slopes[indexVV31]);
815 MFloat wjk = 0.5 * (slopes[indexVV23] - slopes[indexVV32]);
816 OijOjkSki += wij * wjk * ski;
831 for(
MInt nghbr = 0; nghbr < noRecNghbr; nghbr++) {
832 const MInt nghbrId = recNghbr[nghbr];
836 for(
MInt d1 = 0; d1 < nDim; d1++) {
837 for(
MInt d2 = 0; d2 < nDim; d2++) {
838 MInt indexVV12 = nghbrId * PV->noVariables * nDim + PV->VV[d1] * nDim + d2;
839 MInt indexVV21 = nghbrId * PV->noVariables * nDim + PV->VV[d2] * nDim + d1;
840 MFloat sijNgbhr = 0.5 * (slopes[indexVV12] + slopes[indexVV21]);
841 SijSijNgbhr += sijNgbhr * sijNgbhr;
846 const MFloat nutildeNgbhr = vars[nghbrId * PV->noVariables + PV->N];
847 for(
MInt d = 0; d < nDim; d++) {
848 const MFloat recConst_ = recConst[nDim * (recData + nghbr) + d];
849 const MFloat deltaOmega = omegaNgbhr - omega;
850 const MFloat deltaNutilde = nutildeNgbhr - nuTilde;
851 domega[d] += recConst_ * deltaOmega;
852 dnutilde[d] += recConst_ * deltaNutilde;
856 for(
MInt d = 0; d < nDim; ++d) {
857 term1 += domega[d] * domega[d];
858 term2 += dnutilde[d] * domega[d];
862 const MFloat psi_k =
mMax(F0, F1 / pow(omega, F3) * (nuTilde * term1 + omega * term2));
870 for(
MInt d1 = 0; d1 < nDim; d1++) {
871 for(
MInt d2 = 0; d2 < nDim; d2++) {
872 MInt indexVV12 = cellId * PV->noVariables * nDim + PV->VV[d1] * nDim + d2;
873 MInt indexVV21 = cellId * PV->noVariables * nDim + PV->VV[d2] * nDim + d1;
874 Sijduidxj += 0.5 * slopes[indexVV12] * (slopes[indexVV12] + slopes[indexVV21]);
876 MInt indexVV11 = cellId * PV->noVariables * nDim + PV->VV[d1] * nDim + d1;
877 duidxi += slopes[indexVV11];
882 MFloat D_FS = (beta_s - beta) * nuTilde * omega;
885 const MFloat prodDest_FS = rho * (P_FS - D_FS);
895 const MFloat diff_FS = diff1 - diff2;
897 rhs[CV->RHO_N] -= cellVol * (prodDest_FS + diff_FS - k);
900template <MInt nDim,
class RANSModel>
908 const MFloat rRe = F1 / m_Re0;
909 const MFloat rho = vars[cellId * PV->noVariables + PV->RHO];
910 const MFloat k = vars[cellId * PV->noVariables + PV->K];
911 const MFloat omega = vars[cellId * PV->noVariables + PV->OMEGA];
914 for(
MInt d = 0; d < nDim; d++) {
915 dukdxk += slopes[PV->VV[d] * nDim + d];
921 const MFloat mue_Turb = rho * k / omega_hat;
926 for(
MInt d1 = 0; d1 < nDim; d1++) {
927 for(
MInt d2 = 0; d2 < nDim; d2++) {
928 tau = rRe * mue_Turb * (slopes[PV->VV[d1] * nDim + d2] + slopes[PV->VV[d2] * nDim + d1]);
930 tau -= ( F2B3 * rho * k);
932 P += slopes[PV->VV[d1] * nDim + d2] * tau;
934 term += slopes[PV->K * nDim + d1] * slopes[PV->OMEGA * nDim + d1];
938 for(
MInt d1 = 0; d1 < nDim; d1++) {
939 for(
MInt d2 = 0; d2 < nDim; d2++) {
940 MFloat wij = 0.5 * (slopes[PV->VV[d1] * nDim + d2] - slopes[PV->VV[d2] * nDim + d1]);
941 for(
MInt d3 = 0; d3 < nDim; d3++) {
942 MFloat ski = 0.5 * (slopes[PV->VV[d3] * nDim + d1] + slopes[PV->VV[d1] * nDim + d3]);
943 MFloat wjk = 0.5 * (slopes[PV->VV[d2] * nDim + d3] - slopes[PV->VV[d3] * nDim + d2]);
944 OijOjkSki += wij * wjk * ski;
957 const MFloat D_o = Re * beta * rho *
POW2(omega);
964 const MFloat prodDest_K = P_k - D_k;
965 const MFloat prodDest_OMEGA = P_o - D_o;
967 rhs[CV->RHO_K] -= cellVol * (prodDest_K);
968 rhs[CV->RHO_OMEGA] -= cellVol * (prodDest_OMEGA);
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
static constexpr MInt m_ransModel
void viscousFlux(const MInt orientation, const MFloat A, const MBool isBndry, const MFloat *const surfaceCoords, const MFloat *const coord0, const MFloat *const coord1, const MFloat *const cellVars0, const MFloat *const cellVars1, const MFloat *const vars0, const MFloat *const vars1, const MFloat *const slope0, const MFloat *const slope1, const MFloat f0, const MFloat f1, MFloat *const flux)
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)
static constexpr std::array< MInt, nDim > getArray012()
void computeConservativeVariables(const MFloat *const pvarsCell, MFloat *const cvarsCell, const MFloat *const NotUsed(avarsCell))
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 NotUsed(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)
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 computeVolumeForcesRANS_FS(const MInt cellId, MFloat *vars, MFloat *rhs, MFloat cellVol, const MFloat *const slopes, MInt recData, const MInt *const recNghbr, const MFloat *const recConst, MInt noRecNghbr, MFloat)
static constexpr MBool hasSC
void computeVolumeForces(const MInt cellId, MFloat *vars, MFloat *rhs, const MFloat cellVol, const MFloat *const slopes, const MInt recData, const MInt *const recNghbr, const MFloat *const recConst, const MInt noRecNghbr, MFloat dist)
ConservativeVariables * CV
void computeVolumeForcesRANS_SA(const MInt cellId, MFloat *vars, MFloat *rhs, const MFloat cellVol, const MFloat *const slopes, const MInt recData, const MInt *const, const MFloat *const, const MInt noRecNghbr, MFloat dist)
void viscousFluxThreePoint(const MInt orientation, const MFloat A, const MBool isBndry, const MFloat *const surfaceCoords, const MFloat *const coord0, const MFloat *const coord1, const MFloat *const cellVars0, const MFloat *const cellVars1, const MFloat *const vars0, const MFloat *const vars1, const MFloat *const slope0, const MFloat *const slope1, const MFloat f0, const MFloat f1, MFloat *const flux)
std::vector< std::vector< MFloat > > conservativeSlopes(const MFloat *const pvarsCell, const MFloat *const cvarsCell, const MFloat *const avarsCell, const MFloat *const slopesCell)
static constexpr MInt m_noRansEquations
void computePrimitiveVariables(const MFloat *const cvarsCell, MFloat *const pvarsCell, const MFloat *const NotUsed(avarsCell))
void computeVolumeForcesRANS_KOMEGA(const MInt cellId, MFloat *vars, MFloat *rhs, const MFloat cellVol, const MFloat *const slopes, const MInt, const MInt *const, const MFloat *const, const MInt, MFloat)
constexpr Real POW2(const Real x)
constexpr T mMin(const T &x, const T &y)
constexpr T mMax(const T &x, const T &y)
std::basic_string< char > MString
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Static indices for accessing conservative variables in nDim spatial dimensions.
Static indices for accessing primitive variables in nDim spatial dimensions.
static std::vector< MString > varNames
static constexpr MFloat faalpha
static constexpr MFloat fapsik2
static constexpr MFloat fabetcs
static constexpr MFloat fapsik1
static constexpr MFloat fasigma
static constexpr MFloat facv1to3
static constexpr MFloat fabetc
static constexpr MFloat fapsio2
static constexpr MFloat fapsio1
static constexpr MFloat sigma_o
static constexpr MFloat sigma_k
static constexpr MFloat beta
static constexpr MFloat betas
static constexpr MFloat alpha
static constexpr MFloat fbeta1
static constexpr MFloat fbeta2
static constexpr MFloat cw1
static constexpr MFloat Fsigma
static constexpr MFloat cv1to3
static constexpr MFloat cw3to6
static constexpr MFloat Ft2
static constexpr MFloat cb2
static constexpr MFloat Fkap2
static constexpr MFloat cw2
static constexpr MFloat cb1