From d28267520fbfc4ce5522100999fe45bef2bf47dd Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Fri, 31 May 2019 15:56:46 +0100 Subject: [PATCH] ENH: nutWallFunctions - provided option to specify alternative velocity field --- .../nutLowReWallFunctionFvPatchScalarField.C | 2 +- ...utUBlendedWallFunctionFvPatchScalarField.C | 6 ++--- .../nutURoughWallFunctionFvPatchScalarField.C | 4 +-- ...tUSpaldingWallFunctionFvPatchScalarField.C | 6 ++--- ...UTabulatedWallFunctionFvPatchScalarField.C | 4 +-- .../nutUWallFunctionFvPatchScalarField.C | 4 +-- .../nutWallFunctionFvPatchScalarField.C | 27 +++++++++++++++++++ .../nutWallFunctionFvPatchScalarField.H | 11 ++++++++ 8 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C index 5faec29dcc..edd82b2fce 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C @@ -114,7 +114,7 @@ tmp nutLowReWallFunctionFvPatchScalarField::yPlus() const const scalarField& y = turbModel.y()[patchi]; const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; return y*sqrt(nuw*mag(Uw.snGrad()))/nuw; } diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C index 9bbb5ae898..1a362ab51a 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUBlendedWallFunction/nutUBlendedWallFunctionFvPatchScalarField.C @@ -44,7 +44,7 @@ Foam::nutUBlendedWallFunctionFvPatchScalarField::calcNut() const internalField().group() ) ); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magGradU(mag(Uw.snGrad())); const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); @@ -80,7 +80,7 @@ Foam::nutUBlendedWallFunctionFvPatchScalarField::calcUTau const scalarField& nuw = tnuw(); const vectorField n(patch().nf()); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; vectorField Up(Uw.patchInternalField() - Uw); Up -= n*(n & Up); const scalarField magUp(mag(Up)); @@ -197,7 +197,7 @@ Foam::nutUBlendedWallFunctionFvPatchScalarField::yPlus() const const scalarField& y = turbModel.y()[patchi]; const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magGradU(mag(Uw.snGrad())); return y*calcUTau(magGradU)/nuw; diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C index c0db4a5a5d..2e3d5dcad7 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C @@ -51,7 +51,7 @@ tmp nutURoughWallFunctionFvPatchScalarField::calcNut() const ) ); const scalarField& y = turbModel.y()[patchi]; - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); @@ -314,7 +314,7 @@ tmp nutURoughWallFunctionFvPatchScalarField::yPlus() const internalField().group() ) ); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; tmp magUp = mag(Uw.patchInternalField() - Uw); return calcYPlus(magUp()); diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C index bc4e59f187..1e2d5d34ef 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C @@ -50,7 +50,7 @@ tmp nutUSpaldingWallFunctionFvPatchScalarField::calcNut() const internalField().group() ) ); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magGradU(mag(Uw.snGrad())); const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); @@ -120,7 +120,7 @@ tmp nutUSpaldingWallFunctionFvPatchScalarField::calcUTau ); const scalarField& y = turbModel.y()[patchi]; - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const tmp tnuw = turbModel.nu(patchi); @@ -327,7 +327,7 @@ tmp nutUSpaldingWallFunctionFvPatchScalarField::yPlus() const ) ); const scalarField& y = turbModel.y()[patchi]; - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C index c99832acf5..90d2bc1474 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C @@ -51,7 +51,7 @@ tmp nutUTabulatedWallFunctionFvPatchScalarField::calcNut() const ) ); const scalarField& y = turbModel.y()[patchi]; - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const scalarField magGradU(mag(Uw.snGrad())); const tmp tnuw = turbModel.nu(patchi); @@ -193,7 +193,7 @@ tmp nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const ) ); const scalarField& y = turbModel.y()[patchi]; - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C index 7924ec07d2..9d9cb2be8d 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C @@ -50,7 +50,7 @@ tmp nutUWallFunctionFvPatchScalarField::calcNut() const internalField().group() ) ); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); const tmp tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); @@ -187,7 +187,7 @@ tmp nutUWallFunctionFvPatchScalarField::yPlus() const internalField().group() ) ); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + const fvPatchVectorField& Uw = U(turbModel).boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); return calcYPlus(magUp); diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index c01497432e..b2bc4d7a05 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -29,6 +29,7 @@ License #include "fvPatchFieldMapper.H" #include "volFields.H" #include "wallFvPatch.H" +#include "turbulenceModel.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,11 +55,32 @@ void Foam::nutWallFunctionFvPatchScalarField::checkType() } +const Foam::volVectorField& Foam::nutWallFunctionFvPatchScalarField::U +( + const turbulenceModel& turb +) const +{ + if (UName_ == word::null) + { + return turb.U(); + } + else + { + return db().lookupObject(UName_); + } +} + + void Foam::nutWallFunctionFvPatchScalarField::writeLocalEntries ( Ostream& os ) const { + if (UName_ != word::null) + { + os.writeEntry("U", UName_); + } + os.writeEntry("Cmu", Cmu_); os.writeEntry("kappa", kappa_); os.writeEntry("E", E_); @@ -74,6 +96,7 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), + UName_(word::null), Cmu_(0.09), kappa_(0.41), E_(9.8), @@ -92,6 +115,7 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), + UName_(ptf.UName_), Cmu_(ptf.Cmu_), kappa_(ptf.kappa_), E_(ptf.E_), @@ -109,6 +133,7 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict), + UName_(dict.lookupOrDefault("U", word::null)), Cmu_(dict.lookupOrDefault("Cmu", 0.09)), kappa_(dict.lookupOrDefault("kappa", 0.41)), E_(dict.lookupOrDefault("E", 9.8)), @@ -124,6 +149,7 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(wfpsf), + UName_(wfpsf.UName_), Cmu_(wfpsf.Cmu_), kappa_(wfpsf.kappa_), E_(wfpsf.E_), @@ -140,6 +166,7 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(wfpsf, iF), + UName_(wfpsf.UName_), Cmu_(wfpsf.Cmu_), kappa_(wfpsf.kappa_), E_(wfpsf.E_), diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index baa161e776..ee590b87d1 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -76,6 +76,8 @@ SourceFiles namespace Foam { +class turbulenceModel; + /*---------------------------------------------------------------------------*\ Class nutWallFunctionFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ @@ -88,6 +90,11 @@ protected: // Protected data + //- Name of velocity field + // Defult is null (not specified) in which case the velocity is + // retrieved from the turbulence model + word UName_; + //- Cmu coefficient scalar Cmu_; @@ -103,6 +110,10 @@ protected: // Protected Member Functions + //- Helper to return the velocity field either from the turbulence + //- model (default) or the mesh database + virtual const volVectorField& U(const turbulenceModel& turb) const; + //- Check the type of the patch virtual void checkType();