diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.C index 69032a116947e1910aad891ba53f829b03957a49..bc1af21c14cad43497c8793456fe82b4fd115674 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.C +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.C @@ -35,12 +35,11 @@ Foam::chemistryReader<ThermoType>::New speciesTable& species ) { - // Let the chemistry reader type default to CHEMKIN - // for backward compatibility - word readerName("chemkinReader"); - - // otherwise use the specified reader - thermoDict.readIfPresent("chemistryReader", readerName); + // Use specified reader or default to CHEMKIN for backward compatibility + const word readerName + ( + thermoDict.lookupOrDefault<word>("chemistryReader", "chemkinReader") + ); Info<< "Selecting chemistryReader " << readerName << endl; diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H index c9a2e1fc6a4d004e660d256524c986a37fc3613b..859256fca861856771aceaeb5e124826c918fd3f 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemistryReader/chemistryReader.H @@ -59,15 +59,6 @@ typedef HashTable<List<specieElement>> speciesCompositionTable; template<class ThermoType> class chemistryReader { - // Private Member Functions - - //- No copy construct - chemistryReader(const chemistryReader&) = delete; - - //- No copy assignment - void operator=(const chemistryReader&) = delete; - - public: //- Runtime type information @@ -110,8 +101,7 @@ public: //- Destructor - virtual ~chemistryReader() - {} + virtual ~chemistryReader() = default; // Member Functions diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.C index 8d4df10956963fc20f7b07024f83e6eb4fbace25..a2f618052ab18d68e442605a3597e35adfa9c5e4 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.C +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.C @@ -36,7 +36,7 @@ Foam::speciesTable& Foam::foamChemistryReader<ThermoType>::setSpecies speciesTable& species ) { - wordList s(dict.lookup("species")); + wordList s(dict.get<wordList>("species")); species.transfer(s); return species; } @@ -51,23 +51,23 @@ void Foam::foamChemistryReader<ThermoType>::readSpeciesComposition() return; } - wordList e(chemDict_.lookup("elements")); + wordList e(chemDict_.get<wordList>("elements")); label currentElementIndex(0); DynamicList<word> elementNames_; HashTable<label> elementIndices_; - forAll(e, ei) + for (const word& elemName : e) { - if (!elementIndices_.found(e[ei])) + if (!elementIndices_.found(elemName)) { - elementIndices_.insert(e[ei], currentElementIndex++); - elementNames_.append(e[ei]); + elementIndices_.insert(elemName, currentElementIndex++); + elementNames_.append(elemName); } else { IOWarningInFunction(chemDict_) - << "element " << e[ei] << " already in table." << endl; + << "element " << elemName << " already in table." << endl; } } diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H index 4caa30ee3e70f1ccce959b38eb664c5bd46ac7db..74dbe24f9686cfa5bcb9c729592513ff908721f1 100644 --- a/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H +++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/foamChemistryReader/foamChemistryReader.H @@ -126,8 +126,7 @@ public: //- Destructor - virtual ~foamChemistryReader() - {} + virtual ~foamChemistryReader() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/SpecieMixture/SpecieMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/SpecieMixture/SpecieMixture.H index f4a20ca9e651a1e367cc1ba4fa19487a13fb38f6..a8a7627e3b52c1e4789a7d72523326904cc48b49 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/SpecieMixture/SpecieMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/SpecieMixture/SpecieMixture.H @@ -66,12 +66,16 @@ public: // Constructors //- Construct from dictionary, mesh and phase name - SpecieMixture(const dictionary&, const fvMesh&, const word& phaseName); + SpecieMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor - virtual ~SpecieMixture() - {} + virtual ~SpecieMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicCombustionMixture/basicCombustionMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/basicCombustionMixture/basicCombustionMixture.H index f192ef1c53cebd16ef02f70c13f9e13d8c0fb623..a1c3b8d45bdc9df99abff069c1933cf7a8568bf9 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicCombustionMixture/basicCombustionMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicCombustionMixture/basicCombustionMixture.H @@ -69,16 +69,15 @@ public: //- Construct from dictionary, specie names, mesh and phase name basicCombustionMixture ( - const dictionary&, + const dictionary& thermoDict, const wordList& specieNames, - const fvMesh&, - const word& + const fvMesh& mesh, + const word& phaseName ); //- Destructor - virtual ~basicCombustionMixture() - {} + virtual ~basicCombustionMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H index ad2babab73a1fc6a56f9810368dd4a5b9677de88..1ad9cd123d3162b80588bb4399c712498e49725b 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.H @@ -90,16 +90,15 @@ public: //- Construct from dictionary, species names, mesh and phase name basicMultiComponentMixture ( - const dictionary&, + const dictionary& thermoDict, const wordList& specieNames, - const fvMesh&, - const word& + const fvMesh& mesh, + const word& phaseName ); //- Destructor - virtual ~basicMultiComponentMixture() - {} + virtual ~basicMultiComponentMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H index f1d1856d001068b8a0b9788dd72f630b9ed48d02..624266aeda1973eeb4c028dcc233987e3281547c 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicSpecieMixture/basicSpecieMixture.H @@ -69,16 +69,15 @@ public: //- Construct from dictionary, species names, mesh and phase name basicSpecieMixture ( - const dictionary&, + const dictionary& thermoDict, const wordList& specieNames, - const fvMesh&, - const word& + const fvMesh& mesh, + const word& phaseName ); //- Destructor - virtual ~basicSpecieMixture() - {} + virtual ~basicSpecieMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H index d3f64ce274893a6aedc1122be2107ae54486d209..ae3c0947d58d8b180c68685b0d52d1b3ace6c2f8 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H @@ -76,8 +76,8 @@ class egrMixture //- Residual gases volScalarField& egr_; - //- Construct as copy (not implemented) - egrMixture(const egrMixture<ThermoType>&); + //- No copy construct + egrMixture(const egrMixture<ThermoType>&) = delete; public: @@ -89,7 +89,12 @@ public: // Constructors //- Construct from dictionary, mesh and phaseName - egrMixture(const dictionary&, const fvMesh&, const word&); + egrMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor diff --git a/src/thermophysicalModels/reactionThermo/mixtures/homogeneousMixture/homogeneousMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/homogeneousMixture/homogeneousMixture.H index 4e4e2e50e19b46c689d502df0bdbf2e172f485f3..3c600668e8d561b4a5740320b71e823afd9dbc6e 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/homogeneousMixture/homogeneousMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/homogeneousMixture/homogeneousMixture.H @@ -64,12 +64,12 @@ class homogeneousMixture mutable ThermoType mixture_; - //- Construct as copy (not implemented) - homogeneousMixture(const homogeneousMixture<ThermoType>&); - //- Regress variable volScalarField& b_; + //- No copy construct + homogeneousMixture(const homogeneousMixture<ThermoType>&) = delete; + public: @@ -80,12 +80,16 @@ public: // Constructors //- Construct from dictionary, mesh and phase name - homogeneousMixture(const dictionary&, const fvMesh&, const word&); + homogeneousMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor - virtual ~homogeneousMixture() - {} + virtual ~homogeneousMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H index 28078850599902cf1fc9c6b993cfd2e8d8e8f64a..efebb9fa51209b258db7955416ea3a1bd864f57c 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H @@ -73,8 +73,11 @@ class inhomogeneousMixture //- Regress variable volScalarField& b_; - //- Construct as copy (not implemented) - inhomogeneousMixture(const inhomogeneousMixture<ThermoType>&); + //- No copy construct + inhomogeneousMixture + ( + const inhomogeneousMixture<ThermoType>& + ) = delete; public: @@ -86,7 +89,12 @@ public: // Constructors //- Construct from dictionary, mesh and phase name - inhomogeneousMixture(const dictionary&, const fvMesh&, const word&); + inhomogeneousMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor diff --git a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H index 071eb76ffcd17a21a0c44b595b8ebe4230f32741..b467cabbafd5c6215036337294f110cfaa155da8 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/multiComponentMixture/multiComponentMixture.H @@ -96,17 +96,21 @@ public: const dictionary&, const wordList& specieNames, const HashPtrTable<ThermoType>& thermoData, - const fvMesh&, - const word& + const fvMesh& mesh, + const word& phaseName ); //- Construct from dictionary, mesh and phase name - multiComponentMixture(const dictionary&, const fvMesh&, const word&); + multiComponentMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor - virtual ~multiComponentMixture() - {} + virtual ~multiComponentMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C index 124d9a76cc8b4e42e850ee266aba85bfa0d5ff54..0652e4a213bde3049f8ed1b77a4e8465a5b41dbb 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C @@ -26,6 +26,16 @@ License #include "reactingMixture.H" #include "fvMesh.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class ThermoType> +Foam::autoPtr<Foam::chemistryReader<ThermoType>>& +Foam::reactingMixture<ThermoType>::reader() +{ + return static_cast<autoPtr<chemistryReader<ThermoType>>&>(*this); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class ThermoType> @@ -45,20 +55,21 @@ Foam::reactingMixture<ThermoType>::reactingMixture ( thermoDict, *this, - autoPtr<chemistryReader<ThermoType>>::operator()().speciesThermo(), + this->reader()->speciesThermo(), mesh, phaseName ), PtrList<Reaction<ThermoType>> ( - autoPtr<chemistryReader<ThermoType>>::operator()().reactions() + this->reader()->reactions() ), speciesComposition_ ( - autoPtr<chemistryReader<ThermoType>>::operator()().specieComposition() + this->reader()->specieComposition() ) { - autoPtr<chemistryReader<ThermoType>>::clear(); + // Done with reader + reader().clear(); } diff --git a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.H index 774d2b11790ba1bd0944b81f4ae76ab08b52b70a..dc0abf3a9356c223d1e73c204624ae90238f6972 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.H @@ -55,11 +55,11 @@ template<class ThermoType> class reactingMixture : public speciesTable, - public autoPtr<chemistryReader<ThermoType>>, + private autoPtr<chemistryReader<ThermoType>>, public multiComponentMixture<ThermoType>, public PtrList<Reaction<ThermoType>> { - // Private member data + // Private Member Data //- Table of species composition speciesCompositionTable speciesComposition_; @@ -67,6 +67,9 @@ class reactingMixture // Private Member Functions + //- The chemistry reader + autoPtr<chemistryReader<ThermoType>>& reader(); + //- No copy construct reactingMixture(const reactingMixture&) = delete; @@ -83,12 +86,16 @@ public: // Constructors //- Construct from dictionary, mesh and phase name - reactingMixture(const dictionary&, const fvMesh&, const word&); + reactingMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor - virtual ~reactingMixture() - {} + virtual ~reactingMixture() = default; // Member functions @@ -102,20 +109,8 @@ public: //- Read dictionary void read(const dictionary&); - label size() const - { - return PtrList<Reaction<ThermoType>>::size(); - } - - Reaction<ThermoType>& operator[](const label i) - { - return PtrList<Reaction<ThermoType>>::operator[](i); - } - - const Reaction<ThermoType>& operator[](const label i) const - { - return PtrList<Reaction<ThermoType>>::operator[](i); - } + using PtrList<Reaction<ThermoType>>::size; + using PtrList<Reaction<ThermoType>>::operator[]; //- Table of species composition const speciesCompositionTable& specieComposition() const diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.C index b8374445dc9cf154c4a9d7810e0c8167d0977280..637736dd2d6e8f6310f44345957542ab17f97678 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.C @@ -40,13 +40,6 @@ Foam::singleComponentMixture<ThermoType>::singleComponentMixture {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class ThermoType> -Foam::singleComponentMixture<ThermoType>::~singleComponentMixture() -{} - - // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // template<class ThermoType> diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.H index 7067d07081bb61e6957d6ce6181b7f537c0e8840..1870877b8cdac23dcad3570821778f070685e7c7 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleComponentMixture/singleComponentMixture.H @@ -66,11 +66,16 @@ public: // Constructors //- Construct from dictionary, mesh and phase name - singleComponentMixture(const dictionary&, const fvMesh&, const word&); + singleComponentMixture + ( + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName + ); //- Destructor - virtual ~singleComponentMixture(); + virtual ~singleComponentMixture() = default; // Member Functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C index 01b48e5dbdc1c278ca353c6c474431687f12615b..4b915c2ca3192b8cdd60db4692e749e079b1dc1d 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C @@ -32,7 +32,7 @@ template<class ThermoType> void Foam::singleStepReactingMixture<ThermoType>::calculateqFuel() { const Reaction<ThermoType>& reaction = this->operator[](0); - const scalar Wu = this->speciesData()[fuelIndex_].W(); + const scalar Wu = this->speciesData()[fuelIndex_].W(); forAll(reaction.lhs(), i) { @@ -134,7 +134,7 @@ void Foam::singleStepReactingMixture<ThermoType>::fresCorrect() { const Reaction<ThermoType>& reaction = this->operator[](0); - label O2Index = this->species()["O2"]; + const label O2Index = this->species()["O2"]; const volScalarField& YFuel = this->Y()[fuelIndex_]; const volScalarField& YO2 = this->Y()[O2Index]; @@ -236,8 +236,6 @@ Foam::singleStepReactingMixture<ThermoType>::singleStepReactingMixture massAndAirStoichRatios(); calculateMaxProducts(); - - autoPtr<chemistryReader<ThermoType>>::clear(); } else { diff --git a/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H index fe662be352916b7dc23c67a9aa0d1dfff6a74b7d..e6ab583aa0177a40c8888ac2fca6e0e4aa7ec486 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H @@ -76,8 +76,11 @@ class veryInhomogeneousMixture //- Regress variable volScalarField& b_; - //- Construct as copy (not implemented) - veryInhomogeneousMixture(const veryInhomogeneousMixture<ThermoType>&); + //- No copy construct + veryInhomogeneousMixture + ( + const veryInhomogeneousMixture<ThermoType>& + ) = delete; public: @@ -91,9 +94,9 @@ public: //- Construct from dictionary, mesh and phase name veryInhomogeneousMixture ( - const dictionary&, - const fvMesh&, - const word& + const dictionary& thermoDict, + const fvMesh& mesh, + const word& phaseName );