Refactored nutWallFunction according to Vanilla
nutWallFunctionFvPatchScalarField is now an abstract base class (no default behaviour)
This commit is contained in:
parent
6cdc361218
commit
ae91f480ce
2 changed files with 39 additions and 79 deletions
|
@ -44,7 +44,7 @@ void nutWallFunctionFvPatchScalarField::checkType()
|
|||
{
|
||||
if (!patch().isWall())
|
||||
{
|
||||
FatalErrorIn("nutWallFunctionFvPatchScalarField::checkType()")
|
||||
FatalErrorIn(this->type() + "FvPatchScalarField::checkType()")
|
||||
<< "Invalid wall function specification" << nl
|
||||
<< " Patch type for patch " << patch().name()
|
||||
<< " must be wall" << nl
|
||||
|
@ -62,7 +62,7 @@ scalar nutWallFunctionFvPatchScalarField::calcYPlusLam
|
|||
{
|
||||
scalar ypl = 11.0;
|
||||
|
||||
for (int i=0; i<10; i++)
|
||||
for (label i = 0; i < 10; ++i)
|
||||
{
|
||||
ypl = log(E*ypl)/kappa;
|
||||
}
|
||||
|
@ -71,37 +71,6 @@ scalar nutWallFunctionFvPatchScalarField::calcYPlusLam
|
|||
}
|
||||
|
||||
|
||||
tmp<scalarField> nutWallFunctionFvPatchScalarField::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 yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
|
||||
|
||||
if (yPlus > yPlusLam_)
|
||||
{
|
||||
nutw[faceI] = nuw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
return tnutw;
|
||||
}
|
||||
|
||||
|
||||
void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
|
||||
|
@ -198,28 +167,17 @@ nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
|
|||
|
||||
void nutWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
operator==(calcNut());
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
tmp<scalarField> nutWallFunctionFvPatchScalarField::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 nutWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<scalar>::write(os);
|
||||
|
@ -228,10 +186,6 @@ void nutWallFunctionFvPatchScalarField::write(Ostream& os) const
|
|||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace RASModels
|
||||
|
|
|
@ -25,10 +25,37 @@ Class
|
|||
Foam::incompressible::RASModels::nutWallFunctionFvPatchScalarField
|
||||
|
||||
Description
|
||||
Boundary condition for turbulent (kinematic) viscosity when using wall
|
||||
functions
|
||||
Abstract base class for oundary condition for turbulent (kinematic)
|
||||
viscosity when using wall functions
|
||||
- replicates OpenFOAM v1.5 (and earlier) behaviour
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
Cmu | Cmu coefficient | no | 0.09
|
||||
kappa | Von Karman constant | no | 0.41
|
||||
E | E coefficient | no | 9.8
|
||||
\endtable
|
||||
|
||||
Examples of the boundary condition specification:
|
||||
\verbatim
|
||||
<patchName>
|
||||
{
|
||||
type nutWallFunction;
|
||||
value uniform 0.0;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Reference for the default model coefficients:
|
||||
\verbatim
|
||||
H. Versteeg, W. Malalasekera
|
||||
An Introduction to Computational Fluid Dynamics: The Finite Volume
|
||||
Method, subsection "3.5.2 k-epsilon model"
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
|
||||
SourceFiles
|
||||
nutWallFunctionFvPatchScalarField.C
|
||||
|
||||
|
@ -73,7 +100,7 @@ protected:
|
|||
scalar yPlusLam_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
// Protected Member Functions
|
||||
|
||||
//- Check the type of the patch
|
||||
virtual void checkType();
|
||||
|
@ -82,7 +109,7 @@ protected:
|
|||
virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const;
|
||||
|
||||
//- Calculate the turbulence viscosity
|
||||
virtual tmp<scalarField> calcNut() const;
|
||||
virtual tmp<scalarField> calcNut() const = 0;
|
||||
|
||||
//- Write local wall function variables
|
||||
virtual void writeLocalEntries(Ostream&) const;
|
||||
|
@ -128,15 +155,6 @@ public:
|
|||
const nutWallFunctionFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new nutWallFunctionFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
nutWallFunctionFvPatchScalarField
|
||||
(
|
||||
|
@ -144,25 +162,13 @@ public:
|
|||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new nutWallFunctionFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Calculate and return the yPlus at the boundary
|
||||
virtual tmp<scalarField> yPlus() const;
|
||||
virtual tmp<scalarField> yPlus() const = 0;
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
|
Reference in a new issue