76 template <EulerModel model = NS>
82 static const int dim = getDim_Fixed(model);
83 static const int gDim = getGeomDim_Fixed(model);
125 vfv->SetPeriodicTransformations(
129 u(EigenAll, Seq123) =
mesh->periodicInfo.TransVector<
dim, Eigen::Dynamic>(u(EigenAll, Seq123).transpose(), id).transpose();
134 u(EigenAll, Seq123) =
mesh->periodicInfo.TransVectorBack<
dim, Eigen::Dynamic>(u(EigenAll, Seq123).transpose(), id).transpose();
137 vfv->ConstructMetrics();
138 vfv->ConstructBaseAndWeight(
145 return iOrder ? 0. : 1.;
147 return iOrder ? 0. : 1.;
149 return iOrder ? 1. : 1.;
151 return iOrder ? 0. : 1.;
153 vfv->ConstructRecCoeff();
162 bool passiveDiscardSource =
false;
169 int axisSymmetric = 0;
197 std::vector<Eigen::Vector<real, Eigen::Dynamic>>
dWall;
238 int n_nVars = getNVars(model))
245 DNDS_assert_info(nVars == getNVars(model),
"do not change the nVars for this model");
268 v.resize(Eigen::NoChange, nVars);
282 Gas::IdealGasThermalConservative2Primitive<dim>(
settings.farFieldStaticValue, farPrim, gamma);
283 real T = farPrim(
I4) / ((gamma - 1) / gamma *
settings.idealGasProperty.CpGas * farPrim(0));
291 symLU = std::make_shared<Direct::SerialSymLUStructure>(
mesh->getMPI(),
mesh->NumCell());
293 for (
auto &name :
settings.cLDriverBCNames)
297 if (bcID >= Geom::BC_ID_DEFAULT_MAX)
299 "you have to set integrationOption == 1 to make this bc available by CLDriver");
301 DNDS_assert_info(bcID == Geom::BC_ID_DEFAULT_WALL || bcID == Geom::BC_ID_DEFAULT_WALL_INVIS,
302 "default bc must be WALL or WALL_INVIS for CLDriver");
321 void GetWallDist_CollectTriangles(
bool useQuadPatches,
322 std::vector<Eigen::Matrix<real, 3, 3>> &trianglesOut);
325 void GetWallDist_AABB();
328 void GetWallDist_BatchedAABB();
331 void GetWallDist_Poisson();
334 void GetWallDist_ComputeFaceDistances();
407 bool onlyOnHalfAlpha,
480 [[deprecated(
"Use UpdateSGS with uIncIsZero=true instead")]]
494 [[deprecated(
"Use UpdateSGS with uIncIsZero=true instead")]]
521 bool forward,
bool gsUpdate,
TU &sumInc,
522 bool uIncIsZero =
false);
578 bool forward,
TU &sumInc);
628 Eigen::Vector<real, -1> &
res,
632 bool compare =
false,
634 {
return TU::Zero(); },
717 real relax,
int compress = 1,
754 switch (
settings.idealGasProperty.muModel)
757 return settings.idealGasProperty.muGas;
761 return settings.idealGasProperty.muGas *
762 TRel * std::sqrt(TRel) *
764 (T +
settings.idealGasProperty.CSutherland);
769 return settings.idealGasProperty.muGas * U(0);
775 return std::nan(
"0");
797 real Chi = uMean(
I4 + 1) * muRef / muf;
798#ifdef USE_NS_SA_NEGATIVE_MODEL
800 Chi = 0.05 * std::log(1 + std::exp(20 * Chi));
803 real fnu1 = Chi3 / (Chi3 + std::pow(RANS::SA::cnu1, 3));
804 muTur = muf * std::max((Chi * fnu1), 0.0);
810 mut = RANS::GetMut_SST<dim>(uMean, GradUMeanXY, muf,
dWallFace[iFace]);
812 mut = RANS::GetMut_KOWilcox<dim>(uMean, GradUMeanXY, muf,
dWallFace[iFace]);
814 mut = RANS::GetMut_RealizableKe<dim>(uMean, GradUMeanXY, muf,
dWallFace[iFace]);
841 real sigma = RANS::SA::sigma;
843#ifdef USE_NS_SA_NEGATIVE_MODEL
844 if (UMeanXYC(
I4 + 1) < 0)
846 real Chi = UMeanXYC(
I4 + 1) * muRef / mufPhy;
847 fn = (RANS::SA::cn1 + std::pow(Chi, 3)) / (RANS::SA::cn1 - std::pow(Chi, 3));
850 VisFlux(
I4 + 1) = DiffUxyPrimC(Seq012, {
I4 + 1}).dot(uNormC) * (mufPhy + UMeanXYC(
I4 + 1) * muRef * fn) / sigma;
852 real tauPressure = DiffUxyPrimC(Seq012, Seq123).trace() * (2. / 3.) * (muTur);
854 VisFlux(Seq123) -= tauPressure * uNormC;
855 VisFlux(
I4) -= tauPressure * UMeanXYC(Seq123).dot(uNormC) / UMeanXYC(0);
860 RANS::GetVisFlux_SST<dim>(UMeanXYC, DiffUxyPrimC, uNormC, muTur,
dWallFace[iFace], mufPhy, VisFlux);
862 RANS::GetVisFlux_KOWilcox<dim>(UMeanXYC, DiffUxyPrimC, uNormC, muTur,
dWallFace[iFace], mufPhy, VisFlux);
864 RANS::GetVisFlux_RealizableKe<dim>(UMeanXYC, DiffUxyPrimC, uNormC, muTur,
dWallFace[iFace], mufPhy, VisFlux);
882 if (!
mesh->isPeriodic)
884 auto faceID =
mesh->GetFaceZone(iFace);
888 if2c =
vfv->CellIsFaceBack(iCell, iFace) ? 0 : 1;
890 u(Seq123) =
mesh->periodicInfo.TransVectorBack(Eigen::Vector<real, dim>{u(Seq123)}, faceID);
892 u(Seq123) =
mesh->periodicInfo.TransVector(Eigen::Vector<real, dim>{u(Seq123)}, faceID);
899 if (!
mesh->isPeriodic)
901 auto faceID =
mesh->GetFaceZone(iFace);
905 if2c =
vfv->CellIsFaceBack(iCell, iFace) ? 0 : 1;
907 u(Seq123) =
mesh->periodicInfo.TransVector(Eigen::Vector<real, dim>{u(Seq123)}, faceID);
909 u(Seq123) =
mesh->periodicInfo.TransVectorBack(Eigen::Vector<real, dim>{u(Seq123)}, faceID);
916 auto faceID =
mesh->GetFaceZone(iFace);
918 if2c =
vfv->CellIsFaceBack(iCell, iFace) ? 0 : 1;
919 mesh->CellOtherCellPeriodicHandle(
922 { u(Seq123) =
mesh->periodicInfo.TransVector(Eigen::Vector<real, dim>{u(Seq123)}, faceID); },
924 { u(Seq123) =
mesh->periodicInfo.TransVectorBack(Eigen::Vector<real, dim>{u(Seq123)}, faceID); });
931 if (!
mesh->isPeriodic)
933 auto faceID =
mesh->GetFaceZone(iFace);
937 if2c =
vfv->CellIsFaceBack(iCell, iFace) ? 0 : 1;
941 u(Seq012, EigenAll) =
mesh->periodicInfo.TransVectorBack<
dim,
nVarsFixed>(u(Seq012, EigenAll), faceID);
942 u(EigenAll, Seq123) =
mesh->periodicInfo.TransVectorBack<
dim,
dim>(u(EigenAll, Seq123).transpose(), faceID).transpose();
947 u(Seq012, EigenAll) =
mesh->periodicInfo.TransVector<
dim,
nVarsFixed>(u(Seq012, EigenAll), faceID);
948 u(EigenAll, Seq123) =
mesh->periodicInfo.TransVector<
dim,
dim>(u(EigenAll, Seq123).transpose(), faceID).transpose();
989 const TVec &unitNormC,
997 index iFace,
bool ignoreVis);
1036 const TVec &
n = uNorm;
1038 real rhoun =
n.dot(U({1, 2, 3}));
1039 real rhousqr = U({1, 2, 3}).squaredNorm();
1042 subFdU.resize(nVars, nVars);
1045 subFdU(0, 1) =
n(1 - 1);
1046 subFdU(0, 2) =
n(2 - 1);
1047 subFdU(0, 3) =
n(3 - 1);
1048 subFdU(1, 0) = -1.0 / (U(1 - 1) * U(1 - 1)) * U(2 - 1) * rhoun + (1.0 / (U(1 - 1) * U(1 - 1)) *
n(1 - 1) * (gamma - 1.0) * (rhousqr - U(1 - 1) * U(5 - 1) * 2.0)) / 2.0 + (U(5 - 1) *
n(1 - 1) * (gamma - 1.0)) / U(1 - 1);
1049 subFdU(1, 1) = (rhoun + U(2 - 1) *
n(1 - 1) * 2.0 - U(2 - 1) * gamma *
n(1 - 1)) / U(1 - 1);
1050 subFdU(1, 2) = (U(2 - 1) *
n(2 - 1)) / U(1 - 1) - (U(3 - 1) *
n(1 - 1) * (gamma - 1.0)) / U(1 - 1);
1051 subFdU(1, 3) = (U(2 - 1) *
n(3 - 1)) / U(1 - 1) - (U(4 - 1) *
n(1 - 1) * (gamma - 1.0)) / U(1 - 1);
1052 subFdU(1, 4) =
n(1 - 1) * (gamma - 1.0);
1053 subFdU(2, 0) = -1.0 / (U(1 - 1) * U(1 - 1)) * U(3 - 1) * rhoun + (1.0 / (U(1 - 1) * U(1 - 1)) *
n(2 - 1) * (gamma - 1.0) * (rhousqr - U(1 - 1) * U(5 - 1) * 2.0)) / 2.0 + (U(5 - 1) *
n(2 - 1) * (gamma - 1.0)) / U(1 - 1);
1054 subFdU(2, 1) = (U(3 - 1) *
n(1 - 1)) / U(1 - 1) - (U(2 - 1) *
n(2 - 1) * (gamma - 1.0)) / U(1 - 1);
1055 subFdU(2, 2) = (rhoun + U(3 - 1) *
n(2 - 1) * 2.0 - U(3 - 1) * gamma *
n(2 - 1)) / U(1 - 1);
1056 subFdU(2, 3) = (U(3 - 1) *
n(3 - 1)) / U(1 - 1) - (U(4 - 1) *
n(2 - 1) * (gamma - 1.0)) / U(1 - 1);
1057 subFdU(2, 4) =
n(2 - 1) * (gamma - 1.0);
1058 subFdU(3, 0) = -1.0 / (U(1 - 1) * U(1 - 1)) * U(4 - 1) * rhoun + (1.0 / (U(1 - 1) * U(1 - 1)) *
n(3 - 1) * (gamma - 1.0) * (rhousqr - U(1 - 1) * U(5 - 1) * 2.0)) / 2.0 + (U(5 - 1) *
n(3 - 1) * (gamma - 1.0)) / U(1 - 1);
1059 subFdU(3, 1) = (U(4 - 1) *
n(1 - 1)) / U(1 - 1) - (U(2 - 1) *
n(3 - 1) * (gamma - 1.0)) / U(1 - 1);
1060 subFdU(3, 2) = (U(4 - 1) *
n(2 - 1)) / U(1 - 1) - (U(3 - 1) *
n(3 - 1) * (gamma - 1.0)) / U(1 - 1);
1061 subFdU(3, 3) = (rhoun + U(4 - 1) *
n(3 - 1) * 2.0 - U(4 - 1) * gamma *
n(3 - 1)) / U(1 - 1);
1062 subFdU(3, 4) =
n(3 - 1) * (gamma - 1.0);
1063 subFdU(4, 0) = 1.0 / (U(1 - 1) * U(1 - 1) * U(1 - 1)) * rhoun * (-rhousqr + (U(2 - 1) * U(2 - 1)) * gamma + (U(3 - 1) * U(3 - 1)) * gamma + (U(4 - 1) * U(4 - 1)) * gamma - U(1 - 1) * U(5 - 1) * gamma);
1064 subFdU(4, 1) = 1.0 / (U(1 - 1) * U(1 - 1)) *
n(1 - 1) * (-rhousqr + (U(2 - 1) * U(2 - 1)) * gamma + (U(3 - 1) * U(3 - 1)) * gamma + (U(4 - 1) * U(4 - 1)) * gamma - U(1 - 1) * U(5 - 1) * gamma * 2.0) * (-1.0 / 2.0) - 1.0 / (U(1 - 1) * U(1 - 1)) * U(2 - 1) * rhoun * (gamma - 1.0);
1065 subFdU(4, 2) = 1.0 / (U(1 - 1) * U(1 - 1)) *
n(2 - 1) * (-rhousqr + (U(2 - 1) * U(2 - 1)) * gamma + (U(3 - 1) * U(3 - 1)) * gamma + (U(4 - 1) * U(4 - 1)) * gamma - U(1 - 1) * U(5 - 1) * gamma * 2.0) * (-1.0 / 2.0) - 1.0 / (U(1 - 1) * U(1 - 1)) * U(3 - 1) * rhoun * (gamma - 1.0);
1066 subFdU(4, 3) = 1.0 / (U(1 - 1) * U(1 - 1)) *
n(3 - 1) * (-rhousqr + (U(2 - 1) * U(2 - 1)) * gamma + (U(3 - 1) * U(3 - 1)) * gamma + (U(4 - 1) * U(4 - 1)) * gamma - U(1 - 1) * U(5 - 1) * gamma * 2.0) * (-1.0 / 2.0) - 1.0 / (U(1 - 1) * U(1 - 1)) * U(4 - 1) * rhoun * (gamma - 1.0);
1067 subFdU(4, 4) = (gamma * rhoun) / U(1 - 1);
1069 real un = rhoun / U(0);
1074 subFdU(5, 0) = -un * U(5) / U(0);
1075 subFdU(5, 1) =
n(0) * U(5) / U(0);
1076 subFdU(5, 2) =
n(1) * U(5) / U(0);
1077 subFdU(5, 3) =
n(2) * U(5) / U(0);
1082 subFdU(5, 0) = -un * U(5) / U(0);
1083 subFdU(5, 1) =
n(0) * U(5) / U(0);
1084 subFdU(5, 2) =
n(1) * U(5) / U(0);
1085 subFdU(5, 3) =
n(2) * U(5) / U(0);
1087 subFdU(6, 0) = -un * U(6) / U(0);
1088 subFdU(6, 1) =
n(0) * U(6) / U(0);
1089 subFdU(6, 2) =
n(1) * U(6) / U(0);
1090 subFdU(6, 3) =
n(2) * U(6) / U(0);
1109 int useRoeTerm,
int incFsign = -1,
int omitF = 0)
1118 Gas::IdealGasUIncrement<dim>(U,
dU,
velo, gamma, dVelo, dp);
1121 Gas::GasInviscidFluxFacialIncrement<dim>(
1129 if (useRoeTerm == 0)
1130 dF += incFsign * lambdaMain *
dU;
1134 real vsqrRoe{0}, aRoe{0}, asqrRoe{0}, HRoe{0};
1136 Gas::GetRoeAverage<dim>(U, UOther, gamma, veloRoe, vsqrRoe, aRoe, asqrRoe, HRoe, uMean);
1149 Gas::RoeFluxIncFDiff<dim>(
dU,
n, veloRoe, vsqrRoe, aRoe, asqrRoe, HRoe,
1150 incFsign * lambda0, incFsign * lambda123, incFsign * lambda4, gamma,
1152 dF += incFsign * lambdaVis *
dU;
1168 int useRoeTerm,
int incFsign = -1,
int omitF = 0)
1171 J.resize(nVars, nVars);
1173 for (
int i = 0; i < nVars; i++)
1175 U, UOther,
n,
vg, btype, J(EigenAll, i),
1176 lambdaMain, lambdaC, lambdaVis, lambda0, lambda123, lambda4,
1177 useRoeTerm, incFsign, omitF);
1196 Gas::IdealGasUIncrement<dim>(U,
dU,
velo, gamma, dVelo, dp);
1198 Gas::GasInviscidFluxFacialIncrement<dim>(
1213#ifdef USE_ABS_VELO_IN_ROTATION
1214 if (
settings.frameConstRotation.enabled)
1215 ret +=
settings.frameConstRotation.vOmega().cross(
vfv->GetFaceQuadraturePPhys(iFace, iG) -
settings.frameConstRotation.center)(Seq012);
1226#ifdef USE_ABS_VELO_IN_ROTATION
1227 if (
settings.frameConstRotation.enabled)
1228 ret +=
settings.frameConstRotation.vOmega().cross(
1229 (iG >= -1 ?
vfv->GetFaceQuadraturePPhys(iFace, iG) : pPhy) -
settings.frameConstRotation.center)(Seq012);
1240#ifdef USE_ABS_VELO_IN_ROTATION
1241 if (
settings.frameConstRotation.enabled)
1242 ret +=
settings.frameConstRotation.vOmega().cross(
vfv->GetFaceQuadraturePPhysFromCell(iFace, iCell, if2c, iG) -
settings.frameConstRotation.center)(Seq012);
1251 U(Seq123) += direction *
settings.frameConstRotation.vOmega().cross(pPhysics -
settings.frameConstRotation.center)(Seq012) * U(0);
1258#ifndef USE_ABS_VELO_IN_ROTATION
1259 U(
I4) -= U(Seq123).squaredNorm() / (2 * U(0));
1260 U(Seq123) += direction *
settings.frameConstRotation.vOmega().cross(pPhysics -
settings.frameConstRotation.center)(Seq012) * U(0);
1261 U(
I4) += U(Seq123).squaredNorm() / (2 * U(0));
1269#ifdef USE_ABS_VELO_IN_ROTATION
1270 U(
I4) -= U(Seq123).squaredNorm() / (2 * U(0));
1271 U(Seq123) += direction *
settings.frameConstRotation.vOmega().cross(pPhysics -
settings.frameConstRotation.center)(Seq012) * U(0);
1272 U(
I4) += U(Seq123).squaredNorm() / (2 * U(0));
1282 if (
pBCHandler->GetFlagFromIDSoft(i,
"anchorOpt") == 0)
1289 for (
index iBnd = 0; iBnd <
mesh->NumBnd(); iBnd++)
1294 auto f2c =
mesh->face2cell[iFace];
1295 auto gFace =
vfv->GetFaceQuad(iFace);
1298 auto faceBndID =
mesh->GetFaceZone(iFace);
1299 auto faceBCType =
pBCHandler->GetTypeFromID(faceBndID);
1301 if (
pBCHandler->GetFlagFromIDSoft(faceBndID,
"anchorOpt") == 0)
1303 gFace.IntegrationSimple(
1305 [&](
auto finc,
int iG)
1307 TU ULxy = u[f2c[0]];
1308 ULxy += (
vfv->GetIntPointDiffBaseValue(f2c[0], iFace, 0, iG, std::array<int, 1>{0}, 1) *
1312 real dist =
vfv->GetFaceQuadraturePPhys(iFace, iG).norm();
1313 if (
pBCHandler->GetValueExtraFromID(faceBndID).size() >= 3)
1316 dist = (
vfv->GetFaceQuadraturePPhys(iFace, iG) - vOrig).norm();
1322 v.second.ObtainAnchorMPI();
1358 const TMat &normBase,
1371 TU generateBV_FarField(
1372 TU &ULxy,
const TU &ULMeanXy,
1374 const TVec &uNorm,
const TMat &normBase,
1379 TU generateBV_SpecialFar(
1380 TU &ULxy,
const TU &ULMeanXy,
1382 const TVec &uNorm,
const TMat &normBase,
1387 TU generateBV_InviscidWall(
1388 TU &ULxy,
const TU &ULMeanXy,
1390 const TVec &uNorm,
const TMat &normBase,
1395 TU generateBV_ViscousWall(
1396 TU &ULxy,
const TU &ULMeanXy,
1398 const TVec &uNorm,
const TMat &normBase,
1403 TU generateBV_Outflow(
1404 TU &ULxy,
const TU &ULMeanXy,
1406 const TVec &uNorm,
const TMat &normBase,
1411 TU generateBV_Inflow(
1412 TU &ULxy,
const TU &ULMeanXy,
1414 const TVec &uNorm,
const TMat &normBase,
1419 TU generateBV_TotalConditionInflow(
1420 TU &ULxy,
const TU &ULMeanXy,
1422 const TVec &uNorm,
const TMat &normBase,
1433 if (
mesh->getMPI().rank != 0)
1437 std::string fname = name +
"_bc[" +
pBCHandler->GetNameFormID(
id) +
"]_profile.csv";
1438 std::filesystem::path outFile{fname};
1439 std::filesystem::create_directories(outFile.parent_path() /
".");
1440 std::ofstream fout(fname);
1442 bcProfile.OutProfileCSV(fout);
1451 auto intOpt =
pBCHandler->GetFlagFromIDSoft(i.first,
"integrationOpt");
1452 if (
mesh->getMPI().rank == 0)
1456 vPrint(Eigen::seq(nVars, nVars + 1)) /= i.second.div;
1457 log() << fmt::format(
"Bnd [{}] integarted values option [{}] : {:.5e}",
1459 intOpt, vPrint.transpose())
1468 if (
mesh->getMPI().rank != 0)
1472 auto intOpt =
pBCHandler->GetFlagFromIDSoft(
id,
"integrationOpt");
1475 std::string fname = name +
"_bc[" +
pBCHandler->GetNameFormID(
id) +
"]_integrationLog.csv";
1479 for (
int i = 0; i < bndInt.v.size(); i++)
1483 Eigen::Vector<real, Eigen::Dynamic> vPrint = bndInt.v;
1485 vPrint(Eigen::seq(nVars, nVars + 1)) /= bndInt.div;
1486 bndIntegrationLogs.at(
id) << step <<
", " << stage <<
", " << iter << std::setprecision(16) << std::scientific;
1487 for (
auto &val : vPrint)
1506 return {0.0, 0.0, 0.0};
1508 fluxBndCur.setZero(nVars);
1511 if (bcID >= Geom::BC_ID_DEFAULT_MAX)
1519 fluxFaceForce.setZero();
1520 fluxFaceForce(Seq012) = fluxBndCur(Seq123);
1521 fluxFaceForce =
pCLDriver->GetAOARotation().transpose() * fluxFaceForce;
1526 return {CLCur, CDCur, AOACur};
1586 bool rhoFixed =
false;
1587 bool eFixed =
false;
1588 TU ret = umean + uRecInc;
1617#ifdef USE_NS_SA_NUT_REDUCED_ORDER
1619 if (ret(
I4 + 1) < 0)
1620 ret(
I4 + 1) = umean(
I4 + 1), compressed =
true;
1624 if (ret(
I4 + 1) < 0)
1625 ret(
I4 + 1) = umean(
I4 + 1), compressed =
true;
1626 if (ret(
I4 + 2) < 0)
1627 ret(
I4 + 2) = umean(
I4 + 2), compressed =
true;
1661 if (u(0) + ret(0) <= rhoEps)
1664 real newrho = u(0) * std::exp(declineV);
1672 real rhoEinternal = u(
I4) - ekOld;
1674 real ek = 0.5 * (u(Seq123) + ret(Seq123)).squaredNorm() / (u(0) + ret(0) +
verySmallReal);
1675 real rhoEinternalNew = u(
I4) + ret(
I4) - ek;
1676 if (rhoEinternalNew <= pEps)
1678 real declineV = (rhoEinternalNew - rhoEinternal) / (rhoEinternal +
verySmallReal);
1682 newrhoEinteralNew = pEps / (gamma - 1);
1683 real c0 = 2 * u(
I4) * u(0) - u(Seq123).squaredNorm() - 2 * u(0) * newrhoEinteralNew;
1684 real c1 = 2 * u(
I4) * ret(0) + 2 * u(0) * ret(
I4) - 2 * u(Seq123).dot(ret(Seq123)) - 2 * ret(0) * newrhoEinteralNew;
1685 real c2 = 2 * ret(
I4) * ret(0) - ret(Seq123).squaredNorm();
1686 real deltaC =
sqr(c1) - 4 * c0 * c2;
1688 real alphaL = (-std::sqrt(deltaC) - c1) / (2 * c2);
1689 real alphaR = (std::sqrt(deltaC) - c1) / (2 * c2);
1696 real alpha = std::min((c2 > 0 ? alphaL : alphaL), 1.);
1698 ret *=
alpha * (0.99);
1700 real decay = 1 - 1e-1;
1701 for (
int iter = 0; iter < 1000; iter++)
1703 ek = 0.5 * (u(Seq123) + ret(Seq123)).squaredNorm() / (u(0) + ret(0) +
verySmallReal);
1704 if (ret(
I4) + u(
I4) - ek < newrhoEinteralNew)
1705 ret *= decay,
alpha *= decay;
1710 ek = 0.5 * (u(Seq123) + ret(Seq123)).squaredNorm() / (u(0) + ret(0) +
verySmallReal);
1712 if (ret(
I4) + u(
I4) - ek < newrhoEinteralNew * 0.5)
1714 std::cout << std::scientific << std::setprecision(5);
1715 std::cout << u(0) <<
" " << ret(0) << std::endl;
1716 std::cout << rhoEinternalNew <<
" " << rhoEinternal << std::endl;
1717 std::cout << declineV << std::endl;
1718 std::cout << newrhoEinteralNew << std::endl;
1719 std::cout << ret(
I4) + u(
I4) - ek << std::endl;
1720 std::cout <<
alpha << std::endl;
1727#ifndef USE_NS_SA_ALLOW_NEGATIVE_MEAN
1730 if (u(
I4 + 1) + ret(
I4 + 1) < 0)
1735 real declineV = ret(
I4 + 1) / (u(
I4 + 1) + 1e-6);
1736 real newu5 = u(
I4 + 1) * std::exp(declineV);
1739 newu5 = std::max(1e-6, newu5);
1740 ret(
I4 + 1) = newu5 - u(
I4 + 1);
1746 if (u(
I4 + 1) + ret(
I4 + 1) < 0)
1751 real declineV = ret(
I4 + 1) / (u(
I4 + 1) + 1e-6);
1752 real newu5 = u(
I4 + 1) * std::exp(declineV);
1756 ret(
I4 + 1) = newu5 - u(
I4 + 1);
1759 if (u(
I4 + 2) + ret(
I4 + 2) < 0)
1764 real declineV = ret(
I4 + 2) / (u(
I4 + 2) + 1e-6);
1765 real newu5 = u(
I4 + 2) * std::exp(declineV);
1769 ret(
I4 + 2) = newu5 - u(
I4 + 2);
1781 for (
index iCell = 0; iCell < cxInc.
Size(); iCell++)
1800 real alpha_fix_min = 1.0;
1801 for (
index iCell = 0; iCell < cxInc.
Size(); iCell++)
1804 real newAlpha = std::abs(compressedInc(0)) /
1805 (std::abs((cxInc[iCell] *
alpha)(0)));
1808 alpha_fix_min = std::min(
1816 cx[iCell] += compressedInc;
1849 cx[iCell](
I4 + 2) = std::max(cx[iCell](
I4 + 2),
settings.RANSBottomLimit *
settings.farFieldStaticValue(
I4 + 2));
1852 real alpha_fix_min_c = alpha_fix_min;
1854 if (alpha_fix_min < 1.0)
1855 if (cx.
father->getMPI().rank == 0)
1925 for (
int iterS = 1; iterS <= (nStep > 0 ? nStep :
settings.nCentralSmoothStep); iterS++)
1928#if defined(DNDS_DIST_MT_USE_OMP)
1929# pragma omp parallel for schedule(runtime)
1931 for (
index iCell = 0; iCell <
mesh->NumCell(); iCell++)
1935 auto c2f =
mesh->cell2face[iCell];
1936 for (
int ic2f = 0; ic2f < c2f.size(); ic2f++)
1938 index iFace = c2f[ic2f];
1939 index iCellOther =
vfv->CellFaceOther(iCell, iFace);
1943 vC += epsC * rs[iCellOther];
1946 rtemp[iCell] = vC / div;
1949 rs.
trans.startPersistentPull();
1950 rs.
trans.waitPersistentPull();
1983#define DNDS_EulerEvaluator_INS_EXTERN(model, ext) \
1984 namespace DNDS::Euler \
1986 ext template void EulerEvaluator<model>::LUSGSMatrixInit( \
1987 JacobianDiagBlock<nVarsFixed> &JDiag, \
1988 JacobianDiagBlock<nVarsFixed> &JSource, \
1989 ArrayDOFV<1> &dTau, real dt, real alphaDiag, \
1990 ArrayDOFV<nVarsFixed> &u, \
1991 ArrayRECV<nVarsFixed> &uRec, \
1995 ext template void EulerEvaluator<model>::LUSGSMatrixVec( \
1998 ArrayDOFV<nVarsFixed> &u, \
1999 ArrayDOFV<nVarsFixed> &uInc, \
2000 JacobianDiagBlock<nVarsFixed> &JDiag, \
2001 ArrayDOFV<nVarsFixed> &AuInc); \
2003 ext template void EulerEvaluator<model>::LUSGSMatrixToJacobianLU( \
2006 ArrayDOFV<nVarsFixed> &u, \
2007 JacobianDiagBlock<nVarsFixed> &JDiag, \
2008 JacobianLocalLU<nVarsFixed> &jacLU); \
2010 ext template void EulerEvaluator<model>::UpdateLUSGSForward( \
2013 ArrayDOFV<nVarsFixed> &rhs, \
2014 ArrayDOFV<nVarsFixed> &u, \
2015 ArrayDOFV<nVarsFixed> &uInc, \
2016 JacobianDiagBlock<nVarsFixed> &JDiag, \
2017 ArrayDOFV<nVarsFixed> &uIncNew); \
2019 ext template void EulerEvaluator<model>::UpdateLUSGSBackward( \
2022 ArrayDOFV<nVarsFixed> &rhs, \
2023 ArrayDOFV<nVarsFixed> &u, \
2024 ArrayDOFV<nVarsFixed> &uInc, \
2025 JacobianDiagBlock<nVarsFixed> &JDiag, \
2026 ArrayDOFV<nVarsFixed> &uIncNew); \
2028 ext template void EulerEvaluator<model>::UpdateSGS( \
2031 ArrayDOFV<nVarsFixed> &rhs, \
2032 ArrayDOFV<nVarsFixed> &u, \
2033 ArrayDOFV<nVarsFixed> &uInc, \
2034 ArrayDOFV<nVarsFixed> &uIncNew, \
2035 JacobianDiagBlock<nVarsFixed> &JDiag, \
2036 bool forward, bool gsUpdate, TU &sumInc, \
2038 ext template void EulerEvaluator<model>::UpdateSGSWithRec( \
2041 ArrayDOFV<nVarsFixed> &rhs, \
2042 ArrayDOFV<nVarsFixed> &u, \
2043 ArrayRECV<nVarsFixed> &uRec, \
2044 ArrayDOFV<nVarsFixed> &uInc, \
2045 ArrayRECV<nVarsFixed> &uRecInc, \
2046 JacobianDiagBlock<nVarsFixed> &JDiag, \
2047 bool forward, TU &sumInc); \
2049 ext template void EulerEvaluator<model>::LUSGSMatrixSolveJacobianLU( \
2052 ArrayDOFV<nVarsFixed> &rhs, \
2053 ArrayDOFV<nVarsFixed> &u, \
2054 ArrayDOFV<nVarsFixed> &uInc, \
2055 ArrayDOFV<nVarsFixed> &uIncNew, \
2056 ArrayDOFV<nVarsFixed> &bBuf, \
2057 JacobianDiagBlock<nVarsFixed> &JDiag, \
2058 JacobianLocalLU<nVarsFixed> &jacLU, \
2062 ext template void EulerEvaluator<model>::InitializeUDOF(ArrayDOFV<nVarsFixed> &u); \
2064 ext template void EulerEvaluator<model>::FixUMaxFilter( \
2065 ArrayDOFV<nVarsFixed> &u); \
2067 ext template void EulerEvaluator<model>::TimeAverageAddition( \
2068 ArrayDOFV<nVarsFixed> &w, ArrayDOFV<nVarsFixed> &wAveraged, real dt, real &tCur); \
2069 ext template void EulerEvaluator<model>::MeanValueCons2Prim( \
2070 ArrayDOFV<nVarsFixed> &u, ArrayDOFV<nVarsFixed> &w); \
2071 ext template void EulerEvaluator<model>::MeanValuePrim2Cons( \
2072 ArrayDOFV<nVarsFixed> &w, ArrayDOFV<nVarsFixed> &u); \
2074 ext template void EulerEvaluator<model>::EvaluateNorm( \
2075 Eigen::Vector<real, -1> &res, ArrayDOFV<nVarsFixed> &rhs, index P, bool volWise, bool average); \
2077 ext template void EulerEvaluator<model>::EvaluateRecNorm( \
2078 Eigen::Vector<real, -1> &res, \
2079 ArrayDOFV<nVarsFixed> &u, \
2080 ArrayRECV<nVarsFixed> &uRec, \
2083 const tFCompareField &FCompareField, \
2084 const tFCompareFieldWeight &FCompareFieldWeight, \
2087 ext template void EulerEvaluator<model>::LimiterUGrad( \
2088 ArrayDOFV<nVarsFixed> &u, ArrayGRADV<nVarsFixed, gDim> &uGrad, ArrayGRADV<nVarsFixed, gDim> &uGradNew, \
2091 ext template void EulerEvaluator<model>::EvaluateURecBeta( \
2092 ArrayDOFV<nVarsFixed> &u, \
2093 ArrayRECV<nVarsFixed> &uRec, \
2094 ArrayDOFV<1> &uRecBeta, index &nLim, real &betaMin, int flag); \
2096 ext template bool EulerEvaluator<model>::AssertMeanValuePP( \
2097 ArrayDOFV<nVarsFixed> &u, bool panic); \
2099 ext template void EulerEvaluator<model>::EvaluateCellRHSAlpha( \
2100 ArrayDOFV<nVarsFixed> &u, \
2101 ArrayRECV<nVarsFixed> &uRec, \
2102 ArrayDOFV<1> &uRecBeta, \
2103 ArrayDOFV<nVarsFixed> &rhs, \
2104 ArrayDOFV<1> &cellRHSAlpha, index &nLim, real &alphaMin, real relax, \
2108 ext template void EulerEvaluator<model>::EvaluateCellRHSAlphaExpansion( \
2109 ArrayDOFV<nVarsFixed> &u, \
2110 ArrayRECV<nVarsFixed> &uRec, \
2111 ArrayDOFV<1> &uRecBeta, \
2112 ArrayDOFV<nVarsFixed> &res, \
2113 ArrayDOFV<1> &cellRHSAlpha, index &nLim, real alphaMin); \
2114 ext template void EulerEvaluator<model>::MinSmoothDTau( \
2115 ArrayDOFV<1> &dTau, ArrayDOFV<1> &dTauNew); \
2116 ext template void EulerEvaluator<model>::updateBCProfiles(ArrayDOFV<nVarsFixed> &u, ArrayRECV<nVarsFixed> &uRec); \
2117 ext template void EulerEvaluator<model>::updateBCProfilesPressureRadialEq(); \
2128#define DNDS_EulerEvaluator_EvaluateDt_INS_EXTERN(model, ext) \
2129 namespace DNDS::Euler \
2131 ext template void EulerEvaluator<model>::GetWallDist(); \
2132 ext template void EulerEvaluator<model>::GetWallDist_CollectTriangles( \
2133 bool, std::vector<Eigen::Matrix<real, 3, 3>> &); \
2134 ext template void EulerEvaluator<model>::GetWallDist_AABB(); \
2135 ext template void EulerEvaluator<model>::GetWallDist_BatchedAABB(); \
2136 ext template void EulerEvaluator<model>::GetWallDist_Poisson(); \
2137 ext template void EulerEvaluator<model>::GetWallDist_ComputeFaceDistances(); \
2138 ext template void EulerEvaluator<model>::EvaluateDt( \
2140 ArrayDOFV<nVarsFixed> &u, \
2141 ArrayRECV<nVarsFixed> &uRec, \
2142 real CFL, real &dtMinall, real MaxDt, \
2147 EulerEvaluator<model>::fluxFace( \
2148 const TU_Batch &ULxy, \
2149 const TU_Batch &URxy, \
2150 const TU &ULMeanXy, \
2151 const TU &URMeanXy, \
2152 const TDiffU_Batch &DiffUxy, \
2153 const TDiffU_Batch &DiffUxyPrim, \
2154 const TVec_Batch &unitNorm, \
2155 const TVec_Batch &vg, \
2156 const TVec &unitNormC, \
2161 TReal_Batch &lam0V, TReal_Batch &lam123V, TReal_Batch &lam4V, \
2162 Geom::t_index btype, \
2163 typename Gas::RiemannSolverType rsType, \
2164 index iFace, bool ignoreVis); \
2166 typename EulerEvaluator<model>::TU \
2167 EulerEvaluator<model>::source( \
2168 const TU &UMeanXy, \
2169 const TDiffU &DiffUxy, \
2170 const Geom::tPoint &pPhy, \
2171 TJacobianU &jacobian, \
2176 typename EulerEvaluator<model>::TU \
2177 EulerEvaluator<model>::generateBoundaryValue( \
2179 const TU &ULMeanXy, \
2180 index iCell, index iFace, int iG, \
2181 const TVec &uNorm, \
2182 const TMat &normBase, \
2183 const Geom::tPoint &pPhysics, \
2185 Geom::t_index btype, \
2187 int geomMode, int linMode); \
2188 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_FarField( \
2189 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2190 const Geom::tPoint &, real, Geom::t_index, bool, int); \
2191 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_SpecialFar( \
2192 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2193 const Geom::tPoint &, real, Geom::t_index); \
2194 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_InviscidWall( \
2195 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2196 const Geom::tPoint &, real, Geom::t_index); \
2197 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_ViscousWall( \
2198 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2199 const Geom::tPoint &, real, Geom::t_index, bool, int); \
2200 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_Outflow( \
2201 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2202 const Geom::tPoint &, real, Geom::t_index); \
2203 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_Inflow( \
2204 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2205 const Geom::tPoint &, real, Geom::t_index); \
2206 ext template typename EulerEvaluator<model>::TU EulerEvaluator<model>::generateBV_TotalConditionInflow( \
2207 TU &, const TU &, index, index, int, const TVec &, const TMat &, \
2208 const Geom::tPoint &, real, Geom::t_index); \
2209 ext template void EulerEvaluator<model>::InitializeOutputPicker(OutputPicker &op, OutputOverlapDataRefs dataRefs); \
2220#define DNDS_EulerEvaluator_EvaluateRHS_INS_EXTERN(model, ext) \
2221 namespace DNDS::Euler \
2223 ext template void EulerEvaluator<model>::EvaluateRHS( \
2224 ArrayDOFV<nVarsFixed> &rhs, \
2225 JacobianDiagBlock<nVarsFixed> &JSource, \
2226 ArrayDOFV<nVarsFixed> &u, \
2227 ArrayRECV<nVarsFixed> &uRecUnlim, \
2228 ArrayRECV<nVarsFixed> &uRec, \
2229 ArrayDOFV<1> &uRecBeta, \
2230 ArrayDOFV<1> &cellRHSAlpha, \
2231 bool onlyOnHalfAlpha, \
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
Boundary condition types, handlers, integration recorders, and 1-D profile utilities for the compress...
Complete solver configuration for the Euler/Navier-Stokes evaluator.
#define DNDS_EulerEvaluator_INS_EXTERN(model, ext)
#define DNDS_EulerEvaluator_EvaluateDt_INS_EXTERN(model, ext)
#define DNDS_EulerEvaluator_EvaluateRHS_INS_EXTERN(model, ext)
Jacobian storage and factorization structures for implicit time stepping.
Core type definitions, enumerations, and distributed array wrappers for compressible Navier-Stokes / ...
#define DNDS_FV_EULEREVALUATOR_GET_FIXED_EIGEN_SEQS
Declares compile-time Eigen index sequences for sub-vector access into conservative state vectors.
Ideal-gas Riemann solvers, flux functions, and thermodynamic utilities for the compressible Euler / N...
JSON-to-Eigen conversion utilities and nlohmann_json helper macros.
RANS two-equation turbulence model implementations for the DNDSR CFD solver.
Base types and abstract interface for array serialization.
The VR class that provides any information needed in high-order CFV.
MPI-parallel distributed array of per-cell Degrees-of-Freedom (conservative variable vectors).
MPI-parallel distributed array of per-cell gradient matrices.
MPI-parallel distributed array of per-cell reconstruction coefficient matrices.
Core finite-volume evaluator for compressible Navier-Stokes / Euler equations.
Eigen::MatrixFMTSafe< real, nVarsFixed, nVarsFixed > TJacobianU
Jacobian matrix (nVars x nVars) of the flux w.r.t. conserved variables.
Eigen::MatrixFMTSafe< real, nVarsFixed, Eigen::Dynamic, Eigen::ColMajor, nVarsFixed, MaxBatch > TU_Batch
Batch of conservative variable vectors.
Eigen::MatrixFMTSafe< real, dim, dim > TMat
Spatial matrix (dim x dim).
Eigen::MatrixFMTSafe< real, dim, Eigen::Dynamic, Eigen::ColMajor, dim, MaxBatchMult(3)> TMat_Batch
Batch of spatial matrices.
index nFaceReducedOrder
Count of faces where reconstruction order was reduced.
static const uint64_t RHS_Ignore_Viscosity
Skip viscous flux contribution.
Eigen::MatrixFMTSafe< real, nVarsFixed, dim > TDiffUTransposed
Transposed gradient (nVars x dim).
static const uint64_t RHS_Recover_IncFScale
Recover incremental face scaling.
void setPassiveDiscardSource(bool n)
Enable or disable discarding of passive-scalar source terms.
ssp< BoundaryHandler< model > > TpBCHandler
Shared pointer to the boundary condition handler.
static void InitializeFV(ssp< Geom::UnstructuredMesh > &mesh, TpVFV vfv, TpBCHandler pBCHandler)
Initialize the finite-volume infrastructure on the mesh.
void MinSmoothDTau(ArrayDOFV< 1 > &dTau, ArrayDOFV< 1 > &dTauNew)
Smooth the local time step across neighboring cells.
void LUSGSMatrixInit(JacobianDiagBlock< nVarsFixed > &JDiag, JacobianDiagBlock< nVarsFixed > &JSource, ArrayDOFV< 1 > &dTau, real dt, real alphaDiag, ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, int jacobianCode, real t)
Assemble the diagonal blocks of the implicit Jacobian for LU-SGS / SGS.
static const uint64_t DT_Dont_update_lambda01234
Skip recomputation of per-face eigenvalues lambda0/123/4.
void EvaluateRecNorm(Eigen::Vector< real, -1 > &res, ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, index P=1, bool compare=false, const tFCompareField &FCompareField=[](const Geom::tPoint &p, real t) { return TU::Zero();}, const tFCompareFieldWeight &FCompareFieldWeight=[](const Geom::tPoint &p, real t) { return 1.0;}, real t=0)
Compute the reconstruction error norm (optionally against an analytical field).
void GetWallDist()
Compute wall distance for all cells (dispatcher).
ArrayDOFV< 1 > deltaLambdaCell
Per-cell accumulated spectral radius difference.
Eigen::MatrixFMTSafe< real, dim, nVarsFixed > TDiffU
Gradient of conserved variables (dim x nVars).
static const uint64_t RHS_Dont_Record_Bud_Flux
Skip recording per-boundary flux.
TVec GetFaceVGridFromCell(index iFace, index iCell, int if2c, index iG)
Get the grid velocity at a face quadrature point from a specific cell's perspective.
std::vector< real > dWallFace
Per-face wall distance (interpolated from cell values).
bool AssertMeanValuePP(ArrayDOFV< nVarsFixed > &u, bool panic)
Assert that all cell-mean values are physically realizable.
void BndIntegrationLogWriteLine(const std::string &name, index step, index stage, index iter)
Append a line to the per-BC boundary integration CSV log files.
std::tuple< real, real, real > CLDriverGetIntegrationUpdate(index iter)
Query the CL driver for current lift/drag coefficients and update AoA.
static const uint64_t RHS_Direct_2nd_Rec
Use direct 2nd-order reconstruction.
real muEff(const TU &U, real T)
Compute effective molecular viscosity using the configured viscosity model.
Eigen::MatrixFMTSafe< real, 1, Eigen::Dynamic, Eigen::RowMajor, 1, MaxBatch > TReal_Batch
Batch of scalar values.
void UpdateLUSGSBackward(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &rhs, ArrayDOFV< nVarsFixed > &u, ArrayDOFV< nVarsFixed > &uInc, JacobianDiagBlock< nVarsFixed > &JDiag, ArrayDOFV< nVarsFixed > &uIncNew)
Deprecated: use UpdateSGS with uIncIsZero=true instead. Kept for backward compatibility....
std::vector< TVec > fluxBndForceT
Per-boundary-face tangential force.
static const uint64_t RHS_Direct_2nd_Rec_already_have_uGradBufNoLim
uGradBufNoLim is already computed.
static const int EvaluateURecBeta_DEFAULT
Default: evaluate beta without compression.
void InitializeOutputPicker(OutputPicker &op, OutputOverlapDataRefs dataRefs)
Initialize an OutputPicker with field callbacks for VTK/HDF5 output.
static const int nVarsFixed
Number of conserved variables (compile-time fixed).
std::vector< real > lambdaFace123
Per-face eigenvalue |u·n + a| (acoustic wave).
std::vector< real > lambdaFace0
Per-face eigenvalue |u·n| (contact wave).
TU CompressInc(const TU &u, const TU &uInc)
Compress a solution increment to maintain positivity.
ssp< CFV::VariationalReconstruction< gDim > > vfv
std::vector< real > deltaLambdaFace
Per-face spectral radius difference for implicit diagonal.
void InitializeUDOF(ArrayDOFV< nVarsFixed > &u)
Set initial conservative DOF values for all cells.
Eigen::VectorFMTSafe< real, nVarsFixed > TU
Conservative variable vector (nVarsFixed components).
ArrayGRADV< nVarsFixed, gDim > uGradBuf
static const int EvaluateURecBeta_COMPRESS_TO_MEAN
Compress reconstruction toward cell mean to enforce positivity.
static const uint64_t LIMITER_UGRAD_No_Flags
Default limiter flags.
TVec GetFaceVGrid(index iFace, index iG)
Get the grid velocity at a face quadrature point (rotating frame).
std::set< Geom::t_index > cLDriverBndIDs
Boundary IDs driven by the CL (lift-coefficient) driver.
std::map< Geom::t_index, AnchorPointRecorder< nVarsFixed > > anchorRecorders
Per-BC anchor point recorders for profile extraction.
std::map< Geom::t_index, OneDimProfile< nVarsFixed > > profileRecorders
Per-BC 1-D profile recorders.
int GetAxisSymmetric()
Return the axisymmetric mode flag.
TU CompressRecPart(const TU &umean, const TU &uRecInc, bool &compressed)
Compress a reconstruction increment to maintain positivity.
void FixUMaxFilter(ArrayDOFV< nVarsFixed > &u)
Clip extreme conserved-variable values to prevent overflow.
Eigen::MatrixFMTSafe< real, dim, Eigen::Dynamic, Eigen::ColMajor, dim, MaxBatch > TVec_Batch
Batch of spatial vectors.
void FixIncrement(ArrayDOFV< nVarsFixed > &cx, ArrayDOFV< nVarsFixed > &cxInc, real alpha=1.0)
Apply CompressInc to every cell, modifying cxInc in-place.
void EvaluateRHS(ArrayDOFV< nVarsFixed > &rhs, JacobianDiagBlock< nVarsFixed > &JSource, ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRecUnlim, ArrayRECV< nVarsFixed > &uRec, ArrayDOFV< 1 > &uRecBeta, ArrayDOFV< 1 > &cellRHSAlpha, bool onlyOnHalfAlpha, real t, uint64_t flags=RHS_No_Flags)
Evaluate the spatial right-hand side of the semi-discrete system.
CFV::VariationalReconstruction< gDim > TVFV
Variational reconstruction type for this geometric dimension.
static const auto I4
Index of the energy equation (= dim+1).
EulerEvaluatorSettings< model > settings
Physics and numerics settings for this evaluator.
void EvaluateDt(ArrayDOFV< 1 > &dt, ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, real CFL, real &dtMinall, real MaxDt, bool UseLocaldt, real t, uint64_t flags=DT_No_Flags)
Estimate the local or global time step for each cell.
std::vector< real > lambdaFaceC
Per-face convective spectral radius.
void UpdateSGS(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &rhs, ArrayDOFV< nVarsFixed > &u, ArrayDOFV< nVarsFixed > &uInc, ArrayDOFV< nVarsFixed > &uIncNew, JacobianDiagBlock< nVarsFixed > &JDiag, bool forward, bool gsUpdate, TU &sumInc, bool uIncIsZero=false)
Symmetric Gauss-Seidel update for the implicit linear system.
void EvaluateURecBeta(ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, ArrayDOFV< 1 > &uRecBeta, index &nLim, real &betaMin, int flag)
Evaluate the positivity-preserving reconstruction limiter (beta).
static const uint64_t RHS_Direct_2nd_Rec_1st_Conv
2nd-order rec with 1st-order convection.
static constexpr int MaxBatchMult(int n)
Compute the maximum batch-multiplied column count for batched Eigen matrices.
ssp< CFV::VariationalReconstruction< gDim > > TpVFV
Shared pointer to the variational reconstruction object.
int kAv
Artificial viscosity polynomial order (maxOrder + 1).
static const int MaxBatch
Eigen::Vector< real, -1 > fluxWallSum
Accumulated wall flux integral (force on wall boundaries).
static const uint64_t RHS_Direct_2nd_Rec_use_limiter
Apply limiter when using direct 2nd rec.
void LUSGSMatrixToJacobianLU(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &u, JacobianDiagBlock< nVarsFixed > &JDiag, JacobianLocalLU< nVarsFixed > &jacLU)
Build the local LU factorization of the Jacobian for direct solve.
std::unique_ptr< CLDriver > pCLDriver
Lift-coefficient driver for AoA adaptation (null if unused).
ArrayDOFV< nVarsFixed > TDof
Cell-centered DOF array (mean values).
static const int EvaluateCellRHSAlpha_DEFAULT
Default alpha evaluation mode.
void MeanValuePrim2Cons(ArrayDOFV< nVarsFixed > &w, ArrayDOFV< nVarsFixed > &u)
Convert cell-mean primitive variables to conservative variables.
void TransformURotatingFrame(TU &U, const Geom::tPoint &pPhysics, int direction)
Transform full conservative state (momentum + total energy) between frames (relative velocity formula...
void AddFixedIncrement(ArrayDOFV< nVarsFixed > &cx, ArrayDOFV< nVarsFixed > &cxInc, real alpha=1.0)
Add a positivity-compressed increment to the solution.
std::vector< TDiffU > gradUFix
Green-Gauss gradient correction buffer for source term stabilization.
static const uint64_t LIMITER_UGRAD_Disable_Shock_Limiter
Disable shock-detecting component of the limiter.
void PrintBCProfiles(const std::string &name, ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec)
Write boundary profile data to CSV files (rank 0 only).
ArrayGRADV< nVarsFixed, gDim > uGradBufNoLim
Gradient buffers: limited and unlimited.
ssp< BoundaryHandler< model > > pBCHandler
gDim -> 3 for intellisense //!tmptmp ///< Variational reconstruction object.
void UFromFace2Cell(TU &u, index iFace, index iCell, rowsize if2c)
Inverse of UFromCell2Face: transform from face frame back to cell frame.
std::function< TU(const Geom::tPoint &, real)> tFCompareField
Callback type for analytical comparison field.
static const uint64_t DT_No_Flags
No flags for EvaluateDt.
void UpdateLUSGSForward(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &rhs, ArrayDOFV< nVarsFixed > &u, ArrayDOFV< nVarsFixed > &uInc, JacobianDiagBlock< nVarsFixed > &JDiag, ArrayDOFV< nVarsFixed > &uIncNew)
Deprecated: use UpdateSGS with uIncIsZero=true instead. Kept for backward compatibility....
void EvaluateNorm(Eigen::Vector< real, -1 > &res, ArrayDOFV< nVarsFixed > &rhs, index P=1, bool volWise=false, bool average=false)
Compute the norm of the RHS residual vector.
std::map< Geom::t_index, std::ofstream > bndIntegrationLogs
Per-BC log file streams for integration output.
ssp< Direct::SerialSymLUStructure > symLU
Symmetric LU structure for direct preconditioner.
real getMuTur(const TU &uMean, const TDiffU &GradUMeanXY, real muRef, real muf, index iFace)
Compute turbulent eddy viscosity at a face.
ssp< Geom::UnstructuredMesh > mesh
Shared pointer to the unstructured mesh.
static const int gDim
Geometric dimension of the mesh.
void UFromCell2Face(TU &u, index iFace, index iCell, rowsize if2c)
Transform a conservative state vector from cell frame to face frame for periodic BCs.
void CentralSmoothResidual(ArrayDOFV< nVarsFixed > &r, ArrayDOFV< nVarsFixed > &rs, ArrayDOFV< nVarsFixed > &rtemp, int nStep=0)
Apply Laplacian smoothing to a residual field.
void updateBCProfilesPressureRadialEq()
Update boundary profiles using radial-equilibrium pressure extrapolation.
void MeanValueCons2Prim(ArrayDOFV< nVarsFixed > &u, ArrayDOFV< nVarsFixed > &w)
Convert cell-mean conservative variables to primitive variables.
static const int dim
Spatial dimension (2 or 3).
TU fluxJacobian0_Right_Times_du(const TU &U, const TU &UOther, const TVec &n, const TVec &vg, Geom::t_index btype, const TU &dU, real lambdaMain, real lambdaC, real lambdaVis, real lambda0, real lambda123, real lambda4, int useRoeTerm, int incFsign=-1, int omitF=0)
inviscid flux approx jacobian (flux term not reconstructed / no riemann) if lambdaMain == veryLargeRe...
TVec GetFaceVGrid(index iFace, index iG, const Geom::tPoint &pPhy)
Get the grid velocity at a face quadrature point (with explicit physical point).
void LUSGSMatrixVec(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &u, ArrayDOFV< nVarsFixed > &uInc, JacobianDiagBlock< nVarsFixed > &JDiag, ArrayDOFV< nVarsFixed > &AuInc)
Compute the matrix-vector product A * uInc for the implicit system.
static const int EvaluateCellRHSAlpha_MIN_ALL
Always take min(alpha, prev).
void visFluxTurVariable(const TU &UMeanXYC, const TDiffU &DiffUxyPrimC, real muRef, real mufPhy, real muTur, const TVec &uNormC, index iFace, TU &VisFlux)
Compute viscous flux contribution from turbulence model variables.
std::function< real(const Geom::tPoint &, real)> tFCompareFieldWeight
Callback type for comparison weighting function.
std::vector< real > lambdaFaceVis
Per-face viscous spectral radius.
std::vector< real > lambdaFace
Per-face spectral radius (inviscid + viscous combined).
void ConsoleOutputBndIntegrations()
Print boundary integration results (force/flux) to console on rank 0.
void LUSGSMatrixSolveJacobianLU(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &rhs, ArrayDOFV< nVarsFixed > &u, ArrayDOFV< nVarsFixed > &uInc, ArrayDOFV< nVarsFixed > &uIncNew, ArrayDOFV< nVarsFixed > &bBuf, JacobianDiagBlock< nVarsFixed > &JDiag, JacobianLocalLU< nVarsFixed > &jacLU, bool uIncIsZero, TU &sumInc)
Solve the implicit linear system using the pre-factored local LU.
TJacobianU fluxJacobian0_Right_Times_du_AsMatrix(const TU &U, const TU &UOther, const TVec &n, const TVec &vg, Geom::t_index btype, real lambdaMain, real lambdaC, real lambdaVis, real lambda0, real lambda123, real lambda4, int useRoeTerm, int incFsign=-1, int omitF=0)
TU generateBoundaryValue(TU &ULxy, const TU &ULMeanXy, index iCell, index iFace, int iG, const TVec &uNorm, const TMat &normBase, const Geom::tPoint &pPhysics, real t, Geom::t_index btype, bool fixUL=false, int geomMode=0, int linMode=0)
Generate the ghost (boundary) state for a boundary face.
void TransformVelocityRotatingFrame(TU &U, const Geom::tPoint &pPhysics, int direction)
Transform momentum in-place between inertial and rotating frame (velocity only).
Eigen::VectorFMTSafe< real, dim > TVec
Spatial vector (dim components).
void LimiterUGrad(ArrayDOFV< nVarsFixed > &u, ArrayGRADV< nVarsFixed, gDim > &uGrad, ArrayGRADV< nVarsFixed, gDim > &uGradNew, uint64_t flags=LIMITER_UGRAD_No_Flags)
Apply slope limiter to the gradient field.
TU fluxJacobianC_Right_Times_du(const TU &U, const TVec &n, const TVec &vg, Geom::t_index btype, const TU &dU)
void EvaluateCellRHSAlpha(ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, ArrayDOFV< 1 > &uRecBeta, ArrayDOFV< nVarsFixed > &res, ArrayDOFV< 1 > &cellRHSAlpha, index &nLim, real &alphaMin, real relax, int compress=1, int flag=0)
Compute the positivity-preserving RHS scaling factor (alpha) per cell.
void updateBCAnchors(ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec)
Update boundary anchor point recorders from current solution.
ArrayRECV< 1 > TScalar
Scalar reconstruction coefficient array.
std::map< Geom::t_index, IntegrationRecorder > bndIntegrations
Per-BC boundary flux/force integration accumulators.
void updateBCProfiles(ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec)
Update boundary 1-D profiles from the current solution.
void TransformURotatingFrame_ABS_VELO(TU &U, const Geom::tPoint &pPhysics, int direction)
Transform full conservative state for the absolute-velocity rotating frame formulation.
Eigen::MatrixFMTSafe< real, Eigen::Dynamic, nVarsFixed, Eigen::ColMajor, MaxBatchMult(3)> TDiffU_Batch
Batch of gradient matrices.
EulerEvaluator(const decltype(mesh) &Nmesh, const decltype(vfv) &Nvfv, const decltype(pBCHandler) &npBCHandler, const EulerEvaluatorSettings< model > &nSettings, int n_nVars=getNVars(model))
Construct an EulerEvaluator and initialize all internal buffers.
static const uint64_t RHS_Dont_Update_Integration
Skip boundary integration accumulation.
void DiffUFromCell2Face(TDiffU &u, index iFace, index iCell, rowsize if2c, bool reverse=false)
Transform a gradient tensor from cell frame to face frame for periodic BCs.
void TimeAverageAddition(ArrayDOFV< nVarsFixed > &w, ArrayDOFV< nVarsFixed > &wAveraged, real dt, real &tCur)
Accumulate time-averaged primitive variables for unsteady statistics.
std::vector< TU > fluxBnd
Per-boundary-face flux values.
static const int EvaluateCellRHSAlpha_MIN_IF_NOT_ONE
Take min(alpha, prev) only if prev != 1.
std::vector< real > lambdaFace4
Per-face eigenvalue |u·n - a| (acoustic wave).
TU source(const TU &UMeanXy, const TDiffU &DiffUxy, const Geom::tPoint &pPhy, TJacobianU &jacobian, index iCell, index ig, int Mode)
Compute the source term at a cell quadrature point.
void UFromOtherCell(TU &u, index iFace, index iCell, index iCellOther, rowsize if2c)
Transform a state from a neighbor cell across a periodic face.
void EvaluateCellRHSAlphaExpansion(ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, ArrayDOFV< 1 > &uRecBeta, ArrayDOFV< nVarsFixed > &res, ArrayDOFV< 1 > &cellRHSAlpha, index &nLim, real alphaMin)
Expand a previously computed cellRHSAlpha toward 1 where safe.
ArrayRECV< nVarsFixed > TRec
Reconstruction coefficient array (per-cell polynomial coefficients).
void fluxFace(const TU_Batch &ULxy, const TU_Batch &URxy, const TU &ULMeanXy, const TU &URMeanXy, const TDiffU_Batch &DiffUxy, const TDiffU_Batch &DiffUxyPrim, const TVec_Batch &unitNorm, const TVec_Batch &vg, const TVec &unitNormC, const TVec &vgC, TU_Batch &FLfix, TU_Batch &FRfix, TU_Batch &finc, TReal_Batch &lam0V, TReal_Batch &lam123V, TReal_Batch &lam4V, Geom::t_index btype, typename Gas::RiemannSolverType rsType, index iFace, bool ignoreVis)
Compute the numerical flux at a face (batched over quadrature points).
std::vector< Eigen::Vector< real, Eigen::Dynamic > > dWall
Per-cell wall distance (one value per cell node/quadrature point).
static const uint64_t RHS_No_Flags
Default: full RHS evaluation.
auto fluxJacobian0_Right(TU &UR, const TVec &uNorm, Geom::t_index btype)
inviscid flux approx jacobian (flux term not reconstructed / no riemann)
void UpdateSGSWithRec(real alphaDiag, real t, ArrayDOFV< nVarsFixed > &rhs, ArrayDOFV< nVarsFixed > &u, ArrayRECV< nVarsFixed > &uRec, ArrayDOFV< nVarsFixed > &uInc, ArrayRECV< nVarsFixed > &uRecInc, JacobianDiagBlock< nVarsFixed > &JDiag, bool forward, TU &sumInc)
SGS sweep coupled with reconstruction update.
Per-cell diagonal or block-diagonal Jacobian storage for implicit time stepping.
Registry that maps named cell-scalar output fields to getter lambdas.
RiemannSolverType
Selects the approximate Riemann solver and its entropy-fix variant.
void IdealGasThermal(real E, real rho, real vSqr, real gamma, real &p, real &asqr, real &H)
Thin wrapper delegating to IdealGas::IdealGasThermal.
@ RANS_KOSST
Menter k-omega SST two-equation model.
@ RANS_RKE
Realizable k-epsilon two-equation model.
@ RANS_KOWilcox
Wilcox k-omega two-equation model.
@ NS_2EQ_3D
NS + 2-equation RANS, 3D geometry (7 vars).
@ NS_2EQ
NS + 2-equation RANS, 2D geometry (7 vars).
@ BCWallInvis
Inviscid slip wall boundary.
@ BCSpecial
Test-case-specific boundary (Riemann, DMR, isentropic vortex, RT).
@ BCOut
Supersonic outflow (extrapolation) boundary.
@ BCSym
Symmetry plane boundary.
@ BCFar
Far-field (characteristic-based) boundary.
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicDonor(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicMain(t_index id)
MPI_int Allreduce(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Allreduce.
constexpr std::string_view Magenta
ANSI escape: bright magenta foreground.
constexpr std::string_view Reset
ANSI escape: reset all attributes.
constexpr T cube(const T &a)
a * a * a, constexpr.
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
DNDS_CONSTANT const real verySmallReal
Catch-all lower bound ("effectively zero").
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
DNDS_CONSTANT const rowsize DynamicSize
Template parameter flag: "row width is set at runtime but uniform".
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
constexpr T sqr(const T &a)
a * a, constexpr. Works for all arithmetic types.
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
DNDS_CONSTANT const real smallReal
Loose lower bound (for iterative-solver tolerances etc.).
std::ostream & log()
Return the current DNDSR log stream (either std::cout or the installed file).
const MPI_Datatype DNDS_MPI_REAL
MPI datatype matching real (= MPI_REAL8).
ssp< TArray > father
Owned-side array (must be resized before ghost setup).
index Size() const
Combined row count (father->Size() + son->Size()).
TTrans trans
Ghost-communication engine bound to father and son.
Finds the cell closest to a specified anchor point across all MPI ranks.
Master configuration struct for the compressible Euler/Navier-Stokes evaluator.
References to arrays needed by the output data picker.
ArrayDOFV< 1 > & alphaPP
PP RHS limiter alpha.
ArrayRECV< nVarsFixed > & uRec
Reconstruction coefficients.
ArrayDOFV< 1 > & betaPP
PP reconstruction limiter beta.
ArrayDOFV< nVarsFixed > & u
Cell-centered conservative DOFs.
Compile-time traits for EulerModel variants.
static constexpr bool hasSA
True for Spalart-Allmaras models (NS_SA, NS_SA_3D).
static constexpr bool has2EQ
True for 2-equation RANS models (NS_2EQ, NS_2EQ_3D).
Complete LU factorization of the cell-local Jacobian for GMRES preconditioning.
Eigen::Matrix wrapper that hides begin/end from fmt.
Eigen::Matrix< real, 5, 1 > v
Eigen::Vector3d vg(0, 0, 0)
Eigen::Vector< real, 5 > dU
Eigen::Vector3d n(1.0, 0.0, 0.0)