caching yPlusLam locally

This commit is contained in:
andy 2009-07-24 11:15:41 +01:00
parent be65512449
commit 481fd3e2e1
12 changed files with 512 additions and 467 deletions

View File

@ -40,7 +40,7 @@ namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
scalar mutRoughWallFunctionFvPatchScalarField::fnRough
(
@ -65,6 +65,60 @@ scalar mutRoughWallFunctionFvPatchScalarField::fnRough
}
tmp<scalarField> mutRoughWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const scalar Cmu25 = pow(Cmu_, 0.25);
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
forAll(mutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
scalar Edash = E_;
scalar yPlusLamNew = yPlusLam_;
if (KsPlus > 2.25)
{
Edash /= fnRough(KsPlus, Cs_[faceI]);
yPlusLamNew = rasModel.yPlusLam(kappa_, Edash);
}
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", KsPlus = " << KsPlus
<< ", Edash = " << Edash
<< ", yPlusLam = " << yPlusLam_
<< endl;
}
if (yPlus > yPlusLamNew)
{
mutw[faceI] =
muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1);
}
}
return tmutw;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
@ -158,61 +212,6 @@ void mutRoughWallFunctionFvPatchScalarField::rmap
}
tmp<scalarField> mutRoughWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const scalar Cmu25 = pow(Cmu_, 0.25);
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
forAll(mutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
scalar Edash = E_;
scalar yPlusLamNew = yPlusLam;
if (KsPlus > 2.25)
{
Edash /= fnRough(KsPlus, Cs_[faceI]);
yPlusLamNew = rasModel.yPlusLam(kappa_, Edash);
}
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", KsPlus = " << KsPlus
<< ", Edash = " << Edash
<< ", yPlusLam = " << yPlusLam
<< endl;
}
if (yPlus > yPlusLamNew)
{
mutw[faceI] =
muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1);
}
}
return tmutw;
}
void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);

View File

