From 3b311889644737e2b6157c0f9c1be5198fc5663b Mon Sep 17 00:00:00 2001 From: andy <a.heather@opencfd.co.uk> Date: Tue, 9 Feb 2010 12:21:22 +0000 Subject: [PATCH] ENH: Updated Low-Re RAS models to employ auto-created nut/mut --- .../RAS/LaunderSharmaKE/LaunderSharmaKE.C | 7 +- .../backwardsCompatibilityWallFunctions.C | 71 +++++++++++++++++++ .../backwardsCompatibilityWallFunctions.H | 7 ++ .../RAS/LamBremhorstKE/LamBremhorstKE.C | 16 ++++- .../RAS/LaunderSharmaKE/LaunderSharmaKE.C | 16 ++++- .../RAS/LienCubicKELowRe/LienCubicKELowRe.C | 37 ++++++---- .../LienLeschzinerLowRe/LienLeschzinerLowRe.C | 19 ++++- .../backwardsCompatibilityWallFunctions.C | 71 +++++++++++++++++++ .../backwardsCompatibilityWallFunctions.H | 7 ++ 9 files changed, 232 insertions(+), 19 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C index 18f8d499952..f1dc4e92037 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -168,10 +168,10 @@ LaunderSharmaKE::LaunderSharmaKE "mut", runTime_.timeName(), mesh_, - IOobject::MUST_READ, + IOobject::NO_READ, IOobject::AUTO_WRITE ), - rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_) + autoCreateLowReMut("mut", mesh_) ), alphat_ @@ -187,6 +187,9 @@ LaunderSharmaKE::LaunderSharmaKE autoCreateAlphat("alphat", mesh_) ) { + mut_ = rho_*Cmu_*fMu()*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); + alphat_ = mut_/Prt_; alphat_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C index 842d9125ea2..d2e291d915d 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C @@ -29,6 +29,7 @@ License #include "calculatedFvPatchField.H" #include "alphatWallFunctionFvPatchScalarField.H" #include "mutkWallFunctionFvPatchScalarField.H" +#include "mutLowReWallFunctionFvPatchScalarField.H" #include "epsilonWallFunctionFvPatchScalarField.H" #include "kqRWallFunctionFvPatchField.H" #include "omegaWallFunctionFvPatchScalarField.H" @@ -182,6 +183,76 @@ tmp<volScalarField> autoCreateMut } +tmp<volScalarField> autoCreateLowReMut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject mutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (mutHeader.headerOk()) + { + return tmp<volScalarField>(new volScalarField(mutHeader, mesh)); + } + else + { + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList mutBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isA<wallFvPatch>(bm[patchI])) + { + mutBoundaryTypes[patchI] = + RASModels::mutLowReWallFunctionFvPatchScalarField::typeName; + } + else + { + mutBoundaryTypes[patchI] = + calculatedFvPatchField<scalar>::typeName; + } + } + + tmp<volScalarField> mut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + mutBoundaryTypes + ) + ); + + Info<< " Writing new " << fieldName << endl; + mut().write(); + + return mut; + } +} + + tmp<volScalarField> autoCreateEpsilon ( const word& fieldName, diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H index d36be7583cc..31e38aa4152 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H @@ -53,6 +53,13 @@ namespace compressible const fvMesh& mesh ); + //- mut for Low-Reynolds number models + tmp<volScalarField> autoCreateLowReMut + ( + const word& fieldName, + const fvMesh& mesh + ); + //- alphat tmp<volScalarField> autoCreateAlphat ( diff --git a/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C b/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C index 321a7b5ff91..1edcb224b55 100644 --- a/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C +++ b/src/turbulenceModels/incompressible/RAS/LamBremhorstKE/LamBremhorstKE.C @@ -127,8 +127,22 @@ LamBremhorstKE::LamBremhorstKE *(scalar(1) + 20.5/(Rt_ + SMALL)) ), - nut_(Cmu_*fMu_*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) + ) { + nut_ = Cmu_*fMu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C index ad2ebe0821e..3bbdcb6a473 100644 --- a/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/turbulenceModels/incompressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -133,8 +133,22 @@ LaunderSharmaKE::LaunderSharmaKE mesh_ ), - nut_(Cmu_*fMu()*sqr(k_)/(epsilonTilda_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) + ) { + nut_ = Cmu_*fMu()*sqr(k_)/(epsilonTilda_ + epsilonSmall_); + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C b/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C index 2fdb30e8cf9..2146553f0f6 100644 --- a/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C +++ b/src/turbulenceModels/incompressible/RAS/LienCubicKELowRe/LienCubicKELowRe.C @@ -28,6 +28,8 @@ License #include "wallFvPatch.H" #include "addToRunTimeSelectionTable.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -233,20 +235,16 @@ LienCubicKELowRe::LienCubicKELowRe nut_ ( - Cmu_ - *( - scalar(1) - exp(-Am_*yStar_)) - /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL - ) - *sqr(k_)/(epsilon_ + epsilonSmall_) - // cubic term C5, implicit part - + max + IOobject ( - C5viscosity_, - dimensionedScalar("0", C5viscosity_.dimensions(), 0.0) - ) + "nut", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) ), - // turbulent viscosity, with implicit part of C5 nonlinearStress_ ( @@ -282,6 +280,21 @@ LienCubicKELowRe::LienCubicKELowRe ) ) { + nut_ = Cmu_ + *( + scalar(1) - exp(-Am_*yStar_)) + /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL + ) + *sqr(k_)/(epsilon_ + epsilonSmall_) + // cubic term C5, implicit part + + max + ( + C5viscosity_, + dimensionedScalar("0", C5viscosity_.dimensions(), 0.0) + ); + + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C b/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C index b7a82d6d1bd..6e47e1d926f 100644 --- a/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C +++ b/src/turbulenceModels/incompressible/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C @@ -28,6 +28,8 @@ License #include "wallFvPatch.H" #include "addToRunTimeSelectionTable.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -167,11 +169,22 @@ LienLeschzinerLowRe::LienLeschzinerLowRe nut_ ( - Cmu_*(scalar(1) - exp(-Am_*yStar_)) - /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL)*sqr(k_) - /(epsilon_ + epsilonSmall_) + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + autoCreateLowReNut("nut", mesh_) ) { + nut_ = Cmu_*(scalar(1) - exp(-Am_*yStar_)) + /(scalar(1) - exp(-Aepsilon_*yStar_) + SMALL)*sqr(k_) + /(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); + printCoeffs(); } diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C index b2bcedff458..3de77712fdc 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C @@ -28,6 +28,7 @@ License #include "calculatedFvPatchField.H" #include "nutkWallFunctionFvPatchScalarField.H" +#include "nutLowReWallFunctionFvPatchScalarField.H" #include "epsilonWallFunctionFvPatchScalarField.H" #include "kqRWallFunctionFvPatchField.H" #include "omegaWallFunctionFvPatchScalarField.H" @@ -111,6 +112,76 @@ tmp<volScalarField> autoCreateNut } +tmp<volScalarField> autoCreateLowReNut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject nutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (nutHeader.headerOk()) + { + return tmp<volScalarField>(new volScalarField(nutHeader, mesh)); + } + else + { + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; + + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList nutBoundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isA<wallFvPatch>(bm[patchI])) + { + nutBoundaryTypes[patchI] = + RASModels::nutLowReWallFunctionFvPatchScalarField::typeName; + } + else + { + nutBoundaryTypes[patchI] = + calculatedFvPatchField<scalar>::typeName; + } + } + + tmp<volScalarField> nut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar("zero", dimArea/dimTime, 0.0), + nutBoundaryTypes + ) + ); + + Info<< " Writing new " << fieldName << endl; + nut().write(); + + return nut; + } +} + + tmp<volScalarField> autoCreateEpsilon ( const word& fieldName, diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H index 615834f9e80..e3d2c738851 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.H @@ -53,6 +53,13 @@ namespace incompressible const fvMesh& mesh ); + //- nut for Low-Reynolds number models + tmp<volScalarField> autoCreateLowReNut + ( + const word& fieldName, + const fvMesh& mesh + ); + //- epsilon tmp<volScalarField> autoCreateEpsilon ( -- GitLab