Refactored nutkWallFunction according to the new interface

mutkWallFunctionFvPatchScalarField now derives from
mutWallFunctionFvPatchScalarField
This commit is contained in:
Vuko Vukcevic 2018-06-19 15:05:12 +02:00
parent 0726060d77
commit 3d7f902f82
3 changed files with 52 additions and 148 deletions

View file

@ -19,6 +19,8 @@ $(alphatWallFunctions)/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
mutWallFunctions = $(wallFunctions)/mutWallFunctions
$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C
$(mutWallFunctions)/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C
$(mutWallFunctions)/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C
epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions
$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C

View file

@ -40,63 +40,37 @@ namespace RASModels
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void mutkWallFunctionFvPatchScalarField::checkType()
{
if (!patch().isWall())
{
FatalErrorIn("mutkWallFunctionFvPatchScalarField::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 mutkWallFunctionFvPatchScalarField::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> mutkWallFunctionFvPatchScalarField::calcMut() 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& rhow = turbModel.rho().boundaryField()[patchi];
const scalarField& y = turbModel.y()[patchI];
const scalarField& rhow = turbModel.rho().boundaryField()[patchI];
const tmp<volScalarField> tk = turbModel.k();
const volScalarField& k = tk();
const scalarField& muw = turbModel.mu().boundaryField()[patchi];
const scalarField& muw = turbModel.mu().boundaryField()[patchI];
const scalar Cmu25 = pow025(Cmu_);
tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
scalarField& mutw = tmutw();
// Get face cells
const unallocLabelList& fc = patch().faceCells();
forAll(mutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
const label faceCellI = fc[faceI];
scalar yPlus =
const scalar yPlus =
Cmu25*y[faceI]*sqrt(k[faceCellI])/(muw[faceI]/rhow[faceI]);
if (yPlus > yPlusLam_)
{
mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1);
mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0);
}
}
@ -104,14 +78,6 @@ tmp<scalarField> mutkWallFunctionFvPatchScalarField::calcMut() const
}
void mutkWallFunctionFvPatchScalarField::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 * * * * * * * * * * * * * * //
mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
@ -120,11 +86,18 @@ mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
yPlusLam_(calcYPlusLam(kappa_, E_))
mutWallFunctionFvPatchScalarField(p, iF)
{}
mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mutWallFunctionFvPatchScalarField(p, iF, dict)
{}
@ -136,26 +109,7 @@ mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_),
yPlusLam_(ptf.yPlusLam_)
{}
mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
(
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(ptf, p, iF, mapper)
{}
@ -164,11 +118,7 @@ mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
const mutkWallFunctionFvPatchScalarField& wfpsf
)
:
fixedValueFvPatchScalarField(wfpsf),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
mutWallFunctionFvPatchScalarField(wfpsf)
{}
@ -178,55 +128,30 @@ mutkWallFunctionFvPatchScalarField::mutkWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(wfpsf, iF),
Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_),
yPlusLam_(wfpsf.yPlusLam_)
mutWallFunctionFvPatchScalarField(wfpsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutkWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
operator==(calcMut());
fixedValueFvPatchScalarField::updateCoeffs();
}
tmp<scalarField> mutkWallFunctionFvPatchScalarField::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& muw = turbModel.mu().boundaryField()[patchi];
const scalarField& rhow = turbModel.rho().boundaryField()[patchi];
const scalarField kwc(k.boundaryField()[patchI].patchInternalField());
const scalarField& muw = turbModel.mu().boundaryField()[patchI];
const scalarField& rhow = turbModel.rho().boundaryField()[patchI];
return pow025(Cmu_)*y*sqrt(kwc)/(muw/rhow);
}
void mutkWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
writeLocalEntries(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, mutkWallFunctionFvPatchScalarField);

View file

@ -25,10 +25,22 @@ Class
Foam::compressible::RASModels::mutkWallFunctionFvPatchScalarField
Description
Boundary condition for turbulent (kinematic) viscosity when using wall
Boundary condition for turbulent (dynamic) viscosity when using wall
functions, based on turbulence kinetic energy.
- replicates OpenFOAM v1.5 (and earlier) behaviour
Usage
Example of the boundary condition specification:
\verbatim
<patchName>
{
type mutkWallFunction;
}
\endverbatim
See also
Foam::mutWallFunctionFvPatchScalarField
SourceFiles
mutkWallFunctionFvPatchScalarField.C
@ -37,7 +49,7 @@ SourceFiles
#ifndef compressibleMutkWallFunctionFvPatchScalarField_H
#define compressibleMutkWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
#include "mutWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,39 +66,15 @@ namespace RASModels
class mutkWallFunctionFvPatchScalarField
:
public fixedValueFvPatchScalarField
public mutWallFunctionFvPatchScalarField
{
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> calcMut() 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;
};