From 981b6303a4de950397a939e0c1e22b0547c8dd11 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 30 Nov 2015 12:48:20 +0000 Subject: [PATCH 1/9] ENH: Spalart-Allmaras DES, DDES and IDDES model updates Included option to use the low Reynolds number correction, with a default value of 'on'. Further details can be found in the reference: Spalart, P. R., Deck, S., Shur, M.L., Squires, K.D., Strelets, M.Kh, Travin, A. (2006). A new version of detached-eddy simulation, resistant to ambiguous grid densities. Theor. Comput. Fluid Dyn., 20, 181-195. Set using the entry: lowReCorrection on; // off --- .../SpalartAllmarasDDES/SpalartAllmarasDDES.C | 4 +- .../SpalartAllmarasDES/SpalartAllmarasDES.C | 108 +++++++++++++++++- .../SpalartAllmarasDES/SpalartAllmarasDES.H | 28 ++++- .../SpalartAllmarasIDDES.C | 4 +- 4 files changed, 135 insertions(+), 9 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDDES/SpalartAllmarasDDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDDES/SpalartAllmarasDDES.C index 075b61388d..3339dd4ce5 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDDES/SpalartAllmarasDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDDES/SpalartAllmarasDDES.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,7 +88,7 @@ tmp SpalartAllmarasDDES::dTilda - fd(mag(gradU)) *max ( - this->y_ - this->CDES_*this->delta(), + this->y_ - this->psi(chi, fv1)*this->CDES_*this->delta(), dimensionedScalar("zero", dimLength, 0) ), dimensionedScalar("small", dimLength, SMALL) diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C index d1b0da8341..5bf1780bff 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,6 +63,16 @@ tmp SpalartAllmarasDES::fv2 } +template +tmp SpalartAllmarasDES::ft2 +( + const volScalarField& chi +) const +{ + return Ct3_*exp(-Ct4_*sqr(chi)); +} + + template tmp SpalartAllmarasDES::S ( @@ -148,6 +158,53 @@ tmp SpalartAllmarasDES::fw } +template +tmp SpalartAllmarasDES::psi +( + const volScalarField& chi, + const volScalarField& fv1 +) const +{ + tmp tpsi + ( + new volScalarField + ( + IOobject + ( + type() + ":psi", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh(), + dimensionedScalar("one", dimless, 1) + ) + ); + + if (lowReCorrection_) + { + volScalarField& psi = tpsi(); + + const volScalarField fv2(this->fv2(chi, fv1)); + const volScalarField ft2(this->ft2(chi)); + + psi = + sqrt + ( + min + ( + scalar(100), + (1 - Cb1_/(Cw1_*sqr(kappa_)*fwStar_)*(ft2 + (1 - ft2)*fv2)) + /max(SMALL, (fv1*max(1e-10, 1 - ft2))) + ) + ); + } + + return tpsi; +} + + template tmp SpalartAllmarasDES::dTilda ( @@ -156,7 +213,7 @@ tmp SpalartAllmarasDES::dTilda const volTensorField& gradU ) const { - tmp tdTilda(CDES_*this->delta()); + tmp tdTilda(psi(chi, fv1)*CDES_*this->delta()); min(tdTilda().dimensionedInternalField(), tdTilda(), y_); return tdTilda; } @@ -300,6 +357,42 @@ SpalartAllmarasDES::SpalartAllmarasDES 0.07 ) ), + lowReCorrection_ + ( + Switch::lookupOrAddToDict + ( + "lowReCorrection", + this->coeffDict_, + true + ) + ), + Ct3_ + ( + dimensioned::lookupOrAddToDict + ( + "Ct3", + this->coeffDict_, + 1.2 + ) + ), + Ct4_ + ( + dimensioned::lookupOrAddToDict + ( + "Ct4", + this->coeffDict_, + 0.5 + ) + ), + fwStar_ + ( + dimensioned::lookupOrAddToDict + ( + "fwStar", + this->coeffDict_, + 0.424 + ) + ), nuTilda_ ( @@ -345,6 +438,11 @@ bool SpalartAllmarasDES::read() CDES_.readIfPresent(this->coeffDict()); ck_.readIfPresent(this->coeffDict()); + lowReCorrection_.readIfPresent("lowReCorrection", this->coeffDict()); + Ct3_.readIfPresent(this->coeffDict()); + Ct4_.readIfPresent(this->coeffDict()); + fwStar_.readIfPresent(this->coeffDict()); + return true; } else @@ -418,6 +516,7 @@ void SpalartAllmarasDES::correct() const volScalarField chi(this->chi()); const volScalarField fv1(this->fv1(chi)); + const volScalarField ft2(this->ft2(chi)); tmp tgradU = fvc::grad(U); const volScalarField Omega(this->Omega(tgradU())); @@ -431,10 +530,11 @@ void SpalartAllmarasDES::correct() - fvm::laplacian(alpha*rho*DnuTildaEff(), nuTilda_) - Cb2_/sigmaNut_*alpha*rho*magSqr(fvc::grad(nuTilda_)) == - Cb1_*alpha*rho*Stilda*nuTilda_ + Cb1_*alpha*rho*Stilda*nuTilda_*(scalar(1) - ft2) - fvm::Sp ( - Cw1_*alpha*rho*fw(Stilda, dTilda)*nuTilda_/sqr(dTilda), + (Cw1_*fw(Stilda, dTilda) - Cb1_/sqr(kappa_)*ft2) + *alpha*rho*nuTilda_/sqr(dTilda), nuTilda_ ) ); diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H index 3a560be0c8..60294f61d8 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +39,15 @@ Description Advances in DNS/LES, 1, 4-8. \endverbatim + Including the low Reynolds number correction documented in + \verbatim + Spalart, P. R., Deck, S., Shur, M.L., Squires, K.D., Strelets, M.Kh, + Travin, A. (2006). + A new version of detached-eddy simulation, resistant to ambiguous grid + densities. + Theor. Comput. Fluid Dyn., 20, 181-195. + \endverbatim + SourceFiles SpalartAllmarasDES.C @@ -91,6 +100,15 @@ protected: dimensionedScalar CDES_; dimensionedScalar ck_; + + // Low Reynolds number correction + + Switch lowReCorrection_; + dimensionedScalar Ct3_; + dimensionedScalar Ct4_; + dimensionedScalar fwStar_; + + // Fields volScalarField nuTilda_; @@ -113,6 +131,8 @@ protected: const volScalarField& fv1 ) const; + tmp ft2(const volScalarField& chi) const; + tmp S(const volTensorField& gradU) const; tmp Omega(const volTensorField& gradU) const; @@ -138,6 +158,12 @@ protected: const volScalarField& dTilda ) const; + tmp psi + ( + const volScalarField& chi, + const volScalarField& fv1 + ) const; + //- Length scale virtual tmp dTilda ( diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C index f96cdc6a16..0a1015cfdb 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -140,7 +140,7 @@ tmp SpalartAllmarasIDDES::dTilda ( dimensionedScalar("SMALL", dimLength, SMALL), fHyb*(1 + fRestore*Psi)*this->y_ - + (1 - fHyb)*this->CDES_*Psi*this->delta() + + (1 - fHyb)*this->psi(chi, fv1)*this->CDES_*Psi*this->delta() ); } From 3e783accd293d33e94f13b527a8e463d2fa9dcbc Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 30 Nov 2015 16:17:21 +0000 Subject: [PATCH 2/9] ENH: Turbulence - refactored kOmegaSST models to enable easier addition of derived types --- .../RAS/kOmegaSST/kOmegaSST.C | 405 +-------------- .../RAS/kOmegaSST/kOmegaSST.H | 165 +----- .../RAS/kOmegaSST/kOmegaSSTBase.C | 480 ++++++++++++++++++ .../RAS/kOmegaSST/kOmegaSSTBase.H | 320 ++++++++++++ .../{ => doc}/turbulenceModelDoc.H | 0 5 files changed, 819 insertions(+), 551 deletions(-) create mode 100644 src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.C create mode 100644 src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H rename src/TurbulenceModels/turbulenceModels/{ => doc}/turbulenceModelDoc.H (100%) diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C index 76fd9cf0c3..4353b5a748 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C @@ -24,8 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "kOmegaSST.H" -#include "bound.H" -#include "wallDist.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -34,91 +32,22 @@ namespace Foam namespace RASModels { -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -template -tmp kOmegaSST::kOmegaSST::F1 -( - const volScalarField& CDkOmega -) const -{ - tmp CDkOmegaPlus = max - ( - CDkOmega, - dimensionedScalar("1.0e-10", dimless/sqr(dimTime), 1.0e-10) - ); - - tmp arg1 = min - ( - min - ( - max - ( - (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_), - scalar(500)*(this->mu()/this->rho_)/(sqr(y_)*omega_) - ), - (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_)) - ), - scalar(10) - ); - - return tanh(pow4(arg1)); -} - -template -tmp kOmegaSST::kOmegaSST::F2() const -{ - tmp arg2 = min - ( - max - ( - (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_), - scalar(500)*(this->mu()/this->rho_)/(sqr(y_)*omega_) - ), - scalar(100) - ); - - return tanh(sqr(arg2)); -} - -template -tmp kOmegaSST::kOmegaSST::F3() const -{ - tmp arg3 = min - ( - 150*(this->mu()/this->rho_)/(omega_*sqr(y_)), - scalar(10) - ); - - return 1 - tanh(pow4(arg3)); -} - -template -tmp kOmegaSST::kOmegaSST::F23() const -{ - tmp f23(F2()); - - if (F3_) - { - f23() *= F3(); - } - - return f23; -} - +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template void kOmegaSST::correctNut(const volScalarField& S2) { - this->nut_ = a1_*k_/max(a1_*omega_, b1_*F23()*sqrt(S2)); - this->nut_.correctBoundaryConditions(); + // Correct the turbulence viscosity + kOmegaSSTBase > >::correctNut + ( + S2 + ); + // Correct the turbulence thermal diffusivity BasicTurbulenceModel::correctNut(); } -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - template void kOmegaSST::correctNut() { @@ -126,53 +55,6 @@ void kOmegaSST::correctNut() } -template -tmp kOmegaSST::kSource() const -{ - return tmp - ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime - ) - ); -} - - -template -tmp kOmegaSST::omegaSource() const -{ - return tmp - ( - new fvScalarMatrix - ( - omega_, - dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime - ) - ); -} - - -template -tmp kOmegaSST::Qsas -( - const volScalarField& S2, - const volScalarField& gamma, - const volScalarField& beta -) const -{ - return tmp - ( - new fvScalarMatrix - ( - omega_, - dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime - ) - ); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -188,7 +70,7 @@ kOmegaSST::kOmegaSST const word& type ) : - eddyViscosity > + kOmegaSSTBase > > ( type, alpha, @@ -198,286 +80,17 @@ kOmegaSST::kOmegaSST phi, transport, propertiesName - ), - - alphaK1_ - ( - dimensioned::lookupOrAddToDict - ( - "alphaK1", - this->coeffDict_, - 0.85 - ) - ), - alphaK2_ - ( - dimensioned::lookupOrAddToDict - ( - "alphaK2", - this->coeffDict_, - 1.0 - ) - ), - alphaOmega1_ - ( - dimensioned::lookupOrAddToDict - ( - "alphaOmega1", - this->coeffDict_, - 0.5 - ) - ), - alphaOmega2_ - ( - dimensioned::lookupOrAddToDict - ( - "alphaOmega2", - this->coeffDict_, - 0.856 - ) - ), - gamma1_ - ( - dimensioned::lookupOrAddToDict - ( - "gamma1", - this->coeffDict_, - 5.0/9.0 - ) - ), - gamma2_ - ( - dimensioned::lookupOrAddToDict - ( - "gamma2", - this->coeffDict_, - 0.44 - ) - ), - beta1_ - ( - dimensioned::lookupOrAddToDict - ( - "beta1", - this->coeffDict_, - 0.075 - ) - ), - beta2_ - ( - dimensioned::lookupOrAddToDict - ( - "beta2", - this->coeffDict_, - 0.0828 - ) - ), - betaStar_ - ( - dimensioned::lookupOrAddToDict - ( - "betaStar", - this->coeffDict_, - 0.09 - ) - ), - a1_ - ( - dimensioned::lookupOrAddToDict - ( - "a1", - this->coeffDict_, - 0.31 - ) - ), - b1_ - ( - dimensioned::lookupOrAddToDict - ( - "b1", - this->coeffDict_, - 1.0 - ) - ), - c1_ - ( - dimensioned::lookupOrAddToDict - ( - "c1", - this->coeffDict_, - 10.0 - ) - ), - F3_ - ( - Switch::lookupOrAddToDict - ( - "F3", - this->coeffDict_, - false - ) - ), - - y_(wallDist::New(this->mesh_).y()), - - k_ - ( - IOobject - ( - IOobject::groupName("k", U.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - this->mesh_ - ), - omega_ - ( - IOobject - ( - IOobject::groupName("omega", U.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - this->mesh_ ) { - bound(k_, this->kMin_); - bound(omega_, this->omegaMin_); + correctNut(); if (type == typeName) { - correctNut(); this->printCoeffs(type); } } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -bool kOmegaSST::read() -{ - if (eddyViscosity >::read()) - { - alphaK1_.readIfPresent(this->coeffDict()); - alphaK2_.readIfPresent(this->coeffDict()); - alphaOmega1_.readIfPresent(this->coeffDict()); - alphaOmega2_.readIfPresent(this->coeffDict()); - gamma1_.readIfPresent(this->coeffDict()); - gamma2_.readIfPresent(this->coeffDict()); - beta1_.readIfPresent(this->coeffDict()); - beta2_.readIfPresent(this->coeffDict()); - betaStar_.readIfPresent(this->coeffDict()); - a1_.readIfPresent(this->coeffDict()); - b1_.readIfPresent(this->coeffDict()); - c1_.readIfPresent(this->coeffDict()); - F3_.readIfPresent("F3", this->coeffDict()); - - return true; - } - else - { - return false; - } -} - - -template -void kOmegaSST::correct() -{ - if (!this->turbulence_) - { - return; - } - - // Local references - const alphaField& alpha = this->alpha_; - const rhoField& rho = this->rho_; - const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_; - const volVectorField& U = this->U_; - volScalarField& nut = this->nut_; - - eddyViscosity >::correct(); - - volScalarField divU(fvc::div(fvc::absolute(this->phi(), U))); - - tmp tgradU = fvc::grad(U); - volScalarField S2(2*magSqr(symm(tgradU()))); - volScalarField GbyNu((tgradU() && dev(twoSymm(tgradU())))); - volScalarField G(this->GName(), nut*GbyNu); - tgradU.clear(); - - // Update omega and G at the wall - omega_.boundaryField().updateCoeffs(); - - volScalarField CDkOmega - ( - (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_ - ); - - volScalarField F1(this->F1(CDkOmega)); - - { - volScalarField gamma(this->gamma(F1)); - volScalarField beta(this->beta(F1)); - - // Turbulent frequency equation - tmp omegaEqn - ( - fvm::ddt(alpha, rho, omega_) - + fvm::div(alphaRhoPhi, omega_) - - fvm::laplacian(alpha*rho*DomegaEff(F1), omega_) - == - alpha*rho*gamma - *min - ( - GbyNu, - (c1_/a1_)*betaStar_*omega_*max(a1_*omega_, b1_*F23()*sqrt(S2)) - ) - - fvm::SuSp((2.0/3.0)*alpha*rho*gamma*divU, omega_) - - fvm::Sp(alpha*rho*beta*omega_, omega_) - - fvm::SuSp - ( - alpha*rho*(F1 - scalar(1))*CDkOmega/omega_, - omega_ - ) - + Qsas(S2, gamma, beta) - + omegaSource() - ); - - omegaEqn().relax(); - - omegaEqn().boundaryManipulate(omega_.boundaryField()); - - solve(omegaEqn); - bound(omega_, this->omegaMin_); - } - - // Turbulent kinetic energy equation - tmp kEqn - ( - fvm::ddt(alpha, rho, k_) - + fvm::div(alphaRhoPhi, k_) - - fvm::laplacian(alpha*rho*DkEff(F1), k_) - == - min(alpha*rho*G, (c1_*betaStar_)*alpha*rho*k_*omega_) - - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k_) - - fvm::Sp(alpha*rho*betaStar_*omega_, k_) - + kSource() - ); - - kEqn().relax(); - solve(kEqn); - bound(k_, this->kMin_); - - correctNut(S2); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace RASModels diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.H b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.H index 1bbbedc91d..17327ad9dd 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.H @@ -31,6 +31,8 @@ Description Implementation of the k-omega-SST turbulence model for incompressible and compressible flows. + Light wrapper around base class. + Turbulence model described in: \verbatim Menter, F. R. & Esch, T. (2001). @@ -98,11 +100,15 @@ Description SourceFiles kOmegaSST.C +SeeAlso + kOmegaSSTBase.H + \*---------------------------------------------------------------------------*/ #ifndef kOmegaSST_H #define kOmegaSST_H +#include "kOmegaSSTBase.H" #include "RASModel.H" #include "eddyViscosity.H" @@ -114,110 +120,21 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class kOmegaSST Declaration + Class kOmegaSST Declaration \*---------------------------------------------------------------------------*/ template class kOmegaSST : - public eddyViscosity > + public kOmegaSSTBase > > { - // Private Member Functions - - // Disallow default bitwise copy construct and assignment - kOmegaSST(const kOmegaSST&); - kOmegaSST& operator=(const kOmegaSST&); - protected: - // Protected data - - // Model coefficients - - dimensionedScalar alphaK1_; - dimensionedScalar alphaK2_; - - dimensionedScalar alphaOmega1_; - dimensionedScalar alphaOmega2_; - - dimensionedScalar gamma1_; - dimensionedScalar gamma2_; - - dimensionedScalar beta1_; - dimensionedScalar beta2_; - - dimensionedScalar betaStar_; - - dimensionedScalar a1_; - dimensionedScalar b1_; - dimensionedScalar c1_; - - Switch F3_; - - - // Fields - - //- Wall distance - // Note: different to wall distance in parent RASModel - // which is for near-wall cells only - const volScalarField& y_; - - volScalarField k_; - volScalarField omega_; - - - // Private Member Functions - - tmp F1(const volScalarField& CDkOmega) const; - tmp F2() const; - tmp F3() const; - tmp F23() const; - - tmp blend - ( - const volScalarField& F1, - const dimensionedScalar& psi1, - const dimensionedScalar& psi2 - ) const - { - return F1*(psi1 - psi2) + psi2; - } - - tmp alphaK(const volScalarField& F1) const - { - return blend(F1, alphaK1_, alphaK2_); - } - - tmp alphaOmega(const volScalarField& F1) const - { - return blend(F1, alphaOmega1_, alphaOmega2_); - } - - tmp beta(const volScalarField& F1) const - { - return blend(F1, beta1_, beta2_); - } - - tmp gamma(const volScalarField& F1) const - { - return blend(F1, gamma1_, gamma2_); - } - - void correctNut(const volScalarField& S2); - - - // Protected Member Functions + // Protecetd Member Functions + virtual void correctNut(const volScalarField& S2); virtual void correctNut(); - virtual tmp kSource() const; - virtual tmp omegaSource() const; - virtual tmp Qsas - ( - const volScalarField& S2, - const volScalarField& gamma, - const volScalarField& beta - ) const; public: @@ -250,68 +167,6 @@ public: //- Destructor virtual ~kOmegaSST() {} - - - // Member Functions - - //- Re-read model coefficients if they have changed - virtual bool read(); - - //- Return the effective diffusivity for k - tmp DkEff(const volScalarField& F1) const - { - return tmp - ( - new volScalarField("DkEff", alphaK(F1)*this->nut_ + this->nu()) - ); - } - - //- Return the effective diffusivity for omega - tmp DomegaEff(const volScalarField& F1) const - { - return tmp - ( - new volScalarField - ( - "DomegaEff", - alphaOmega(F1)*this->nut_ + this->nu() - ) - ); - } - - //- Return the turbulence kinetic energy - virtual tmp k() const - { - return k_; - } - - //- Return the turbulence kinetic energy dissipation rate - virtual tmp epsilon() const - { - return tmp - ( - new volScalarField - ( - IOobject - ( - "epsilon", - this->mesh_.time().timeName(), - this->mesh_ - ), - betaStar_*k_*omega_, - omega_.boundaryField().types() - ) - ); - } - - //- Return the turbulence kinetic energy dissipation rate - virtual tmp omega() const - { - return omega_; - } - - //- Solve the turbulence equations and correct the turbulence viscosity - virtual void correct(); }; diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.C new file mode 100644 index 0000000000..19943c0c1b --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.C @@ -0,0 +1,480 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "kOmegaSSTBase.H" +#include "bound.H" +#include "wallDist.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +tmp kOmegaSSTBase::F1 +( + const volScalarField& CDkOmega +) const +{ + tmp CDkOmegaPlus = max + ( + CDkOmega, + dimensionedScalar("1.0e-10", dimless/sqr(dimTime), 1.0e-10) + ); + + tmp arg1 = min + ( + min + ( + max + ( + (scalar(1)/betaStar_)*sqrt(k_)/(omega_*y_), + scalar(500)*(this->mu()/this->rho_)/(sqr(y_)*omega_) + ), + (4*alphaOmega2_)*k_/(CDkOmegaPlus*sqr(y_)) + ), + scalar(10) + ); + + return tanh(pow4(arg1)); +} + + +template +tmp kOmegaSSTBase::F2() const +{ + tmp arg2 = min + ( + max + ( + (scalar(2)/betaStar_)*sqrt(k_)/(omega_*y_), + scalar(500)*(this->mu()/this->rho_)/(sqr(y_)*omega_) + ), + scalar(100) + ); + + return tanh(sqr(arg2)); +} + + +template +tmp kOmegaSSTBase::F3() const +{ + tmp arg3 = min + ( + 150*(this->mu()/this->rho_)/(omega_*sqr(y_)), + scalar(10) + ); + + return 1 - tanh(pow4(arg3)); +} + + +template +tmp kOmegaSSTBase::F23() const +{ + tmp f23(F2()); + + if (F3_) + { + f23() *= F3(); + } + + return f23; +} + + +template +void kOmegaSSTBase::correctNut +( + const volScalarField& S2 +) +{ + // Correct the turbulence viscosity + this->nut_ = a1_*k_/max(a1_*omega_, b1_*F23()*sqrt(S2)); + this->nut_.correctBoundaryConditions(); +} + + +template +void kOmegaSSTBase::correctNut() +{ + correctNut(2*magSqr(symm(fvc::grad(this->U_)))); +} + + +template +tmp kOmegaSSTBase::kSource() const +{ + return tmp + ( + new fvScalarMatrix + ( + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime + ) + ); +} + + +template +tmp kOmegaSSTBase::omegaSource() const +{ + return tmp + ( + new fvScalarMatrix + ( + omega_, + dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime + ) + ); +} + + +template +tmp kOmegaSSTBase::Qsas +( + const volScalarField& S2, + const volScalarField& gamma, + const volScalarField& beta +) const +{ + return tmp + ( + new fvScalarMatrix + ( + omega_, + dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime + ) + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +kOmegaSSTBase::kOmegaSSTBase +( + const word& type, + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName +) +: + BasicEddyViscosityModel + ( + type, + alpha, + rho, + U, + alphaRhoPhi, + phi, + transport, + propertiesName + ), + + alphaK1_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaK1", + this->coeffDict_, + 0.85 + ) + ), + alphaK2_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaK2", + this->coeffDict_, + 1.0 + ) + ), + alphaOmega1_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaOmega1", + this->coeffDict_, + 0.5 + ) + ), + alphaOmega2_ + ( + dimensioned::lookupOrAddToDict + ( + "alphaOmega2", + this->coeffDict_, + 0.856 + ) + ), + gamma1_ + ( + dimensioned::lookupOrAddToDict + ( + "gamma1", + this->coeffDict_, + 5.0/9.0 + ) + ), + gamma2_ + ( + dimensioned::lookupOrAddToDict + ( + "gamma2", + this->coeffDict_, + 0.44 + ) + ), + beta1_ + ( + dimensioned::lookupOrAddToDict + ( + "beta1", + this->coeffDict_, + 0.075 + ) + ), + beta2_ + ( + dimensioned::lookupOrAddToDict + ( + "beta2", + this->coeffDict_, + 0.0828 + ) + ), + betaStar_ + ( + dimensioned::lookupOrAddToDict + ( + "betaStar", + this->coeffDict_, + 0.09 + ) + ), + a1_ + ( + dimensioned::lookupOrAddToDict + ( + "a1", + this->coeffDict_, + 0.31 + ) + ), + b1_ + ( + dimensioned::lookupOrAddToDict + ( + "b1", + this->coeffDict_, + 1.0 + ) + ), + c1_ + ( + dimensioned::lookupOrAddToDict + ( + "c1", + this->coeffDict_, + 10.0 + ) + ), + F3_ + ( + Switch::lookupOrAddToDict + ( + "F3", + this->coeffDict_, + false + ) + ), + + y_(wallDist::New(this->mesh_).y()), + + k_ + ( + IOobject + ( + IOobject::groupName("k", U.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + this->mesh_ + ), + omega_ + ( + IOobject + ( + IOobject::groupName("omega", U.group()), + this->runTime_.timeName(), + this->mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + this->mesh_ + ) +{ + bound(k_, this->kMin_); + bound(omega_, this->omegaMin_); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool kOmegaSSTBase::read() +{ + if (BasicEddyViscosityModel::read()) + { + alphaK1_.readIfPresent(this->coeffDict()); + alphaK2_.readIfPresent(this->coeffDict()); + alphaOmega1_.readIfPresent(this->coeffDict()); + alphaOmega2_.readIfPresent(this->coeffDict()); + gamma1_.readIfPresent(this->coeffDict()); + gamma2_.readIfPresent(this->coeffDict()); + beta1_.readIfPresent(this->coeffDict()); + beta2_.readIfPresent(this->coeffDict()); + betaStar_.readIfPresent(this->coeffDict()); + a1_.readIfPresent(this->coeffDict()); + b1_.readIfPresent(this->coeffDict()); + c1_.readIfPresent(this->coeffDict()); + F3_.readIfPresent("F3", this->coeffDict()); + + return true; + } + else + { + return false; + } +} + + +template +void kOmegaSSTBase::correct() +{ + if (!this->turbulence_) + { + return; + } + + // Local references + const alphaField& alpha = this->alpha_; + const rhoField& rho = this->rho_; + const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_; + const volVectorField& U = this->U_; + volScalarField& nut = this->nut_; + + BasicEddyViscosityModel::correct(); + + volScalarField divU(fvc::div(fvc::absolute(this->phi(), U))); + + tmp tgradU = fvc::grad(U); + volScalarField S2(2*magSqr(symm(tgradU()))); + volScalarField GbyNu((tgradU() && dev(twoSymm(tgradU())))); + volScalarField G(this->GName(), nut*GbyNu); + tgradU.clear(); + + // Update omega and G at the wall + omega_.boundaryField().updateCoeffs(); + + volScalarField CDkOmega + ( + (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_ + ); + + volScalarField F1(this->F1(CDkOmega)); + + { + volScalarField gamma(this->gamma(F1)); + volScalarField beta(this->beta(F1)); + + // Turbulent frequency equation + tmp omegaEqn + ( + fvm::ddt(alpha, rho, omega_) + + fvm::div(alphaRhoPhi, omega_) + - fvm::laplacian(alpha*rho*DomegaEff(F1), omega_) + == + alpha*rho*gamma + *min + ( + GbyNu, + (c1_/a1_)*betaStar_*omega_*max(a1_*omega_, b1_*F23()*sqrt(S2)) + ) + - fvm::SuSp((2.0/3.0)*alpha*rho*gamma*divU, omega_) + - fvm::Sp(alpha*rho*beta*omega_, omega_) + - fvm::SuSp + ( + alpha*rho*(F1 - scalar(1))*CDkOmega/omega_, + omega_ + ) + + Qsas(S2, gamma, beta) + + omegaSource() + ); + + omegaEqn().relax(); + + omegaEqn().boundaryManipulate(omega_.boundaryField()); + + solve(omegaEqn); + bound(omega_, this->omegaMin_); + } + + // Turbulent kinetic energy equation + tmp kEqn + ( + fvm::ddt(alpha, rho, k_) + + fvm::div(alphaRhoPhi, k_) + - fvm::laplacian(alpha*rho*DkEff(F1), k_) + == + min(alpha*rho*G, (c1_*betaStar_)*alpha*rho*k_*omega_) + - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k_) + - fvm::Sp(alpha*rho*betaStar_*omega_, k_) + + kSource() + ); + + kEqn().relax(); + solve(kEqn); + bound(k_, this->kMin_); + + correctNut(S2); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H new file mode 100644 index 0000000000..eaa4bd7652 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H @@ -0,0 +1,320 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::kOmegaSSTBase + +Description + Base class implementation of the k-omega-SST turbulence model for + incompressible and compressible flows. + + Turbulence model described in: + \verbatim + Menter, F. R. & Esch, T. (2001). + Elements of Industrial Heat Transfer Prediction. + 16th Brazilian Congress of Mechanical Engineering (COBEM). + \endverbatim + + with updated coefficients from + \verbatim + Menter, F. R., Kuntz, M., and Langtry, R. (2003). + Ten Years of Industrial Experience with the SST Turbulence Model. + Turbulence, Heat and Mass Transfer 4, ed: K. Hanjalic, Y. Nagano, + & M. Tummers, Begell House, Inc., 625 - 632. + \endverbatim + + but with the consistent production terms from the 2001 paper as form in the + 2003 paper is a typo, see + \verbatim + http://turbmodels.larc.nasa.gov/sst.html + \endverbatim + + and the addition of the optional F3 term for rough walls from + \verbatim + Hellsten, A. (1998). + "Some Improvements in Menter’s k-omega-SST turbulence model" + 29th AIAA Fluid Dynamics Conference, AIAA-98-2554. + \endverbatim + + Note that this implementation is written in terms of alpha diffusion + coefficients rather than the more traditional sigma (alpha = 1/sigma) so + that the blending can be applied to all coefficuients in a consistent + manner. The paper suggests that sigma is blended but this would not be + consistent with the blending of the k-epsilon and k-omega models. + + Also note that the error in the last term of equation (2) relating to + sigma has been corrected. + + Wall-functions are applied in this implementation by using equations (14) + to specify the near-wall omega as appropriate. + + The blending functions (15) and (16) are not currently used because of the + uncertainty in their origin, range of applicability and that if y+ becomes + sufficiently small blending u_tau in this manner clearly becomes nonsense. + + The default model coefficients are + \verbatim + kOmegaSSTBaseCoeffs + { + alphaK1 0.85; + alphaK2 1.0; + alphaOmega1 0.5; + alphaOmega2 0.856; + beta1 0.075; + beta2 0.0828; + betaStar 0.09; + gamma1 5/9; + gamma2 0.44; + a1 0.31; + b1 1.0; + c1 10.0; + F3 no; + } + \endverbatim + +SourceFiles + kOmegaSSTBase.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kOmegaSSTBase_H +#define kOmegaSSTBase_H + +#include "RASModel.H" +#include "eddyViscosity.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class kOmegaSSTBase Declaration +\*---------------------------------------------------------------------------*/ + +template +class kOmegaSSTBase +: + public BasicEddyViscosityModel +{ + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + kOmegaSSTBase(const kOmegaSSTBase&); + kOmegaSSTBase& operator=(const kOmegaSSTBase&); + + +protected: + + // Protected data + + // Model coefficients + + dimensionedScalar alphaK1_; + dimensionedScalar alphaK2_; + + dimensionedScalar alphaOmega1_; + dimensionedScalar alphaOmega2_; + + dimensionedScalar gamma1_; + dimensionedScalar gamma2_; + + dimensionedScalar beta1_; + dimensionedScalar beta2_; + + dimensionedScalar betaStar_; + + dimensionedScalar a1_; + dimensionedScalar b1_; + dimensionedScalar c1_; + + Switch F3_; + + + // Fields + + //- Wall distance + // Note: different to wall distance in parent RASModel + // which is for near-wall cells only + const volScalarField& y_; + + volScalarField k_; + volScalarField omega_; + + + // Protected Member Functions + + tmp F1(const volScalarField& CDkOmega) const; + tmp F2() const; + tmp F3() const; + tmp F23() const; + + tmp blend + ( + const volScalarField& F1, + const dimensionedScalar& psi1, + const dimensionedScalar& psi2 + ) const + { + return F1*(psi1 - psi2) + psi2; + } + + tmp alphaK(const volScalarField& F1) const + { + return blend(F1, alphaK1_, alphaK2_); + } + + tmp alphaOmega(const volScalarField& F1) const + { + return blend(F1, alphaOmega1_, alphaOmega2_); + } + + tmp beta(const volScalarField& F1) const + { + return blend(F1, beta1_, beta2_); + } + + tmp gamma(const volScalarField& F1) const + { + return blend(F1, gamma1_, gamma2_); + } + + void correctNut(const volScalarField& S2); + + virtual void correctNut(); + virtual tmp kSource() const; + virtual tmp omegaSource() const; + virtual tmp Qsas + ( + const volScalarField& S2, + const volScalarField& gamma, + const volScalarField& beta + ) const; + + +public: + + typedef typename BasicEddyViscosityModel::alphaField alphaField; + typedef typename BasicEddyViscosityModel::rhoField rhoField; + typedef typename BasicEddyViscosityModel::transportModel transportModel; + + + // Constructors + + //- Construct from components + kOmegaSSTBase + ( + const word& type, + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName + ); + + + //- Destructor + virtual ~kOmegaSSTBase() + {} + + + // Member Functions + + //- Re-read model coefficients if they have changed + virtual bool read(); + + //- Return the effective diffusivity for k + tmp DkEff(const volScalarField& F1) const + { + return tmp + ( + new volScalarField("DkEff", alphaK(F1)*this->nut_ + this->nu()) + ); + } + + //- Return the effective diffusivity for omega + tmp DomegaEff(const volScalarField& F1) const + { + return tmp + ( + new volScalarField + ( + "DomegaEff", + alphaOmega(F1)*this->nut_ + this->nu() + ) + ); + } + + //- Return the turbulence kinetic energy + virtual tmp k() const + { + return k_; + } + + //- Return the turbulence kinetic energy dissipation rate + virtual tmp epsilon() const + { + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + this->mesh_.time().timeName(), + this->mesh_ + ), + betaStar_*k_*omega_, + omega_.boundaryField().types() + ) + ); + } + + //- Return the turbulence kinetic energy dissipation rate + virtual tmp omega() const + { + return omega_; + } + + //- Solve the turbulence equations and correct the turbulence viscosity + virtual void correct(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "kOmegaSSTBase.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/turbulenceModelDoc.H b/src/TurbulenceModels/turbulenceModels/doc/turbulenceModelDoc.H similarity index 100% rename from src/TurbulenceModels/turbulenceModels/turbulenceModelDoc.H rename to src/TurbulenceModels/turbulenceModels/doc/turbulenceModelDoc.H From 43f91a1415d1d698d9649a6d6df733fd4e36477b Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 30 Nov 2015 16:18:17 +0000 Subject: [PATCH 3/9] CONTRIBUTION: Turbulence - new kOmegaSST DES, DDES and IDDES model variants - Initial code supplied by CFD Software E+F GmbH - Refactored and integrated into the new templated Turbulence structure by OpenCFD References: - kOmegaSSTDES model: Strelets, M. (2001) Detached Eddy Simulation of Massively Separated Flows, 39th AIAA Aerospace Sciences Meeting and Exhibit, Reno, NV - kOmegaSSTDDES model: Gritskevich, M.S., Garbaruk, A.V., Schuetze, J., Menter, F.R. (2011) Development of DDES and IDDES Formulations for the k-omega Shear Stress Transport Model, Flow, Turbulence and Combustion, pp. 1-19 - kOmegaSSTIDDES model: Gritskevich, M.S., Garbaruk, A.V., Schuetze, J., Menter, F.R. (2011) Development of DDES and IDDES Formulations for the k-omega Shear Stress Transport Model, Flow, Turbulence and Combustion, pp. 1-19 --- .../turbulentFluidThermoModels.C | 9 + .../turbulentTransportModels.C | 9 + .../DES/kOmegaSSTDDES/kOmegaSSTDDES.C | 173 +++++++++++ .../DES/kOmegaSSTDDES/kOmegaSSTDDES.H | 154 ++++++++++ .../DES/kOmegaSSTDES/kOmegaSSTDES.C | 289 ++++++++++++++++++ .../DES/kOmegaSSTDES/kOmegaSSTDES.H | 162 ++++++++++ .../DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C | 254 +++++++++++++++ .../DES/kOmegaSSTIDDES/kOmegaSSTIDDES.H | 167 ++++++++++ .../turbulenceModels/LES/LESModel/LESModel.C | 11 + .../turbulenceModels/LES/LESModel/LESModel.H | 5 +- 10 files changed, 1232 insertions(+), 1 deletion(-) create mode 100644 src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.C create mode 100644 src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.H create mode 100644 src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C create mode 100644 src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.H create mode 100644 src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C create mode 100644 src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.H diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C index db2d414070..2f15cab115 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/turbulentFluidThermoModels.C @@ -129,5 +129,14 @@ makeLESModel(SpalartAllmarasIDDES); #include "DeardorffDiffStress.H" makeLESModel(DeardorffDiffStress); +#include "kOmegaSSTDES.H" +makeLESModel(kOmegaSSTDES); + +#include "kOmegaSSTDDES.H" +makeLESModel(kOmegaSSTDDES); + +#include "kOmegaSSTIDDES.H" +makeLESModel(kOmegaSSTIDDES); + // ************************************************************************* // diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C index 1a3dc38620..db4f1ab398 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/turbulentTransportModels.C @@ -121,5 +121,14 @@ makeLESModel(SpalartAllmarasIDDES); #include "DeardorffDiffStress.H" makeLESModel(DeardorffDiffStress); +#include "kOmegaSSTDES.H" +makeLESModel(kOmegaSSTDES); + +#include "kOmegaSSTDDES.H" +makeLESModel(kOmegaSSTDDES); + +#include "kOmegaSSTIDDES.H" +makeLESModel(kOmegaSSTIDDES); + // ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.C new file mode 100644 index 0000000000..9256590ddb --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.C @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "kOmegaSSTDDES.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESModels +{ + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +tmp kOmegaSSTDDES::rd +( + const volScalarField& nur, + const volScalarField& magGradU +) const +{ + tmp tr + ( + min + ( + nur + /( + max + ( + magGradU, + dimensionedScalar("SMALL", magGradU.dimensions(), SMALL) + ) + *sqr(this->kappa_*this->y_) + ), + scalar(10) + ) + ); + tr().boundaryField() == 0.0; + + return tr; +} + + +template +tmp kOmegaSSTDDES::fd +( + const volScalarField& magGradU +) const +{ + return 1 - tanh(pow(cd1_*rd(this->nuEff(), magGradU), cd2_)); +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +tmp kOmegaSSTDDES::dTilda +( + const volScalarField& magGradU, + const volScalarField& CDES +) const +{ + const volScalarField& k = this->k_; + const volScalarField& omega = this->omega_; + + const volScalarField lRAS(sqrt(k)/(this->betaStar_*omega)); + const volScalarField lLES(CDES*this->delta()); + const dimensionedScalar d0("SMALL", dimLength, SMALL); + + return max(lRAS - fd(magGradU)*max(lRAS - lLES, d0), d0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +kOmegaSSTDDES::kOmegaSSTDDES +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName, + const word& type +) +: + kOmegaSSTDES + ( + alpha, + rho, + U, + alphaRhoPhi, + phi, + transport, + propertiesName, + type + ), + + cd1_ + ( + dimensioned::lookupOrAddToDict + ( + "cd1", + this->coeffDict_, + 20 + ) + ), + cd2_ + ( + dimensioned::lookupOrAddToDict + ( + "cd2", + this->coeffDict_, + 3 + ) + ) +{ + if (type == typeName) + { + this->printCoeffs(type); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool kOmegaSSTDDES::read() +{ + if (kOmegaSSTDES::read()) + { + cd1_.readIfPresent(this->coeffDict()); + cd2_.readIfPresent(this->coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.H b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.H new file mode 100644 index 0000000000..ebc3e3ab12 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDDES/kOmegaSSTDDES.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::LESModels::kOmegaSSTDDES + +Group + grpDESTurbulence + +Description + k-omega-SST DDES turbulence model for incompressible and compressible flows + + Reference: + \verbatim + Gritskevich, M.S., Garbaruk, A.V., Schuetze, J., Menter, F.R. (2011) + Development of DDES and IDDES Formulations for the k-omega + Shear Stress Transport Model, Flow, Turbulence and Combustion, + pp. 1-19 + \endverbatim + +SourceFiles + kOmegaSSTDDES.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kOmegaSSTDDES_H +#define kOmegaSSTDDES_H + +#include "kOmegaSSTDES.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class kOmegaSSTDDES Declaration +\*---------------------------------------------------------------------------*/ + +template +class kOmegaSSTDDES +: + public kOmegaSSTDES +{ + // Private Member Functions + + tmp rd + ( + const volScalarField& nur, + const volScalarField& magGradU + ) const; + + tmp fd(const volScalarField& magGradU) const; + + // Disallow default bitwise copy construct and assignment + kOmegaSSTDDES(const kOmegaSSTDDES&); + kOmegaSSTDDES& operator=(const kOmegaSSTDDES&); + + +protected: + + // Protected data + + // Model coefficients + + dimensionedScalar cd1_; + dimensionedScalar cd2_; + + + // Protected Member Functions + + //- Length scale + virtual tmp dTilda + ( + const volScalarField& magGradU, + const volScalarField& CDES + ) const; + + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("kOmegaSSTDDES"); + + + // Constructors + + //- Construct from components + kOmegaSSTDDES + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName, + const word& type = typeName + ); + + + //- Destructor + virtual ~kOmegaSSTDDES() + {} + + + // Member Functions + + //- Re-read model coefficients if they have changed + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "kOmegaSSTDDES.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C new file mode 100644 index 0000000000..6045b886ab --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "kOmegaSSTDES.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESModels +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +void kOmegaSSTDES::correctNut(const volScalarField& S2) +{ + // Correct the turbulence viscosity + kOmegaSSTBase >::correctNut(S2); + + // Correct the turbulence thermal diffusivity + BasicTurbulenceModel::correctNut(); +} + + +template +void kOmegaSSTDES::correctNut() +{ + correctNut(2*magSqr(symm(fvc::grad(this->U_)))); +} + + +template +tmp kOmegaSSTDES::dTilda +( + const volScalarField& magGradU, + const volScalarField& CDES +) const +{ + const volScalarField& k = this->k_; + const volScalarField& omega = this->omega_; + + return min(CDES*this->delta(), sqrt(k)/(this->betaStar_*omega)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +kOmegaSSTDES::kOmegaSSTDES +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName, + const word& type +) +: + kOmegaSSTBase > + ( + type, + alpha, + rho, + U, + alphaRhoPhi, + phi, + transport, + propertiesName + ), + + kappa_ + ( + dimensioned::lookupOrAddToDict + ( + "kappa", + this->coeffDict_, + 0.41 + ) + ), + CDESkom_ + ( + dimensioned::lookupOrAddToDict + ( + "CDESkom", + this->coeffDict_, + 0.78 + ) + ), + CDESkeps_ + ( + dimensioned::lookupOrAddToDict + ( + "CDESkeps", + this->coeffDict_, + 0.61 + ) + ) +{ + correctNut(); + + if (type == typeName) + { + this->printCoeffs(type); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool kOmegaSSTDES::read() +{ + if (kOmegaSSTBase >::read()) + { + CDESkom_.readIfPresent(this->coeffDict()); + CDESkeps_.readIfPresent(this->coeffDict()); + + return true; + } + else + { + return false; + } +} + + +template +void kOmegaSSTDES::correct() +{ + if (!this->turbulence_) + { + return; + } + + // Local references + const alphaField& alpha = this->alpha_; + const rhoField& rho = this->rho_; + const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_; + const volVectorField& U = this->U_; + volScalarField& k = this->k_; + volScalarField& omega = this->omega_; + volScalarField& nut = this->nut_; + + DESModel::correct(); + + volScalarField divU(fvc::div(fvc::absolute(this->phi(), U))); + + tmp tgradU = fvc::grad(U); + volScalarField magGradU(mag(tgradU())); + volScalarField S2(2*magSqr(symm(tgradU()))); + volScalarField GbyNu((tgradU() && dev(twoSymm(tgradU())))); + volScalarField G(this->GName(), nut*GbyNu); + tgradU.clear(); + + // Update omega and G at the wall + omega.boundaryField().updateCoeffs(); + + volScalarField CDkOmega + ( + (2*this->alphaOmega2_)*(fvc::grad(k) & fvc::grad(omega))/omega + ); + + volScalarField F1(this->F1(CDkOmega)); + + { + volScalarField gamma(this->gamma(F1)); + volScalarField beta(this->beta(F1)); + + // Turbulent frequency equation + tmp omegaEqn + ( + fvm::ddt(alpha, rho, omega) + + fvm::div(alphaRhoPhi, omega) + - fvm::laplacian(alpha*rho*this->DomegaEff(F1), omega) + == + alpha*rho*gamma*GbyNu // Using unlimited GybNu + - fvm::SuSp((2.0/3.0)*alpha*rho*gamma*divU, omega) + - fvm::Sp(alpha*rho*beta*omega, omega) + - fvm::SuSp(alpha*rho*(F1 - scalar(1))*CDkOmega/omega, omega) + + this->omegaSource() + ); + + omegaEqn().relax(); + + omegaEqn().boundaryManipulate(omega.boundaryField()); + + solve(omegaEqn); + bound(omega, this->omegaMin_); + } + + { + volScalarField CDES(this->CDES(F1)); + volScalarField dTilda(this->dTilda(magGradU, CDES)); + + // Turbulent kinetic energy equation + tmp kEqn + ( + fvm::ddt(alpha, rho, k) + + fvm::div(alphaRhoPhi, k) + - fvm::laplacian(alpha*rho*this->DkEff(F1), k) + == + min(alpha*rho*G, (this->c1_*this->betaStar_)*alpha*rho*k*omega) + - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k) + - fvm::Sp(alpha*rho*sqrt(k)/dTilda, k) // modified for DES + + this->kSource() + ); + + kEqn().relax(); + solve(kEqn); + bound(k, this->kMin_); + } + + this->correctNut(S2); +} + + +template +tmp kOmegaSSTDES::LESRegion() const +{ + const volScalarField& k = this->k_; + const volScalarField& omega = this->omega_; + const volVectorField& U = this->U_; + + const volScalarField CDkOmega + ( + (2*this->alphaOmega2_)*(fvc::grad(k) & fvc::grad(omega))/omega + ); + + const volScalarField F1(this->F1(CDkOmega)); + + tmp tLESRegion + ( + new volScalarField + ( + IOobject + ( + "DES::LESRegion", + this->mesh_.time().timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + neg + ( + dTilda + ( + mag(fvc::grad(U)), + F1*CDESkom_ + (1 - F1)*CDESkeps_ + ) + - sqrt(k)/(this->betaStar_*omega) + ) + ) + ); + + return tLESRegion; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.H b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.H new file mode 100644 index 0000000000..219c041c04 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::LESModels::kOmegaSSTDES + +Group + grpDESTurbulence + +Description + k-omega-SST DES turbulence model for incompressible and compressible flows + + Reference: + \verbatim + Strelets, M. (2001) + Detached Eddy Simulation of Massively Separated Flows, + 39th AIAA Aerospace Sciences Meeting and Exhibit, Reno, NV + \endverbatim + +SourceFiles + kOmegaSSTDES.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kOmegaSSTDES_H +#define kOmegaSSTDES_H + +#include "DESModel.H" +#include "kOmegaSSTBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + class kOmegaSSTDES Declaration +\*---------------------------------------------------------------------------*/ + +template +class kOmegaSSTDES +: + public kOmegaSSTBase > +{ + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + kOmegaSSTDES(const kOmegaSSTDES&); + kOmegaSSTDES& operator=(const kOmegaSSTDES&); + + +protected: + + // Protected data + + // Model coefficients + + dimensionedScalar kappa_; + dimensionedScalar CDESkom_; + dimensionedScalar CDESkeps_; + + + // Protected Member Functions + + //- Blending for CDES parameter + virtual tmp CDES(const volScalarField& F1) const + { + return this->blend(F1, CDESkom_, CDESkeps_); + } + + virtual void correctNut(const volScalarField& S2); + virtual void correctNut(); + + //- Length scale + virtual tmp dTilda + ( + const volScalarField& magGradU, + const volScalarField& CDES + ) const; + + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("kOmegaSSTDES"); + + + // Constructors + + //- Construct from components + kOmegaSSTDES + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName, + const word& type = typeName + ); + + + //- Destructor + virtual ~kOmegaSSTDES() + {} + + + // Member Functions + + //- Re-read model coefficients if they have changed + virtual bool read(); + + //- Solve the turbulence equations and correct the turbulence viscosity + virtual void correct(); + + //- Return the LES field indicator + virtual tmp LESRegion() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "kOmegaSSTDES.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C new file mode 100644 index 0000000000..3c4bb99ce7 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C @@ -0,0 +1,254 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "kOmegaSSTIDDES.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESModels +{ + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +const IDDESDelta& kOmegaSSTIDDES::setDelta() const +{ + if (!isA(this->delta_())) + { + FatalErrorIn + ( + "const kOmegaSSTIDDES::setDelta() const" + ) + << "The delta function must be set to a " << IDDESDelta::typeName + << " -based model" << exit(FatalError); + } + + return refCast(this->delta_()); +} + + +template +tmp kOmegaSSTIDDES::alpha() const +{ + return max + ( + 0.25 - this->y_/static_cast(IDDESDelta_.hmax()), + scalar(-5) + ); +} + + +template +tmp kOmegaSSTIDDES::ft +( + const volScalarField& magGradU +) const +{ + return tanh(pow3(sqr(ct_)*rd(this->nut_, magGradU))); +} + + +template +tmp kOmegaSSTIDDES::fl +( + const volScalarField& magGradU +) const +{ + return tanh(pow(sqr(cl_)*rd(this->nu(), magGradU), 10)); +} + + +template +tmp kOmegaSSTIDDES::rd +( + const volScalarField& nur, + const volScalarField& magGradU +) const +{ + tmp tr + ( + min + ( + nur + /( + max + ( + magGradU, + dimensionedScalar("SMALL", magGradU.dimensions(), SMALL) + ) + *sqr(this->kappa_*this->y_) + ), + scalar(10) + ) + ); + tr().boundaryField() == 0.0; + + return tr; +} + + +template +tmp kOmegaSSTIDDES::fd +( + const volScalarField& magGradU +) const +{ + return 1 - tanh(pow(cdt1_*rd(this->nuEff(), magGradU), cdt2_)); +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +tmp kOmegaSSTIDDES::dTilda +( + const volScalarField& magGradU, + const volScalarField& CDES +) const +{ + const volScalarField& k = this->k_; + const volScalarField& omega = this->omega_; + + const volScalarField lRAS(sqrt(k)/(this->betaStar_*omega)); + const volScalarField lLES(CDES*this->delta()); + const dimensionedScalar d0("SMALL", dimLength, SMALL); + + const volScalarField alpha(this->alpha()); + const volScalarField expTerm(exp(sqr(alpha))); + + tmp fStep = min(2*pow(expTerm, -9.0), scalar(1)); + const volScalarField fHyb(max(1 - fd(magGradU), fStep)); + // Simplified version where fRestore = 0 + // return max(d0, fHyb*lRAS + (1 - fHyb)*lLES); + + // Original form + tmp fHill = + 2*(pos(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.0)); + tmp fAmp = 1 - max(ft(magGradU), fl(magGradU)); + tmp fRestore = max(fHill - 1, scalar(0))*fAmp; + return max(d0, fHyb*(1 + fRestore)*lRAS + (1 - fHyb)*lLES); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +kOmegaSSTIDDES::kOmegaSSTIDDES +( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName, + const word& type +) +: + kOmegaSSTDES + ( + alpha, + rho, + U, + alphaRhoPhi, + phi, + transport, + propertiesName, + type + ), + cdt1_ + ( + dimensioned::lookupOrAddToDict + ( + "cdt1", + this->coeffDict_, + 20 + ) + ), + cdt2_ + ( + dimensioned::lookupOrAddToDict + ( + "cdt2", + this->coeffDict_, + 3 + ) + ), + cl_ + ( + dimensioned::lookupOrAddToDict + ( + "cl", + this->coeffDict_, + 5 + ) + ), + ct_ + ( + dimensioned::lookupOrAddToDict + ( + "ct", + this->coeffDict_, + 1.87 + ) + ), + IDDESDelta_(setDelta()) +{ + if (type == typeName) + { + this->printCoeffs(type); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool kOmegaSSTIDDES::read() +{ + if (kOmegaSSTDES::read()) + { + cdt1_.readIfPresent(this->coeffDict()); + cdt2_.readIfPresent(this->coeffDict()); + cl_.readIfPresent(this->coeffDict()); + ct_.readIfPresent(this->coeffDict()); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.H b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.H new file mode 100644 index 0000000000..fe5e50a304 --- /dev/null +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::LESModels::kOmegaSSTIDDES + +Group + grpDESTurbulence + +Description + k-omega-SST IDDES turbulence model for incompressible and compressible + flows + + Reference: + \verbatim + Gritskevich, M.S., Garbaruk, A.V., Schuetze, J., Menter, F.R. (2011) + Development of DDES and IDDES Formulations for the k-omega + Shear Stress Transport Model, Flow, Turbulence and Combustion, + pp. 1-19 + \endverbatim + +SourceFiles + kOmegaSSTIDDES.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kOmegaSSTIDDES_H +#define kOmegaSSTIDDES_H + +#include "kOmegaSSTDES.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + class kOmegaSSTIDDES Declaration +\*---------------------------------------------------------------------------*/ + +template +class kOmegaSSTIDDES +: + public kOmegaSSTDES +{ + // Private Member Functions + + //- Check that the supplied delta is an IDDESDelta + const IDDESDelta& setDelta() const; + + tmp alpha() const; + tmp ft(const volScalarField& magGradU) const; + tmp fl(const volScalarField& magGradU) const; + + tmp rd + ( + const volScalarField& nur, + const volScalarField& magGradU + ) const; + + //- Delay function + tmp fd(const volScalarField& maggradU) const; + + // Disallow default bitwise copy construct and assignment + kOmegaSSTIDDES(const kOmegaSSTIDDES&); + kOmegaSSTIDDES& operator=(const kOmegaSSTIDDES&); + + +protected: + + // Protected data + + // Model coefficients + + dimensionedScalar cdt1_; + dimensionedScalar cdt2_; + dimensionedScalar cl_; + dimensionedScalar ct_; + + // Fields + + const IDDESDelta& IDDESDelta_; + + + //- Length scale + virtual tmp dTilda + ( + const volScalarField& magGradU, + const volScalarField& CDES + ) const; + + +public: + + typedef typename BasicTurbulenceModel::alphaField alphaField; + typedef typename BasicTurbulenceModel::rhoField rhoField; + typedef typename BasicTurbulenceModel::transportModel transportModel; + + + //- Runtime type information + TypeName("kOmegaSSTIDDES"); + + + // Constructors + + //- Construct from components + kOmegaSSTIDDES + ( + const alphaField& alpha, + const rhoField& rho, + const volVectorField& U, + const surfaceScalarField& alphaRhoPhi, + const surfaceScalarField& phi, + const transportModel& transport, + const word& propertiesName = turbulenceModel::propertiesName, + const word& type = typeName + ); + + + //- Destructor + virtual ~kOmegaSSTIDDES() + {} + + + // Member Functions + + //- Re-read model coefficients if they have changed + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "kOmegaSSTIDDES.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#endif + +// ************************************************************************* // diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C index 9955478f41..3135d1d654 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C @@ -80,6 +80,17 @@ Foam::LESModel::LESModel ) ), + omegaMin_ + ( + dimensioned::lookupOrAddToDict + ( + "omegaMin", + LESDict_, + dimless/dimTime, + SMALL + ) + ), + delta_ ( LESdelta::New diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.H b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.H index cefb8dd70e..5ecfeecee3 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.H +++ b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -78,6 +78,9 @@ protected: //- Lower limit of k dimensionedScalar kMin_; + //- Lower limit of omega + dimensionedScalar omegaMin_; + //- Run-time selectable delta model autoPtr delta_; From ea62de36dcbffdcd3200b7a86717c6bda47df933 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 30 Nov 2015 17:51:23 +0000 Subject: [PATCH 4/9] ENH: Turbulence model updates --- .../SpalartAllmarasIDDES.C | 21 +++---------------- .../DES/kOmegaSSTDES/kOmegaSSTDES.C | 1 + .../DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C | 6 +----- .../RAS/kOmegaSST/kOmegaSST.C | 3 +-- .../RAS/kOmegaSST/kOmegaSSTBase.H | 2 +- .../RAS/kOmegaSSTSAS/kOmegaSSTSAS.C | 1 + 6 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C index 0a1015cfdb..5f94e2731d 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C @@ -119,28 +119,13 @@ tmp SpalartAllmarasIDDES::dTilda tmp fAmp = 1 - max(ft(magGradU), fl(magGradU)); tmp fRestore = max(fHill - 1, scalar(0))*fAmp; - // IGNORING ft2 terms - const volScalarField Psi - ( - sqrt - ( - min - ( - scalar(100), - ( - 1 - - this->Cb1_*this->fv2(chi, fv1) - /(this->Cw1_*sqr(this->kappa_)*fwStar_) - )/max(SMALL, fv1) - ) - ) - ); + const volScalarField psi(this->psi(chi, fv1)); return max ( dimensionedScalar("SMALL", dimLength, SMALL), - fHyb*(1 + fRestore*Psi)*this->y_ - + (1 - fHyb)*this->psi(chi, fv1)*this->CDES_*Psi*this->delta() + fHyb*(1 + fRestore*psi)*this->y_ + + (1 - fHyb)*psi*this->CDES_*this->delta() ); } diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C index 6045b886ab..449eb03e15 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C @@ -137,6 +137,7 @@ bool kOmegaSSTDES::read() { if (kOmegaSSTBase >::read()) { + kappa_.readIfPresent(this->coeffDict()); CDESkom_.readIfPresent(this->coeffDict()); CDESkeps_.readIfPresent(this->coeffDict()); diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C index 3c4bb99ce7..9b12fb86a1 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C @@ -54,11 +54,7 @@ const IDDESDelta& kOmegaSSTIDDES::setDelta() const template tmp kOmegaSSTIDDES::alpha() const { - return max - ( - 0.25 - this->y_/static_cast(IDDESDelta_.hmax()), - scalar(-5) - ); + return max(0.25 - this->y_/IDDESDelta_.hmax(), scalar(-5)); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C index 4353b5a748..14443ac537 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C @@ -82,10 +82,9 @@ kOmegaSST::kOmegaSST propertiesName ) { - correctNut(); - if (type == typeName) { + correctNut(); this->printCoeffs(type); } } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H index eaa4bd7652..9684892ea9 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H @@ -199,7 +199,7 @@ protected: return blend(F1, gamma1_, gamma2_); } - void correctNut(const volScalarField& S2); + virtual void correctNut(const volScalarField& S2); virtual void correctNut(); virtual tmp kSource() const; diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C index 7f14345c13..f2b9951ba6 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C @@ -175,6 +175,7 @@ kOmegaSSTSAS::kOmegaSSTSAS { if (type == typeName) { + this->correctNut(); this->printCoeffs(type); } } From 5e3f430526cc84ee2cd47dd426f4a6bf92cc2251 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 30 Nov 2015 17:51:23 +0000 Subject: [PATCH 5/9] ENH: Turbulence modeul updates --- .../SpalartAllmarasIDDES.C | 21 +++---------------- .../DES/kOmegaSSTDES/kOmegaSSTDES.C | 1 + .../DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C | 6 +----- .../RAS/kOmegaSST/kOmegaSST.C | 3 +-- .../RAS/kOmegaSST/kOmegaSSTBase.H | 2 +- .../RAS/kOmegaSSTSAS/kOmegaSSTSAS.C | 1 + 6 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C index 0a1015cfdb..5f94e2731d 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C @@ -119,28 +119,13 @@ tmp SpalartAllmarasIDDES::dTilda tmp fAmp = 1 - max(ft(magGradU), fl(magGradU)); tmp fRestore = max(fHill - 1, scalar(0))*fAmp; - // IGNORING ft2 terms - const volScalarField Psi - ( - sqrt - ( - min - ( - scalar(100), - ( - 1 - - this->Cb1_*this->fv2(chi, fv1) - /(this->Cw1_*sqr(this->kappa_)*fwStar_) - )/max(SMALL, fv1) - ) - ) - ); + const volScalarField psi(this->psi(chi, fv1)); return max ( dimensionedScalar("SMALL", dimLength, SMALL), - fHyb*(1 + fRestore*Psi)*this->y_ - + (1 - fHyb)*this->psi(chi, fv1)*this->CDES_*Psi*this->delta() + fHyb*(1 + fRestore*psi)*this->y_ + + (1 - fHyb)*psi*this->CDES_*this->delta() ); } diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C index 6045b886ab..449eb03e15 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTDES/kOmegaSSTDES.C @@ -137,6 +137,7 @@ bool kOmegaSSTDES::read() { if (kOmegaSSTBase >::read()) { + kappa_.readIfPresent(this->coeffDict()); CDESkom_.readIfPresent(this->coeffDict()); CDESkeps_.readIfPresent(this->coeffDict()); diff --git a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C index 3c4bb99ce7..9b12fb86a1 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/kOmegaSSTIDDES/kOmegaSSTIDDES.C @@ -54,11 +54,7 @@ const IDDESDelta& kOmegaSSTIDDES::setDelta() const template tmp kOmegaSSTIDDES::alpha() const { - return max - ( - 0.25 - this->y_/static_cast(IDDESDelta_.hmax()), - scalar(-5) - ); + return max(0.25 - this->y_/IDDESDelta_.hmax(), scalar(-5)); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C index 4353b5a748..14443ac537 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSST.C @@ -82,10 +82,9 @@ kOmegaSST::kOmegaSST propertiesName ) { - correctNut(); - if (type == typeName) { + correctNut(); this->printCoeffs(type); } } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H index eaa4bd7652..9684892ea9 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSST/kOmegaSSTBase.H @@ -199,7 +199,7 @@ protected: return blend(F1, gamma1_, gamma2_); } - void correctNut(const volScalarField& S2); + virtual void correctNut(const volScalarField& S2); virtual void correctNut(); virtual tmp kSource() const; diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C index 7f14345c13..498d6f0173 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTSAS/kOmegaSSTSAS.C @@ -175,6 +175,7 @@ kOmegaSSTSAS::kOmegaSSTSAS { if (type == typeName) { + correctNut(); this->printCoeffs(type); } } From 184a95a96a901c61e846fc84c32d1e9b697cdfb5 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 1 Dec 2015 09:54:47 +0000 Subject: [PATCH 6/9] ENH: Turbulence models - header documentation updates --- .../RAS/LamBremhorstKE/LamBremhorstKE.H | 2 +- .../turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.H | 2 +- .../RAS/LienLeschziner/LienLeschziner.H | 2 +- .../RAS/ShihQuadraticKE/ShihQuadraticKE.H | 2 +- .../turbulentTransportModels/RAS/kkLOmega/kkLOmega.H | 2 +- .../incompressible/turbulentTransportModels/RAS/qZeta/qZeta.H | 2 +- .../DES/SpalartAllmarasDES/SpalartAllmarasDES.H | 2 +- .../DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H | 2 +- .../turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.H | 2 +- src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.H | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.H b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.H index 603b5295f1..e0d1fda37b 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.H +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.H @@ -131,7 +131,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for k diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.H b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.H index 8580991b9b..f38e40a4c7 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.H +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienCubicKE/LienCubicKE.H @@ -156,7 +156,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for k diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.H b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.H index d861281f0f..e74a64f443 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.H +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/LienLeschziner/LienLeschziner.H @@ -144,7 +144,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for k diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.H b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.H index d81435cf09..5a61675371 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.H +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/ShihQuadraticKE/ShihQuadraticKE.H @@ -131,7 +131,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for k diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/kkLOmega/kkLOmega.H b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/kkLOmega/kkLOmega.H index 68ba379380..198c0bf3db 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/kkLOmega/kkLOmega.H +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/kkLOmega/kkLOmega.H @@ -237,7 +237,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for k diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.H b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.H index 600845160b..7be89ff9c9 100644 --- a/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.H +++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/RAS/qZeta/qZeta.H @@ -138,7 +138,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the lower allowable limit for q (default: SMALL) diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H index 60294f61d8..2ffbbbd714 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasDES/SpalartAllmarasDES.H @@ -210,7 +210,7 @@ public: // Member Functions - //- Read LESProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for nuTilda diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H index 2bfaf6089a..1db9a9fad8 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H @@ -146,7 +146,7 @@ public: // Member Functions - //- Read LESProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); }; diff --git a/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.H b/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.H index 51d303361c..c84373b9e2 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.H @@ -183,7 +183,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for nuTilda diff --git a/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.H b/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.H index 099e0cb079..a76c4ee689 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.H +++ b/src/TurbulenceModels/turbulenceModels/RAS/v2f/v2f.H @@ -208,7 +208,7 @@ public: // Member Functions - //- Read RASProperties dictionary + //- Re-read model coefficients if they have changed virtual bool read(); //- Return the effective diffusivity for k From 7ebfbecd7485ab25418bd35ff0193069568fb48e Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 1 Dec 2015 10:26:23 +0000 Subject: [PATCH 7/9] Turbulence - updated Spalart-Allmaras IDDES to be consistent with reference --- .../SpalartAllmarasIDDES.C | 29 +++++++++++++------ .../SpalartAllmarasIDDES.H | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C index 5f94e2731d..40ea5c9e6a 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C @@ -37,6 +37,7 @@ namespace LESModels template tmp SpalartAllmarasIDDES::alpha() const { + // Equation 9 (plus limits) return max ( 0.25 - this->y_/static_cast(IDDESDelta_.hmax()), @@ -51,6 +52,7 @@ tmp SpalartAllmarasIDDES::ft const volScalarField& magGradU ) const { + // Equation 13 return tanh(pow3(sqr(ct_)*rd(this->nut_, magGradU))); } @@ -61,6 +63,7 @@ tmp SpalartAllmarasIDDES::fl const volScalarField& magGradU ) const { + // Equation 13 return tanh(pow(sqr(cl_)*rd(this->nu(), magGradU), 10)); } @@ -90,11 +93,12 @@ tmp SpalartAllmarasIDDES::rd // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template -tmp SpalartAllmarasIDDES::fd +tmp SpalartAllmarasIDDES::fdt ( const volScalarField& magGradU ) const { + // Related to equation 16 return 1 - tanh(pow3(8*rd(this->nuEff(), magGradU))); } @@ -111,21 +115,28 @@ tmp SpalartAllmarasIDDES::dTilda const volScalarField expTerm(exp(sqr(alpha))); const volScalarField magGradU(mag(gradU)); - tmp fHill = + // Equation 9 + tmp fB = min(2*pow(expTerm, -9.0), scalar(1)); + + // Equation 11 + tmp fe1 = 2*(pos(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.0)); - tmp fStep = min(2*pow(expTerm, -9.0), scalar(1)); - const volScalarField fHyb(max(1 - fd(magGradU), fStep)); - tmp fAmp = 1 - max(ft(magGradU), fl(magGradU)); - tmp fRestore = max(fHill - 1, scalar(0))*fAmp; + // Equation 12 + tmp fe2 = 1 - max(ft(magGradU), fl(magGradU)); + // Equation 10 const volScalarField psi(this->psi(chi, fv1)); + tmp fe = max(fe1 - 1, scalar(0))*psi*fe2; + // Equation 16 + const volScalarField fdTilda(max(1 - fdt(magGradU), fB)); + + // Equation 17 (plus limits) return max ( - dimensionedScalar("SMALL", dimLength, SMALL), - fHyb*(1 + fRestore*psi)*this->y_ - + (1 - fHyb)*psi*this->CDES_*this->delta() + fdTilda*(1 + fe)*this->y_ + (1 - fdTilda)*psi*this->CDES_*this->delta(), + dimensionedScalar("SMALL", dimLength, SMALL) ); } diff --git a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H index 1db9a9fad8..f146bf1dbf 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H +++ b/src/TurbulenceModels/turbulenceModels/DES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H @@ -92,7 +92,7 @@ class SpalartAllmarasIDDES ) const; //- Delay function - tmp fd(const volScalarField& magGradU) const; + tmp fdt(const volScalarField& magGradU) const; // Disallow default bitwise copy construct and assignment SpalartAllmarasIDDES(const SpalartAllmarasIDDES&); From 7fe531bde5dace6af46a4436fe69d87cf3490c02 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 1 Dec 2015 15:22:13 +0000 Subject: [PATCH 8/9] ENH: OutputFilter function object updates from internal development line --- .../OutputFilterFunctionObject.C | 25 ++++++++++++++++--- .../OutputFilterFunctionObject.H | 11 +++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index 100e88f27f..9590eb153c 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -47,10 +47,14 @@ void Foam::OutputFilterFunctionObject::readDict() template bool Foam::OutputFilterFunctionObject::active() const { + // The logic here mimics that of Time itself and uses 0.5*deltaT + // as the tolerance to account for numerical precision errors + // (see e.g. Time::run()) since the current time might be e.g. + // 0.3000000000001 instead of exactly 0.3. return enabled_ - && time_.value() >= timeStart_ - && time_.value() <= timeEnd_; + && time_.value() >= (timeStart_ - 0.5*time_.deltaTValue()) + && time_.value() <= (timeEnd_ + 0.5*time_.deltaTValue()); } @@ -179,6 +183,13 @@ bool Foam::OutputFilterFunctionObject::execute destroyFilter(); } } + else if (enabled_ && time_.value() > timeEnd_) + { + // End early if the time is controlled by the user timeEnd entry + end(); + + enabled_ = false; + } return true; } @@ -196,7 +207,10 @@ bool Foam::OutputFilterFunctionObject::end() ptr_->end(); - if (outputControl_.output()) + // Only write if + // - time within timeStart_ and timeEnd_ + // - it is an output time + if (active() && outputControl_.output()) { ptr_->write(); } @@ -236,6 +250,9 @@ bool Foam::OutputFilterFunctionObject::adjustTimeStep() const label outputTimeIndex = outputControl_.outputTimeLastDump(); const scalar writeInterval = outputControl_.writeInterval(); + // Logic mimics that of Time::adjustDeltaT() except we only allow + // making the time step lower. + scalar timeToNextWrite = max ( 0.0, diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index 6e874dc52a..3b54ebc779 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,15 @@ Note writeInterval to be degrees crank angle, but the functionObject execution \a interval would still be in timestep. + The function object can be limited to operate within a time range using + the timeStart and timEnd options. All objects are read (and the + OutputFilter allocated) on construction. However, if a timeEnd is + supplied, the object will call the 'end' function of the filter + at the timeEnd time and destroy the filter. + Any other callback (execute(), write(), timeSet() etc) will only operate + if within the timeStart, timeEnd time range. Note that the time range + uses 0.5 * deltaT as a comparison tolerance to account for precision errors. + SourceFiles OutputFilterFunctionObject.C From bd737621a0897c45d0918502fb4f6d408400ddbd Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 1 Dec 2015 15:34:25 +0000 Subject: [PATCH 9/9] ENH: fluxSummary function object - added faceZone area output on construction --- .../utilities/fluxSummary/fluxSummary.C | 222 ++++++++++-------- 1 file changed, 120 insertions(+), 102 deletions(-) diff --git a/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C b/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C index 7ec070bef0..e1b078a417 100644 --- a/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C +++ b/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C @@ -677,120 +677,138 @@ Foam::fluxSummary::~fluxSummary() void Foam::fluxSummary::read(const dictionary& dict) { - if (active_) + if (!active_) { - functionObjectFile::read(dict); + return; + } - log_ = dict.lookupOrDefault("log", true); + functionObjectFile::read(dict); - mode_ = modeTypeNames_.read(dict.lookup("mode")); - phiName_= dict.lookupOrDefault("phiName", "phi"); - dict.readIfPresent("scaleFactor", scaleFactor_); - dict.readIfPresent("tolerance", tolerance_); + log_ = dict.lookupOrDefault("log", true); - // initialise with capacity of 10 faceZones - DynamicList refDir(10); - DynamicList faceZoneName(refDir.size()); - DynamicList > faceID(refDir.size()); - DynamicList > facePatchID(refDir.size()); - DynamicList > faceSign(refDir.size()); + mode_ = modeTypeNames_.read(dict.lookup("mode")); + phiName_= dict.lookupOrDefault("phiName", "phi"); + dict.readIfPresent("scaleFactor", scaleFactor_); + dict.readIfPresent("tolerance", tolerance_); - switch (mode_) + // initialise with capacity of 10 faceZones + DynamicList refDir(10); + DynamicList faceZoneName(refDir.size()); + DynamicList > faceID(refDir.size()); + DynamicList > facePatchID(refDir.size()); + DynamicList > faceSign(refDir.size()); + + switch (mode_) + { + case mdFaceZone: { - case mdFaceZone: - { - List zones(dict.lookup("faceZones")); + List zones(dict.lookup("faceZones")); - forAll(zones, i) - { - initialiseFaceZone - ( - zones[i], - faceZoneName, - faceID, - facePatchID, - faceSign - ); - } - break; - } - case mdFaceZoneAndDirection: + forAll(zones, i) { - List > - zoneAndDirection(dict.lookup("faceZoneAndDirection")); - - forAll(zoneAndDirection, i) - { - initialiseFaceZoneAndDirection - ( - zoneAndDirection[i].first(), - zoneAndDirection[i].second(), - refDir, - faceZoneName, - faceID, - facePatchID, - faceSign - ); - } - break; - } - case mdCellZoneAndDirection: - { - List > - zoneAndDirection(dict.lookup("cellZoneAndDirection")); - - forAll(zoneAndDirection, i) - { - initialiseCellZoneAndDirection - ( - zoneAndDirection[i].first(), - zoneAndDirection[i].second(), - refDir, - faceZoneName, - faceID, - facePatchID, - faceSign - ); - } - break; - } - default: - { - FatalIOErrorIn + initialiseFaceZone ( - "void Foam::fluxSummary::read(const dictionary&)", - dict - ) - << "unhandled enumeration " << modeTypeNames_[mode_] - << abort(FatalIOError); - } - } - - faceZoneName_.transfer(faceZoneName); - refDir_.transfer(refDir); - faceID_.transfer(faceID); - facePatchID_.transfer(facePatchID); - faceSign_.transfer(faceSign); - - initialiseFaceArea(); - - if (writeToFile()) - { - filePtrs_.setSize(faceZoneName_.size()); - - forAll(filePtrs_, fileI) - { - const word& fzName = faceZoneName_[fileI]; - filePtrs_.set(fileI, createFile(fzName)); - writeFileHeader - ( - fzName, - faceArea_[fileI], - refDir_[fileI], - filePtrs_[fileI] + zones[i], + faceZoneName, + faceID, + facePatchID, + faceSign ); } + break; } + case mdFaceZoneAndDirection: + { + List > + zoneAndDirection(dict.lookup("faceZoneAndDirection")); + + forAll(zoneAndDirection, i) + { + initialiseFaceZoneAndDirection + ( + zoneAndDirection[i].first(), + zoneAndDirection[i].second(), + refDir, + faceZoneName, + faceID, + facePatchID, + faceSign + ); + } + break; + } + case mdCellZoneAndDirection: + { + List > + zoneAndDirection(dict.lookup("cellZoneAndDirection")); + + forAll(zoneAndDirection, i) + { + initialiseCellZoneAndDirection + ( + zoneAndDirection[i].first(), + zoneAndDirection[i].second(), + refDir, + faceZoneName, + faceID, + facePatchID, + faceSign + ); + } + break; + } + default: + { + FatalIOErrorIn + ( + "void Foam::fluxSummary::read(const dictionary&)", + dict + ) + << "unhandled enumeration " << modeTypeNames_[mode_] + << abort(FatalIOError); + } + } + + faceZoneName_.transfer(faceZoneName); + refDir_.transfer(refDir); + faceID_.transfer(faceID); + facePatchID_.transfer(facePatchID); + faceSign_.transfer(faceSign); + + initialiseFaceArea(); + + if (writeToFile()) + { + filePtrs_.setSize(faceZoneName_.size()); + + forAll(filePtrs_, fileI) + { + const word& fzName = faceZoneName_[fileI]; + filePtrs_.set(fileI, createFile(fzName)); + writeFileHeader + ( + fzName, + faceArea_[fileI], + refDir_[fileI], + filePtrs_[fileI] + ); + } + } + + // Provide some output + if (log_) + { + Info<< type() << " " << name_ << " output:" << nl; + + forAll(faceZoneName_, zoneI) + { + const word& zoneName = faceZoneName_[zoneI]; + scalar zoneArea = faceArea_[zoneI]; + + Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl; + } + + Info<< endl; } }