diff --git a/src/turbulenceModels/compressible/RAS/Make/files b/src/turbulenceModels/compressible/RAS/Make/files index 247015969..b01efb832 100644 --- a/src/turbulenceModels/compressible/RAS/Make/files +++ b/src/turbulenceModels/compressible/RAS/Make/files @@ -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 diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C index 7505476c0..378ff0ec3 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C @@ -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 mutkWallFunctionFvPatchScalarField::calcMut() const { - const label patchi = patch().index(); + const label patchI = patch().index(); + const turbulenceModel& turbModel = db().lookupObject("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 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 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 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& 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& 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& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF, dict), - Cmu_(dict.lookupOrDefault("Cmu", 0.09)), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("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& 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 mutkWallFunctionFvPatchScalarField::yPlus() const { - const label patchi = patch().index(); + const label patchI = patch().index(); const turbulenceModel& turbModel = db().lookupObject("turbulenceModel"); - const scalarField& y = turbModel.y()[patchi]; + const scalarField& y = turbModel.y()[patchI]; const tmp 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::write(os); - writeLocalEntries(os); - writeEntry("value", os); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField(fvPatchScalarField, mutkWallFunctionFvPatchScalarField); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H index 765d0b7f6..91a219dd2 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkWallFunction/mutkWallFunctionFvPatchScalarField.H @@ -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 + + { + 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 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 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 yPlus() const; };