From 6bd284dda35314e02f6e222461a5bbba43013843 Mon Sep 17 00:00:00 2001 From: henry Date: Thu, 22 Apr 2010 15:18:20 +0100 Subject: [PATCH] wall-functions: Added "updated" check and avoid /0 in the case that the velocity field is uniform 0. --- .../alphatWallFunction/alphatWallFunctionFvPatchScalarField.C | 7 +++++++ .../epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C | 7 +++++++ .../mutSpalartAllmarasWallFunctionFvPatchScalarField.C | 6 +++++- .../omegaWallFunction/omegaWallFunctionFvPatchScalarField.C | 7 +++++++ .../epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C | 7 +++++++ .../nutSpalartAllmarasWallFunctionFvPatchScalarField.C | 6 +++++- .../omegaWallFunction/omegaWallFunctionFvPatchScalarField.C | 9 +++++++++ 7 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C index ad2115cd..dbc93fc8 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C @@ -111,10 +111,17 @@ alphatWallFunctionFvPatchScalarField void alphatWallFunctionFvPatchScalarField::updateCoeffs() { + if (updated()) + { + return; + } + const scalarField& mutw = patch().lookupPatchField(mutName_); operator==(mutw/Prt_); + + fixedValueFvPatchScalarField::updateCoeffs(); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index dc6f2a36..b181a8b3 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -169,6 +169,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField void epsilonWallFunctionFvPatchScalarField::updateCoeffs() { + if (updated()) + { + return; + } + const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar Cmu25 = pow(Cmu_, 0.25); @@ -225,6 +230,8 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() } // TODO: perform averaging for cells sharing more than one boundary face + + fixedInternalValueFvPatchField::updateCoeffs(); } 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 dfe1e88c..becc5dbb 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -116,7 +116,11 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - return max(scalar(0), rhow*sqr(calcUTau(magGradU))/magGradU - muw); + return max + ( + scalar(0), + rhow*sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - muw + ); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 8583936b..171d60f0 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -174,6 +174,11 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField void omegaWallFunctionFvPatchScalarField::updateCoeffs() { + if (updated()) + { + return; + } + const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patch().index()]; @@ -232,6 +237,8 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() } // TODO: perform averaging for cells sharing more than one boundary face + + fixedInternalValueFvPatchField::updateCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 93cad818..de9a768d 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -164,6 +164,11 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField void epsilonWallFunctionFvPatchScalarField::updateCoeffs() { + if (updated()) + { + return; + } + const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patch().index()]; @@ -214,6 +219,8 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() } // TODO: perform averaging for cells sharing more than one boundary face + + fixedInternalValueFvPatchField::updateCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C index 8b968a4f..eef98df9 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -51,7 +51,11 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const const scalarField magGradU = mag(Uw.snGrad()); const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - return max(scalar(0), sqr(calcUTau(magGradU))/magGradU - nuw); + return max + ( + scalar(0), + sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw + ); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 9eddcb54..4da1a306 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -169,6 +169,11 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField void omegaWallFunctionFvPatchScalarField::updateCoeffs() { + if (updated()) + { + return; + } + const RASModel& rasModel = db().lookupObject("RASProperties"); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patch().index()]; @@ -192,6 +197,8 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() const fvPatchVectorField& Uw = patch().lookupPatchField(UName_); + vectorField n = patch().nf(); + const scalarField magGradUw = mag(Uw.snGrad()); // Set omega and G @@ -222,6 +229,8 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() } // TODO: perform averaging for cells sharing more than one boundary face + + fixedInternalValueFvPatchField::updateCoeffs(); } -- 2.11.4.GIT