BUG: Species table now held by reactingMixture class so that it

persists after chemistry reader class is deleted

- corresponds to mantis bug report 326
This commit is contained in:
andy
2011-10-27 11:36:39 +01:00
parent 96b94ccace
commit 13aa738013
8 changed files with 72 additions and 25 deletions

View File

@ -31,7 +31,8 @@ template<class ThermoType>
Foam::autoPtr<Foam::chemistryReader<ThermoType> >
Foam::chemistryReader<ThermoType>::New
(
const dictionary& thermoDict
const dictionary& thermoDict,
speciesTable& species
)
{
// Let the chemistry reader type default to CHEMKIN
@ -50,7 +51,7 @@ Foam::chemistryReader<ThermoType>::New
{
FatalErrorIn
(
"chemistryReader::New(const dictionary& thermoDict)"
"chemistryReader::New(const dictionary&, speciesTable&)"
) << "Unknown chemistryReader type "
<< chemistryReaderTypeName << nl << nl
<< "Valid chemistryReader types are:" << nl
@ -58,7 +59,10 @@ Foam::chemistryReader<ThermoType>::New
<< exit(FatalError);
}
return autoPtr<chemistryReader<ThermoType> >(cstrIter()(thermoDict));
return autoPtr<chemistryReader<ThermoType> >
(
cstrIter()(thermoDict, species)
);
}

View File

@ -85,16 +85,21 @@ public:
chemistryReader,
dictionary,
(
const dictionary& thermoDict
const dictionary& thermoDict,
speciesTable& species
),
(thermoDict)
(thermoDict, species)
);
// Selectors
//- Select constructed from dictionary
static autoPtr<chemistryReader> New(const dictionary& thermoDict);
static autoPtr<chemistryReader> New
(
const dictionary& thermoDict,
speciesTable& species
);
//- Destructor
@ -104,9 +109,6 @@ public:
// Member Functions
//- Return access to the list of species
virtual const speciesTable& species() const = 0;
//- Return access to the thermo packages
virtual const HashPtrTable<ThermoType>& speciesThermo() const = 0;

View File

@ -854,29 +854,31 @@ void Foam::chemkinReader::read
Foam::chemkinReader::chemkinReader
(
const fileName& CHEMKINFileName,
speciesTable& species,
const fileName& thermoFileName
)
:
lineNo_(1),
specieNames_(10),
speciesTable_(),
speciesTable_(species),
reactions_(speciesTable_, speciesThermo_)
{
read(CHEMKINFileName, thermoFileName);
}
Foam::chemkinReader::chemkinReader(const dictionary& thermoDict)
Foam::chemkinReader::chemkinReader
(
const dictionary& thermoDict,
speciesTable& species
)
:
lineNo_(1),
specieNames_(10),
speciesTable_(),
speciesTable_(species),
reactions_(speciesTable_, speciesThermo_)
{
fileName chemkinFile
(
fileName(thermoDict.lookup("CHEMKINFile")).expand()
);
fileName chemkinFile(fileName(thermoDict.lookup("CHEMKINFile")).expand());
fileName thermoFile = fileName::null;

View File

@ -193,7 +193,7 @@ private:
HashTable<label> specieIndices_;
//- Table of species
speciesTable speciesTable_;
speciesTable& speciesTable_;
//- Specie phase
HashTable<phase> speciePhase_;
@ -318,11 +318,12 @@ public:
chemkinReader
(
const fileName& chemkinFile,
speciesTable& species,
const fileName& thermoFileName = fileName::null
);
//- Construct by getting the CHEMKIN III file name from dictionary
chemkinReader(const dictionary& thermoDict);
chemkinReader(const dictionary& thermoDict, speciesTable& species);
//- Destructor

View File

@ -27,12 +27,28 @@ License
#include "IFstream.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ThermoType>
Foam::speciesTable& Foam::foamChemistryReader<ThermoType>::setSpecies
(
const dictionary& dict,
speciesTable& species
)
{
wordList s(dict.lookup("species"));
species.transfer(s);
return species;
}
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class ThermoType>
Foam::foamChemistryReader<ThermoType>::foamChemistryReader
(
const fileName& reactionsFileName,
speciesTable& species,
const fileName& thermoFileName
)
:
@ -51,8 +67,8 @@ Foam::foamChemistryReader<ThermoType>::foamChemistryReader
fileName(thermoFileName).expand()
)()
),
speciesTable_(setSpecies(chemDict_, species)),
speciesThermo_(thermoDict_),
speciesTable_(chemDict_.lookup("species")),
reactions_(speciesTable_, speciesThermo_, chemDict_)
{}
@ -60,7 +76,8 @@ Foam::foamChemistryReader<ThermoType>::foamChemistryReader
template<class ThermoType>
Foam::foamChemistryReader<ThermoType>::foamChemistryReader
(
const dictionary& thermoDict
const dictionary& thermoDict,
speciesTable& species
)
:
chemistryReader<ThermoType>(),
@ -79,7 +96,7 @@ Foam::foamChemistryReader<ThermoType>::foamChemistryReader
)()
),
speciesThermo_(thermoDict_),
speciesTable_(chemDict_.lookup("species")),
speciesTable_(setSpecies(chemDict_, species)),
reactions_(speciesTable_, speciesThermo_, chemDict_)
{}

View File

@ -67,7 +67,7 @@ class foamChemistryReader
HashPtrTable<ThermoType> speciesThermo_;
//- Table of species
speciesTable speciesTable_;
speciesTable& speciesTable_;
//- List of the reactions
ReactionList<ThermoType> reactions_;
@ -75,6 +75,9 @@ class foamChemistryReader
// Private Member Functions
//- Set the species list
speciesTable& setSpecies(const dictionary& dict, speciesTable& species);
//- Disallow default bitwise copy construct
foamChemistryReader(const foamChemistryReader&);
@ -94,12 +97,17 @@ public:
foamChemistryReader
(
const fileName& reactionsFileName,
speciesTable& species,
const fileName& thermoFileName
);
//- Construct by getting the foamChemistry and thermodynamics file names
// from dictionary
foamChemistryReader(const dictionary& thermoDict);
foamChemistryReader
(
const dictionary& thermoDict,
speciesTable& species
);
//- Destructor

View File

@ -35,14 +35,15 @@ Foam::reactingMixture<ThermoType>::reactingMixture
const fvMesh& mesh
)
:
speciesTable(),
autoPtr<chemistryReader<ThermoType> >
(
chemistryReader<ThermoType>::New(thermoDict)
chemistryReader<ThermoType>::New(thermoDict, *this)
),
multiComponentMixture<ThermoType>
(
thermoDict,
autoPtr<chemistryReader<ThermoType> >::operator()().species(),
*this,
autoPtr<chemistryReader<ThermoType> >::operator()().speciesThermo(),
mesh
),

View File

@ -35,6 +35,7 @@ SourceFiles
#ifndef reactingMixture_H
#define reactingMixture_H
#include "speciesTable.H"
#include "chemistryReader.H"
#include "multiComponentMixture.H"
@ -50,6 +51,7 @@ namespace Foam
template<class ThermoType>
class reactingMixture
:
public speciesTable,
public autoPtr<chemistryReader<ThermoType> >,
public multiComponentMixture<ThermoType>,
public PtrList<Reaction<ThermoType> >
@ -84,6 +86,16 @@ 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);
}
};