From b31f23321a40f1e606cebf78b51cc8debe022503 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Tue, 19 Jun 2018 11:21:28 +0200 Subject: [PATCH] Refactored nutSpalartAllmarasStandardWallFunction This wall function is now the same as nutUWallFunction, we simply derive from it to enable backward compatibility. --- ...asStandardWallFunctionFvPatchScalarField.C | 105 +----------------- ...asStandardWallFunctionFvPatchScalarField.H | 33 +----- 2 files changed, 10 insertions(+), 128 deletions(-) diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index d7b79839c..0dd1c7991 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -38,76 +38,6 @@ namespace incompressible namespace RASModels { -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -tmp -nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - - tmp tyPlus = calcYPlus(magUp); - scalarField& yPlus = tyPlus(); - - tmp tnutw(new scalarField(patch().size(), 0.0)); - scalarField& nutw = tnutw(); - - forAll(yPlus, facei) - { - if (yPlus[facei] > yPlusLam_) - { - nutw[facei] = - nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); - } - } - - return tnutw; -} - - -tmp -nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus -( - const scalarField& magUp -) const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalarField& y = rasModel.y()[patchI]; - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - - tmp tyPlus(new scalarField(patch().size(), 0.0)); - scalarField& yPlus = tyPlus(); - - forAll(yPlus, facei) - { - scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei]; - - scalar yp = yPlusLam_; - scalar ryPlusLam = 1.0/yp; - - int iter = 0; - scalar yPlusLast = 0.0; - - do - { - yPlusLast = yp; - yp = (kappaRe + yp)/(1.0 + log(E_*yp)); - - } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 ); - - yPlus[facei] = max(0.0, yp); - } - - return tyPlus; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: @@ -117,7 +47,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField const DimensionedField& iF ) : - nutWallFunctionFvPatchScalarField(p, iF) + nutUWallFunctionFvPatchScalarField(p, iF) {} @@ -130,7 +60,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper) + nutUWallFunctionFvPatchScalarField(ptf, p, iF, mapper) {} @@ -142,7 +72,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField const dictionary& dict ) : - nutWallFunctionFvPatchScalarField(p, iF, dict) + nutUWallFunctionFvPatchScalarField(p, iF, dict) {} @@ -152,7 +82,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf ) : - nutWallFunctionFvPatchScalarField(sawfpsf) + nutUWallFunctionFvPatchScalarField(sawfpsf) {} @@ -163,35 +93,10 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField const DimensionedField& iF ) : - nutWallFunctionFvPatchScalarField(sawfpsf, iF) + nutUWallFunctionFvPatchScalarField(sawfpsf, iF) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -tmp -nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const -{ - const label patchI = patch().index(); - const RASModel& rasModel = db().lookupObject("RASProperties"); - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - - return calcYPlus(magUp); -} - - -void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write -( - Ostream& os -) const -{ - fvPatchField::write(os); - writeLocalEntries(os); - writeEntry("value", os); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H index 9084f3e23..dc4caca96 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -26,7 +26,9 @@ Class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField Description - Wall function boundary condition for walls + This boundary condition is the same as nutUWallFunction. We will simply + derive from nutUWallFunctionFvPatchScalarField to enable backward + compatibility. SourceFiles nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -36,7 +38,7 @@ SourceFiles #ifndef nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H #define nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H -#include "nutWallFunctionFvPatchScalarField.H" +#include "nutUWallFunctionFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,19 +55,8 @@ namespace RASModels class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField : - public nutWallFunctionFvPatchScalarField + public nutUWallFunctionFvPatchScalarField { -protected: - - // Protected member functions - - //- Calculate yPLus - virtual tmp calcYPlus(const scalarField& magUp) const; - - //- Calculate the turbulence viscosity - virtual tmp calcNut() const; - - public: //- Runtime type information @@ -140,20 +131,6 @@ public: ) ); } - - - // Member functions - - // Evaluation functions - - //- Calculate and return the yPlus at the boundary - virtual tmp yPlus() const; - - - // I-O - - //- Write - virtual void write(Ostream& os) const; };