From ae91f480ce57a64288b12c8ba602220d849fadd7 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Tue, 19 Jun 2018 11:01:36 +0200 Subject: [PATCH] Refactored nutWallFunction according to Vanilla nutWallFunctionFvPatchScalarField is now an abstract base class (no default behaviour) --- .../nutWallFunctionFvPatchScalarField.C | 60 +++---------------- .../nutWallFunctionFvPatchScalarField.H | 58 ++++++++++-------- 2 files changed, 39 insertions(+), 79 deletions(-) diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 3e9df999e..f196cf53b 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -44,7 +44,7 @@ void nutWallFunctionFvPatchScalarField::checkType() { if (!patch().isWall()) { - FatalErrorIn("nutWallFunctionFvPatchScalarField::checkType()") + FatalErrorIn(this->type() + "FvPatchScalarField::checkType()") << "Invalid wall function specification" << nl << " Patch type for patch " << patch().name() << " must be wall" << nl @@ -62,7 +62,7 @@ scalar nutWallFunctionFvPatchScalarField::calcYPlusLam { scalar ypl = 11.0; - for (int i=0; i<10; i++) + for (label i = 0; i < 10; ++i) { ypl = log(E*ypl)/kappa; } @@ -71,37 +71,6 @@ scalar nutWallFunctionFvPatchScalarField::calcYPlusLam } -tmp nutWallFunctionFvPatchScalarField::calcNut() 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& nuw = rasModel.nu().boundaryField()[patchI]; - - const scalar Cmu25 = pow(Cmu_, 0.25); - - tmp tnutw(new scalarField(patch().size(), 0.0)); - scalarField& nutw = tnutw(); - - forAll(nutw, faceI) - { - label faceCellI = patch().faceCells()[faceI]; - - scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; - - if (yPlus > yPlusLam_) - { - nutw[faceI] = nuw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0); - } - } - - return tnutw; -} - - void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const { os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; @@ -198,28 +167,17 @@ nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField void nutWallFunctionFvPatchScalarField::updateCoeffs() { + if (updated()) + { + return; + } + operator==(calcNut()); fixedValueFvPatchScalarField::updateCoeffs(); } -tmp nutWallFunctionFvPatchScalarField::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& nuw = rasModel.nu().boundaryField()[patchI]; - - return pow(Cmu_, 0.25)*y*sqrt(kwc)/nuw; -} - - void nutWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); @@ -228,10 +186,6 @@ void nutWallFunctionFvPatchScalarField::write(Ostream& os) const } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField); - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace RASModels diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index 489a9bc20..2a5bab5ad 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -25,10 +25,37 @@ Class Foam::incompressible::RASModels::nutWallFunctionFvPatchScalarField Description - Boundary condition for turbulent (kinematic) viscosity when using wall - functions + Abstract base class for oundary condition for turbulent (kinematic) + viscosity when using wall functions - replicates OpenFOAM v1.5 (and earlier) behaviour +Usage + \table + Property | Description | Required | Default value + Cmu | Cmu coefficient | no | 0.09 + kappa | Von Karman constant | no | 0.41 + E | E coefficient | no | 9.8 + \endtable + + Examples of the boundary condition specification: + \verbatim + + { + type nutWallFunction; + value uniform 0.0; + } + \endverbatim + + Reference for the default model coefficients: + \verbatim + H. Versteeg, W. Malalasekera + An Introduction to Computational Fluid Dynamics: The Finite Volume + Method, subsection "3.5.2 k-epsilon model" + \endverbatim + +See also + Foam::fixedValueFvPatchField + SourceFiles nutWallFunctionFvPatchScalarField.C @@ -73,7 +100,7 @@ protected: scalar yPlusLam_; - // Protected member functions + // Protected Member Functions //- Check the type of the patch virtual void checkType(); @@ -82,7 +109,7 @@ protected: virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const; //- Calculate the turbulence viscosity - virtual tmp calcNut() const; + virtual tmp calcNut() const = 0; //- Write local wall function variables virtual void writeLocalEntries(Ostream&) const; @@ -128,15 +155,6 @@ public: const nutWallFunctionFvPatchScalarField& ); - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new nutWallFunctionFvPatchScalarField(*this) - ); - } - //- Construct as copy setting internal field reference nutWallFunctionFvPatchScalarField ( @@ -144,25 +162,13 @@ public: const DimensionedField& ); - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new nutWallFunctionFvPatchScalarField(*this, iF) - ); - } - // Member functions // Evaluation functions //- Calculate and return the yPlus at the boundary - virtual tmp yPlus() const; + virtual tmp yPlus() const = 0; //- Update the coefficients associated with the patch field virtual void updateCoeffs();