Refactored nutSpalartAllmarasStandardWallFunction

This wall function is now the same as nutUWallFunction, we simply derive from it
to enable backward compatibility.
This commit is contained in:
Vuko Vukcevic 2018-06-19 11:21:28 +02:00
parent 68d275b2b8
commit b31f23321a
2 changed files with 10 additions and 128 deletions

View file

@ -38,76 +38,6 @@ namespace incompressible
namespace RASModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magUp = mag(Uw.patchInternalField() - Uw);
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
tmp<scalarField> tyPlus = calcYPlus(magUp);
scalarField& yPlus = tyPlus();
tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
scalarField& nutw = tnutw();
forAll(yPlus, facei)
{
if (yPlus[facei] > yPlusLam_)
{
nutw[facei] =
nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
}
}
return tnutw;
}
tmp<scalarField>
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
(
const scalarField& magUp
) const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
scalarField& yPlus = tyPlus();
forAll(yPlus, facei)
{
scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
scalar yp = yPlusLam_;
scalar ryPlusLam = 1.0/yp;
int iter = 0;
scalar yPlusLast = 0.0;
do
{
yPlusLast = yp;
yp = (kappaRe + yp)/(1.0 + log(E_*yp));
} while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
yPlus[facei] = max(0.0, yp);
}
return tyPlus;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
@ -117,7 +47,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
nutWallFunctionFvPatchScalarField(p, iF)
nutUWallFunctionFvPatchScalarField(p, iF)
{}
@ -130,7 +60,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper
)
:
nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
nutUWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
{}
@ -142,7 +72,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const dictionary& dict
)
:
nutWallFunctionFvPatchScalarField(p, iF, dict)
nutUWallFunctionFvPatchScalarField(p, iF, dict)
{}
@ -152,7 +82,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
)
:
nutWallFunctionFvPatchScalarField(sawfpsf)
nutUWallFunctionFvPatchScalarField(sawfpsf)
{}
@ -163,35 +93,10 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
nutWallFunctionFvPatchScalarField(sawfpsf, iF)
nutUWallFunctionFvPatchScalarField(sawfpsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magUp = mag(Uw.patchInternalField() - Uw);
return calcYPlus(magUp);
}
void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchField<scalar>::write(os);
writeLocalEntries(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField

View file

@ -26,7 +26,9 @@ Class
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
Description
Wall function boundary condition for walls
This boundary condition is the same as nutUWallFunction. We will simply
derive from nutUWallFunctionFvPatchScalarField to enable backward
compatibility.
SourceFiles
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C
@ -36,7 +38,7 @@ SourceFiles
#ifndef nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
#define nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
#include "nutWallFunctionFvPatchScalarField.H"
#include "nutUWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,19 +55,8 @@ namespace RASModels
class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
:
public nutWallFunctionFvPatchScalarField
public nutUWallFunctionFvPatchScalarField
{
protected:
// Protected member functions
//- Calculate yPLus
virtual tmp<scalarField> calcYPlus(const scalarField& magUp) const;
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcNut() const;
public:
//- Runtime type information
@ -140,20 +131,6 @@ public:
)
);
}
// Member functions
// Evaluation functions
//- Calculate and return the yPlus at the boundary
virtual tmp<scalarField> yPlus() const;
// I-O
//- Write
virtual void write(Ostream& os) const;
};