STYLE: make chemistryReader private inheritance (issue #1144)
- The chemistryReader is only used during construction of reactingMixture and thus does not require public visibility.
This commit is contained in:
parent
3a374bf315
commit
c13199d3ce
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,8 +126,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamChemistryReader()
|
||||
{}
|
||||
virtual ~foamChemistryReader() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -40,13 +40,6 @@ Foam::singleComponentMixture<ThermoType>::singleComponentMixture
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::singleComponentMixture<ThermoType>::~singleComponentMixture()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user