diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 4a2b5b6d311d2a5068217bdaed5ee80e23963258..07382bad5236b4d841ae82a7a88d33cff391931d 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/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<word>(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,15 +91,13 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(p, iF), - UName_("U"), - kName_("k"), GName_("RASModel::G"), - rhoName_("rho"), - muName_("mu"), - mutName_("mut"), Cmu_(0.09), kappa_(0.41), - E_(9.8) + E_(9.8), + yPlusLam_(calcYPlusLam(kappa_, E_)) + + { checkType(); } @@ -88,15 +112,12 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper), - UName_(ptf.UName_), - kName_(ptf.kName_), GName_(ptf.GName_), - rhoName_(ptf.rhoName_), - muName_(ptf.muName_), - mutName_(ptf.mutName_), Cmu_(ptf.Cmu_), kappa_(ptf.kappa_), - E_(ptf.E_) + E_(ptf.E_), + yPlusLam_(ptf.yPlusLam_) + { checkType(); } @@ -110,15 +131,12 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(p, iF, dict), - UName_(dict.lookupOrDefault<word>("U", "U")), - kName_(dict.lookupOrDefault<word>("k", "k")), GName_(dict.lookupOrDefault<word>("G", "RASModel::G")), - rhoName_(dict.lookupOrDefault<word>("rho", "rho")), - muName_(dict.lookupOrDefault<word>("mu", "mu")), - mutName_(dict.lookupOrDefault<word>("mut", "mut")), Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), - E_(dict.lookupOrDefault<scalar>("E", 9.8)) + E_(dict.lookupOrDefault<scalar>("E", 9.8)), + yPlusLam_(calcYPlusLam(kappa_, E_)) + { checkType(); } @@ -130,15 +148,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(ewfpsf), - UName_(ewfpsf.UName_), - kName_(ewfpsf.kName_), GName_(ewfpsf.GName_), - rhoName_(ewfpsf.rhoName_), - muName_(ewfpsf.muName_), - mutName_(ewfpsf.mutName_), Cmu_(ewfpsf.Cmu_), kappa_(ewfpsf.kappa_), - E_(ewfpsf.E_) + E_(ewfpsf.E_), + yPlusLam_(ewfpsf.yPlusLam_) { checkType(); } @@ -151,15 +165,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(ewfpsf, iF), - UName_(ewfpsf.UName_), - kName_(ewfpsf.kName_), GName_(ewfpsf.GName_), - rhoName_(ewfpsf.rhoName_), - muName_(ewfpsf.muName_), - mutName_(ewfpsf.mutName_), Cmu_(ewfpsf.Cmu_), kappa_(ewfpsf.kappa_), - E_(ewfpsf.E_) + E_(ewfpsf.E_), + yPlusLam_(ewfpsf.yPlusLam_) { checkType(); } @@ -174,33 +184,36 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() return; } + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const scalar Cmu25 = pow(Cmu_, 0.25); const scalar Cmu75 = pow(Cmu_, 0.75); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patch().index()]; + const scalarField& y = rasModel.y()[patchI]; - volScalarField& G = const_cast<volScalarField&> - (db().lookupObject<volScalarField>(GName_)); + volScalarField& G = + const_cast<volScalarField&>(db().lookupObject<volScalarField>(GName_)); - volScalarField& epsilon = const_cast<volScalarField&> - (db().lookupObject<volScalarField>(dimensionedInternalField().name())); + DimensionedField<scalar, volMesh>& epsilon = + const_cast<DimensionedField<scalar, volMesh>&> + ( + dimensionedInternalField() + ); - const volScalarField& k = db().lookupObject<volScalarField>(kName_); + const tmp<volScalarField> tk = rasModel.k(); + const volScalarField& k = tk(); - const scalarField& rhow = - patch().lookupPatchField<volScalarField, scalar>(rhoName_); + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = - patch().lookupPatchField<volScalarField, scalar>(muName_); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - const scalarField& mutw = - patch().lookupPatchField<volScalarField, scalar>(mutName_); + const tmp<volScalarField> tmut = rasModel.mut(); + const volScalarField& mut = tmut(); + const scalarField& mutw = mut.boundaryField()[patchI]; - const fvPatchVectorField& Uw = - patch().lookupPatchField<volVectorField, vector>(UName_); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; const scalarField magGradUw = mag(Uw.snGrad()); @@ -215,7 +228,7 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]); - if (yPlus > yPlusLam) + if (yPlus > yPlusLam_) { G[faceCellI] = (mutw[faceI] + muw[faceI]) @@ -247,15 +260,7 @@ void epsilonWallFunctionFvPatchScalarField::evaluate void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const { fixedInternalValueFvPatchField<scalar>::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "k", "k", kName_); - writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "mu", "mu", muName_); - writeEntryIfDifferent<word>(os, "mut", "mut", mutName_); - 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/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H index 5d5865e11edceb1df7ebbdc8509031d74799f907..1d4c64fb41c3057e89b3c54f4e4655b3bcba9831 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -57,26 +57,13 @@ class epsilonWallFunctionFvPatchScalarField : public fixedInternalValueFvPatchField<scalar> { - // 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 density field - word rhoName_; - - //- Name of laminar viscosity field - word muName_; - - //- Name of turbulent viscosity field - word mutName_; - //- Cmu coefficient scalar Cmu_; @@ -86,11 +73,20 @@ class epsilonWallFunctionFvPatchScalarField //- E coefficient scalar E_; + //- Y+ at the edge of the laminar sublayer + scalar yPlusLam_; - // Private member functions + + // 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: @@ -176,7 +172,7 @@ public: // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 84ac6ba06054333e19bc4a8a08b84f10945aa752..6e475094ec7cfad5ad5c401508c3a65b78426ab0 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -40,7 +40,7 @@ namespace compressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void omegaWallFunctionFvPatchScalarField::checkType() { @@ -56,6 +56,32 @@ void omegaWallFunctionFvPatchScalarField::checkType() } +scalar omegaWallFunctionFvPatchScalarField::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 omegaWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ + writeEntryIfDifferent<word>(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 * * * * * * * * * * * * * * // omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField @@ -65,15 +91,12 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(p, iF), - UName_("U"), - rhoName_("rho"), - kName_("k"), GName_("RASModel::G"), - muName_("mu"), - mutName_("mut"), Cmu_(0.09), kappa_(0.41), - E_(9.8) + E_(9.8), + yPlusLam_(calcYPlusLam(kappa_, E_)) + { checkType(); } @@ -88,15 +111,11 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper), - UName_(ptf.UName_), - rhoName_(ptf.rhoName_), - kName_(ptf.kName_), GName_(ptf.GName_), - muName_(ptf.muName_), - mutName_(ptf.mutName_), Cmu_(ptf.Cmu_), kappa_(ptf.kappa_), - E_(ptf.E_) + E_(ptf.E_), + yPlusLam_(ptf.yPlusLam_) { checkType(); } @@ -110,15 +129,11 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(p, iF, dict), - UName_(dict.lookupOrDefault<word>("U", "U")), - rhoName_(dict.lookupOrDefault<word>("rho", "rho")), - kName_(dict.lookupOrDefault<word>("k", "k")), GName_(dict.lookupOrDefault<word>("G", "RASModel::G")), - muName_(dict.lookupOrDefault<word>("mu", "mu")), - mutName_(dict.lookupOrDefault<word>("mut", "mut")), Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), - E_(dict.lookupOrDefault<scalar>("E", 9.8)) + E_(dict.lookupOrDefault<scalar>("E", 9.8)), + yPlusLam_(calcYPlusLam(kappa_, E_)) { checkType(); } @@ -130,15 +145,11 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(owfpsf), - UName_(owfpsf.UName_), - rhoName_(owfpsf.rhoName_), - kName_(owfpsf.kName_), GName_(owfpsf.GName_), - muName_(owfpsf.muName_), - mutName_(owfpsf.mutName_), Cmu_(owfpsf.Cmu_), kappa_(owfpsf.kappa_), - E_(owfpsf.E_) + E_(owfpsf.E_), + yPlusLam_(owfpsf.yPlusLam_) { checkType(); } @@ -151,15 +162,12 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField ) : fixedInternalValueFvPatchField<scalar>(owfpsf, iF), - UName_(owfpsf.UName_), - rhoName_(owfpsf.rhoName_), - kName_(owfpsf.kName_), GName_(owfpsf.GName_), - muName_(owfpsf.muName_), - mutName_(owfpsf.mutName_), Cmu_(owfpsf.Cmu_), kappa_(owfpsf.kappa_), - E_(owfpsf.E_) + E_(owfpsf.E_), + yPlusLam_(owfpsf.yPlusLam_) + { checkType(); } @@ -174,8 +182,9 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() return; } + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patch().index()]; const scalar Cmu25 = pow(Cmu_, 0.25); @@ -183,22 +192,24 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() volScalarField& G = const_cast<volScalarField&> (db().lookupObject<volScalarField>(GName_)); - volScalarField& omega = const_cast<volScalarField&> - (db().lookupObject<volScalarField>(dimensionedInternalField().name())); + DimensionedField<scalar, volMesh>& omega = + const_cast<DimensionedField<scalar, volMesh>&> + ( + dimensionedInternalField() + ); - const scalarField& k = db().lookupObject<volScalarField>(kName_); + const tmp<volScalarField> tk = rasModel.k(); + const volScalarField& k = tk(); - const scalarField& rhow = - patch().lookupPatchField<volScalarField, scalar>(rhoName_); + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = - patch().lookupPatchField<volScalarField, scalar>(muName_); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - const scalarField& mutw = - patch().lookupPatchField<volScalarField, scalar>(mutName_); + const tmp<volScalarField> tmut = rasModel.mut(); + const volScalarField& mut = tmut(); + const scalarField& mutw = mut.boundaryField()[patchI]; - const fvPatchVectorField& Uw = - patch().lookupPatchField<volVectorField, vector>(UName_); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; const scalarField magGradUw = mag(Uw.snGrad()); @@ -213,7 +224,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]); - if (yPlus > yPlusLam) + if (yPlus > yPlusLam_) { G[faceCellI] = (mutw[faceI] + muw[faceI]) @@ -236,15 +247,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const { fixedInternalValueFvPatchField<scalar>::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); - writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - writeEntryIfDifferent<word>(os, "k", "k", kName_); - writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_); - writeEntryIfDifferent<word>(os, "mu", "mu", muName_); - writeEntryIfDifferent<word>(os, "mut", "mut", mutName_); - 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/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H index 2eb47792791517e84f79a3d2a07ad04ca14bdb76..2efcc1e191f977c0a6ac058e66d4f775e0eca42b 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -55,26 +55,13 @@ class omegaWallFunctionFvPatchScalarField : public fixedInternalValueFvPatchField<scalar> { - // Private data +protected: - //- Name of velocity field - word UName_; - - //- Name of density field - word rhoName_; - - //- Name of turbulence kinetic energy field - word kName_; + // Protected data //- Name of turbulence generation field word GName_; - //- Name of laminar viscosity field - word muName_; - - //- Name of turbulent viscosity field - word mutName_; - //- Cmu coefficient scalar Cmu_; @@ -84,11 +71,20 @@ class omegaWallFunctionFvPatchScalarField //- E coefficient scalar E_; + //- Y+ at the edge of the laminar sublayer + scalar yPlusLam_; - // Private member functions + + // 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: @@ -171,7 +167,7 @@ public: // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; };