@ -39,6 +39,8 @@ namespace compressible
namespace RASModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
tmp<scalarField>
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
(
@ -48,7 +50,6 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI];
@ -74,7 +75,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei];
const scalar kappaRe = kappa_*Re;
scalar yp = yPlusLam;
scalar yp = yPlusLam_;
const scalar ryPlusLam = 1.0/yp;
int iter = 0;
@ -146,7 +147,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei];
const scalar kappaRe = kappa_*Re;
scalar yp = yPlusLam;
scalar yp = yPlusLam_;
const scalar ryPlusLam = 1.0/yp;
int iter = 0;
@ -171,6 +172,38 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
}
tmp<scalarField>
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI];
scalarField magUp = mag(Uw.patchInternalField() - Uw);
tmp<scalarField> tyPlus = calcYPlus(magUp);
scalarField& yPlus = tyPlus();
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
forAll(yPlus, facei)
{
if (yPlus[facei] > yPlusLam_)
{
const scalar Re = rho[facei]*magUp[facei]*y[facei]/muw[facei];
mutw[facei] = muw[facei]*(sqr(yPlus[facei])/Re - 1);
}
}
return tmutw;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
@ -247,39 +280,6 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI];
scalarField magUp = mag(Uw.patchInternalField() - Uw);
tmp<scalarField> tyPlus = calcYPlus(magUp);
scalarField& yPlus = tyPlus();
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
forAll(yPlus, facei)
{
if (yPlus[facei] > yPlusLam)
{
const scalar Re = rho[facei]*magUp[facei]*y[facei]/muw[facei];
mutw[facei] = muw[facei]*(sqr(yPlus[facei])/Re - 1);
}
}
return tmutw;
}
tmp<scalarField>
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const
{

View File

@ -50,7 +50,6 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI];
const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
@ -62,7 +61,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
{
scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]);
scalar yp = yPlusLam;
scalar yp = yPlusLam_;
scalar ryPlusLam = 1.0/yp;
int iter = 0;
@ -82,6 +81,35 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
}
tmp<scalarField>
mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() 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 fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
tmp<scalarField> tyPlus = calcYPlus(magUp);
scalarField& yPlus = tyPlus();
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
forAll(yPlus, faceI)
{
if (yPlus[faceI] > yPlusLam_)
{
mutw[faceI] =
muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0);
}
}
return tmutw;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
@ -143,36 +171,6 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magUp = mag(Uw.patchInternalField() - Uw);
const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
tmp<scalarField> tyPlus = calcYPlus(magUp);
scalarField& yPlus = tyPlus();
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
forAll(yPlus, faceI)
{
if (yPlus[faceI] > yPlusLam)
{
mutw[faceI] =
muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0);
}
}
return tmutw;
}
tmp<scalarField>
mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
{

View File

@ -105,6 +105,21 @@ tmp<scalarField> mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
}
tmp<scalarField>
mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magGradU = mag(Uw.snGrad());
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutSpalartAllmarasWallFunctionFvPatchScalarField::
@ -166,21 +181,6 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magGradU = mag(Uw.snGrad());
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw);
}
tmp<scalarField>
mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
{

View File

@ -40,7 +40,7 @@ namespace compressible
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void mutWallFunctionFvPatchScalarField::checkType()
{
@ -56,82 +56,20 @@ void mutWallFunctionFvPatchScalarField::checkType()
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
scalar mutWallFunctionFvPatchScalarField::calcYPlusLam
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8)
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const mutWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_)
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8))
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const mutWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_)
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const mutWallFunctionFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutWallFunctionFvPatchScalarField::updateCoeffs()
const scalar kappa,
const scalar E
) const
{
operator==(calcMut());
scalar ypl = 11.0;
fixedValueFvPatchScalarField::updateCoeffs();
for (int i=0; i<10; i++)
{
ypl = log(E*ypl)/kappa;
}
return ypl;
}
@ -139,7 +77,6 @@ tmp<scalarField> mutWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const tmp<volScalarField> tk = rasModel.k();
@ -156,10 +93,9 @@ tmp<scalarField> mutWallFunctionFvPatchScalarField::calcMut() const
label faceCellI = patch().faceCells()[faceI];
scalar yPlus =
Cmu25*y[faceI]*sqrt(k[faceCellI])
/(muw[faceI]/rhow[faceI]);
Cmu25*y[faceI]*sqrt(k[faceCellI])/(muw[faceI]/rhow[faceI]);
if (yPlus > yPlusLam)
if (yPlus > yPlusLam_)
{
mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1);
}
@ -169,6 +105,98 @@ tmp<scalarField> mutWallFunctionFvPatchScalarField::calcMut() const
}
void mutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
{
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
yPlusLam_(calcYPlusLam(kappa_, E_))
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const mutWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_),
yPlusLam_(ptf.yPlusLam_)
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)),
yPlusLam_(calcYPlusLam(kappa_, E_))
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const mutWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
{}
mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
(
const mutWallFunctionFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutWallFunctionFvPatchScalarField::updateCoeffs()
{
operator==(calcMut());
fixedValueFvPatchScalarField::updateCoeffs();
}
tmp<scalarField> mutWallFunctionFvPatchScalarField::yPlus() const
{
const label patchI = patch().index();
@ -194,14 +222,6 @@ void mutWallFunctionFvPatchScalarField::write(Ostream& os) const
}
void mutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
{
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, mutWallFunctionFvPatchScalarField);

View File

@ -70,12 +70,18 @@ protected:
//- E coefficient
scalar E_;
//- Y+ at the edge of the laminar sublayer
scalar yPlusLam_;
// Protected member functions
//- Check the type of the patch
virtual void checkType();
//- Calculate the Y+ at the edge of the laminar sublayer
virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const;
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcMut() const;

View File

@ -39,7 +39,7 @@ namespace incompressible
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
scalar nutRoughWallFunctionFvPatchScalarField::fnRough
(
@ -64,6 +64,68 @@ scalar nutRoughWallFunctionFvPatchScalarField::fnRough
}
tmp<scalarField> nutRoughWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
const scalar Cmu25 = pow(Cmu_, 0.25);
tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
scalarField& nutw = tnutw();
forAll(nutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/nuw[faceI];
scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI];
scalar Edash = E_;
if (KsPlus > 2.25)
{
Edash /= fnRough(KsPlus, Cs_[faceI]);
}
if (yPlus > yPlusLam_)
{
scalar limitingNutw = max(nutw[faceI], nuw[faceI]);
// To avoid oscillations limit the change in the wall viscosity
// which is particularly important if it temporarily becomes zero
nutw[faceI] =
max
(
min
(
nuw[faceI]
*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1),
2*limitingNutw
), 0.5*limitingNutw
);
}
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", KsPlus = " << KsPlus
<< ", Edash = " << Edash
<< ", nutw = " << nutw[faceI]
<< endl;
}
}
return tnutw;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutRoughWallFunctionFvPatchScalarField::nutRoughWallFunctionFvPatchScalarField
@ -157,69 +219,6 @@ void nutRoughWallFunctionFvPatchScalarField::rmap
}
tmp<scalarField> nutRoughWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
const scalar Cmu25 = pow(Cmu_, 0.25);
tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
scalarField& nutw = tnutw();
forAll(nutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/nuw[faceI];
scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI];
scalar Edash = E_;
if (KsPlus > 2.25)
{
Edash /= fnRough(KsPlus, Cs_[faceI]);
}
if (yPlus > yPlusLam)
{
scalar limitingNutw = max(nutw[faceI], nuw[faceI]);
// To avoid oscillations limit the change in the wall viscosity
// which is particularly important if it temporarily becomes zero
nutw[faceI] =
max
(
min
(
nuw[faceI]
*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1),
2*limitingNutw
), 0.5*limitingNutw
);
}
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", KsPlus = " << KsPlus
<< ", Edash = " << Edash
<< ", nutw = " << nutw[faceI]
<< endl;
}
}
return tnutw;
}
void nutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);

