Refactored nutMEWTWallFunction according to the new interface
This commit is contained in:
parent
a598804c79
commit
5c16db8055
2 changed files with 60 additions and 171 deletions
|
@ -51,48 +51,19 @@ namespace RASModels
|
|||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void nutMEWTWallFunctionFvPatchScalarField::checkType()
|
||||
{
|
||||
if (!patch().isWall())
|
||||
{
|
||||
FatalErrorIn("nutMEWTWallFunctionFvPatchScalarField::checkType()")
|
||||
<< "Invalid wall function specification" << nl
|
||||
<< " Patch type for patch " << patch().name()
|
||||
<< " must be wall" << nl
|
||||
<< " Current patch type is " << patch().type() << nl << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scalar nutMEWTWallFunctionFvPatchScalarField::calcYPlusLam
|
||||
(
|
||||
const scalar kappa,
|
||||
const scalar E
|
||||
) const
|
||||
{
|
||||
scalar ypl = 11.0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
ypl = log(E*ypl)/kappa;
|
||||
}
|
||||
|
||||
return ypl;
|
||||
}
|
||||
|
||||
|
||||
tmp<scalarField> nutMEWTWallFunctionFvPatchScalarField::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 turbulenceModel& turbModel =
|
||||
db().lookupObject<turbulenceModel>("turbulenceModel");
|
||||
|
||||
const scalar Cmu25 = pow(Cmu_, 0.25);
|
||||
const scalarField& y = turbModel.y()[patchI];
|
||||
const tmp<volScalarField> tk = turbModel.k();
|
||||
const volScalarField& k = tk();
|
||||
const scalarField& nuw = turbModel.nu().boundaryField()[patchI];
|
||||
|
||||
const scalar Cmu25 = pow025(Cmu_);
|
||||
|
||||
// Get normals
|
||||
const vectorField n = patch().nf();
|
||||
|
@ -141,8 +112,15 @@ tmp<scalarField> nutMEWTWallFunctionFvPatchScalarField::calcNut() const
|
|||
}
|
||||
else
|
||||
{
|
||||
Info<< "Field pressureGradient not found. Neglecting pressure gradient "
|
||||
InfoIn
|
||||
(
|
||||
"tmp<scalarField>"
|
||||
"nutCWTWallFunctionFvPatchScalarField::calcNut() const"
|
||||
) << "Field pressureGradient not found. Neglecting pressure gradient "
|
||||
<< "effects for wall functions at patch: " << patch().name()
|
||||
<< nl
|
||||
<< "If you would like to include pressure gradient effects, set up"
|
||||
<< " pressureGradient function object."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
@ -175,8 +153,15 @@ tmp<scalarField> nutMEWTWallFunctionFvPatchScalarField::calcNut() const
|
|||
}
|
||||
else
|
||||
{
|
||||
Info<< "Field velocityConvection not found. Neglecting convection "
|
||||
InfoIn
|
||||
(
|
||||
"tmp<scalarField>"
|
||||
"nutCWTWallFunctionFvPatchScalarField::calcNut() const"
|
||||
) << "Field velocityConvection not found. Neglecting convection "
|
||||
<< "effects for wall functions at patch: " << patch().name()
|
||||
<< nl
|
||||
<< "If you would like to include convection effects, set up"
|
||||
<< " velocityConvection function object."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
@ -254,12 +239,11 @@ tmp<scalarField> nutMEWTWallFunctionFvPatchScalarField::calcNut() const
|
|||
|
||||
void nutMEWTWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
|
||||
{
|
||||
nutkWallFunctionFvPatchScalarField::writeLocalEntries(os);
|
||||
|
||||
writeEntryIfDifferent<word>(os, "U", "U", UName_);
|
||||
writeEntryIfDifferent<word>(os, "p", "p", pName_);
|
||||
writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
|
||||
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,17 +255,11 @@ nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
|||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
nutkWallFunctionFvPatchScalarField(p, iF),
|
||||
UName_("U"),
|
||||
pName_("p"),
|
||||
nutName_("nut"),
|
||||
Cmu_(0.09),
|
||||
kappa_(0.41),
|
||||
E_(9.8),
|
||||
yPlusLam_(calcYPlusLam(kappa_, E_))
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
nutName_("nut")
|
||||
{}
|
||||
|
||||
|
||||
nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
||||
|
@ -291,17 +269,11 @@ nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
|||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF, dict),
|
||||
nutkWallFunctionFvPatchScalarField(p, iF, dict),
|
||||
UName_(dict.lookupOrDefault<word>("U", "U")),
|
||||
pName_(dict.lookupOrDefault<word>("p", "p")),
|
||||
nutName_(dict.lookupOrDefault<word>("nut", "nut")),
|
||||
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();
|
||||
}
|
||||
nutName_(dict.lookupOrDefault<word>("nut", "nut"))
|
||||
{}
|
||||
|
||||
|
||||
nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
||||
|
@ -312,17 +284,11 @@ nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
|||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
|
||||
UName_(ptf.UName_),
|
||||
pName_(ptf.pName_),
|
||||
nutName_(ptf.nutName_),
|
||||
Cmu_(ptf.Cmu_),
|
||||
kappa_(ptf.kappa_),
|
||||
E_(ptf.E_),
|
||||
yPlusLam_(ptf.yPlusLam_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
nutName_(ptf.nutName_)
|
||||
{}
|
||||
|
||||
|
||||
nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
||||
|
@ -330,17 +296,11 @@ nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
|||
const nutMEWTWallFunctionFvPatchScalarField& wfpsf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(wfpsf),
|
||||
nutkWallFunctionFvPatchScalarField(wfpsf),
|
||||
UName_(wfpsf.UName_),
|
||||
pName_(wfpsf.pName_),
|
||||
nutName_(wfpsf.nutName_),
|
||||
Cmu_(wfpsf.Cmu_),
|
||||
kappa_(wfpsf.kappa_),
|
||||
E_(wfpsf.E_),
|
||||
yPlusLam_(wfpsf.yPlusLam_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
nutName_(wfpsf.nutName_)
|
||||
{}
|
||||
|
||||
|
||||
nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
||||
|
@ -349,51 +309,11 @@ nutMEWTWallFunctionFvPatchScalarField::nutMEWTWallFunctionFvPatchScalarField
|
|||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(wfpsf, iF),
|
||||
nutkWallFunctionFvPatchScalarField(wfpsf, iF),
|
||||
UName_(wfpsf.UName_),
|
||||
pName_(wfpsf.pName_),
|
||||
nutName_(wfpsf.nutName_),
|
||||
Cmu_(wfpsf.Cmu_),
|
||||
kappa_(wfpsf.kappa_),
|
||||
E_(wfpsf.E_),
|
||||
yPlusLam_(wfpsf.yPlusLam_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void nutMEWTWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
operator==(calcNut());
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
tmp<scalarField> nutMEWTWallFunctionFvPatchScalarField::yPlus() 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 kwc = k.boundaryField()[patchI].patchInternalField();
|
||||
const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
|
||||
|
||||
return pow(Cmu_, 0.25)*y*sqrt(kwc)/nuw;
|
||||
}
|
||||
|
||||
|
||||
void nutMEWTWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<scalar>::write(os);
|
||||
writeLocalEntries(os);
|
||||
writeEntry("value", os);
|
||||
}
|
||||
nutName_(wfpsf.nutName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
|
|
@ -39,6 +39,18 @@ Description
|
|||
year = {2017},
|
||||
}
|
||||
|
||||
Usage
|
||||
Example of the boundary condition specification:
|
||||
\verbatim
|
||||
<patchName>
|
||||
{
|
||||
type nutCWTWallFunction;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::nutkWallFunctionFvPatchScalarField
|
||||
|
||||
SourceFiles
|
||||
nutMEWTWallFunctionFvPatchScalarField.C
|
||||
|
||||
|
@ -50,7 +62,7 @@ Author
|
|||
#ifndef nutMEWTWallFunctionFvPatchScalarField_H
|
||||
#define nutMEWTWallFunctionFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "nutkWallFunctionFvPatchScalarField.H"
|
||||
#include "tolerancesSwitch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -68,19 +80,13 @@ namespace RASModels
|
|||
|
||||
class nutMEWTWallFunctionFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField
|
||||
public nutkWallFunctionFvPatchScalarField
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
// Private static data member
|
||||
|
||||
//- Tolerance for the A dimensionless parameter
|
||||
//- Static tolerance for the A dimensionless parameter
|
||||
static const debug::tolerancesSwitch dimlessAFactorTol_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of velocity field
|
||||
word UName_;
|
||||
|
||||
|
@ -90,29 +96,10 @@ protected:
|
|||
//- Name of eddy viscosity field
|
||||
word nutName_;
|
||||
|
||||
//- Name of omega field
|
||||
word omegaName_;
|
||||
|
||||
//- Cmu coefficient
|
||||
scalar Cmu_;
|
||||
protected:
|
||||
|
||||
//- Von Karman constant
|
||||
scalar kappa_;
|
||||
|
||||
//- 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;
|
||||
// Protected Member Functions
|
||||
|
||||
//- Calculate the turbulence viscosity
|
||||
virtual tmp<scalarField> calcNut() const;
|
||||
|
@ -144,8 +131,7 @@ public:
|
|||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// nutMEWTWallFunctionFvPatchScalarField
|
||||
//- Construct by mapping given nutMEWTWallFunctionFvPatchScalarField
|
||||
// onto a new patch
|
||||
nutMEWTWallFunctionFvPatchScalarField
|
||||
(
|
||||
|
@ -188,23 +174,6 @@ public:
|
|||
new nutMEWTWallFunctionFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Calculate and return the yPlus at the boundary
|
||||
virtual tmp<scalarField> yPlus() const;
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
Reference in a new issue