diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index 034b00e1af..eec2b9fe78 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -31,7 +31,7 @@ derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsi derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C /* Patch fields */ diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index 09bf558499..a5b0dd6a9d 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -128,7 +128,7 @@ RASModel::~RASModel() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -scalar RASModel::yPlusLam(const scalar kappa, const scalar E) +scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const { scalar ypl = 11.0; @@ -150,9 +150,7 @@ tmp RASModel::yPlus(const label patchNo) const if (typeid(curPatch) == typeid(wallFvPatch)) { - scalar Cmu(readScalar(coeffDict_.lookup("Cmu"))); - - Yp = pow(Cmu, 0.25)*y_[patchNo] + Yp = pow(Cmu_.value(), 0.25)*y_[patchNo] *sqrt(k()().boundaryField()[patchNo].patchInternalField()) /nu().boundaryField()[patchNo]; } @@ -161,9 +159,9 @@ tmp RASModel::yPlus(const label patchNo) const WarningIn ( "tmp RASModel::yPlus(const label patchNo)" - ) << "const : " << endl - << "Patch " << patchNo << " is not a wall. Returning blank field" - << endl; + ) << "const : " << nl + << "Patch " << patchNo << " is not a wall. Returning zero field" + << nl << endl; Yp.setSize(0); } @@ -187,9 +185,11 @@ bool RASModel::read() { lookup("turbulence") >> turbulence_; coeffDict_ = subDict(type() + "Coeffs"); + wallFunctionDict_ = subDict("wallFunctionCoeffs"); - kappa_.readIfPresent(subDict("wallFunctionCoeffs")); - E_.readIfPresent(subDict("wallFunctionCoeffs")); + kappa_.readIfPresent(wallFunctionDict_); + E_.readIfPresent(wallFunctionDict_); + Cmu_.readIfPresent(wallFunctionDict_); yPlusLam_ = yPlusLam(kappa_.value(), E_.value()); diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index 21220f2e3a..b5edce3ea3 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -93,7 +93,6 @@ protected: dimensionedScalar E_; dimensionedScalar Cmu_; - scalar yPlusLam(const scalar kappa, const scalar E); scalar yPlusLam_; dimensionedScalar k0_; @@ -236,6 +235,9 @@ public: return y_; } + //- Calculate y+ at the edge of the laminar sublayer + scalar yPlusLam(const scalar kappa, const scalar E) const; + //- Return y+ at the edge of the laminar sublayer // for use in wall-functions scalar yPlusLam() const diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 7765dc0757..a4f0bd13f7 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -140,7 +140,7 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() volScalarField& epsilon = const_cast (db().lookupObject("epsilon")); - const scalarField& k = db().lookupObject("k"); + const volScalarField& k = db().lookupObject("k"); const scalarField& nuw = patch().lookupPatchField("nu"); @@ -158,9 +158,9 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() { label faceCellI = patch().faceCells()[faceI]; - scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; - epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceCellI]); + epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceI]); if (yPlus > yPlusLam) { @@ -168,7 +168,11 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() (nutw[faceI] + nuw[faceI]) *magGradUw[faceI] *Cmu25*sqrt(k[faceCellI]) - /(kappa*y[faceCellI]); + /(kappa*y[faceI]); + } + else + { + G[faceCellI] = 0.0; } } diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C index 0a25cf0527..2f760cd9cf 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C @@ -100,83 +100,12 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void fixedInternalValueFvPatchField::evaluate(const Pstream::commsTypes) -{ - if (!this->updated()) - { - this->updateCoeffs(); - } - - Info<< "fixedInternalValueFvPatchField::evaluate" << endl; - zeroGradientFvPatchField::evaluate(); -} - - -template -tmp > fixedInternalValueFvPatchField::valueInternalCoeffs -( - const tmp& -) const -{ - Info<< "fixedInternalValueFvPatchField::valueInternalCoeffs" << endl; - return tmp > - ( - new Field(this->size(), pTraits::one) - ); -} - - -template -tmp > fixedInternalValueFvPatchField::valueBoundaryCoeffs -( - const tmp& -) const -{ - Info<< "fixedInternalValueFvPatchField::valueBoundaryCoeffs" << endl; -// return tmp > -// ( -// new Field(this->size(), pTraits::zero) -// ); - return this->patchInternalField(); -} - - -template -tmp > fixedInternalValueFvPatchField:: -gradientInternalCoeffs() const -{ - Info<< "fixedInternalValueFvPatchField::gradientInternalCoeffs" - << endl; - return tmp > - ( - new Field(this->size(), pTraits::zero) - ); -} - - -template -tmp > fixedInternalValueFvPatchField:: -gradientBoundaryCoeffs() const -{ - Info<< "fixedInternalValueFvPatchField::gradientBoundaryCoeffs" - << endl; - return tmp > - ( - new Field(this->size(), pTraits::zero) - ); -} - - template void fixedInternalValueFvPatchField::manipulateMatrix ( fvMatrix& matrix ) { - Info<< "fixedInternalValueFvPatchField::manipulateMatrix(...)" - << endl; - // Apply the patch internal field as a constraint in the matrix matrix.setValues(this->patch().faceCells(), this->patchInternalField()); } diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H index 4783f65400..7ad3ed8f39 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -131,34 +131,6 @@ public: // Evaluation functions - //- Evaluate the patch field - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::Pstream::blocking - ); - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the value of this patchField with given weights - virtual tmp > valueInternalCoeffs - ( - const tmp& - ) const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the value of this patchField with given weights - virtual tmp > valueBoundaryCoeffs - ( - const tmp& - ) const; - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp > gradientInternalCoeffs() const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp > gradientBoundaryCoeffs() const; - //-Manipulate a matrix virtual void manipulateMatrix(fvMatrix& matrix); }; diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C index 233ab8de50..3cc934ebf7 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C @@ -45,6 +45,7 @@ namespace RASModels scalar nutRoughWallFunctionFvPatchScalarField::fnRough ( const scalar KsPlus, + const scalar Cs, const scalar kappa ) const { @@ -58,15 +59,15 @@ scalar nutRoughWallFunctionFvPatchScalarField::fnRough { deltaB = 1.0/kappa - *log((KsPlus - 2.25)/87.75 + Cs_*KsPlus) + *log((KsPlus - 2.25)/87.75 + Cs*KsPlus) *sin(0.4258*(log(KsPlus) - 0.811)); } else { - deltaB = 1.0/kappa*(1.0 + Cs_*KsPlus); + deltaB = 1.0/kappa*log(1.0 + Cs*KsPlus); } - return exp(deltaB*kappa); + return exp(min(deltaB*kappa, 50.0)); } @@ -80,8 +81,8 @@ nutRoughWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - Ks_(0.0), - Cs_(0.0) + Ks_(p.size(), 0.0), + Cs_(p.size(), 0.0) {} @@ -95,8 +96,8 @@ nutRoughWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), - Ks_(ptf.Ks_), - Cs_(ptf.Cs_) + Ks_(ptf.Ks_, mapper), + Cs_(ptf.Cs_, mapper) {} @@ -109,8 +110,8 @@ nutRoughWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict), - Ks_(readScalar(dict.lookup("Ks"))), - Cs_(readScalar(dict.lookup("Cs"))) + Ks_("Ks", dict, p.size()), + Cs_("Cs", dict, p.size()) {} @@ -133,12 +134,41 @@ nutRoughWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(nrwfpsf, iF) + fixedValueFvPatchScalarField(nrwfpsf, iF), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void nutRoughWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + Ks_.autoMap(m); + Cs_.autoMap(m); +} + + +void nutRoughWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const nutRoughWallFunctionFvPatchScalarField& nrwfpsf = + refCast(ptf); + + Cs_.rmap(nrwfpsf.Cs_, addr); + Ks_.rmap(nrwfpsf.Ks_, addr); +} + + void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() { const RASModel& ras = db().lookupObject("RASProperties"); @@ -147,7 +177,6 @@ void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() const scalar Cmu25 = pow(Cmu, 0.25); const scalar kappa = ras.kappa().value(); const scalar E = ras.E().value(); - const scalar yPlusLam = ras.yPlusLam(); const scalarField& y = ras.y()[patch().index()]; @@ -164,11 +193,13 @@ void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() scalar uStar = Cmu25*sqrt(k[faceCellI]); - scalar yPlus = uStar*y[faceCellI]/nuw[faceI]; + scalar yPlus = uStar*y[faceI]/nuw[faceI]; - scalar KsPlus = uStar*Ks_/nuw[faceI]; + scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI]; - scalar Edash = E/fnRough(KsPlus, kappa); + scalar Edash = E/fnRough(KsPlus, Cs_[faceI], kappa); + + scalar yPlusLam = ras.yPlusLam(kappa, Edash); if (yPlus > yPlusLam) { diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H index e0c8122e4a..22f8a36cf2 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H @@ -32,6 +32,9 @@ Description Manipulates the E parameter to account for roughness effects, based on KsPlus. + - roughness height = sand-grain roughness (0 for smooth walls) + - roughness constant = 0.5-1.0 (0.5 default) + SourceFiles nutRoughWallFunctionFvPatchScalarField.C @@ -62,16 +65,21 @@ class nutRoughWallFunctionFvPatchScalarField // Private data //- Roughness height - scalar Ks_; + scalarField Ks_; //- Roughness constant - scalar Cs_; + scalarField Cs_; // Private member functions //- Compute the roughness function - scalar fnRough(const scalar KsPlus, const scalar kappa) const; + scalar fnRough + ( + const scalar KsPlus, + const scalar Cs, + const scalar kappa + ) const; public: @@ -145,6 +153,21 @@ public: // Member functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + // Evaluation functions //- Update the coefficients associated with the patch field diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 25bbee8a29..d86963a792 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -112,7 +112,7 @@ void nutWallFunctionFvPatchScalarField::updateCoeffs() const scalarField& y = ras.y()[patch().index()]; - const scalarField& k = db().lookupObject("k"); + const volScalarField& k = db().lookupObject("k"); const scalarField& nuw = patch().lookupPatchField("nu"); @@ -123,7 +123,7 @@ void nutWallFunctionFvPatchScalarField::updateCoeffs() { label faceCellI = patch().faceCells()[faceI]; - scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; if (yPlus > yPlusLam) { diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C index 9bc9aad003..213af8446c 100644 --- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C @@ -130,7 +130,7 @@ kEpsilon::kEpsilon mesh_ ) { - nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); printCoeffs(); @@ -219,6 +219,11 @@ void kEpsilon::correct() RASModel::correct(); + if (mesh_.changing()) + { + y_.correct(); + } + volScalarField G("G", nut_*2*magSqr(symm(fvc::grad(U_)))); // Update espsilon and G at the wall