Refactored nutSpalartAllmarasWallFunction according to the new interface

This commit is contained in:
Vuko Vukcevic 2018-06-19 11:27:01 +02:00
parent 8612bd74d3
commit 798d0f0a4d

View file

@ -45,14 +45,16 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const
{ {
const label patchI = patch().index(); const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const turbulenceModel& turbModel =
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; db().lookupObject<turbulenceModel>("turbulenceModel");
const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchI];
const scalarField magGradU = mag(Uw.snGrad()); const scalarField magGradU = mag(Uw.snGrad());
const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; const scalarField& nuw = turbModel.nu().boundaryField()[patchI];
return max return max
( (
scalar(0), 0.0,
sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw
); );
} }
@ -63,51 +65,53 @@ tmp<scalarField> nutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
const scalarField& magGradU const scalarField& magGradU
) const ) const
{ {
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const turbulenceModel& turbModel =
const scalarField& y = rasModel.y()[patch().index()]; db().lookupObject<turbulenceModel>("turbulenceModel");
const scalarField& y = turbModel.y()[patch().index()];
const fvPatchVectorField& Uw = const fvPatchVectorField& Uw =
rasModel.U().boundaryField()[patch().index()]; turbModel.U().boundaryField()[patch().index()];
const scalarField magUp = mag(Uw.patchInternalField() - Uw); const scalarField magUp = mag(Uw.patchInternalField() - Uw);
const scalarField& nuw = rasModel.nu().boundaryField()[patch().index()]; const scalarField& nuw = turbModel.nu().boundaryField()[patch().index()];
const scalarField& nutw = *this; const scalarField& nutw = *this;
tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0)); tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
scalarField& uTau = tuTau(); scalarField& uTau = tuTau();
forAll(uTau, facei) forAll(uTau, faceI)
{ {
scalar magUpara = magUp[facei]; const scalar& magUpara = magUp[faceI];
scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]); scalar ut = sqrt((nutw[faceI] + nuw[faceI])*magGradU[faceI]);
if (ut > VSMALL) if (ut > VSMALL)
{ {
int iter = 0; label iter = 0;
scalar err = GREAT; scalar err = GREAT;
do do
{ {
scalar kUu = min(kappa_*magUpara/ut, 50); const scalar kUu = min(kappa_*magUpara/ut, 50);
scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); const scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
scalar f = const scalar f =
- ut*y[facei]/nuw[facei] - ut*y[faceI]/nuw[faceI]
+ magUpara/ut + magUpara/ut
+ 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
scalar df = const scalar df =
y[facei]/nuw[facei] y[faceI]/nuw[faceI]
+ magUpara/sqr(ut) + magUpara/sqr(ut)
+ 1/E_*kUu*fkUu/ut; + 1/E_*kUu*fkUu/ut;
scalar uTauNew = ut + f/df; const scalar uTauNew = ut + f/df;
err = mag((ut - uTauNew)/ut); err = mag((ut - uTauNew)/ut);
ut = uTauNew; ut = uTauNew;
} while (ut > VSMALL && err > 0.01 && ++iter < 10); } while (ut > VSMALL && err > 0.01 && ++iter < 10);
uTau[facei] = max(0.0, ut); uTau[faceI] = max(0.0, ut);
} }
} }
@ -128,6 +132,18 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField
{} {}
nutSpalartAllmarasWallFunctionFvPatchScalarField::
nutSpalartAllmarasWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
nutWallFunctionFvPatchScalarField(p, iF, dict)
{}
nutSpalartAllmarasWallFunctionFvPatchScalarField:: nutSpalartAllmarasWallFunctionFvPatchScalarField::
nutSpalartAllmarasWallFunctionFvPatchScalarField nutSpalartAllmarasWallFunctionFvPatchScalarField
( (
@ -141,18 +157,6 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField
{} {}
nutSpalartAllmarasWallFunctionFvPatchScalarField::
nutSpalartAllmarasWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
nutWallFunctionFvPatchScalarField(p, iF, dict)
{}
nutSpalartAllmarasWallFunctionFvPatchScalarField:: nutSpalartAllmarasWallFunctionFvPatchScalarField::
nutSpalartAllmarasWallFunctionFvPatchScalarField nutSpalartAllmarasWallFunctionFvPatchScalarField
( (
@ -181,26 +185,17 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
{ {
const label patchI = patch().index(); const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const turbulenceModel& turbModel =
const scalarField& y = rasModel.y()[patchI]; db().lookupObject<turbulenceModel>("turbulenceModel");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; const scalarField& y = turbModel.y()[patchI];
const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchI];
const scalarField& nuw = turbModel.nu().boundaryField()[patchI];
return y*calcUTau(mag(Uw.snGrad()))/nuw; return y*calcUTau(mag(Uw.snGrad()))/nuw;
} }
void nutSpalartAllmarasWallFunctionFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchField<scalar>::write(os);
writeLocalEntries(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField makePatchTypeField