From a98fe1c74f1337d5ae374ea25bbc11047dc60614 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 23 Jul 2009 11:17:28 +0100 Subject: [PATCH] updates to compressible wall functions --- .../mutRoughWallFunctionFvPatchScalarField.C | 79 ++------ .../mutRoughWallFunctionFvPatchScalarField.H | 36 +--- ...ndardRoughWallFunctionFvPatchScalarField.C | 109 ++++------- ...ndardRoughWallFunctionFvPatchScalarField.H | 41 ++-- ...asStandardWallFunctionFvPatchScalarField.C | 91 ++++----- ...asStandardWallFunctionFvPatchScalarField.H | 36 ++-- ...rtAllmarasWallFunctionFvPatchScalarField.C | 178 +++++++++--------- ...rtAllmarasWallFunctionFvPatchScalarField.H | 37 ++-- .../mutWallFunctionFvPatchScalarField.C | 99 +++++----- .../mutWallFunctionFvPatchScalarField.H | 23 ++- 10 files changed, 312 insertions(+), 417 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C index 9183cf6654..4fe171f2fd 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C @@ -74,13 +74,7 @@ mutRoughWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(p, iF), - rhoName_("rho"), - muName_("mu"), - kName_("k"), - Cmu_(0.09), - kappa_(0.41), - E_(9.8), + mutWallFunctionFvPatchScalarField(p, iF), Ks_(p.size(), 0.0), Cs_(p.size(), 0.0) {} @@ -95,13 +89,7 @@ mutRoughWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - rhoName_(ptf.rhoName_), - muName_(ptf.muName_), - kName_(ptf.kName_), - Cmu_(0.09), - kappa_(0.41), - E_(9.8), + mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper), Ks_(ptf.Ks_, mapper), Cs_(ptf.Cs_, mapper) {} @@ -115,13 +103,7 @@ mutRoughWallFunctionFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict), - rhoName_(dict.lookupOrDefault("rho", "rho")), - muName_(dict.lookupOrDefault("mu", "mu")), - kName_(dict.lookupOrDefault("k", "k")), - Cmu_(dict.lookupOrDefault("Cmu", 0.09)), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)), + mutWallFunctionFvPatchScalarField(p, iF, dict), Ks_("Ks", dict, p.size()), Cs_("Cs", dict, p.size()) {} @@ -133,13 +115,7 @@ mutRoughWallFunctionFvPatchScalarField const mutRoughWallFunctionFvPatchScalarField& rwfpsf ) : - fixedValueFvPatchScalarField(rwfpsf), - rhoName_(rwfpsf.rhoName_), - muName_(rwfpsf.muName_), - kName_(rwfpsf.kName_), - Cmu_(rwfpsf.Cmu_), - kappa_(rwfpsf.kappa_), - E_(rwfpsf.E_), + mutWallFunctionFvPatchScalarField(rwfpsf), Ks_(rwfpsf.Ks_), Cs_(rwfpsf.Cs_) {} @@ -152,13 +128,7 @@ mutRoughWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(rwfpsf, iF), - rhoName_(rwfpsf.rhoName_), - muName_(rwfpsf.muName_), - kName_(rwfpsf.kName_), - Cmu_(rwfpsf.Cmu_), - kappa_(rwfpsf.kappa_), - E_(rwfpsf.E_), + mutWallFunctionFvPatchScalarField(rwfpsf, iF), Ks_(rwfpsf.Ks_), Cs_(rwfpsf.Cs_) {} @@ -171,7 +141,7 @@ void mutRoughWallFunctionFvPatchScalarField::autoMap const fvPatchFieldMapper& m ) { - fixedValueFvPatchScalarField::autoMap(m); + mutWallFunctionFvPatchScalarField::autoMap(m); Ks_.autoMap(m); Cs_.autoMap(m); } @@ -183,7 +153,7 @@ void mutRoughWallFunctionFvPatchScalarField::rmap const labelList& addr ) { - fixedValueFvPatchScalarField::rmap(ptf, addr); + mutWallFunctionFvPatchScalarField::rmap(ptf, addr); const mutRoughWallFunctionFvPatchScalarField& nrwfpsf = refCast(ptf); @@ -193,23 +163,22 @@ void mutRoughWallFunctionFvPatchScalarField::rmap } -void mutRoughWallFunctionFvPatchScalarField::updateCoeffs() +tmp mutRoughWallFunctionFvPatchScalarField::calcMut() const { + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject("RASProperties"); - scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patch().index()]; + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalarField& y = rasModel.y()[patchI]; + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; const scalar Cmu25 = pow(Cmu_, 0.25); - const scalarField& rhow = - patch().lookupPatchField(rhoName_); - - const scalarField& k = db().lookupObject(kName_); - - const scalarField& muw = - patch().lookupPatchField(muName_); - - scalarField& mutw = *this; + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); forAll(mutw, faceI) { @@ -243,23 +212,15 @@ void mutRoughWallFunctionFvPatchScalarField::updateCoeffs() mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1); } - else - { - mutw[faceI] = 0.0; - } } + + return tmutw; } void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "mu", "mu", muName_); - writeEntryIfDifferent(os, "k", "k", kName_); - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; Cs_.writeEntry("Cs", os); Ks_.writeEntry("Ks", os); writeEntry("value", os); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H index b3642ed4f0..4cbe9ee09c 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H @@ -43,7 +43,7 @@ SourceFiles #ifndef mutRoughWallFunctionFvPatchScalarField_H #define mutRoughWallFunctionFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "mutWallFunctionFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,27 +60,11 @@ namespace RASModels class mutRoughWallFunctionFvPatchScalarField : - public fixedValueFvPatchScalarField + public mutWallFunctionFvPatchScalarField { - // Private data +protected: - //- Name of density field - word rhoName_; - - //- Name of laminar viscosity field - word muName_; - - //- Name of turbulence kinetic energy field - word kName_; - - //- Cmu coefficient - scalar Cmu_; - - //- Von-karman constant - scalar kappa_; - - //- E coefficient - scalar E_; + // Protected data //- Roughness height scalarField Ks_; @@ -92,7 +76,10 @@ class mutRoughWallFunctionFvPatchScalarField // Private member functions //- Compute the roughness function - scalar fnRough(const scalar KsPlus, const scalar Cs) const; + virtual scalar fnRough(const scalar KsPlus, const scalar Cs) const; + + //- Calculate the turbulence viscosity + virtual tmp calcMut() const; public: @@ -181,16 +168,11 @@ public: const labelList& ); - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index 8bade4a9f7..172cfb0db5 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -27,6 +27,7 @@ License #include "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H" #include "fvPatchFieldMapper.H" #include "volFields.H" +#include "RASModel.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,12 +48,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(p, iF), - UName_("U"), - rhoName_("rho"), - muName_("mu"), - kappa_(0.41), - E_(9.8), + mutWallFunctionFvPatchScalarField(p, iF), roughnessHeight_(pTraits::zero), roughnessConstant_(pTraits::zero), roughnessFudgeFactor_(pTraits::zero) @@ -68,12 +64,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - UName_(ptf.UName_), - rhoName_(ptf.rhoName_), - muName_(ptf.muName_), - kappa_(ptf.kappa_), - E_(ptf.E_), + mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper), roughnessHeight_(ptf.roughnessHeight_), roughnessConstant_(ptf.roughnessConstant_), roughnessFudgeFactor_(ptf.roughnessFudgeFactor_) @@ -88,12 +79,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict), - UName_(dict.lookupOrDefault("U", "U")), - rhoName_(dict.lookupOrDefault("rho", "rho")), - muName_(dict.lookupOrDefault("mu", "mu")), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)), + mutWallFunctionFvPatchScalarField(p, iF, dict), roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))), roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))), roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor"))) @@ -106,12 +92,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& rwfpsf ) : - fixedValueFvPatchScalarField(rwfpsf), - UName_(rwfpsf.UName_), - rhoName_(rwfpsf.rhoName_), - muName_(rwfpsf.muName_), - kappa_(rwfpsf.kappa_), - E_(rwfpsf.E_), + mutWallFunctionFvPatchScalarField(rwfpsf), roughnessHeight_(rwfpsf.roughnessHeight_), roughnessConstant_(rwfpsf.roughnessConstant_), roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_) @@ -125,12 +106,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(rwfpsf, iF), - UName_(rwfpsf.UName_), - rhoName_(rwfpsf.rhoName_), - muName_(rwfpsf.muName_), - kappa_(rwfpsf.kappa_), - E_(rwfpsf.E_), + mutWallFunctionFvPatchScalarField(rwfpsf, iF), roughnessHeight_(rwfpsf.roughnessHeight_), roughnessConstant_(rwfpsf.roughnessConstant_), roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_) @@ -139,28 +115,24 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate -( - const Pstream::commsTypes -) +tmp +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const { - const scalar yPlusLam = 11.225; + const label patchI = patch().index(); - // The reciprical of the distance to the adjacent cell centre. - const scalarField& ry = patch().deltaCoeffs(); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& U = - patch().lookupPatchField(UName_); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - const fvPatchScalarField& rho = - patch().lookupPatchField(rhoName_); + scalarField magUp = mag(Uw.patchInternalField() - Uw); - // The flow velocity at the adjacent cell centre. - scalarField magUp = mag(U.patchInternalField() - U); + const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = - patch().lookupPatchField(muName_); - scalarField& mutw = *this; + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); if (roughnessHeight_ > 0.0) { @@ -177,7 +149,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate forAll(mutw, facei) { const scalar magUpara = magUp[facei]; - const scalar Re = rho[facei]*magUpara/(muw[facei]*ry[facei]); + const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; const scalar kappaRe = kappa_*Re; scalar yPlus = yPlusLam; @@ -185,7 +157,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate int iter = 0; scalar yPlusLast = 0.0; - scalar dKsPlusdYPlus = roughnessHeight_*ry[facei]; + scalar dKsPlusdYPlus = roughnessHeight_/y[facei]; // Enforce the roughnessHeight to be less than the distance to // the first cell centre. @@ -194,18 +166,17 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate dKsPlusdYPlus = 1; } - // Fudge factor to get results to be similar to fluent - // (at least difference between rough and smooth). + // Additional tuning parameter (fudge factor) - nominally = 1 dKsPlusdYPlus *= roughnessFudgeFactor_; do { yPlusLast = yPlus; - // The non-dimensional roughness height. + // The non-dimensional roughness height scalar KsPlus = yPlus*dKsPlusdYPlus; - // The extra term in the law-of-the-wall. + // The extra term in the law-of-the-wall scalar G = 0.0; scalar yPlusGPrime = 0.0; @@ -238,7 +209,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate } else { - // Ensure immediate end and mutw = 0. + // Ensure immediate end and mutw = 0 yPlus = 0; } @@ -253,20 +224,16 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate { mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); } - else - { - mutw[facei] = 0.0; - } } } } else { - // Smooth Walls. + // Smooth Walls forAll(mutw, facei) { const scalar magUpara = magUp[facei]; - const scalar Re = rho[facei]*magUpara/(muw[facei]*ry[facei]); + const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; const scalar kappaRe = kappa_*Re; scalar yPlus = yPlusLam; @@ -290,12 +257,23 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate { mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); } - else - { - mutw[facei] = 0.0; - } } } + + return tmutw; +} + + +tmp +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const +{ + notImplemented + ( + "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus()" + "const" + ); + + return tmp(NULL); } @@ -305,11 +283,6 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write ) const { fixedValueFvPatchScalarField::write(os); - writeEntryIfDifferent(os, "U", "U", UName_); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "mu", "mu", muName_); - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessHeight") << roughnessHeight_ << token::END_STATEMENT << nl; os.writeKeyword("roughnessConstant") diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H index 8fa529d863..e2434c8183 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H @@ -37,7 +37,7 @@ SourceFiles #ifndef mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H #define mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "mutWallFunctionFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,25 +54,11 @@ Class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField : - public fixedValueFvPatchScalarField + public mutWallFunctionFvPatchScalarField { - // Private data - - //- Name of velocity field - word UName_; - - //- Name of density field - word rhoName_; - - //- Name of laminar viscosity field - word muName_; - - //- Von Karman constant - scalar kappa_; - - //- E coefficient - scalar E_; +protected: + // Protected data // Roughness parameters @@ -86,6 +72,12 @@ class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField scalar roughnessFudgeFactor_; + // Protected member functions + + //- Calculate the turbulence viscosity + virtual tmp calcMut() const; + + public: //- Runtime type information @@ -206,15 +198,14 @@ public: // Evaluation functions - //- Evaluate the patchField - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); + //- Calculate and return the yPlus at the boundary + virtual tmp yPlus() const; - //- Write - virtual void write(Ostream& os) const; + // I-O + + //- Write + virtual void write(Ostream& os) const; }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index c2d48d2258..f2337dab47 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -48,12 +48,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(p, iF), - UName_("U"), - rhoName_("rho"), - muName_("mu"), - kappa_(0.41), - E_(9.8) + mutWallFunctionFvPatchScalarField(p, iF) {} @@ -66,12 +61,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - UName_(ptf.UName_), - rhoName_(ptf.rhoName_), - muName_(ptf.muName_), - kappa_(ptf.kappa_), - E_(ptf.E_) + mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper) {} @@ -83,12 +73,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict), - UName_(dict.lookupOrDefault("U", "U")), - rhoName_(dict.lookupOrDefault("rho", "rho")), - muName_(dict.lookupOrDefault("mu", "mu")), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) + mutWallFunctionFvPatchScalarField(p, iF, dict) {} @@ -98,12 +83,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf ) : - fixedValueFvPatchScalarField(sawfpsf), - UName_(sawfpsf.UName_), - rhoName_(sawfpsf.rhoName_), - muName_(sawfpsf.muName_), - kappa_(sawfpsf.kappa_), - E_(sawfpsf.E_) + mutWallFunctionFvPatchScalarField(sawfpsf) {} @@ -114,46 +94,37 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(sawfpsf, iF), - UName_(sawfpsf.UName_), - rhoName_(sawfpsf.rhoName_), - muName_(sawfpsf.muName_), - kappa_(sawfpsf.kappa_), - E_(sawfpsf.E_) + mutWallFunctionFvPatchScalarField(sawfpsf, iF) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate -( - const Pstream::commsTypes -) +tmp +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const { + const label patchI = patch().index(); + const RASModel& rasModel = db().lookupObject("RASProperties"); - scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); + const scalarField& y = rasModel.y()[patchI]; - const scalarField& ry = patch().deltaCoeffs(); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const fvPatchVectorField& U = - patch().lookupPatchField(UName_); + const scalarField magUp = mag(Uw.patchInternalField() - Uw); - scalarField magUp = mag(U.patchInternalField() - U); + const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& rhow = - patch().lookupPatchField(rhoName_); + const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; - const scalarField& muw = - patch().lookupPatchField(muName_); - scalarField& mutw = *this; - - scalarField magFaceGradU = mag(U.snGrad()); + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); forAll(mutw, faceI) { scalar magUpara = magUp[faceI]; - scalar kappaRe = kappa_*magUpara/((muw[faceI]/rhow[faceI])*ry[faceI]); + scalar kappaRe = kappa_*magUpara*y[faceI]/(muw[faceI]/rhow[faceI]); scalar yPlus = yPlusLam; scalar ryPlusLam = 1.0/yPlus; @@ -166,17 +137,28 @@ void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate yPlusLast = yPlus; yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus)); - } while (mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); + } while (mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10); if (yPlus > yPlusLam) { - mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1); - } - else - { - mutw[faceI] = 0.0; + mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0); } } + + return tmutw; +} + + +tmp +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const +{ + notImplemented + ( + "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() " + "const" + ); + + return tmp(NULL); } @@ -186,9 +168,6 @@ void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write ) const { fvPatchField::write(os); - writeEntryIfDifferent(os, "U", "U", UName_); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "mu", "mu", muName_); os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; writeEntry("value", os); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H index a1c13581bf..6813e59667 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -37,7 +37,7 @@ SourceFiles #ifndef mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H #define mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "mutWallFunctionFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,24 +54,14 @@ namespace RASModels class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField : - public fixedValueFvPatchScalarField + public mutWallFunctionFvPatchScalarField { - // Private data +protected: - //- Name of velocity field - word UName_; + // Protected member functions - //- Name of density field - word rhoName_; - - //- Name of laminar viscosity field - word muName_; - - //- Von Karman constant - scalar kappa_; - - //- E coefficient - scalar E_; + //- Calculate the turbulence viscosity + virtual tmp calcMut() const; public: @@ -154,14 +144,14 @@ public: // Evaluation functions - //- Evaluate the patchField - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); + //- Calculate and return the yPlus at the boundary + virtual tmp yPlus() const; - //- Write - virtual void write(Ostream& os) const; + + // I-O + + //- Write + virtual void write(Ostream& os) const; }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C index 414d932ee0..c8454c4c7f 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -27,6 +27,7 @@ License #include "mutSpalartAllmarasWallFunctionFvPatchScalarField.H" #include "fvPatchFieldMapper.H" #include "volFields.H" +#include "RASModel.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -38,6 +39,72 @@ namespace compressible namespace RASModels { +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +tmp mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau +( + const scalarField& magGradU +) const +{ + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patch().index()]; + + const fvPatchVectorField& Uw = + rasModel.U().boundaryField()[patch().index()]; + + scalarField magUp = mag(Uw.patchInternalField() - Uw); + + const fvPatchScalarField& rhow = + rasModel.rho().boundaryField()[patch().index()]; + + const fvPatchScalarField& muw = + rasModel.mu().boundaryField()[patch().index()]; + const scalarField& mutw = *this; + + tmp tuTau(new scalarField(patch().size(), 0.0)); + scalarField& uTau = tuTau(); + + forAll(mutw, faceI) + { + scalar magUpara = magUp[faceI]; + + scalar ut = + sqrt((mutw[faceI] + muw[faceI])*magGradU[faceI]/rhow[faceI]); + + if (ut > VSMALL) + { + int iter = 0; + scalar err = GREAT; + + do + { + scalar kUu = min(kappa_*magUpara/ut, 50); + scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); + + scalar f = + - ut*y[faceI]/(muw[faceI]/rhow[faceI]) + + magUpara/ut + + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + + scalar df = + y[faceI]/(muw[faceI]/rhow[faceI]) + + magUpara/sqr(ut) + + 1/E_*kUu*fkUu/ut; + + scalar uTauNew = ut + f/df; + err = mag((ut - uTauNew)/ut); + ut = uTauNew; + + } while (ut > VSMALL && err > 0.01 && ++iter < 10); + + uTau[faceI] = max(0.0, ut); + } + } + + return tuTau; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSpalartAllmarasWallFunctionFvPatchScalarField:: @@ -47,12 +114,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(p, iF), - UName_("U"), - rhoName_("rho"), - muName_("mu"), - kappa_(0.41), - E_(9.8) + mutWallFunctionFvPatchScalarField(p, iF) {} @@ -65,12 +127,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - UName_(ptf.UName_), - rhoName_(ptf.rhoName_), - muName_(ptf.muName_), - kappa_(ptf.kappa_), - E_(ptf.E_) + mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper) {} @@ -82,12 +139,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict), - UName_(dict.lookupOrDefault("U", "U")), - rhoName_(dict.lookupOrDefault("rho", "rho")), - muName_(dict.lookupOrDefault("mu", "mu")), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) + mutWallFunctionFvPatchScalarField(p, iF, dict) {} @@ -97,12 +149,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf ) : - fixedValueFvPatchScalarField(wfpsf), - UName_(wfpsf.UName_), - rhoName_(wfpsf.rhoName_), - muName_(wfpsf.muName_), - kappa_(wfpsf.kappa_), - E_(wfpsf.E_) + mutWallFunctionFvPatchScalarField(wfpsf) {} @@ -113,83 +160,45 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(wfpsf, iF), - UName_(wfpsf.UName_), - rhoName_(wfpsf.rhoName_), - muName_(wfpsf.muName_), - kappa_(wfpsf.kappa_), - E_(wfpsf.E_) + mutWallFunctionFvPatchScalarField(wfpsf, iF) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void mutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate -( - const Pstream::commsTypes -) +tmp +mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const { - const scalarField& ry = patch().deltaCoeffs(); + const label patchI = patch().index(); - const fvPatchVectorField& U = - patch().lookupPatchField(UName_); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - scalarField magUp = mag(U.patchInternalField() - U); + const scalarField magGradU = mag(Uw.snGrad()); - const scalarField& rhow = - patch().lookupPatchField(rhoName_); + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = - patch().lookupPatchField(muName_); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - scalarField& mutw = *this; + return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw); +} - scalarField magFaceGradU = mag(U.snGrad()); - forAll(mutw, faceI) - { - scalar magUpara = magUp[faceI]; +tmp +mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const +{ + const label patchI = patch().index(); - scalar utau = - sqrt((mutw[faceI] + muw[faceI])*magFaceGradU[faceI]/rhow[faceI]); + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; - if (utau > VSMALL) - { - int iter = 0; - scalar err = GREAT; + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - do - { - scalar kUu = min(kappa_*magUpara/utau, 50); - scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - scalar f = - - utau/(ry[faceI]*(muw[faceI]/rhow[faceI])) - + magUpara/utau - + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - scalar df = - 1.0/(ry[faceI]*(muw[faceI]/rhow[faceI])) - + magUpara/sqr(utau) - + 1/E_*kUu*fkUu/utau; - - scalar utauNew = utau + f/df; - err = mag((utau - utauNew)/utau); - utau = utauNew; - - } while (utau > VSMALL && err > 0.01 && ++iter < 10); - - mutw[faceI] = max - ( - rhow[faceI]*sqr(max(utau, 0))/magFaceGradU[faceI] - muw[faceI], - 0.0 - ); - } - else - { - mutw[faceI] = 0; - } - } + return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow); } @@ -199,9 +208,6 @@ void mutSpalartAllmarasWallFunctionFvPatchScalarField::write ) const { fvPatchField::write(os); - writeEntryIfDifferent(os, "U", "U", UName_); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "mu", "mu", muName_); os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; writeEntry("value", os); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H index 1b2dfa9f90..69f12cd87a 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H @@ -37,7 +37,7 @@ SourceFiles #ifndef mutSpalartAllmarasWallFunctionFvPatchScalarField_H #define mutSpalartAllmarasWallFunctionFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "mutWallFunctionFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,24 +54,17 @@ namespace RASModels class mutSpalartAllmarasWallFunctionFvPatchScalarField : - public fixedValueFvPatchScalarField + public mutWallFunctionFvPatchScalarField { - // Private data +protected: - //- Name of velocity field - word UName_; + // Protected member functions - //- Name of density field - word rhoName_; + //- Calculate the turbulence viscosity + virtual tmp calcMut() const; - //- Name of laminar viscosity field - word muName_; - - //- Von Karman constant - scalar kappa_; - - //- E coefficient - scalar E_; + //- Calculate the friction velocity + virtual tmp calcUTau(const scalarField& magGradU) const; public: @@ -147,14 +140,14 @@ public: // Evaluation functions - //- Evaluate the patchField - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); + //- Calculate and return the yPlus at the boundary + virtual tmp yPlus() const; - //- Write - virtual void write(Ostream& os) const; + + // I-O + + //- Write + virtual void write(Ostream& os) const; }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C index 22725e7757..e7cdea1dea 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C @@ -28,6 +28,7 @@ License #include "RASModel.H" #include "fvPatchFieldMapper.H" #include "volFields.H" +#include "wallFvPatch.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,27 +40,38 @@ namespace compressible namespace RASModels { +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void mutWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("mutWallFunctionFvPatchScalarField::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); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -mutWallFunctionFvPatchScalarField:: -mutWallFunctionFvPatchScalarField +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF ) : fixedValueFvPatchScalarField(p, iF), - rhoName_("rho"), - muName_("mu"), - kName_("k"), Cmu_(0.09), kappa_(0.41), E_(9.8) {} -mutWallFunctionFvPatchScalarField:: -mutWallFunctionFvPatchScalarField +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField ( const mutWallFunctionFvPatchScalarField& ptf, const fvPatch& p, @@ -68,17 +80,13 @@ mutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), - rhoName_(ptf.rhoName_), - muName_(ptf.muName_), - kName_(ptf.kName_), Cmu_(ptf.Cmu_), kappa_(ptf.kappa_), E_(ptf.E_) {} -mutWallFunctionFvPatchScalarField:: -mutWallFunctionFvPatchScalarField +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, @@ -86,42 +94,31 @@ mutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict), - rhoName_(dict.lookupOrDefault("rho", "rho")), - muName_(dict.lookupOrDefault("mu", "mu")), - kName_(dict.lookupOrDefault("k", "k")), Cmu_(dict.lookupOrDefault("Cmu", 0.09)), kappa_(dict.lookupOrDefault("kappa", 0.41)), E_(dict.lookupOrDefault("E", 9.8)) {} -mutWallFunctionFvPatchScalarField:: -mutWallFunctionFvPatchScalarField +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField ( const mutWallFunctionFvPatchScalarField& wfpsf ) : fixedValueFvPatchScalarField(wfpsf), - rhoName_(wfpsf.rhoName_), - muName_(wfpsf.muName_), - kName_(wfpsf.kName_), Cmu_(wfpsf.Cmu_), kappa_(wfpsf.kappa_), E_(wfpsf.E_) {} -mutWallFunctionFvPatchScalarField:: -mutWallFunctionFvPatchScalarField +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField ( const mutWallFunctionFvPatchScalarField& wfpsf, const DimensionedField& iF ) : fixedValueFvPatchScalarField(wfpsf, iF), - rhoName_(wfpsf.rhoName_), - muName_(wfpsf.muName_), - kName_(wfpsf.kName_), Cmu_(wfpsf.Cmu_), kappa_(wfpsf.kappa_), E_(wfpsf.E_) @@ -132,21 +129,27 @@ mutWallFunctionFvPatchScalarField void mutWallFunctionFvPatchScalarField::updateCoeffs() { + operator==(calcMut()); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +tmp mutWallFunctionFvPatchScalarField::calcMut() const +{ + 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 scalarField& rhow = rasModel.rho().boundaryField()[patchI]; + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; const scalar Cmu25 = pow(Cmu_, 0.25); - const scalarField& rhow = - patch().lookupPatchField(rhoName_); - - const volScalarField& k = db().lookupObject(kName_); - - const scalarField& muw = - patch().lookupPatchField(muName_); - - scalarField& mutw = *this; + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); forAll(mutw, faceI) { @@ -160,20 +163,32 @@ void mutWallFunctionFvPatchScalarField::updateCoeffs() { mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1); } - else - { - mutw[faceI] = 0.0; - } } + + return tmutw; +} + + +tmp mutWallFunctionFvPatchScalarField::yPlus() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + const scalarField kwc = k.boundaryField()[patchI].patchInternalField(); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; + + return pow(Cmu_, 0.25)*y*sqrt(kwc)/(muw/rhow); } void mutWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "mu", "mu", muName_); - writeEntryIfDifferent(os, "k", "k", kName_); os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H index e99b7cd79f..962790c510 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H @@ -57,16 +57,9 @@ class mutWallFunctionFvPatchScalarField : public fixedValueFvPatchScalarField { - // Private data +protected: - //- Name of density field - word rhoName_; - - //- Name of laminar viscosity field - word muName_; - - //- Name of turbulence kinetic energy field - word kName_; + // Protected data //- Cmu coefficient scalar Cmu_; @@ -78,6 +71,15 @@ class mutWallFunctionFvPatchScalarField scalar E_; + // Protected member functions + + //- Check the type of the patch + virtual void checkType(); + + //- Calculate the turbulence viscosity + virtual tmp calcMut() const; + + public: //- Runtime type information @@ -151,6 +153,9 @@ public: // 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();