diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 96815c3931..5f771ec663 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -56,6 +56,32 @@ void epsilonWallFunctionFvPatchScalarField::checkType() } +scalar epsilonWallFunctionFvPatchScalarField::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; +} + + +void epsilonWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ + writeEntryIfDifferent(os, "G", "RASModel::G", GName_); + 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 * * * * * * * * * * * * * * // epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField @@ -65,14 +91,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField(p, iF), - UName_("U"), - kName_("k"), GName_("RASModel::G"), - nuName_("nu"), - nutName_("nut"), Cmu_(0.09), kappa_(0.41), - E_(9.8) + E_(9.8), + yPlusLam_(calcYPlusLam(kappa_, E_)) { checkType(); } @@ -87,14 +110,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField(ptf, p, iF, mapper), - UName_(ptf.UName_), - kName_(ptf.kName_), GName_(ptf.GName_), - nuName_(ptf.nuName_), - nutName_(ptf.nutName_), Cmu_(ptf.Cmu_), kappa_(ptf.kappa_), - E_(ptf.E_) + E_(ptf.E_), + yPlusLam_(ptf.yPlusLam_) { checkType(); } @@ -108,14 +128,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField(p, iF, dict), - UName_(dict.lookupOrDefault("U", "U")), - kName_(dict.lookupOrDefault("k", "k")), GName_(dict.lookupOrDefault("G", "RASModel::G")), - nuName_(dict.lookupOrDefault("nu", "nu")), - nutName_(dict.lookupOrDefault("nut", "nut")), Cmu_(dict.lookupOrDefault("Cmu", 0.09)), kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) + E_(dict.lookupOrDefault("E", 9.8)), + yPlusLam_(calcYPlusLam(kappa_, E_)) { checkType(); } @@ -127,14 +144,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField(ewfpsf), - UName_(ewfpsf.UName_), - kName_(ewfpsf.kName_), GName_(ewfpsf.GName_), - nuName_(ewfpsf.nuName_), - nutName_(ewfpsf.nutName_), Cmu_(ewfpsf.Cmu_), kappa_(ewfpsf.kappa_), - E_(ewfpsf.E_) + E_(ewfpsf.E_), + yPlusLam_(ewfpsf.yPlusLam_) { checkType(); } @@ -147,14 +161,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField(ewfpsf, iF), - UName_(ewfpsf.UName_), - kName_(ewfpsf.kName_), GName_(ewfpsf.GName_), - nuName_(ewfpsf.nuName_), - nutName_(ewfpsf.nutName_), Cmu_(ewfpsf.Cmu_), kappa_(ewfpsf.kappa_), - E_(ewfpsf.E_) + E_(ewfpsf.E_), + yPlusLam_(ewfpsf.yPlusLam_) { checkType(); } @@ -169,29 +180,33 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() return; } + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patch().index()]; + const scalarField& y = rasModel.y()[patchI]; const scalar Cmu25 = pow(Cmu_, 0.25); const scalar Cmu75 = pow(Cmu_, 0.75); - volScalarField& G = const_cast - (db().lookupObject(GName_)); + volScalarField& G = + const_cast(db().lookupObject(GName_)); - volScalarField& epsilon = const_cast - (db().lookupObject(dimensionedInternalField().name())); + DimensionedField& epsilon = + const_cast&> + ( + dimensionedInternalField() + ); - const volScalarField& k = db().lookupObject(kName_); + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); - const scalarField& nuw = - patch().lookupPatchField(nuName_); + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - const scalarField& nutw = - patch().lookupPatchField(nutName_); + const tmp tnut = rasModel.nut(); + const volScalarField& nut = tnut(); + const scalarField& nutw = nut.boundaryField()[patchI]; - const fvPatchVectorField& Uw = - patch().lookupPatchField(UName_); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; const scalarField magGradUw = mag(Uw.snGrad()); @@ -204,7 +219,7 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]); - if (yPlus > yPlusLam) + if (yPlus > yPlusLam_) { G[faceCellI] = (nutw[faceI] + nuw[faceI]) @@ -236,14 +251,7 @@ void epsilonWallFunctionFvPatchScalarField::evaluate void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const { fixedInternalValueFvPatchField::write(os); - writeEntryIfDifferent(os, "U", "U", UName_); - writeEntryIfDifferent(os, "k", "k", kName_); - writeEntryIfDifferent(os, "G", "RASModel::G", GName_); - writeEntryIfDifferent(os, "nu", "nu", nuName_); - writeEntryIfDifferent(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; + writeLocalEntries(os); writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H index bd98cced76..805daeb503 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -57,23 +57,13 @@ class epsilonWallFunctionFvPatchScalarField : public fixedInternalValueFvPatchField { - // Private data +protected: - //- Name of velocity field - word UName_; - - //- Name of turbulence kinetic energy field - word kName_; + // Protected data //- Name of turbulence generation field word GName_; - //- Name of laminar viscosity field - word nuName_; - - //- Name of turbulent viscosity field - word nutName_; - //- Cmu coefficient scalar Cmu_; @@ -84,10 +74,20 @@ class epsilonWallFunctionFvPatchScalarField scalar E_; - // Private member functions + //- Y+ at the edge of the laminar sublayer + scalar yPlusLam_; + + + // Protected member functions //- Check the type of the patch - void checkType(); + virtual void checkType(); + + //- Calculate the Y+ at the edge of the laminar sublayer + virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const; + + //- Write local wall function variables + virtual void writeLocalEntries(Ostream&) const; public: @@ -173,7 +173,7 @@ public: // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; };