From c59dc00623699fc31ee6840110e2db74c654ea9c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 16 Sep 2022 11:32:11 +0200 Subject: [PATCH] STYLE: update code style for regionFaModels, optionsList --- src/faOptions/faOption/faOptionList.C | 23 ++-- .../cfdTools/general/fvOptions/fvOptionList.C | 20 ++-- .../KirchhoffShell/KirchhoffShell.C | 6 +- .../KirchhoffShell/KirchhoffShell.H | 4 +- .../velocityFilmShellFvPatchVectorField.C | 43 ++++--- .../velocityFilmShellFvPatchVectorField.H | 10 +- .../thermalShellFvPatchScalarField.C | 12 +- .../thermalShellFvPatchScalarField.H | 16 ++- .../vibrationShellFvPatchScalarField.C | 20 ++-- .../vibrationShellFvPatchScalarField.H | 10 +- .../liquidFilm/liquidFilmBase.H | 8 +- .../liquidFilmModel/liquidFilmModel.C | 4 +- .../subModels/filmSubModelBaseTemplates.C | 8 +- .../regionFaModel/regionFaModel.C | 4 +- .../regionFaModel/regionFaModel.H | 113 +++++++++--------- .../regionFaModel/regionFaModelI.H | 44 +------ .../thermalShell/thermalShell.C | 4 +- .../thermalShell/thermalShell.H | 4 +- .../thermalShellModel/thermalShellModel.H | 6 +- .../thermalShellModel/thermalShellModelNew.C | 15 +-- .../vibrationShellModel/vibrationShellModel.H | 4 +- .../vibrationShellModelNew.C | 15 +-- .../regionModel/regionModel/regionModel.H | 104 ++++++++-------- .../regionModel/regionModel/regionModelI.H | 97 +++------------ .../thermalBaffleFvPatchScalarField.C | 14 +-- .../thermalBaffleFvPatchScalarField.H | 18 ++- 26 files changed, 270 insertions(+), 356 deletions(-) diff --git a/src/faOptions/faOption/faOptionList.C b/src/faOptions/faOption/faOptionList.C index 2c312807e7..f49c5e2039 100644 --- a/src/faOptions/faOption/faOptionList.C +++ b/src/faOptions/faOption/faOptionList.C @@ -79,21 +79,6 @@ void Foam::fa::optionList::checkApplied() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::fa::optionList::optionList -( - const fvPatch& p, - const dictionary& dict -) -: - PtrList(), - mesh_(p.boundaryMesh().mesh()), - patch_(p), - checkTimeIndex_(mesh_.time().startTimeIndex() + 2) -{ - reset(optionsDict(dict)); -} - - Foam::fa::optionList::optionList(const fvPatch& p) : PtrList(), @@ -103,6 +88,14 @@ Foam::fa::optionList::optionList(const fvPatch& p) {} +Foam::fa::optionList::optionList(const fvPatch& p, const dictionary& dict) +: + Foam::fa::optionList(p) +{ + reset(optionsDict(dict)); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::fa::optionList::reset(const dictionary& dict) diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C index 45d114ca11..32087f9f20 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -81,16 +81,6 @@ void Foam::fv::optionList::checkApplied() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::fv::optionList::optionList(const fvMesh& mesh, const dictionary& dict) -: - PtrList(), - mesh_(mesh), - checkTimeIndex_(mesh_.time().startTimeIndex() + 2) -{ - reset(optionsDict(dict)); -} - - Foam::fv::optionList::optionList(const fvMesh& mesh) : PtrList(), @@ -99,6 +89,14 @@ Foam::fv::optionList::optionList(const fvMesh& mesh) {} +Foam::fv::optionList::optionList(const fvMesh& mesh, const dictionary& dict) +: + Foam::fv::optionList(mesh) +{ + reset(optionsDict(dict)); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::fv::optionList::reset(const dictionary& dict) diff --git a/src/regionFaModels/KirchhoffShell/KirchhoffShell.C b/src/regionFaModels/KirchhoffShell/KirchhoffShell.C index a1daf29c33..c77de46b6c 100644 --- a/src/regionFaModels/KirchhoffShell/KirchhoffShell.C +++ b/src/regionFaModels/KirchhoffShell/KirchhoffShell.C @@ -214,7 +214,7 @@ KirchhoffShell::KirchhoffShell ), w00_ ( - IOobject + IOobject ( "w00_" + regionName_, primaryMesh().time().timeName(), @@ -227,7 +227,7 @@ KirchhoffShell::KirchhoffShell ), laplaceW0_ ( - IOobject + IOobject ( "laplaceW0_" + regionName_, primaryMesh().time().timeName(), @@ -240,7 +240,7 @@ KirchhoffShell::KirchhoffShell ), laplace2W0_ ( - IOobject + IOobject ( "laplace2W0_" + regionName_, primaryMesh().time().timeName(), diff --git a/src/regionFaModels/KirchhoffShell/KirchhoffShell.H b/src/regionFaModels/KirchhoffShell/KirchhoffShell.H index 24fe3c7a97..45b584714a 100644 --- a/src/regionFaModels/KirchhoffShell/KirchhoffShell.H +++ b/src/regionFaModels/KirchhoffShell/KirchhoffShell.H @@ -61,8 +61,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef KirchhoffShell_H -#define KirchhoffShell_H +#ifndef Foam_regionModels_KirchhoffShell_H +#define Foam_regionModels_KirchhoffShell_H #include "volFieldsFwd.H" #include "vibrationShellModel.H" diff --git a/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.C b/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.C index e2fe02f80f..b62840a444 100644 --- a/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.C +++ b/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,7 @@ License \*---------------------------------------------------------------------------*/ #include "velocityFilmShellFvPatchVectorField.H" +#include "dictionaryContent.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -42,13 +43,13 @@ velocityFilmShellFvPatchVectorField::velocityFilmShellFvPatchVectorField ) : mixedFvPatchField(p, iF), - baffle_(), - dict_(dictionary::null), + baffle_(nullptr), + dict_(), curTimeIndex_(-1), zeroWallVelocity_(true) { - refValue() = 0; - refGrad() = 0; + refValue() = Zero; + refGrad() = Zero; valueFraction() = 1; } @@ -68,7 +69,7 @@ velocityFilmShellFvPatchVectorField::velocityFilmShellFvPatchVectorField iF, mapper ), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_), curTimeIndex_(-1), zeroWallVelocity_(true) @@ -84,14 +85,25 @@ velocityFilmShellFvPatchVectorField::velocityFilmShellFvPatchVectorField : mixedFvPatchField(p, iF), baffle_(nullptr), - dict_(dict), + dict_ + ( + // Copy dictionary, but without "heavy" data chunks + dictionaryContent::copyDict + ( + dict, + wordRes(), // allow + wordRes // deny + ({ + "type", // redundant + "value", "refValue", "refGradient", "valueFraction" + }) + ) + ), curTimeIndex_(-1), zeroWallVelocity_(dict.getOrDefault("zeroWallVelocity", true)) { fvPatchVectorField::operator=(vectorField("value", dict, p.size())); - typedef regionModels::areaSurfaceFilmModels::liquidFilmBase baffle; - if (dict.found("refValue")) { // Full restart @@ -103,13 +115,13 @@ velocityFilmShellFvPatchVectorField::velocityFilmShellFvPatchVectorField { // Start from user entered data. Assume fixedValue. refValue() = *this; - refGrad() = vector::zero; + refGrad() = Zero; valueFraction() = 1; } if (!baffle_) { - baffle_.reset(baffle::New(p, dict).ptr()); + baffle_.reset(baffleType::New(p, dict_)); } } @@ -121,7 +133,7 @@ velocityFilmShellFvPatchVectorField::velocityFilmShellFvPatchVectorField ) : mixedFvPatchField(ptf, iF), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_), curTimeIndex_(-1), zeroWallVelocity_(true) @@ -172,13 +184,6 @@ void velocityFilmShellFvPatchVectorField::updateCoeffs() void velocityFilmShellFvPatchVectorField::write(Ostream& os) const { mixedFvPatchField::write(os); - - // Remove value and type already written by mixedFvPatchField - dict_.remove("value"); - dict_.remove("type"); - dict_.remove("refValue"); - dict_.remove("refGradient"); - dict_.remove("valueFraction"); dict_.write(os, false); } diff --git a/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.H b/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.H index 66ba8205ee..56c805024d 100644 --- a/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.H +++ b/src/regionFaModels/derivedFvPatchFields/filmShell/velocityFilmShellFvPatchVectorField.H @@ -127,10 +127,16 @@ class velocityFilmShellFvPatchVectorField : public mixedFvPatchField { + // Typedefs + + //- The finite-area region model + typedef regionModels::areaSurfaceFilmModels::liquidFilmBase baffleType; + + // Private Data - //- Thermal baffle - autoPtr baffle_; + //- The liquid film + autoPtr baffle_; //- Dictionary mutable dictionary dict_; diff --git a/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C index b8c65a61ec..ac66c8eb38 100644 --- a/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C +++ b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.C @@ -45,7 +45,7 @@ thermalShellFvPatchScalarField::thermalShellFvPatchScalarField ) : fixedValueFvPatchField(p, iF), - baffle_(), + baffle_(nullptr), dict_() {} @@ -65,7 +65,7 @@ thermalShellFvPatchScalarField::thermalShellFvPatchScalarField iF, mapper ), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_) {} @@ -78,7 +78,7 @@ thermalShellFvPatchScalarField::thermalShellFvPatchScalarField ) : fixedValueFvPatchField(p, iF, dict), - baffle_(), + baffle_(nullptr), dict_ ( // Copy dictionary, but without "heavy" data chunks @@ -94,11 +94,9 @@ thermalShellFvPatchScalarField::thermalShellFvPatchScalarField ) ) { - typedef regionModels::thermalShellModel baffle; - if (!baffle_) { - baffle_.reset(baffle::New(p, dict).ptr()); + baffle_.reset(baffleType::New(p, dict_)); } } @@ -110,7 +108,7 @@ thermalShellFvPatchScalarField::thermalShellFvPatchScalarField ) : fixedValueFvPatchField(ptf, iF), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_) {} diff --git a/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H index 60470784af..1ee34af3e3 100644 --- a/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H +++ b/src/regionFaModels/derivedFvPatchFields/thermalShell/thermalShellFvPatchScalarField.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,8 +68,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef thermalShellFvPatchScalarField_H -#define thermalShellFvPatchScalarField_H +#ifndef Foam_thermalShellFvPatchScalarField_H +#define Foam_thermalShellFvPatchScalarField_H #include "autoPtr.H" #include "thermalShellModel.H" @@ -90,10 +90,16 @@ class thermalShellFvPatchScalarField : public fixedValueFvPatchField { + // Typedefs + + //- The finite-area region model + typedef regionModels::thermalShellModel baffleType; + + // Private Data - //- Thermal baffle - autoPtr baffle_; + //- The thermal baffle + autoPtr baffle_; //- Dictionary dictionary dict_; diff --git a/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C index 69d224b761..ebf8843663 100644 --- a/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C +++ b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,8 +26,8 @@ License \*---------------------------------------------------------------------------*/ #include "vibrationShellFvPatchScalarField.H" -#include "addToRunTimeSelectionTable.H" #include "dictionaryContent.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,11 +43,11 @@ vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField ) : mixedFvPatchField(p, iF), - baffle_(), + baffle_(nullptr), dict_() { - refValue() = 0; - refGrad() = 0; + refValue() = Zero; + refGrad() = Zero; valueFraction() = 1; } @@ -67,7 +67,7 @@ vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField iF, mapper ), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_) {} @@ -80,7 +80,7 @@ vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField ) : mixedFvPatchField(p, iF), - baffle_(), + baffle_(nullptr), dict_ ( // Copy dictionary, but without "heavy" data chunks @@ -109,13 +109,13 @@ vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField { // Start from user entered data. Assume fixedValue. refValue() = *this; - refGrad() = 0; + refGrad() = Zero; valueFraction() = 1; } if (!baffle_) { - baffle_.reset(regionModels::vibrationShellModel::New(p, dict).ptr()); + baffle_.reset(baffleType::New(p, dict_)); } } @@ -127,7 +127,7 @@ vibrationShellFvPatchScalarField::vibrationShellFvPatchScalarField ) : mixedFvPatchField(ptf, iF), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_) {} diff --git a/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H index 4bdd103b79..af184d2aea 100644 --- a/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H +++ b/src/regionFaModels/derivedFvPatchFields/vibrationShell/vibrationShellFvPatchScalarField.H @@ -79,10 +79,16 @@ class vibrationShellFvPatchScalarField : public mixedFvPatchField { + // Typedefs + + //- The finite-area region model + typedef regionModels::vibrationShellModel baffleType; + + // Private Data - //- Thermal baffle - autoPtr baffle_; + //- The vibration shell + autoPtr baffle_; //- Dictionary dictionary dict_; diff --git a/src/regionFaModels/liquidFilm/liquidFilmBase.H b/src/regionFaModels/liquidFilm/liquidFilmBase.H index b51d8d6f45..fa47857826 100644 --- a/src/regionFaModels/liquidFilm/liquidFilmBase.H +++ b/src/regionFaModels/liquidFilm/liquidFilmBase.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef liquidFilmBase_H -#define liquidFilmBase_H +#ifndef Foam_liquidFilmBase_H +#define Foam_liquidFilmBase_H #include "runTimeSelectionTables.H" #include "autoPtr.H" @@ -111,7 +111,7 @@ protected: //- Film pressure areaScalarField pf_; - //- Primary region pressure + //- Primary region pressure areaScalarField ppf_; //- Film momentum flux @@ -289,7 +289,7 @@ public: // Thermo variables - //- Access const reference mu + //- Access const reference mu virtual const areaScalarField& mu() const = 0; //- Access const reference rho diff --git a/src/regionFaModels/liquidFilm/liquidFilmModel/liquidFilmModel.C b/src/regionFaModels/liquidFilm/liquidFilmModel/liquidFilmModel.C index 14d462c640..6e030e9b38 100644 --- a/src/regionFaModels/liquidFilm/liquidFilmModel/liquidFilmModel.C +++ b/src/regionFaModels/liquidFilm/liquidFilmModel/liquidFilmModel.C @@ -51,7 +51,7 @@ void liquidFilmModel::correctThermoFields() { scalarField X(thermo_.size(), 1); - forAll (rho_, faceI) + forAll(rho_, faceI) { rho_[faceI] = thermo_.rho(pRef_, Tf_[faceI], X); mu_[faceI] = thermo_.mu(pRef_, Tf_[faceI], X); @@ -59,7 +59,7 @@ void liquidFilmModel::correctThermoFields() Cp_[faceI] = thermo_.Cp(pRef_, Tf_[faceI], X); } - forAll (regionMesh().boundary(), patchI) + forAll(regionMesh().boundary(), patchI) { const scalarField& patchTf = Tf_.boundaryFieldRef()[patchI]; diff --git a/src/regionFaModels/liquidFilm/subModels/filmSubModelBaseTemplates.C b/src/regionFaModels/liquidFilm/subModels/filmSubModelBaseTemplates.C index 355f1a8851..051a642a4a 100644 --- a/src/regionFaModels/liquidFilm/subModels/filmSubModelBaseTemplates.C +++ b/src/regionFaModels/liquidFilm/subModels/filmSubModelBaseTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +37,9 @@ namespace areaSurfaceFilmModels template const FilmType& filmSubModelBase::filmType() const { - if (!isA(filmModel_)) + const auto* filmPtr = isA(filmModel_); + + if (!filmPtr) { FatalErrorInFunction << "Model " << this->modelType() << " requested film type " @@ -45,7 +47,7 @@ const FilmType& filmSubModelBase::filmType() const << abort(FatalError); } - return refCast(filmModel_); + return *filmPtr; } diff --git a/src/regionFaModels/regionFaModel/regionFaModel.C b/src/regionFaModels/regionFaModel/regionFaModel.C index 27bd759b63..260c587cf5 100644 --- a/src/regionFaModels/regionFaModel/regionFaModel.C +++ b/src/regionFaModels/regionFaModel/regionFaModel.C @@ -145,8 +145,7 @@ Foam::regionModels::regionFaModel::regionFaModel coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")), outputPropertiesPtr_(nullptr), vsmPtr_(nullptr), - patchID_(patch.index()), - regionName_(dict.lookup("region")) + regionName_(dict.get("region")) { constructMeshObjects(); initialise(); @@ -201,4 +200,5 @@ Foam::scalar Foam::regionModels::regionFaModel::CourantNumber() const return 0; } + // ************************************************************************* // diff --git a/src/regionFaModels/regionFaModel/regionFaModel.H b/src/regionFaModels/regionFaModel/regionFaModel.H index bc2246c111..6506949c25 100644 --- a/src/regionFaModels/regionFaModel/regionFaModel.H +++ b/src/regionFaModels/regionFaModel/regionFaModel.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,8 +64,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef regionFaModel_H -#define regionFaModel_H +#ifndef Foam_regionFaModel_H +#define Foam_regionFaModel_H #include "volMesh.H" #include "IOdictionary.H" @@ -79,7 +79,6 @@ SourceFiles namespace Foam { - namespace regionModels { @@ -134,16 +133,9 @@ protected: //- Dictionary of output properties autoPtr outputPropertiesPtr_; - //-Volume-to surface mapping + //- Volume/surface mapping autoPtr vsmPtr_; - - // Addressing - - //- Patch IDs on the primary region coupled to this region - label patchID_; - - //- Region name word regionName_; @@ -182,73 +174,76 @@ public: // Member Functions - // Access + // Access - //- Return the reference to the primary mesh database - inline const fvMesh& primaryMesh() const; + //- Return the reference to the primary mesh database + const fvMesh& primaryMesh() const noexcept { return primaryMesh_; } - //- Return the reference to the time database - inline const Time& time() const; + //- Return the reference to the time database + const Time& time() const noexcept { return time_; } - //- Return the active flag - inline const Switch& active() const; + //- Return the active flag + Switch active() const noexcept { return active_; } - //- Return the information flag - inline const Switch& infoOutput() const; + //- Return the information flag + Switch infoOutput() const noexcept { return infoOutput_; } - //- Return the model name - inline const word& modelName() const; + //- Return the model name + const word& modelName() const noexcept { return modelName_; } - //- Return the region mesh database - inline const faMesh& regionMesh() const; + //- Return the region mesh database + inline const faMesh& regionMesh() const; - //- Return the region mesh database for manipulation - inline faMesh& regionMesh(); + //- Return the region mesh database for manipulation + inline faMesh& regionMesh(); - //- Return the model coefficients dictionary - inline const dictionary& coeffs() const; + //- Return the model coefficients dictionary + const dictionary& coeffs() const noexcept { return coeffs_; } - //- Return const access to the output properties dictionary - inline const IOdictionary& outputProperties() const; + //- Return const access to the output properties dictionary + inline const IOdictionary& outputProperties() const; - //- Return output properties dictionary - inline IOdictionary& outputProperties(); + //- Return output properties dictionary + inline IOdictionary& outputProperties(); - //- Return the solution dictionary - inline const dictionary& solution() const; - - //- Return patch ID - inline label patchID() const; + //- Return the solution dictionary + inline const dictionary& solution() const; - // Help Functions + // Addressing - //- Return mapping between surface and volume fields - const volSurfaceMapping& vsm() const; + //- The patch ID on the primary region coupled to this region + label patchID() const { return patch_.index(); } - // Evolution + // Helper Functions - //- Main driver routing to evolve the region - calls other evolves - virtual void evolve(); - - //- Pre-evolve region - virtual void preEvolveRegion(); - - //- Evolve the region - virtual void evolveRegion(); - - //- Post-evolve region - virtual void postEvolveRegion(); - - //- Courant number of the region - virtual scalar CourantNumber() const; + //- Return mapping between surface and volume fields + const volSurfaceMapping& vsm() const; - // IO + // Evolution - //- Provide some feedback - virtual void info() = 0; + //- Main driver routing to evolve the region - calls other evolves + virtual void evolve(); + + //- Pre-evolve region + virtual void preEvolveRegion(); + + //- Evolve the region + virtual void evolveRegion(); + + //- Post-evolve region + virtual void postEvolveRegion(); + + //- Courant number of the region + virtual scalar CourantNumber() const; + + + // IO + + //- Provide some feedback + virtual void info() = 0; }; diff --git a/src/regionFaModels/regionFaModel/regionFaModelI.H b/src/regionFaModels/regionFaModel/regionFaModelI.H index da8c018f61..91c58827db 100644 --- a/src/regionFaModels/regionFaModel/regionFaModelI.H +++ b/src/regionFaModels/regionFaModel/regionFaModelI.H @@ -29,40 +29,9 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inline const Foam::fvMesh& -Foam::regionModels::regionFaModel::primaryMesh() const -{ - return primaryMesh_; -} - - -inline const Foam::Time& Foam::regionModels::regionFaModel::time() const -{ - return time_; -} - - -inline const Foam::Switch& Foam::regionModels::regionFaModel::active() const -{ - return active_; -} - - -inline const Foam::Switch& Foam::regionModels::regionFaModel::infoOutput() const -{ - return infoOutput_; -} - - -inline const Foam::word& Foam::regionModels::regionFaModel::modelName() const -{ - return modelName_; -} - - inline const Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() const { - const auto* regionPtr = time_.findObject(regionName_); + auto* regionPtr = time_.getObjectPtr(regionName_); if (regionPtr) { @@ -96,11 +65,6 @@ inline Foam::faMesh& Foam::regionModels::regionFaModel::regionMesh() } -inline const Foam::dictionary& Foam::regionModels::regionFaModel::coeffs() const -{ - return coeffs_; -} - inline const Foam::IOdictionary& Foam::regionModels::regionFaModel::outputProperties() const { @@ -135,10 +99,4 @@ Foam::regionModels::regionFaModel::solution() const } -inline Foam::label Foam::regionModels::regionFaModel::patchID() const -{ - return patchID_; -} - - // ************************************************************************* // diff --git a/src/regionFaModels/thermalShell/thermalShell.C b/src/regionFaModels/thermalShell/thermalShell.C index 491b432be1..dcc170fcb5 100644 --- a/src/regionFaModels/thermalShell/thermalShell.C +++ b/src/regionFaModels/thermalShell/thermalShell.C @@ -75,11 +75,11 @@ tmp thermalShell::qr() dimensionedScalar(dimPower/dimArea, Zero) ); - if (qrName_ != "none") + if (!qrName_.empty() && qrName_ != "none") { auto& aqr = taqr.ref(); - const auto qr = primaryMesh().lookupObject(qrName_); + const auto& qr = primaryMesh().lookupObject(qrName_); const volScalarField::Boundary& vqr = qr.boundaryField(); diff --git a/src/regionFaModels/thermalShell/thermalShell.H b/src/regionFaModels/thermalShell/thermalShell.H index d675d68f3c..d1543d1652 100644 --- a/src/regionFaModels/thermalShell/thermalShell.H +++ b/src/regionFaModels/thermalShell/thermalShell.H @@ -71,8 +71,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef thermalShell_H -#define thermalShell_H +#ifndef Foam_regionModels_thermalShell_H +#define Foam_regionModels_thermalShell_H #include "volFieldsFwd.H" #include "thermalShellModel.H" diff --git a/src/regionFaModels/thermalShellModel/thermalShellModel.H b/src/regionFaModels/thermalShellModel/thermalShellModel.H index 5a6294e9f8..5263c5fa44 100644 --- a/src/regionFaModels/thermalShellModel/thermalShellModel.H +++ b/src/regionFaModels/thermalShellModel/thermalShellModel.H @@ -65,8 +65,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef thermalShellModel_H -#define thermalShellModel_H +#ifndef Foam_regionModels_thermalShellModel_H +#define Foam_regionModels_thermalShellModel_H #include "runTimeSelectionTables.H" #include "autoPtr.H" @@ -103,7 +103,7 @@ protected: //- Shell temperature areaScalarField T_; - //- Pointer to faOptions + //- Reference to faOptions Foam::fa::options& faOptions_; diff --git a/src/regionFaModels/thermalShellModel/thermalShellModelNew.C b/src/regionFaModels/thermalShellModel/thermalShellModelNew.C index 29712839e5..b60e5d0735 100644 --- a/src/regionFaModels/thermalShellModel/thermalShellModelNew.C +++ b/src/regionFaModels/thermalShellModel/thermalShellModelNew.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,12 +49,13 @@ autoPtr thermalShellModel::New if (!ctorPtr) { - FatalErrorInFunction - << "Unknown thermalShellModel type " - << modelType << nl << nl - << "Valid thermalShellModel types :" << nl - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalError); + FatalIOErrorInLookup + ( + dict, + "thermalShellModel", + modelType, + *dictionaryConstructorTablePtr_ + ) << exit(FatalIOError); } return autoPtr(ctorPtr(modelType, p, dict)); diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModel.H b/src/regionFaModels/vibrationShellModel/vibrationShellModel.H index a3eb697e3b..ecf9a55d16 100644 --- a/src/regionFaModels/vibrationShellModel/vibrationShellModel.H +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModel.H @@ -68,8 +68,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef thermalShellModel_H -#define thermalShellModel_H +#ifndef Foam_regionModels_vibrationShellModel_H +#define Foam_regionModels_vibrationShellModel_H #include "runTimeSelectionTables.H" #include "autoPtr.H" diff --git a/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C b/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C index c914ef7e7c..8f93e31f5c 100644 --- a/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C +++ b/src/regionFaModels/vibrationShellModel/vibrationShellModelNew.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,12 +48,13 @@ autoPtr vibrationShellModel::New if (!ctorPtr) { - FatalErrorInFunction - << "Unknown vibrationShellModel type " - << modelType << nl << nl - << "Valid vibrationShellModel types :" << nl - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalError); + FatalIOErrorInLookup + ( + dict, + "vibrationShellModel", + modelType, + *dictionaryConstructorTablePtr_ + ) << exit(FatalIOError); } return autoPtr(ctorPtr(modelType, p, dict)); diff --git a/src/regionModels/regionModel/regionModel/regionModel.H b/src/regionModels/regionModel/regionModel/regionModel.H index f237810fad..a06b1b6960 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.H +++ b/src/regionModels/regionModel/regionModel/regionModel.H @@ -62,7 +62,6 @@ class regionModel : public IOdictionary { - private: // Private Member Functions @@ -132,7 +131,7 @@ protected: interRegionAMI_; - // Protected member functions + // Protected Member Functions //- Read control parameters from dictionary virtual bool read(); @@ -187,65 +186,64 @@ public: // Member Functions - // Access + // Access - //- Return the reference to the primary mesh database - inline const fvMesh& primaryMesh() const; + //- Return the reference to the primary mesh database + const fvMesh& primaryMesh() const noexcept { return primaryMesh_; } - //- Return the reference to the time database - inline const Time& time() const; + //- Return the reference to the time database + const Time& time() const noexcept { return time_; } - //- Return the active flag - inline Switch active() const; + //- Return the active flag + Switch active() const noexcept { return active_; } - //- Return the information flag - inline Switch infoOutput() const; + //- Return the information flag + Switch infoOutput() const noexcept { return infoOutput_; } - //- Return the model name - inline const word& modelName() const; + //- Return the model name + const word& modelName() const noexcept { return modelName_; } - //- Return the region mesh database - inline const fvMesh& regionMesh() const; + //- Return the region mesh database + inline const fvMesh& regionMesh() const; - //- Return the region mesh database for manipulation - inline fvMesh& regionMesh(); + //- Return the region mesh database for manipulation + inline fvMesh& regionMesh(); - //- Return the model coefficients dictionary - inline const dictionary& coeffs() const; + //- Return the model coefficients dictionary + const dictionary& coeffs() const noexcept { return coeffs_; } - //- Return the solution dictionary - inline const dictionary& solution() const; + //- Return the solution dictionary + inline const dictionary& solution() const; - //- Return const access to the output properties dictionary - inline const IOdictionary& outputProperties() const; + //- Return const access to the output properties dictionary + inline const IOdictionary& outputProperties() const; - //- Return output properties dictionary - inline IOdictionary& outputProperties(); + //- Return output properties dictionary + inline IOdictionary& outputProperties(); - // Addressing - //- Return true if patchi on the local region is a coupled - // patch to the primary region - inline bool isCoupledPatch(const label regionPatchi) const; + // Addressing - //- Return true if patchi on the primary region is a coupled - // patch to the local region - inline bool isRegionPatch(const label primaryPatchi) const; + //- List of patch IDs on the primary region coupled to this region + inline const labelList& primaryPatchIDs() const noexcept; - //- Return the list of patch IDs on the primary region coupled - // to this region - inline const labelList& primaryPatchIDs() const; + //- List of patch IDs internally coupled with the primary region + inline const labelList& intCoupledPatchIDs() const noexcept; - //- Return the list of patch IDs internally coupled with the - // primary region - inline const labelList& intCoupledPatchIDs() const; + //- True if patchi on the local region is a coupled + //- patch to the primary region + inline bool isCoupledPatch(const label regionPatchi) const; - //- Return region ID corresponding to primaryPatchID - inline label regionPatchID(const label primaryPatchID) const; + //- True if patchi on the primary region is a coupled + //- patch to the local region + inline bool isRegionPatch(const label primaryPatchi) const; + + //- Return region ID corresponding to primaryPatch ID + inline label regionPatchID(const label primaryPatchi) const; - // Helper + // Helper Functions //- Return the coupled patch ID paired with coupled patch // regionPatchi @@ -322,25 +320,25 @@ public: ) const; - // Evolution + // Evolution - //- Main driver routing to evolve the region - calls other evolves - virtual void evolve(); + //- Main driver routing to evolve the region - calls other evolves + virtual void evolve(); - //- Pre-evolve region - virtual void preEvolveRegion(); + //- Pre-evolve region + virtual void preEvolveRegion(); - //- Evolve the region - virtual void evolveRegion(); + //- Evolve the region + virtual void evolveRegion(); - //- Post-evolve region - virtual void postEvolveRegion(); + //- Post-evolve region + virtual void postEvolveRegion(); - // I-O + // I-O - //- Provide some feedback - virtual void info(); + //- Provide some feedback + virtual void info(); }; diff --git a/src/regionModels/regionModel/regionModel/regionModelI.H b/src/regionModels/regionModel/regionModel/regionModelI.H index fc101bdbe5..91590d87b6 100644 --- a/src/regionModels/regionModel/regionModel/regionModelI.H +++ b/src/regionModels/regionModel/regionModel/regionModelI.H @@ -30,37 +30,6 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inline const Foam::fvMesh& -Foam::regionModels::regionModel::primaryMesh() const -{ - return primaryMesh_; -} - - -inline const Foam::Time& Foam::regionModels::regionModel::time() const -{ - return time_; -} - - -inline Foam::Switch Foam::regionModels::regionModel::active() const -{ - return active_; -} - - -inline Foam::Switch Foam::regionModels::regionModel::infoOutput() const -{ - return infoOutput_; -} - - -inline const Foam::word& Foam::regionModels::regionModel::modelName() const -{ - return modelName_; -} - - inline const Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() const { const fvMesh* regionPtr = time_.getObjectPtr(regionName_); @@ -89,12 +58,6 @@ inline Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() } -inline const Foam::dictionary& Foam::regionModels::regionModel::coeffs() const -{ - return coeffs_; -} - - inline const Foam::dictionary& Foam::regionModels::regionModel::solution() const { @@ -130,20 +93,26 @@ Foam::regionModels::regionModel::outputProperties() } +inline const Foam::labelList& +Foam::regionModels::regionModel::primaryPatchIDs() const noexcept +{ + return primaryPatchIDs_; +} + + +inline const Foam::labelList& +Foam::regionModels::regionModel::intCoupledPatchIDs() const noexcept +{ + return intCoupledPatchIDs_; +} + + inline bool Foam::regionModels::regionModel::isCoupledPatch ( const label regionPatchi ) const { - forAll(intCoupledPatchIDs_, i) - { - if (intCoupledPatchIDs_[i] == regionPatchi) - { - return true; - } - } - - return false; + return intCoupledPatchIDs_.found(regionPatchi); } @@ -152,46 +121,18 @@ inline bool Foam::regionModels::regionModel::isRegionPatch const label primaryPatchi ) const { - forAll(primaryPatchIDs_, i) - { - if (primaryPatchIDs_[i] == primaryPatchi) - { - return true; - } - } - - return false; -} - - -inline const Foam::labelList& -Foam::regionModels::regionModel::primaryPatchIDs() const -{ - return primaryPatchIDs_; -} - - -inline const Foam::labelList& -Foam::regionModels::regionModel::intCoupledPatchIDs() const -{ - return intCoupledPatchIDs_; + return primaryPatchIDs_.found(primaryPatchi); } inline Foam::label Foam::regionModels::regionModel::regionPatchID ( - const label primaryPatchID + const label primaryPatchi ) const { - forAll(primaryPatchIDs_, i) - { - if (primaryPatchIDs_[i] == primaryPatchID) - { - return intCoupledPatchIDs_[i]; - } - } + const label i = primaryPatchIDs_.find(primaryPatchi); - return -1; + return (i >= 0 ? intCoupledPatchIDs_[i] : -1); } diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C index 507acfeac8..9d38d83a7a 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020-2021 OpenCFD Ltd + Copyright (C) 2020-2022 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,7 +49,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField turbulentTemperatureRadCoupledMixedFvPatchScalarField(p, iF), owner_(false), internal_(true), - baffle_(), + baffle_(nullptr), dict_(), extrudeMeshPtr_() {} @@ -72,7 +72,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField ), owner_(ptf.owner_), internal_(ptf.internal_), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_), extrudeMeshPtr_() {} @@ -88,15 +88,13 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField turbulentTemperatureRadCoupledMixedFvPatchScalarField(p, iF, dict), owner_(false), internal_(true), - baffle_(), + baffle_(nullptr), dict_(dict), extrudeMeshPtr_() { const fvMesh& thisMesh = patch().boundaryMesh().mesh(); - typedef regionModels::thermalBaffleModels::thermalBaffleModel baffle; - word regionName("none"); dict_.readIfPresent("region", regionName); @@ -115,7 +113,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField createPatchMesh(); } - baffle_.reset(baffle::New(thisMesh, dict).ptr()); + baffle_.reset(baffleType::New(thisMesh, dict)); owner_ = true; baffle_->rename(baffleName); } @@ -131,7 +129,7 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField turbulentTemperatureRadCoupledMixedFvPatchScalarField(ptf, iF), owner_(ptf.owner_), internal_(ptf.internal_), - baffle_(), + baffle_(nullptr), dict_(ptf.dict_), extrudeMeshPtr_() {} diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H index 15d7134717..26fdc2cf27 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd + Copyright (C) 2020-2022 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -229,7 +229,15 @@ class thermalBaffleFvPatchScalarField : public turbulentTemperatureRadCoupledMixedFvPatchScalarField { - // Private data + // Typedefs + + //- The baffle region model + typedef + regionModels::thermalBaffleModels::thermalBaffleModel + baffleType; + + + // Private Data //- Enumeration of patch IDs enum patchID @@ -246,7 +254,7 @@ class thermalBaffleFvPatchScalarField bool internal_; //- Thermal baffle - autoPtr baffle_; + autoPtr baffle_; //- Dictionary dictionary dict_; @@ -255,7 +263,7 @@ class thermalBaffleFvPatchScalarField autoPtr extrudeMeshPtr_; - // Private member functions + // Private Member Functions //- Extrude mesh void createPatchMesh(); @@ -323,7 +331,7 @@ public: } - // Member functions + // Member Functions //- Update the coefficients associated with the patch field virtual void updateCoeffs();