48 alphaK1_(dimensioned<scalar>::lookupOrAddToDict(
52 alphaK2_(dimensioned<scalar>::lookupOrAddToDict(
56 alphaOmega1_(dimensioned<scalar>::lookupOrAddToDict(
60 alphaOmega2_(dimensioned<scalar>::lookupOrAddToDict(
64 gamma1_(dimensioned<scalar>::lookupOrAddToDict(
68 gamma2_(dimensioned<scalar>::lookupOrAddToDict(
72 beta1_(dimensioned<scalar>::lookupOrAddToDict(
76 beta2_(dimensioned<scalar>::lookupOrAddToDict(
80 betaStar_(dimensioned<scalar>::lookupOrAddToDict(
84 a1_(dimensioned<scalar>::lookupOrAddToDict(
88 b1_(dimensioned<scalar>::lookupOrAddToDict(
92 c1_(dimensioned<scalar>::lookupOrAddToDict(
96 F3_(Switch::lookupOrAddToDict(
101 omega_(const_cast<volScalarField&>(
102 mesh_.thisDb().lookupObject<volScalarField>(
"omega"))),
106 mesh.time().timeName(),
111 #ifdef CompressibleFlow
112 dimensionedScalar(
"omegaRes", dimensionSet(1, -3, -2, 0, 0, 0, 0), 0.0),
114 #ifdef IncompressibleFlow
115 dimensionedScalar(
"omegaRes", dimensionSet(0, 0, -2, 0, 0, 0, 0), 0.0),
117 zeroGradientFvPatchField<scalar>::typeName),
121 mesh.time().timeName(),
129 mesh.time().timeName(),
137 mesh.time().timeName(),
143 const_cast<volScalarField&>(
144 mesh_.thisDb().lookupObject<volScalarField>(
"k"))),
148 mesh.time().timeName(),
153 #ifdef CompressibleFlow
154 dimensionedScalar(
"kRes", dimensionSet(1, -1, -3, 0, 0, 0, 0), 0.0),
156 #ifdef IncompressibleFlow
157 dimensionedScalar(
"kRes", dimensionSet(0, 2, -3, 0, 0, 0, 0), 0.0),
159 zeroGradientFvPatchField<scalar>::typeName),
163 mesh.time().timeName(),
171 mesh.time().timeName(),
179 mesh.time().timeName(),
187 "betaFieldInversion",
188 mesh.time().timeName(),
190 IOobject::READ_IF_PRESENT,
191 IOobject::AUTO_WRITE),
193 dimensionedScalar(
"betaFieldInversion", dimensionSet(0, 0, 0, 0, 0, 0, 0), 1.0),
194 zeroGradientFvPatchScalarField::typeName),
195 betaFieldInversionML_(
197 "betaFieldInversionML",
198 mesh.time().timeName(),
201 IOobject::AUTO_WRITE),
203 dimensionedScalar(
"betaFieldInversionML", dimensionSet(0, 0, 0, 0, 0, 0, 0), 1.0),
204 zeroGradientFvPatchScalarField::typeName),
208 mesh.time().timeName(),
211 IOobject::AUTO_WRITE),
213 dimensionedScalar(
"QCriterion", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
214 zeroGradientFvPatchScalarField::typeName),
215 p_(const_cast<volScalarField&>(
216 mesh_.thisDb().lookupObject<volScalarField>(
"p"))),
220 mesh.time().timeName(),
223 IOobject::AUTO_WRITE),
225 dimensionedScalar(
"pressureAlongStream", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
226 zeroGradientFvPatchScalarField::typeName),
227 turbulenceIntensity_(
229 "turbulenceIntensity",
230 mesh.time().timeName(),
233 IOobject::AUTO_WRITE),
235 dimensionedScalar(
"turbulenceIntensity", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
236 zeroGradientFvPatchScalarField::typeName),
237 transportProperties_(
239 "transportProperties",
240 mesh.time().constant(),
243 IOobject::NO_WRITE)),
247 mesh.time().timeName(),
250 IOobject::AUTO_WRITE),
252 dimensionedScalar(
"ReT", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
253 zeroGradientFvPatchScalarField::typeName),
257 mesh.time().timeName(),
260 IOobject::AUTO_WRITE),
262 dimensionedScalar(
"convectionTKE", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
263 zeroGradientFvPatchScalarField::typeName),
267 mesh.time().timeName(),
270 IOobject::AUTO_WRITE),
272 dimensionedScalar(
"tauRatio", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
273 zeroGradientFvPatchScalarField::typeName),
277 mesh.time().timeName(),
280 IOobject::AUTO_WRITE),
282 dimensionedScalar(
"pressureStress", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
283 zeroGradientFvPatchScalarField::typeName),
287 mesh.time().timeName(),
290 IOobject::AUTO_WRITE),
292 dimensionedScalar(
"curvature", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
293 zeroGradientFvPatchScalarField::typeName),
297 mesh.time().timeName(),
300 IOobject::AUTO_WRITE),
302 dimensionedScalar(
"UGradMisalignment", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0),
303 zeroGradientFvPatchScalarField::typeName),
304 y_(mesh_.thisDb().lookupObject<volScalarField>(
"yWall"))
309 IOdictionary fvSchemes(
312 mesh.time().system(),
317 word ddtScheme = word(fvSchemes.subDict(
"ddtSchemes").lookup(
"default"));
318 if (ddtScheme ==
"steadyState")
321 daOption.getAllOptions().lookupOrDefault<label>(
"printInterval", 100);
326 daOption.getAllOptions().lookupOrDefault<label>(
"printIntervalUnsteady", 500);
330 label nWallFaces = 0;
333 if (
omega_.boundaryField()[patchI].type() ==
"omegaWallFunction"
334 &&
omega_.boundaryField()[patchI].size() > 0)
351 const volScalarField& CDkOmega)
const
354 tmp<volScalarField> CDkOmegaPlus = max(
356 dimensionedScalar(
"1.0e-10", dimless / sqr(dimTime), 1.0e-10));
358 tmp<volScalarField> arg1 = min(
362 scalar(500) * (this->
nu()) / (sqr(
y_) *
omega_)),
366 return tanh(pow4(arg1));
372 tmp<volScalarField> arg2 = min(
375 scalar(500) * (this->
nu()) / (sqr(
y_) *
omega_)),
378 return tanh(sqr(arg2));
384 tmp<volScalarField> arg3 = min(
388 return 1 - tanh(pow4(arg3));
393 tmp<volScalarField> f23(
F2());
404 const volScalarField::Internal& GbyNu0,
405 const volScalarField::Internal& F2,
406 const volScalarField::Internal& S2)
const
415 const volScalarField::Internal& G)
const
421 const volScalarField& F1,
422 const volTensorField& gradU)
const
429 const volScalarField&
rho = rho_;
430 return tmp<fvScalarMatrix>(
433 dimVolume *
rho.dimensions() *
k_.dimensions() / dimTime));
438 const volScalarField&
rho = rho_;
439 return tmp<fvScalarMatrix>(
442 dimVolume *
rho.dimensions() *
omega_.dimensions() / dimTime));
446 const volScalarField::Internal& S2,
447 const volScalarField::Internal& gamma,
448 const volScalarField::Internal& beta)
const
450 const volScalarField&
rho = rho_;
451 return tmp<fvScalarMatrix>(
454 dimVolume *
rho.dimensions() *
omega_.dimensions() / dimTime));
485 word stateName = modelStates[idxI];
486 if (stateName ==
"nut")
488 modelStates[idxI] =
"omega";
489 modelStates.append(
"k");
502 const volVectorField
U =
mesh_.thisDb().lookupObject<volVectorField>(
"U");
503 tmp<volTensorField> tgradU = fvc::grad(
U);
504 volScalarField S2(2 * magSqr(symm(tgradU())));
508 nut_.correctBoundaryConditions();
525 k_.correctBoundaryConditions();
550 omega_.correctBoundaryConditions();
564 if (
omega_.boundaryField()[patchI].type() ==
"omegaWallFunction"
565 and
omega_.boundaryField()[patchI].size() > 0)
567 const UList<label>& faceCells =
mesh_.boundaryMesh()[patchI].faceCells();
589 if (
omega_.boundaryField()[patchI].type() ==
"omegaWallFunction"
590 &&
omega_.boundaryField()[patchI].size() > 0)
592 const UList<label>& faceCells =
mesh_.boundaryMesh()[patchI].faceCells();
597 omega_.boundaryFieldRef()[patchI][faceI] =
omega_[faceCells[faceI]];
653 label stateConSize = stateCon.size();
657 forAll(stateCon[idxI], idxJ)
659 word conStateName = stateCon[idxI][idxJ];
660 if (conStateName ==
"nut")
662 stateCon[idxI][idxJ] =
"omega";
663 stateCon[idxI].append(
"k");
673 forAll(stateCon[idxI], idxJ)
675 word conStateName = stateCon[idxI][idxJ];
676 if (conStateName ==
"U")
683 stateCon[idxI].append(
"U");
688 if (idxI != stateConSize - 1)
691 forAll(stateCon[idxI + 1], idxJ)
693 word conStateName = stateCon[idxI + 1][idxJ];
694 if (conStateName ==
"U")
701 stateCon[idxI + 1].append(
"U");
707 "In DAStateInfo, nut shows in the largest connectivity level! "
708 "This is not supported!")
755 if (
mesh_.thisDb().foundObject<volScalarField>(
"p"))
759 else if (
mesh_.thisDb().foundObject<volScalarField>(
"p_rgh"))
766 "Neither p nor p_rgh was found in mesh.thisDb()!"
767 "addModelResidualCon failed to setup turbulence residuals!")
772 #ifdef IncompressibleFlow
776 {
"U",
"omega",
"k",
"phi"},
783 {
"U",
"omega",
"k",
"phi"},
789 #ifdef CompressibleFlow
793 {
"U",
"T", pName,
"omega",
"k",
"phi"},
794 {
"U",
"T", pName,
"omega",
"k"},
795 {
"U",
"T", pName,
"omega",
"k"}
800 {
"U",
"T", pName,
"omega",
"k",
"phi"},
801 {
"U",
"T", pName,
"omega",
"k"},
802 {
"U",
"T", pName,
"omega",
"k"}
820 dictionary dummyOptions;
832 volTensorField UGrad(fvc::grad(
U_));
833 volTensorField Omega(
"Omega", skew(UGrad));
834 volScalarField magOmegaSqr(magSqr(Omega));
835 volSymmTensorField S(
"S", symm(UGrad));
836 volScalarField magS(mag(S));
837 volScalarField magSSqr(magSqr(S));
838 QCriterion_ = (magOmegaSqr - magSSqr) / (magOmegaSqr + magSSqr);
841 volVectorField pGrad(
"gradP", fvc::grad(
p_));
842 volScalarField pG_denominator(mag(
U_) * mag(pGrad) + mag(
U_ & pGrad));
843 pGradAlongStream_ = (
U_ & pGrad) / Foam::max(pG_denominator, dimensionedScalar(
"minpG", dimensionSet(0, 2, -3, 0, 0, 0, 0), SMALL));
850 dimensionedScalar maxReT(
"maxReT", dimless, 2.0);
851 ReT_ = Foam::min((sqrt(
k_) *
y_) / (scalar(50.0) * this->
nu()), maxReT);
854 volSymmTensorField tau(2.0 / 3.0 * I *
k_ -
nut_ * twoSymm(fvc::grad(
U_)));
855 volVectorField kGrad(
"gradK", fvc::grad(
k_));
862 volVectorField diagUGrad(
863 IOobject(
"diagUGrad",
864 mesh_.time().timeName(),
869 dimensionedVector(
"diagUGrad", dimensionSet(0, 0, 0, 0, 0, 0, 0), Foam::vector(0, 0, 0)),
870 zeroGradientFvPatchScalarField::typeName);
874 diagUGrad[cI].component(0) = UGrad[cI].xx();
875 diagUGrad[cI].component(1) = UGrad[cI].yy();
876 diagUGrad[cI].component(2) = UGrad[cI].zz();
877 pressureStress_[cI] = mag(pGrad[cI]) / (mag(pGrad[cI]) + mag(3.0 * cmptAv(
U_[cI] & diagUGrad[cI])));
883 curvature_[cI] = mag(
U_[cI] & UGrad[cI]) / (mag(
U_[cI] &
U_[cI]) + mag(
U_[cI] & UGrad[cI]));
890 / (mag(
U_[cI]) * mag(UGrad[cI] &
U_[cI]) + mag(
U_[cI] & UGrad[cI] &
U_[cI]));
893 label n = 9 *
mesh_.nCells();
894 label m =
mesh_.nCells();
910 #if defined(CODI_AD_REVERSE)
914 codi::ExternalFunctionHelper<codi::RealReverse> externalFunc;
915 for (label i = 0; i <
mesh_.nCells() * 9; i++)
917 externalFunc.addInput(
inputs_[i]);
920 for (label i = 0; i <
mesh_.nCells(); i++)
922 externalFunc.addOutput(
outputs_[i]);
925 externalFunc.callPrimalFunc(DAkOmegaSSTFIML::betaCompute);
927 codi::RealReverse::Tape& tape = codi::RealReverse::getTape();
931 externalFunc.addToTape(DAkOmegaSSTFIML::betaJacVecProd);
939 #elif defined(CODI_AD_FORWARD)
941 for (label i = 0; i < n; i++)
943 inputsDouble_[i] =
inputs_[i].value();
946 for (label i = 0; i < m; i++)
948 outputsDouble_[i] =
outputs_[i].value();
996 word divKScheme =
"div(phi,k)";
997 word divOmegaScheme =
"div(phi,omega)";
1003 isPC = options.getLabel(
"isPC");
1007 divKScheme =
"div(pc)";
1008 divOmegaScheme =
"div(pc)";
1017 volScalarField::Internal divU(fvc::div(fvc::absolute(
phi_ / fvc::interpolate(rho_),
U_)));
1019 tmp<volTensorField> tgradU = fvc::grad(
U_);
1020 volScalarField S2(2 * magSqr(symm(tgradU())));
1021 volScalarField::Internal GbyNu0((tgradU() && dev(twoSymm(tgradU()))));
1022 volScalarField::Internal G(
"kOmegaSSTFIML:G",
nut_ * GbyNu0);
1027 omega_.boundaryFieldRef().updateCoeffs();
1036 volScalarField CDkOmega(
1039 volScalarField
F1(this->
F1(CDkOmega));
1040 volScalarField
F23(this->
F23());
1044 volScalarField::Internal
gamma(this->
gamma(F1));
1045 volScalarField::Internal
beta(this->
beta(F1));
1048 tmp<fvScalarMatrix> omegaEqn(
1063 omegaEqn.ref().relax();
1064 omegaEqn.ref().boundaryManipulate(
omega_.boundaryFieldRef());
1071 SolverPerformance<scalar> solverOmega =
solve(omegaEqn);
1074 Info <<
"omega Initial residual: " << solverOmega.initialResidual() << endl
1075 <<
" Final residual: " << solverOmega.finalResidual() << endl;
1093 tmp<fvScalarMatrix> kEqn(
1098 - fvm::SuSp((2.0 / 3.0) *
phase_() * rho_() * divU,
k_)
1111 SolverPerformance<scalar> solverK =
solve(kEqn);
1114 Info <<
"k Initial residual: " << solverK.initialResidual() << endl
1115 <<
" Final residual: " << solverK.finalResidual() << endl;