From 31a7c2a9cddf4e2febc2849eb4ce871032267e89 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 3 Dec 2021 12:59:34 +0100 Subject: [PATCH] ENH: initial use of ReactionTable to wrap information --- .../TDACChemistryModel/TDACChemistryModel.C | 2 +- .../TDACChemistryModel/TDACChemistryModel.H | 2 +- .../BilgerMixtureFraction.C | 2 +- .../chemistryReader/chemistryReader.H | 8 +- .../chemkinReader/chemkinReader.C | 2 +- .../chemkinReader/chemkinReader.H | 10 +-- .../foamChemistryReader/foamChemistryReader.H | 13 ++- .../basicSpecieMixture/basicSpecieMixture.H | 10 +-- .../multiComponentMixture.C | 2 +- .../multiComponentMixture.H | 9 +- .../rhoReactionThermo/rhoReactionThermo.H | 1 - .../Reactions/solidReaction/solidReaction.C | 5 +- .../Reactions/solidReaction/solidReaction.H | 13 ++- .../IrreversibleReaction.C | 3 +- .../IrreversibleReaction.H | 6 +- .../NonEquilibriumReversibleReaction.C | 3 +- .../NonEquilibriumReversibleReaction.H | 8 +- .../reaction/Reactions/Reaction/Reaction.C | 18 ++-- .../reaction/Reactions/Reaction/Reaction.H | 87 ++++++++++--------- .../reaction/Reactions/Reaction/ReactionI.H | 37 +------- .../Reactions/ReactionList/ReactionList.C | 6 +- .../Reactions/ReactionList/ReactionList.H | 15 ++-- .../ReversibleReaction/ReversibleReaction.C | 3 +- .../ReversibleReaction/ReversibleReaction.H | 6 +- 24 files changed, 116 insertions(+), 155 deletions(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C index 0eb8919d9bc..a35fdf17598 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C @@ -75,7 +75,7 @@ Foam::TDACChemistryModel<ReactionThermo, ThermoType>::TDACChemistryModel // Store the species composition according to the species index speciesTable speciesTab = composition.species(); - autoPtr<HashTable<List<specieElement>>> specCompPtr + autoPtr<speciesCompositionTable> specCompPtr ( dynamicCast<const reactingMixture<ThermoType>>(this->thermo()) .specieComposition() diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H index 747e759cf07..17392834d32 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H @@ -85,7 +85,7 @@ class TDACChemistryModel : public StandardChemistryModel<ReactionThermo, ThermoType> { - // Private member data + // Private Member Data bool variableTimeStep_; diff --git a/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C b/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C index 65a93a982f2..dae741f81ea 100644 --- a/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C +++ b/src/thermophysicalModels/chemistryModel/functionObjects/BilgerMixtureFraction/BilgerMixtureFraction.C @@ -285,7 +285,7 @@ bool Foam::functionObjects::BilgerMixtureFraction::read(const dictionary& dict) const auto* rhoChemPtr = mesh_.cfindObject<rhoChemistryModelType>("chemistryProperties"); - autoPtr<HashTable<List<specieElement>>> speciesCompPtr; + autoPtr<speciesCompositionTable> speciesCompPtr; if (psiChemPtr) { diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H index 054beb3d052..ce51b7d2209 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,7 +54,6 @@ namespace Foam typedef HashTable<List<specieElement>> speciesCompositionTable; - /*---------------------------------------------------------------------------*\ Class chemistryReader Declaration \*---------------------------------------------------------------------------*/ @@ -72,7 +72,7 @@ public: // Constructors - //- Construct null + //- Default construct chemistryReader() {} @@ -115,7 +115,7 @@ public: virtual const speciesCompositionTable& specieComposition() const = 0; //- Return access to the thermo packages - virtual const HashPtrTable<ThermoType>& speciesThermo() const = 0; + virtual const ReactionTable<ThermoType>& speciesThermo() const = 0; //- Return access to the list of reactions virtual const ReactionList<ThermoType>& reactions() const = 0; @@ -143,7 +143,7 @@ public: #define makeChemistryReaderType(Reader, Thermo) \ defineNamedTemplateTypeNameAndDebug(Reader<Thermo>, 0); \ - chemistryReader<Thermo>::adddictionaryConstructorToTable<Reader<Thermo>> \ + chemistryReader<Thermo>::adddictionaryConstructorToTable<Reader<Thermo>> \ add##Reader##Thermo##ConstructorToTable_ diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C index 3605b16296e..b9b6006abde 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C @@ -27,7 +27,7 @@ License \*---------------------------------------------------------------------------*/ #include "chemkinReader.H" -#include <fstream> +#include "IFstream.H" #include "atomicWeights.H" #include "IrreversibleReaction.H" #include "ReversibleReaction.H" diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H index baf37602165..2b764b1bc1d 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,8 +45,6 @@ SourceFiles #include "chemistryReader.H" #include "fileName.H" #include "typeInfo.H" -#include "HashPtrTable.H" -#include "ReactionList.H" #include "DynamicList.H" #include "labelList.H" #include "speciesTable.H" @@ -68,10 +67,9 @@ class chemkinReader public chemistryReader<gasHThermoPhysics>, public yyFlexLexer { - public: - // Public data types + // Public Data Types enum phase { @@ -176,7 +174,7 @@ private: HashTable<phase> speciePhase_; //- Table of the thermodynamic data given in the CHEMKIN file - HashPtrTable<gasHThermoPhysics> speciesThermo_; + ReactionTable<gasHThermoPhysics> speciesThermo_; //- Table of species composition speciesCompositionTable speciesComposition_; @@ -357,7 +355,7 @@ public: } //- Table of the thermodynamic data given in the CHEMKIN file - const HashPtrTable<gasHThermoPhysics>& speciesThermo() const + const ReactionTable<gasHThermoPhysics>& speciesThermo() const { return speciesThermo_; } diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H index 2e4589e2ea1..c9017806a87 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,8 +43,6 @@ SourceFiles #include "chemistryReader.H" #include "fileName.H" -#include "typeInfo.H" -#include "HashPtrTable.H" #include "labelList.H" #include "speciesTable.H" #include "atomicWeights.H" @@ -81,7 +80,7 @@ class foamChemistryReader speciesCompositionTable speciesComposition_; //- Table of the thermodynamic data given in the foamChemistry file - HashPtrTable<ThermoType> speciesThermo_; + ReactionTable<ThermoType> speciesThermo_; //- List of the reactions ReactionList<ThermoType> reactions_; @@ -118,8 +117,8 @@ public: const fileName& thermoFileName ); - //- Construct by getting the foamChemistry and thermodynamics file names - // from dictionary + //- Construct by getting foamChemistry and thermodynamics file names + //- from dictionary foamChemistryReader ( const dictionary& thermoDict, @@ -131,7 +130,7 @@ public: virtual ~foamChemistryReader() = default; - // Member functions + // Member Functions //- List of elements const wordList& elementNames() const @@ -158,7 +157,7 @@ public: } //- Table of the thermodynamic data given in the foamChemistry file - const HashPtrTable<ThermoType>& speciesThermo() const + const ReactionTable<ThermoType>& speciesThermo() const { return speciesThermo_; } diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H index 522c4be19e9..d6b623d590b 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,7 +86,7 @@ public: virtual ~basicSpecieMixture() = default; - // Member functions + // Member Functions // Per specie properties @@ -210,11 +210,7 @@ public: //- Species composition virtual autoPtr<speciesCompositionTable> specieComposition() const { - return - autoPtr<speciesCompositionTable> - ( - new speciesCompositionTable() - ); + return autoPtr<speciesCompositionTable>::New(); } }; diff --git a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C index 0414b0077e3..d8fdf377d42 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C @@ -89,7 +89,7 @@ Foam::multiComponentMixture<ThermoType>::multiComponentMixture ( const dictionary& thermoDict, const wordList& specieNames, - const HashPtrTable<ThermoType>& thermoData, + const ReactionTable<ThermoType>& thermoData, const fvMesh& mesh, const word& phaseName ) diff --git a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H index 60dbf62783e..30cd0957a7d 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +42,7 @@ SourceFiles #define multiComponentMixture_H #include "basicSpecieMixture.H" -#include "HashPtrTable.H" +#include "Reaction.H" // For ReactionTable // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +58,7 @@ class multiComponentMixture : public basicSpecieMixture { - // Private data + // Private Data //- Species data PtrList<ThermoType> speciesData_; @@ -92,12 +93,12 @@ public: // Constructors //- Construct from dictionary, specie names, thermo database, - // mesh and phase name + //- mesh and phase name multiComponentMixture ( const dictionary&, const wordList& specieNames, - const HashPtrTable<ThermoType>& thermoData, + const ReactionTable<ThermoType>& thermoData, const fvMesh& mesh, const word& phaseName ); diff --git a/src/thermophysicalModels/reactionThermo/rhoReactionThermo/rhoReactionThermo.H b/src/thermophysicalModels/reactionThermo/rhoReactionThermo/rhoReactionThermo.H index 72ce0177b6a..788d9e9326c 100644 --- a/src/thermophysicalModels/reactionThermo/rhoReactionThermo/rhoReactionThermo.H +++ b/src/thermophysicalModels/reactionThermo/rhoReactionThermo/rhoReactionThermo.H @@ -62,7 +62,6 @@ class rhoReactionThermo : public rhoThermo { - public: //- Runtime type information diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C index 26d264d706a..16efbc6578f 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C +++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,6 @@ License #include "solidReaction.H" #include "DynamicList.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class ReactionThermo> @@ -66,7 +65,7 @@ template<class ReactionThermo> Foam::solidReaction<ReactionThermo>::solidReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ) : diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.H b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.H index a89e1106a69..089b092c04b 100644 --- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.H +++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +48,7 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward Declarations template<class ReactionThermo> class solidReaction; @@ -62,12 +62,11 @@ inline Ostream& operator<<(Ostream&, const solidReaction<ReactionThermo>&); template<class ReactionThermo> class solidReaction : - public Reaction<ReactionThermo> + public Reaction<ReactionThermo> { - private: - // Private data + // Private Data typedef typename Reaction<ReactionThermo>::specieCoeffs specieCoeffs; @@ -127,7 +126,7 @@ public: solidReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ); @@ -171,7 +170,7 @@ public: //- Write - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; // Ostream Operator diff --git a/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.C b/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.C index 3093f0fa2ed..766b6bbf089 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,7 +58,7 @@ Foam::IrreversibleReaction<ReactionType, ReactionThermo, ReactionRate>:: IrreversibleReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ) : diff --git a/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.H b/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.H index 57b4c8911df..c0e3215cfc9 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/IrreversibleReaction/IrreversibleReaction.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,7 +63,7 @@ class IrreversibleReaction : public ReactionType<ReactionThermo> { - // Private data + // Private Data ReactionRate k_; @@ -113,7 +113,7 @@ public: IrreversibleReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ); diff --git a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C index 10a624c4aa3..703081ff5a6 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +70,7 @@ Foam::NonEquilibriumReversibleReaction NonEquilibriumReversibleReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ) : diff --git a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.H b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.H index d263fbae189..00c038fd13b 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,7 +63,7 @@ class NonEquilibriumReversibleReaction : public ReactionType<ReactionThermo> { - // Private data + // Private Data ReactionRate fk_; ReactionRate rk_; @@ -109,7 +109,7 @@ public: NonEquilibriumReversibleReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ); @@ -175,7 +175,7 @@ public: //- Write - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; }; diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C index ee9908f7fb5..a1bc3468bf7 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,6 +34,7 @@ License template<class ReactionThermo> Foam::label Foam::Reaction<ReactionThermo>::nUnNamedReactions = 0; + // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template<class ReactionThermo> @@ -111,7 +112,7 @@ Foam::string Foam::Reaction<ReactionThermo>::reactionStr template<class ReactionThermo> void Foam::Reaction<ReactionThermo>::setThermo ( - const HashPtrTable<ReactionThermo>& thermoDatabase + const ReactionTable<ReactionThermo>& thermoDatabase ) { @@ -158,7 +159,7 @@ Foam::Reaction<ReactionThermo>::Reaction const speciesTable& species, const List<specieCoeffs>& lhs, const List<specieCoeffs>& rhs, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, bool initReactionThermo ) : @@ -321,7 +322,7 @@ template<class ReactionThermo> Foam::Reaction<ReactionThermo>::Reaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict, bool initReactionThermo ) @@ -352,7 +353,7 @@ Foam::autoPtr<Foam::Reaction<ReactionThermo>> Foam::Reaction<ReactionThermo>::New ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ) { @@ -425,13 +426,6 @@ Foam::scalar Foam::Reaction<ReactionThermo>::kr } -template<class ReactionThermo> -const Foam::speciesTable& Foam::Reaction<ReactionThermo>::species() const -{ - return species_; -} - - template<class ReactionThermo> const Foam::speciesTable& Foam::Reaction<ReactionThermo>::gasSpecies() const { diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H index 8fbed62df88..a40e63f00e5 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,7 +51,10 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward Declarations + +template<class ThermoType> +using ReactionTable = HashPtrTable<ThermoType>; template<class ReactionThermo> class Reaction; @@ -69,29 +72,18 @@ class Reaction : public ReactionThermo::thermoType { -protected: - - // Protected member functions - - //- Return string representation of the left of the reaction - void reactionStrLeft(OStringStream& reaction) const; - - //- Return string representation of the right of the reaction - void reactionStrRight(OStringStream& reaction) const; - - public: - // Static data + // Static Data //- Number of un-named reactions static label nUnNamedReactions; - // Public data types + // Public Classes - //- Class to hold the specie index and its coefficients in the - // reaction rate expression + //- Hold specie index and its coefficients in the + //- reaction rate expression struct specieCoeffs { label index; @@ -129,7 +121,7 @@ public: private: - // Private data + // Private Data //- Name of reaction const word name_; @@ -150,13 +142,24 @@ private: string reactionStr(OStringStream& reaction) const; //- Construct reaction thermo - void setThermo(const HashPtrTable<ReactionThermo>& thermoDatabase); + void setThermo(const ReactionTable<ReactionThermo>& thermoDatabase); + + //- Return new reaction ID for un-named reactions + label getNewReactionID(); //- No copy assignment void operator=(const Reaction<ReactionThermo>&) = delete; - //- Return new reaction ID for un-named reactions - label getNewReactionID(); + +protected: + + // Protected Member Functions + + //- Return string representation of the left of the reaction + void reactionStrLeft(OStringStream& reaction) const; + + //- Return string representation of the right of the reaction + void reactionStrRight(OStringStream& reaction) const; public: @@ -174,7 +177,7 @@ public: dictionary, ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ), (species, thermoDatabase, dict) @@ -189,7 +192,7 @@ public: const speciesTable& species, const List<specieCoeffs>& lhs, const List<specieCoeffs>& rhs, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, bool initReactionThermo = true ); @@ -207,13 +210,13 @@ public: Reaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict, bool initReactionThermo = true ); //- Construct and return a clone - virtual autoPtr<Reaction<ReactionThermo>> clone() const // + virtual autoPtr<Reaction<ReactionThermo>> clone() const { return autoPtr<Reaction<ReactionThermo>>::New(*this); } @@ -234,7 +237,7 @@ public: static autoPtr<Reaction<ReactionThermo>> New ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ); @@ -245,23 +248,29 @@ public: // Member Functions - // Access + // Access + + //- Name of reaction + const word& name() const noexcept { return name_; } + + //- Access to specie list + const speciesTable& species() const noexcept { return species_; } - inline const word& name() const; + //- Specie info for the left-hand-side of the reaction + const List<specieCoeffs>& lhs() const noexcept { return lhs_; } + + //- Specie info for the right-hand-side of the reaction + const List<specieCoeffs>& rhs() const noexcept { return rhs_; } - // - Access to basic components of the reaction - inline const List<specieCoeffs>& lhs() const; - inline const List<specieCoeffs>& rhs() const; + //- Access to gas specie list + virtual const speciesTable& gasSpecies() const; - // - Access to gas components of the reaction - virtual const List<specieCoeffs>& grhs() const; - virtual const List<specieCoeffs>& glhs() const; + //- Access to gas components of the reaction + virtual const List<specieCoeffs>& grhs() const; + virtual const List<specieCoeffs>& glhs() const; - //- Access to specie list - const speciesTable& species() const; - //- Access to gas specie list - virtual const speciesTable& gasSpecies() const; + // Manipulation //- Construct the left- and right-hand-side reaction coefficients void setLRhs @@ -304,7 +313,7 @@ public: //- Write - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; // Ostream Operator diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/ReactionI.H b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/ReactionI.H index b8a05f17625..816c37932e4 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/ReactionI.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/ReactionI.H @@ -27,48 +27,15 @@ License #include "Reaction.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class ReactionThermo> -inline const word& Reaction<ReactionThermo>::name() const -{ - return name_; -} - - -template<class ReactionThermo> -inline const List<typename Reaction<ReactionThermo>::specieCoeffs>& -Reaction<ReactionThermo>::lhs() const -{ - return lhs_; -} - - -template<class ReactionThermo> -inline const List<typename Reaction<ReactionThermo>::specieCoeffs>& -Reaction<ReactionThermo>::rhs() const -{ - return rhs_; -} - - -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // - -template<class ReactionThermo> -inline Ostream& operator<<(Ostream& os, const Reaction<ReactionThermo>& r) +inline Foam::Ostream& +Foam::operator<<(Ostream& os, const Reaction<ReactionThermo>& r) { r.write(os); return os; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C index 45f0fe8ac9d..322e0b406ff 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C @@ -27,8 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "ReactionList.H" -#include "IFstream.H" -#include "SLPtrList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -36,7 +34,7 @@ template<class ThermoType> Foam::ReactionList<ThermoType>::ReactionList ( const speciesTable& species, - const HashPtrTable<ThermoType>& thermoDb + const ReactionTable<ThermoType>& thermoDb ) : SLPtrList<Reaction<ThermoType>>(), @@ -50,7 +48,7 @@ template<class ThermoType> Foam::ReactionList<ThermoType>::ReactionList ( const speciesTable& species, - const HashPtrTable<ThermoType>& thermoDb, + const ReactionTable<ThermoType>& thermoDb, const dictionary& dict ) : diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.H b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.H index 750a89565f4..7a1dedf66a0 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,9 +41,8 @@ SourceFiles #include "PtrList.H" #include "SLPtrList.H" #include "speciesTable.H" -#include "HashPtrTable.H" -#include "Reaction.H" #include "fileName.H" +#include "Reaction.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,13 +58,13 @@ class ReactionList : public SLPtrList<Reaction<ThermoType>> { - // Private data + // Private Data //- Reference to the table of species const speciesTable& species_; //- Reference to the thermo database - const HashPtrTable<ThermoType>& thermoDb_; + const ReactionTable<ThermoType>& thermoDb_; //- The dictionary used for construction const dictionary dict_; @@ -81,18 +80,18 @@ public: // Constructors - //- Default construct + //- Construct empty list ReactionList ( const speciesTable& species, - const HashPtrTable<ThermoType>& thermoDatabase + const ReactionTable<ThermoType>& thermoDatabase ); //- Construct from dictionary ReactionList ( const speciesTable& species, - const HashPtrTable<ThermoType>& thermoDatabase, + const ReactionTable<ThermoType>& thermoDatabase, const dictionary& dict ); diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.C b/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.C index 849cc4df671..d26b98d2c89 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.C +++ b/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,7 +58,7 @@ Foam::ReversibleReaction<ReactionType, ReactionThermo, ReactionRate>:: ReversibleReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ) : diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.H b/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.H index 7ba5a75f342..00fef102654 100644 --- a/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.H +++ b/src/thermophysicalModels/specie/reaction/Reactions/ReversibleReaction/ReversibleReaction.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,7 +63,7 @@ class ReversibleReaction : public ReactionType<ReactionThermo> { - // Private data + // Private Data ReactionRate k_; @@ -113,7 +113,7 @@ public: ReversibleReaction ( const speciesTable& species, - const HashPtrTable<ReactionThermo>& thermoDatabase, + const ReactionTable<ReactionThermo>& thermoDatabase, const dictionary& dict ); -- GitLab