From 7ee39746ff2870f88558a6af251179d0a834c24e Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Fri, 21 Apr 2017 18:22:46 +0100 Subject: [PATCH] turbulenceModels: The "<type>Coeffs" sub-dictionary is now optional --- .../turbulenceModels/LES/LESModel/LESModel.C | 11 ++++------ .../LES/LESdeltas/IDDESDelta/IDDESDelta.C | 10 +++++++--- .../LES/LESdeltas/PrandtlDelta/PrandtlDelta.C | 12 +++++++---- .../cubeRootVolDelta/cubeRootVolDelta.C | 10 +++++++--- .../LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.C | 10 +++++++--- .../LES/LESdeltas/smoothDelta/smoothDelta.C | 11 ++++++---- .../LESdeltas/vanDriestDelta/vanDriestDelta.C | 20 +++++++++++++------ .../anisotropicFilter/anisotropicFilter.C | 9 ++++++--- .../LESfilters/laplaceFilter/laplaceFilter.C | 9 ++++++--- .../turbulenceModels/RAS/RASModel/RASModel.C | 11 ++++------ .../laminar/laminarModel/laminarModel.C | 15 ++++---------- 11 files changed, 74 insertions(+), 54 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C index c5cc7ebdb70..0ff62667376 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ void Foam::LESModel<BasicTurbulenceModel>::printCoeffs(const word& type) { if (printCoeffs_) { - Info<< type << "Coeffs" << coeffDict_ << endl; + Info<< coeffDict_.dictName() << coeffDict_ << endl; } } @@ -67,7 +67,7 @@ Foam::LESModel<BasicTurbulenceModel>::LESModel LESDict_(this->subOrEmptyDict("LES")), turbulence_(LESDict_.lookup("turbulence")), printCoeffs_(LESDict_.lookupOrDefault<Switch>("printCoeffs", false)), - coeffDict_(LESDict_.subOrEmptyDict(type + "Coeffs")), + coeffDict_(LESDict_.optionalSubDict(type + "Coeffs")), kMin_ ( @@ -183,10 +183,7 @@ bool Foam::LESModel<BasicTurbulenceModel>::read() LESDict_ <<= this->subDict("LES"); LESDict_.lookup("turbulence") >> turbulence_; - if (const dictionary* dictPtr = LESDict_.subDictPtr(type() + "Coeffs")) - { - coeffDict_ <<= *dictPtr; - } + coeffDict_ <<= LESDict_.optionalSubDict(type() + "Coeffs"); delta_().read(LESDict_); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C index af812a6f464..8c7396c14fc 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -148,7 +148,11 @@ Foam::LESModels::IDDESDelta::IDDESDelta ), Cw_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("Cw", 0.15) + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar> + ( + "Cw", + 0.15 + ) ) { calcDelta(); @@ -159,7 +163,7 @@ Foam::LESModels::IDDESDelta::IDDESDelta void Foam::LESModels::IDDESDelta::read(const dictionary& dict) { - const dictionary& coeffsDict(dict.subDict(type() + "Coeffs")); + const dictionary& coeffsDict(dict.optionalSubDict(type() + "Coeffs")); coeffsDict.readIfPresent<scalar>("Cw", Cw_); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/PrandtlDelta/PrandtlDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/PrandtlDelta/PrandtlDelta.C index d2b9f762b4a..f09e9c240bb 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/PrandtlDelta/PrandtlDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/PrandtlDelta/PrandtlDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,13 +67,17 @@ Foam::LESModels::PrandtlDelta::PrandtlDelta ( name, turbulence, - dict.subDict(type() + "Coeffs") + dict.optionalSubDict(type() + "Coeffs") ) ), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), Cdelta_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("Cdelta", 0.158) + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar> + ( + "Cdelta", + 0.158 + ) ) { calcDelta(); @@ -84,7 +88,7 @@ Foam::LESModels::PrandtlDelta::PrandtlDelta void Foam::LESModels::PrandtlDelta::read(const dictionary& dict) { - const dictionary& coeffDict(dict.subDict(type() + "Coeffs")); + const dictionary& coeffDict(dict.optionalSubDict(type() + "Coeffs")); geometricDelta_().read(coeffDict); dict.readIfPresent<scalar>("kappa", kappa_); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/cubeRootVolDelta/cubeRootVolDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/cubeRootVolDelta/cubeRootVolDelta.C index 053c365a2fa..ce13cbad1fb 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/cubeRootVolDelta/cubeRootVolDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/cubeRootVolDelta/cubeRootVolDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -91,7 +91,11 @@ Foam::LESModels::cubeRootVolDelta::cubeRootVolDelta LESdelta(name, turbulence), deltaCoeff_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("deltaCoeff", 1) + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar> + ( + "deltaCoeff", + 1 + ) ) { calcDelta(); @@ -102,7 +106,7 @@ Foam::LESModels::cubeRootVolDelta::cubeRootVolDelta void Foam::LESModels::cubeRootVolDelta::read(const dictionary& dict) { - dict.subDict(type() + "Coeffs").readIfPresent<scalar> + dict.optionalSubDict(type() + "Coeffs").readIfPresent<scalar> ( "deltaCoeff", deltaCoeff_ diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.C index 2163a3201c5..ab6dddafcc4 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -102,7 +102,11 @@ Foam::LESModels::maxDeltaxyz::maxDeltaxyz LESdelta(name, turbulence), deltaCoeff_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("deltaCoeff", 1) + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar> + ( + "deltaCoeff", + 1 + ) ) { calcDelta(); @@ -113,7 +117,7 @@ Foam::LESModels::maxDeltaxyz::maxDeltaxyz void Foam::LESModels::maxDeltaxyz::read(const dictionary& dict) { - const dictionary& coeffsDict(dict.subDict(type() + "Coeffs")); + const dictionary& coeffsDict(dict.optionalSubDict(type() + "Coeffs")); coeffsDict.readIfPresent<scalar>("deltaCoeff", deltaCoeff_); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.C index c8a95cc048c..306ea663b00 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/smoothDelta/smoothDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -153,12 +153,15 @@ Foam::LESModels::smoothDelta::smoothDelta ( "geometricDelta", turbulence, - dict.subDict(type() + "Coeffs") + dict.optionalSubDict(type() + "Coeffs") ) ), maxDeltaRatio_ ( - readScalar(dict.subDict(type() + "Coeffs").lookup("maxDeltaRatio")) + readScalar + ( + dict.optionalSubDict(type() + "Coeffs").lookup("maxDeltaRatio") + ) ) { calcDelta(); @@ -169,7 +172,7 @@ Foam::LESModels::smoothDelta::smoothDelta void Foam::LESModels::smoothDelta::read(const dictionary& dict) { - const dictionary& coeffsDict(dict.subDict(type() + "Coeffs")); + const dictionary& coeffsDict(dict.optionalSubDict(type() + "Coeffs")); geometricDelta_().read(coeffsDict); coeffsDict.lookup("maxDeltaRatio") >> maxDeltaRatio_; diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C index 97effadd45a..05b1774c2f6 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -108,21 +108,29 @@ Foam::LESModels::vanDriestDelta::vanDriestDelta ( IOobject::groupName("geometricDelta", turbulence.U().group()), turbulence, - dict.subDict(type() + "Coeffs") + dict.optionalSubDict(type() + "Coeffs") ) ), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), Aplus_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("Aplus", 26.0) + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar> + ( + "Aplus", + 26.0 + ) ), Cdelta_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("Cdelta", 0.158) + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar> + ( + "Cdelta", + 0.158 + ) ), calcInterval_ ( - dict.subDict(type() + "Coeffs").lookupOrDefault<label> + dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<label> ( "calcInterval", 1 @@ -137,7 +145,7 @@ Foam::LESModels::vanDriestDelta::vanDriestDelta void Foam::LESModels::vanDriestDelta::read(const dictionary& dict) { - const dictionary& coeffsDict(dict.subDict(type() + "Coeffs")); + const dictionary& coeffsDict(dict.optionalSubDict(type() + "Coeffs")); geometricDelta_().read(coeffsDict); dict.readIfPresent<scalar>("kappa", kappa_); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C index 467949de78a..f988138fe3e 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,7 +84,10 @@ Foam::anisotropicFilter::anisotropicFilter ) : LESfilter(mesh), - widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))), + widthCoeff_ + ( + readScalar(bd.optionalSubDict(type() + "Coeffs").lookup("widthCoeff")) + ), coeff_ ( IOobject @@ -118,7 +121,7 @@ Foam::anisotropicFilter::anisotropicFilter void Foam::anisotropicFilter::read(const dictionary& bd) { - bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_; + bd.optionalSubDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_; } diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/laplaceFilter/laplaceFilter.C b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/laplaceFilter/laplaceFilter.C index 11fea865431..61934975af1 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/laplaceFilter/laplaceFilter.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/laplaceFilter/laplaceFilter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -64,7 +64,10 @@ Foam::laplaceFilter::laplaceFilter(const fvMesh& mesh, scalar widthCoeff) Foam::laplaceFilter::laplaceFilter(const fvMesh& mesh, const dictionary& bd) : LESfilter(mesh), - widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))), + widthCoeff_ + ( + readScalar(bd.optionalSubDict(type() + "Coeffs").lookup("widthCoeff")) + ), coeff_ ( IOobject @@ -86,7 +89,7 @@ Foam::laplaceFilter::laplaceFilter(const fvMesh& mesh, const dictionary& bd) void Foam::laplaceFilter::read(const dictionary& bd) { - bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_; + bd.optionalSubDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_; } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C index d95f2bffb3f..cc22f4d64cc 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ void Foam::RASModel<BasicTurbulenceModel>::printCoeffs(const word& type) { if (printCoeffs_) { - Info<< type << "Coeffs" << coeffDict_ << endl; + Info<< coeffDict_.dictName() << coeffDict_ << endl; } } @@ -67,7 +67,7 @@ Foam::RASModel<BasicTurbulenceModel>::RASModel RASDict_(this->subOrEmptyDict("RAS")), turbulence_(RASDict_.lookup("turbulence")), printCoeffs_(RASDict_.lookupOrDefault<Switch>("printCoeffs", false)), - coeffDict_(RASDict_.subOrEmptyDict(type + "Coeffs")), + coeffDict_(RASDict_.optionalSubDict(type + "Coeffs")), kMin_ ( @@ -173,10 +173,7 @@ bool Foam::RASModel<BasicTurbulenceModel>::read() RASDict_ <<= this->subDict("RAS"); RASDict_.lookup("turbulence") >> turbulence_; - if (const dictionary* dictPtr = RASDict_.subDictPtr(type() + "Coeffs")) - { - coeffDict_ <<= *dictPtr; - } + coeffDict_ <<= RASDict_.optionalSubDict(type() + "Coeffs"); kMin_.readIfPresent(RASDict_); epsilonMin_.readIfPresent(RASDict_); diff --git a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C index 0bd0bb49e3a..b91406d464a 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,7 +33,7 @@ void Foam::laminarModel<BasicTurbulenceModel>::printCoeffs(const word& type) { if (printCoeffs_) { - Info<< type << "Coeffs" << coeffDict_ << endl; + Info<< coeffDict_.dictName() << coeffDict_ << endl; } } @@ -67,7 +67,7 @@ Foam::laminarModel<BasicTurbulenceModel>::laminarModel laminarDict_(this->subOrEmptyDict("laminar")), printCoeffs_(laminarDict_.lookupOrDefault<Switch>("printCoeffs", false)), - coeffDict_(laminarDict_.subOrEmptyDict(type + "Coeffs")) + coeffDict_(laminarDict_.optionalSubDict(type + "Coeffs")) { // Force the construction of the mesh deltaCoeffs which may be needed // for the construction of the derived models and BCs @@ -170,14 +170,7 @@ bool Foam::laminarModel<BasicTurbulenceModel>::read() { laminarDict_ <<= this->subDict("laminar"); - if - ( - const dictionary* dictPtr = - laminarDict_.subDictPtr(type() + "Coeffs") - ) - { - coeffDict_ <<= *dictPtr; - } + coeffDict_ <<= laminarDict_.optionalSubDict(type() + "Coeffs"); return true; } -- GitLab