View File

@ -39,7 +39,39 @@ namespace incompressible
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
// The flow velocity at the adjacent cell centre
const scalarField magUp = mag(Uw.patchInternalField() - Uw);
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_)
{
const scalar Re = magUp[facei]*y[facei]/nuw[facei];
nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1);
}
}
return tnutw;
}
tmp<scalarField>
nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
@ -50,7 +82,6 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
@ -75,7 +106,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
const scalar Re = magUpara*y[facei]/nuw[facei];
const scalar kappaRe = kappa_*Re;
scalar yp = yPlusLam;
scalar yp = yPlusLam_;
const scalar ryPlusLam = 1.0/yp;
int iter = 0;
@ -133,7 +164,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
&& yp > VSMALL
);
yPlus[facei] = yp;
yPlus[facei] = max(0.0, yp);
}
}
}
@ -146,7 +177,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
const scalar Re = magUpara*y[facei]/nuw[facei];
const scalar kappaRe = kappa_*Re;
scalar yp = yPlusLam;
scalar yp = yPlusLam_;
const scalar ryPlusLam = 1.0/yp;
int iter = 0;
@ -159,7 +190,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus
} while(mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 && ++iter < 10);
yPlus[facei] = yp;
yPlus[facei] = max(0.0, yp);
}
}
@ -243,39 +274,6 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
// The flow velocity at the adjacent cell centre
const scalarField magUp = mag(Uw.patchInternalField() - Uw);
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)
{
const scalar Re = magUp[facei]*y[facei]/nuw[facei];
nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1);
}
}
return tnutw;
}
tmp<scalarField>
nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const
{

View File

@ -41,6 +41,35 @@ 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
(
@ -50,7 +79,6 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
@ -61,7 +89,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
{
scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
scalar yp = yPlusLam;
scalar yp = yPlusLam_;
scalar ryPlusLam = 1.0/yp;
int iter = 0;
@ -142,36 +170,6 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
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::yPlus() const
{

View File

@ -39,7 +39,21 @@ namespace incompressible
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magGradU = mag(Uw.snGrad());
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
return max(0.0, sqr(calcUTau(magGradU))/magGradU - nuw);
}
tmp<scalarField> nutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
(
@ -159,20 +173,6 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<scalarField>
nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const scalarField magGradU = mag(Uw.snGrad());
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
return max(0.0, sqr(calcUTau(magGradU))/magGradU - nuw);
}
tmp<scalarField>
nutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
{

View File

@ -56,92 +56,20 @@ void nutWallFunctionFvPatchScalarField::checkType()
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
scalar nutWallFunctionFvPatchScalarField::calcYPlusLam
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8)
const scalar kappa,
const scalar E
) const
{
checkType();
}
scalar ypl = 11.0;
for (int i=0; i<10; i++)
{
ypl = log(E*ypl)/kappa;
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const nutWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_)
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8))
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const nutWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_)
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const nutWallFunctionFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_)
{
checkType();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void nutWallFunctionFvPatchScalarField::updateCoeffs()
{
operator==(calcNut());
fixedValueFvPatchScalarField::updateCoeffs();
return ypl;
}
@ -150,7 +78,6 @@ tmp<scalarField> nutWallFunctionFvPatchScalarField::calcNut() const
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
@ -167,7 +94,7 @@ tmp<scalarField> nutWallFunctionFvPatchScalarField::calcNut() const
scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
if (yPlus > yPlusLam)
if (yPlus > yPlusLam_)
{
nutw[faceI] = nuw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0);
}
@ -177,6 +104,108 @@ tmp<scalarField> nutWallFunctionFvPatchScalarField::calcNut() const
}
void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
{
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
yPlusLam_(calcYPlusLam(kappa_, E_))
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const nutWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_),
yPlusLam_(ptf.yPlusLam_)
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)),
yPlusLam_(calcYPlusLam(kappa_, E_))
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const nutWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
{
checkType();
}
nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
(
const nutWallFunctionFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
{
checkType();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void nutWallFunctionFvPatchScalarField::updateCoeffs()
{
operator==(calcNut());
fixedValueFvPatchScalarField::updateCoeffs();
}
tmp<scalarField> nutWallFunctionFvPatchScalarField::yPlus() const
{
const label patchI = patch().index();
@ -201,14 +230,6 @@ void nutWallFunctionFvPatchScalarField::write(Ostream& os) const
}
void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
{
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField);

View File

@ -70,12 +70,18 @@ protected:
//- E coefficient
scalar E_;
//- Y+ at the edge of the laminar sublayer
scalar yPlusLam_;
// Protected member functions
//- Check the type of the patch
virtual void checkType();
//- Calculate the Y+ at the edge of the laminar sublayer
virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const;
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcNut() const;