Refactored nutkWallFunction according to Vanilla

nutkWallFunctionFvPatchScalarField now derives from
nutWallFunctionFvPatchScalarField
This commit is contained in:
Vuko Vukcevic 2018-06-19 11:07:06 +02:00
parent ae91f480ce
commit f78472f100
2 changed files with 40 additions and 149 deletions

View file

@ -40,58 +40,31 @@ namespace RASModels
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void nutkWallFunctionFvPatchScalarField::checkType()
{
if (!patch().isWall())
{
FatalErrorIn("nutkWallFunctionFvPatchScalarField::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 nutkWallFunctionFvPatchScalarField::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> nutkWallFunctionFvPatchScalarField::calcNut() const
{
const label patchi = patch().index();
const label patchI = patch().index();
const turbulenceModel& turbModel =
db().lookupObject<turbulenceModel>("turbulenceModel");
const scalarField& y = turbModel.y()[patchi];
const scalarField& y = turbModel.y()[patchI];
const tmp<volScalarField> tk = turbModel.k();
const volScalarField& k = tk();
const scalarField& nuw = turbModel.nu().boundaryField()[patchi];
const scalarField& nuw = turbModel.nu().boundaryField()[patchI];
const scalar Cmu25 = pow025(Cmu_);
tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
scalarField& nutw = tnutw();
// Get face cells
const unallocLabelList& fc = patch().faceCells();
forAll(nutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
const label cellI = fc[faceI];
scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
const scalar yPlus = Cmu25*y[faceI]*sqrt(k[cellI])/nuw[faceI];
if (yPlus > yPlusLam_)
{
@ -103,14 +76,6 @@ tmp<scalarField> nutkWallFunctionFvPatchScalarField::calcNut() const
}
void nutkWallFunctionFvPatchScalarField::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 * * * * * * * * * * * * * * //
nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
@ -119,14 +84,8 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
yPlusLam_(calcYPlusLam(kappa_, E_))
{
checkType();
}
nutWallFunctionFvPatchScalarField(p, iF)
{}
nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
@ -136,14 +95,8 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
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(p, iF, dict)
{}
nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
@ -154,14 +107,8 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_),
yPlusLam_(ptf.yPlusLam_)
{
checkType();
}
nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
{}
nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
@ -169,14 +116,8 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
const nutkWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
{
checkType();
}
nutWallFunctionFvPatchScalarField(wfpsf)
{}
nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
@ -185,56 +126,29 @@ nutkWallFunctionFvPatchScalarField::nutkWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
{
checkType();
}
nutWallFunctionFvPatchScalarField(wfpsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void nutkWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
operator==(calcNut());
fixedValueFvPatchScalarField::updateCoeffs();
}
tmp<scalarField> nutkWallFunctionFvPatchScalarField::yPlus() const
{
const label patchi = patch().index();
const label patchI = patch().index();
const turbulenceModel& turbModel =
db().lookupObject<turbulenceModel>("turbulenceModel");
const scalarField& y = turbModel.y()[patchi];
const scalarField& y = turbModel.y()[patchI];
const tmp<volScalarField> tk = turbModel.k();
const volScalarField& k = tk();
const scalarField kwc = k.boundaryField()[patchi].patchInternalField();
const scalarField& nuw = turbModel.nu().boundaryField()[patchi];
const scalarField kwc = k.boundaryField()[patchI].patchInternalField();
const scalarField& nuw = turbModel.nu().boundaryField()[patchI];
return pow025(Cmu_)*y*sqrt(kwc)/nuw;
}
void nutkWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
writeLocalEntries(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, nutkWallFunctionFvPatchScalarField);

View file

@ -29,6 +29,18 @@ Description
functions, based on turbulence kinetic energy.
- replicates OpenFOAM v1.5 (and earlier) behaviour
Usage
Example of the boundary condition specification:
\verbatim
<patchName>
{
type nutkWallFunction;
}
\endverbatim
See also
Foam::nutWallFunctionFvPatchScalarField
SourceFiles
nutkWallFunctionFvPatchScalarField.C
@ -37,7 +49,7 @@ SourceFiles
#ifndef nutkWallFunctionFvPatchScalarField_H
#define nutkWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
#include "nutWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,39 +66,15 @@ namespace RASModels
class nutkWallFunctionFvPatchScalarField
:
public fixedValueFvPatchScalarField
public nutWallFunctionFvPatchScalarField
{
protected:
// Protected data
//- Cmu coefficient
scalar Cmu_;
//- 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;
//- Write local wall function variables
virtual void writeLocalEntries(Ostream&) const;
public:
@ -159,19 +147,8 @@ public:
// 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;
//- Calculate and return the yPlus at the boundary
virtual tmp<scalarField> yPlus() const;
};