From 08c1cac832ab94fa648c8741374119557b9421de Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Thu, 16 May 2013 15:58:15 +0100 Subject: [PATCH] ENH: Added option to (de)activate Ashford correction in turbulnce SA models --- .../LES/SpalartAllmaras/SpalartAllmaras.C | 67 +++++++++++++++---- .../LES/SpalartAllmaras/SpalartAllmaras.H | 25 +++++-- .../RAS/SpalartAllmaras/SpalartAllmaras.C | 53 ++++++++++++--- .../RAS/SpalartAllmaras/SpalartAllmaras.H | 12 +++- .../LES/SpalartAllmaras/SpalartAllmaras.C | 61 ++++++++++++++--- .../LES/SpalartAllmaras/SpalartAllmaras.H | 15 ++++- .../RAS/SpalartAllmaras/SpalartAllmaras.C | 55 ++++++++++++--- .../RAS/SpalartAllmaras/SpalartAllmaras.H | 14 ++-- 8 files changed, 249 insertions(+), 53 deletions(-) diff --git a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C index 6994f926e37..324d857a319 100644 --- a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,20 +63,51 @@ tmp<volScalarField> SpalartAllmaras::fv1() const tmp<volScalarField> SpalartAllmaras::fv2() const { - return 1.0/pow3(scalar(1) + rho()*nuTilda_/(mu()*Cv2_)); + if (ashfordCorrection_) + { + return 1.0/pow3(scalar(1) + rho()*nuTilda_/(mu()*Cv2_)); + } + else + { + const volScalarField chi("chi", rho()*nuTilda_/mu()); + return 1.0 - chi/(1.0 + chi*fv1()); + } } tmp<volScalarField> SpalartAllmaras::fv3() const { - volScalarField chi(rho()*nuTilda_/mu()); - volScalarField chiByCv2((1/Cv2_)*chi); - - return - (scalar(1) + chi*fv1()) - *(1/Cv2_) - *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) - /pow3(scalar(1) + chiByCv2); + if (ashfordCorrection_) + { + volScalarField chi(rho()*nuTilda_/mu()); + volScalarField chiByCv2((1/Cv2_)*chi); + + return + (scalar(1) + chi*fv1()) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); + } + else + { + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "fv3", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("fv3", dimless, 1), + zeroGradientFvPatchScalarField::typeName + ) + ); + } } @@ -222,6 +253,8 @@ SpalartAllmaras::SpalartAllmaras ) ), + ashfordCorrection_(coeffDict_.lookupOrDefault("ashfordCorrection", true)), + nuTilda_ ( IOobject @@ -265,6 +298,11 @@ SpalartAllmaras::SpalartAllmaras updateSubGridScaleFields(); printCoeffs(); + + if (ashfordCorrection_) + { + Info<< " Employing Ashford correction" << endl; + } } @@ -344,16 +382,19 @@ bool SpalartAllmaras::read() { sigmaNut_.readIfPresent(coeffDict()); Prt_.readIfPresent(coeffDict()); + Cb1_.readIfPresent(coeffDict()); Cb2_.readIfPresent(coeffDict()); - Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_; - Cw2_.readIfPresent(coeffDict()); - Cw3_.readIfPresent(coeffDict()); Cv1_.readIfPresent(coeffDict()); Cv2_.readIfPresent(coeffDict()); CDES_.readIfPresent(coeffDict()); ck_.readIfPresent(coeffDict()); kappa_.readIfPresent(*this); + Cw1_ = Cb1_/sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_; + Cw2_.readIfPresent(coeffDict()); + Cw3_.readIfPresent(coeffDict()); + + ashfordCorrection_.readIfPresent("ashfordCorrection", coeffDict()); return true; } diff --git a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H index 18975789422..11d24d3388c 100644 --- a/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H +++ b/src/turbulenceModels/compressible/LES/SpalartAllmaras/SpalartAllmaras.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,6 +30,15 @@ Group Description SpalartAllmaras for compressible flows + Extended according to + \verbatim + "An Unstructured Grid Generation and Adaptive Solution Technique + for High Reynolds Number Compressible Flows" + G.A. Ashford, + Ph.D. thesis, University of Michigan, 1996. + \endverbatim + by using the optional flag \c ashfordCorrection + SourceFiles SpalartAllmaras.C @@ -77,12 +86,16 @@ class SpalartAllmaras dimensionedScalar Cw3_; - // Fields + //- Optional flag to activate the Ashford correction + Switch ashfordCorrection_; + + + // Fields - volScalarField nuTilda_; - volScalarField dTilda_; - volScalarField muSgs_; - volScalarField alphaSgs_; + volScalarField nuTilda_; + volScalarField dTilda_; + volScalarField muSgs_; + volScalarField alphaSgs_; // Private Member Functions diff --git a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C index 6c5f3aae0c8..9e5cf2d11fb 100644 --- a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,7 +63,14 @@ tmp<volScalarField> SpalartAllmaras::fv2 const volScalarField& fv1 ) const { - return 1.0/pow3(scalar(1) + chi/Cv2_); + if (ashfordCorrection_) + { + return 1.0/pow3(scalar(1) + chi/Cv2_); + } + else + { + return 1.0 - chi/(1.0 + chi*fv1); + } } @@ -73,13 +80,36 @@ tmp<volScalarField> SpalartAllmaras::fv3 const volScalarField& fv1 ) const { - const volScalarField chiByCv2((1/Cv2_)*chi); + if (ashfordCorrection_) + { + const volScalarField chiByCv2((1/Cv2_)*chi); - return - (scalar(1) + chi*fv1) - *(1/Cv2_) - *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) - /pow3(scalar(1) + chiByCv2); + return + (scalar(1) + chi*fv1) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); + } + else + { + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "fv3", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("fv3", dimless, 1), + zeroGradientFvPatchScalarField::typeName + ) + ); + } } @@ -252,6 +282,11 @@ SpalartAllmaras::SpalartAllmaras alphat_.correctBoundaryConditions(); printCoeffs(); + + if (ashfordCorrection_) + { + Info<< " Employing Ashford correction" << endl; + } } @@ -372,6 +407,8 @@ bool SpalartAllmaras::read() Cv1_.readIfPresent(coeffDict()); Cv2_.readIfPresent(coeffDict()); + ashfordCorrection_.readIfPresent("ashfordCorrection", coeffDict()); + return true; } else diff --git a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H index ea829fc88df..ce1054c482e 100644 --- a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H +++ b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,14 +37,16 @@ Description P.R. Spalart, S.R. Allmaras, La Recherche Aerospatiale, No. 1, 1994, pp. 5-21. + \endverbatim - Extended according to: - + Extended according to: + \verbatim "An Unstructured Grid Generation and Adaptive Solution Technique for High Reynolds Number Compressible Flows" G.A. Ashford, Ph.D. thesis, University of Michigan, 1996. \endverbatim + by using the optional flag \c ashfordCorrection The default model coefficients correspond to the following: \verbatim @@ -110,6 +112,10 @@ protected: dimensionedScalar Cv2_; + //- Optional flag to activate the Ashford correction + Switch ashfordCorrection_; + + // Fields volScalarField nuTilda_; diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C index 4bbf67702af..39afb02f306 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,20 +60,51 @@ tmp<volScalarField> SpalartAllmaras::fv1() const tmp<volScalarField> SpalartAllmaras::fv2() const { - return 1/pow3(scalar(1) + nuTilda_/(Cv2_*nu())); + if (ashfordCorrection_) + { + return 1/pow3(scalar(1) + nuTilda_/(Cv2_*nu())); + } + else + { + const volScalarField chi("chi", nuTilda_/nu()); + return 1.0 - chi/(1.0 + chi*fv1()); + } } tmp<volScalarField> SpalartAllmaras::fv3() const { - const volScalarField chi("chi", nuTilda_/nu()); - const volScalarField chiByCv2(chi/Cv2_); - - return - (scalar(1) + chi*fv1()) - *(1/Cv2_) - *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) - /pow3(scalar(1) + chiByCv2); + if (ashfordCorrection_) + { + const volScalarField chi("chi", nuTilda_/nu()); + const volScalarField chiByCv2(chi/Cv2_); + + return + (scalar(1) + chi*fv1()) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); + } + else + { + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "fv3", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("fv3", dimless, 1), + zeroGradientFvPatchScalarField::typeName + ) + ); + } } @@ -246,6 +277,8 @@ SpalartAllmaras::SpalartAllmaras ) ), + ashfordCorrection_(coeffDict_.lookupOrDefault("ashfordCorrection", true)), + y_(mesh_), nuTilda_ @@ -275,6 +308,11 @@ SpalartAllmaras::SpalartAllmaras ) { updateSubGridScaleFields(); + + if (ashfordCorrection_) + { + Info<< " Employing Ashford correction" << endl; + } } @@ -376,6 +414,7 @@ bool SpalartAllmaras::read() { sigmaNut_.readIfPresent(coeffDict()); kappa_.readIfPresent(*this); + Cb1_.readIfPresent(coeffDict()); Cb2_.readIfPresent(coeffDict()); Cv1_.readIfPresent(coeffDict()); @@ -386,6 +425,8 @@ bool SpalartAllmaras::read() Cw2_.readIfPresent(coeffDict()); Cw3_.readIfPresent(coeffDict()); + ashfordCorrection_.readIfPresent("ashfordCorrection", coeffDict()); + return true; } else diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H index fe4fe280f31..3f3b39e12b1 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmaras/SpalartAllmaras.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,6 +30,15 @@ Group Description SpalartAllmaras DES (SA + LES) turbulence model for incompressible flows + Extended according to + \verbatim + "An Unstructured Grid Generation and Adaptive Solution Technique + for High Reynolds Number Compressible Flows" + G.A. Ashford, + Ph.D. thesis, University of Michigan, 1996. + \endverbatim + by using the optional flag \c ashfordCorrection + SourceFiles SpalartAllmaras.C @@ -90,6 +99,10 @@ protected: dimensionedScalar Cw3_; + //- Optional flag to activate the Ashford correction + Switch ashfordCorrection_; + + // Fields wallDist y_; diff --git a/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.C index 76046a80e25..999978f3c92 100644 --- a/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -61,7 +61,14 @@ tmp<volScalarField> SpalartAllmaras::fv2 const volScalarField& fv1 ) const { - return 1.0/pow3(scalar(1) + chi/Cv2_); + if (ashfordCorrection_) + { + return 1.0/pow3(scalar(1) + chi/Cv2_); + } + else + { + return 1.0 - chi/(1.0 + chi*fv1); + } } @@ -71,13 +78,36 @@ tmp<volScalarField> SpalartAllmaras::fv3 const volScalarField& fv1 ) const { - const volScalarField chiByCv2((1/Cv2_)*chi); + if (ashfordCorrection_) + { + const volScalarField chiByCv2((1/Cv2_)*chi); - return - (scalar(1) + chi*fv1) - *(1/Cv2_) - *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) - /pow3(scalar(1) + chiByCv2); + return + (scalar(1) + chi*fv1) + *(1/Cv2_) + *(3*(scalar(1) + chiByCv2) + sqr(chiByCv2)) + /pow3(scalar(1) + chiByCv2); + } + else + { + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "fv3", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("fv3", dimless, 1), + zeroGradientFvPatchScalarField::typeName + ) + ); + } } @@ -195,6 +225,8 @@ SpalartAllmaras::SpalartAllmaras ) ), + ashfordCorrection_(coeffDict_.lookupOrDefault("ashfordCorrection", true)), + nuTilda_ ( IOobject @@ -224,6 +256,11 @@ SpalartAllmaras::SpalartAllmaras d_(mesh_) { printCoeffs(); + + if (ashfordCorrection_) + { + Info<< " Employing Ashford correction" << endl; + } } @@ -368,6 +405,8 @@ bool SpalartAllmaras::read() Cv1_.readIfPresent(coeffDict()); Cv2_.readIfPresent(coeffDict()); + ashfordCorrection_.readIfPresent("ashfordCorrection", coeffDict()); + return true; } else diff --git a/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.H b/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.H index d7479c2dd5b..597b0859c41 100644 --- a/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.H +++ b/src/turbulenceModels/incompressible/RAS/SpalartAllmaras/SpalartAllmaras.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,14 +37,16 @@ Description P.R. Spalart, S.R. Allmaras, La Recherche Aerospatiale, No. 1, 1994, pp. 5-21. + \endverbatim - Extended according to: - + Extended according to + \verbatim "An Unstructured Grid Generation and Adaptive Solution Technique for High Reynolds Number Compressible Flows" G.A. Ashford, Ph.D. thesis, University of Michigan, 1996. \endverbatim + using the optional flag \c ashfordCorrection The default model coefficients correspond to the following: \verbatim @@ -82,7 +84,7 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class SpalartAllmaras Declaration + Class SpalartAllmaras Declaration \*---------------------------------------------------------------------------*/ class SpalartAllmaras @@ -108,6 +110,10 @@ protected: dimensionedScalar Cv2_; + //- Optional flag to activate the Ashford correction + Switch ashfordCorrection_; + + // Fields volScalarField nuTilda_; -- GitLab