From 31a7c2a9cddf4e2febc2849eb4ce871032267e89 Mon Sep 17 00:00:00 2001 From: Mark Olesen 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 0eb8919d9b..a35fdf1759 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C @@ -75,7 +75,7 @@ Foam::TDACChemistryModel::TDACChemistryModel // Store the species composition according to the species index speciesTable speciesTab = composition.species(); - autoPtr>> specCompPtr + autoPtr specCompPtr ( dynamicCast>(this->thermo()) .specieComposition() diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H index 747e759cf0..17392834d3 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 { - // 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 65a93a982f..dae741f81e 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("chemistryProperties"); - autoPtr>> speciesCompPtr; + autoPtr speciesCompPtr; if (psiChemPtr) { diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H index 054beb3d05..ce51b7d220 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> 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& speciesThermo() const = 0; + virtual const ReactionTable& speciesThermo() const = 0; //- Return access to the list of reactions virtual const ReactionList& reactions() const = 0; @@ -143,7 +143,7 @@ public: #define makeChemistryReaderType(Reader, Thermo) \ defineNamedTemplateTypeNameAndDebug(Reader, 0); \ - chemistryReader::adddictionaryConstructorToTable> \ + chemistryReader::adddictionaryConstructorToTable> \ add##Reader##Thermo##ConstructorToTable_ diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C index 3605b16296..b9b6006abd 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 +#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 baf3760216..2b764b1bc1 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, public yyFlexLexer { - public: - // Public data types + // Public Data Types enum phase { @@ -176,7 +174,7 @@ private: HashTable speciePhase_; //- Table of the thermodynamic data given in the CHEMKIN file - HashPtrTable speciesThermo_; + ReactionTable speciesThermo_; //- Table of species composition speciesCompositionTable speciesComposition_; @@ -357,7 +355,7 @@ public: } //- Table of the thermodynamic data given in the CHEMKIN file - const HashPtrTable& speciesThermo() const + const ReactionTable& speciesThermo() const { return speciesThermo_; } diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H index 2e4589e2ea..c9017806a8 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 speciesThermo_; + ReactionTable speciesThermo_; //- List of the reactions ReactionList 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& speciesThermo() const + const ReactionTable& speciesThermo() const { return speciesThermo_; } diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H index 522c4be19e..d6b623d590 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 specieComposition() const { - return - autoPtr - ( - new speciesCompositionTable() - ); + return autoPtr::New(); } }; diff --git a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C index 0414b0077e..d8fdf377d4 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.C @@ -89,7 +89,7 @@ Foam::multiComponentMixture::multiComponentMixture ( const dictionary& thermoDict, const wordList& specieNames, - const HashPtrTable& thermoData, + const ReactionTable& 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 60dbf62783..30cd0957a7 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 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& thermoData, + const ReactionTable& thermoData, const fvMesh& mesh, const word& phaseName ); diff --git a/src/thermophysicalModels/reactionThermo/rhoReactionThermo/rhoReactionThermo.H b/src/thermophysicalModels/reactionThermo/rhoReactionThermo/rhoReactionThermo.H index 72ce0177b6..788d9e9326 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 26d264d706..16efbc6578 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 @@ -66,7 +65,7 @@ template Foam::solidReaction::solidReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 a89e1106a6..089b092c04 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 solidReaction; @@ -62,12 +62,11 @@ inline Ostream& operator<<(Ostream&, const solidReaction&); template class solidReaction : - public Reaction + public Reaction { - private: - // Private data + // Private Data typedef typename Reaction::specieCoeffs specieCoeffs; @@ -127,7 +126,7 @@ public: solidReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 3093f0fa2e..766b6bbf08 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:: IrreversibleReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 57b4c8911d..c0e3215cfc 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 { - // Private data + // Private Data ReactionRate k_; @@ -113,7 +113,7 @@ public: IrreversibleReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 10a624c4aa..703081ff5a 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& thermoDatabase, + const ReactionTable& 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 d263fbae18..00c038fd13 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 { - // Private data + // Private Data ReactionRate fk_; ReactionRate rk_; @@ -109,7 +109,7 @@ public: NonEquilibriumReversibleReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 ee9908f7fb..a1bc3468bf 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 Foam::label Foam::Reaction::nUnNamedReactions = 0; + // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template @@ -111,7 +112,7 @@ Foam::string Foam::Reaction::reactionStr template void Foam::Reaction::setThermo ( - const HashPtrTable& thermoDatabase + const ReactionTable& thermoDatabase ) { @@ -158,7 +159,7 @@ Foam::Reaction::Reaction const speciesTable& species, const List& lhs, const List& rhs, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, bool initReactionThermo ) : @@ -321,7 +322,7 @@ template Foam::Reaction::Reaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, const dictionary& dict, bool initReactionThermo ) @@ -352,7 +353,7 @@ Foam::autoPtr> Foam::Reaction::New ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, const dictionary& dict ) { @@ -425,13 +426,6 @@ Foam::scalar Foam::Reaction::kr } -template -const Foam::speciesTable& Foam::Reaction::species() const -{ - return species_; -} - - template const Foam::speciesTable& Foam::Reaction::gasSpecies() const { diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.H index 8fbed62df8..a40e63f00e 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 +using ReactionTable = HashPtrTable; template 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& thermoDatabase); + void setThermo(const ReactionTable& thermoDatabase); + + //- Return new reaction ID for un-named reactions + label getNewReactionID(); //- No copy assignment void operator=(const Reaction&) = 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& thermoDatabase, + const ReactionTable& thermoDatabase, const dictionary& dict ), (species, thermoDatabase, dict) @@ -189,7 +192,7 @@ public: const speciesTable& species, const List& lhs, const List& rhs, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, bool initReactionThermo = true ); @@ -207,13 +210,13 @@ public: Reaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, const dictionary& dict, bool initReactionThermo = true ); //- Construct and return a clone - virtual autoPtr> clone() const // + virtual autoPtr> clone() const { return autoPtr>::New(*this); } @@ -234,7 +237,7 @@ public: static autoPtr> New ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, const dictionary& dict ); @@ -245,23 +248,29 @@ public: // Member Functions - // Access + // Access - inline const word& name() const; + //- Name of reaction + const word& name() const noexcept { return name_; } - // - Access to basic components of the reaction - inline const List& lhs() const; - inline const List& rhs() const; + //- Access to specie list + const speciesTable& species() const noexcept { return species_; } - // - Access to gas components of the reaction - virtual const List& grhs() const; - virtual const List& glhs() const; + //- Specie info for the left-hand-side of the reaction + const List& lhs() const noexcept { return lhs_; } - //- Access to specie list - const speciesTable& species() const; + //- Specie info for the right-hand-side of the reaction + const List& rhs() const noexcept { return rhs_; } - //- Access to gas specie list - virtual const speciesTable& gasSpecies() const; + //- Access to gas specie list + virtual const speciesTable& gasSpecies() const; + + //- Access to gas components of the reaction + virtual const List& grhs() const; + virtual const List& glhs() 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 b8a05f1762..816c37932e 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 -inline const word& Reaction::name() const -{ - return name_; -} - - -template -inline const List::specieCoeffs>& -Reaction::lhs() const -{ - return lhs_; -} - - -template -inline const List::specieCoeffs>& -Reaction::rhs() const -{ - return rhs_; -} - - -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // - -template -inline Ostream& operator<<(Ostream& os, const Reaction& r) +inline Foam::Ostream& +Foam::operator<<(Ostream& os, const Reaction& 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 45f0fe8ac9..322e0b406f 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 Foam::ReactionList::ReactionList ( const speciesTable& species, - const HashPtrTable& thermoDb + const ReactionTable& thermoDb ) : SLPtrList>(), @@ -50,7 +48,7 @@ template Foam::ReactionList::ReactionList ( const speciesTable& species, - const HashPtrTable& thermoDb, + const ReactionTable& 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 750a89565f..7a1dedf66a 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> { - // Private data + // Private Data //- Reference to the table of species const speciesTable& species_; //- Reference to the thermo database - const HashPtrTable& thermoDb_; + const ReactionTable& 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& thermoDatabase + const ReactionTable& thermoDatabase ); //- Construct from dictionary ReactionList ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 849cc4df67..d26b98d2c8 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:: ReversibleReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& 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 7ba5a75f34..00fef10265 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 { - // Private data + // Private Data ReactionRate k_; @@ -113,7 +113,7 @@ public: ReversibleReaction ( const speciesTable& species, - const HashPtrTable& thermoDatabase, + const ReactionTable& thermoDatabase, const dictionary& dict );