Commit 9bf80af3 authored by Henry's avatar Henry
Browse files

Thermodynamics: Update selection mechanism for reaction and chemistry thermodynamics

parent 149a584c
......@@ -266,15 +266,28 @@ Foam::wordList Foam::basicThermo::splitThermoName
{
wordList cmpts(nCmpt);
string::size_type beg=0, end=0;
string::size_type beg=0, end=0, endb=0, endc=0;
int i = 0;
while
(
(end = thermoName.find('<', beg)) != string::npos
|| (end = thermoName.find(',', beg)) != string::npos
(endb = thermoName.find('<', beg)) != string::npos
|| (endc = thermoName.find(',', beg)) != string::npos
)
{
if (endb == string::npos)
{
end = endc;
}
else if ((endc = thermoName.find(',', beg)) != string::npos)
{
end = min(endb, endc);
}
else
{
end = endb;
}
if (beg < end)
{
cmpts[i] = thermoName.substr(beg, end-beg);
......
......@@ -76,6 +76,8 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
+ word(thermoTypeDict.lookup("specie")) + ">>,"
+ word(thermoTypeDict.lookup("energy")) + ">>>";
Info<< thermoTypeName << endl;
// Lookup the thermo package
typename Thermo::fvMeshConstructorTable::iterator cstrIter =
Thermo::fvMeshConstructorTablePtr_->find(thermoTypeName);
......
......@@ -39,51 +39,45 @@ Description
#define makeThermo(BaseThermo,Cthermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie)\
\
typedef Cthermo \
< \
Mixture \
typedef \
Transport \
< \
Transport \
species::thermo \
< \
species::thermo \
Thermo \
< \
Thermo \
EqnOfState \
< \
EqnOfState \
< \
Specie \
> \
>, \
Type \
> \
Specie \
> \
>, \
Type \
> \
> \
> Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie; \
> Transport##Type##Thermo##EqnOfState##Specie; \
\
typedef \
Cthermo \
< \
Mixture \
< \
Transport##Type##Thermo##EqnOfState##Specie \
> \
> Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie; \
\
defineTemplateTypeNameAndDebugWithName \
( \
Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie, \
#Cthermo \
"<" \
#Mixture \
"<" \
#Transport \
"<" \
#Thermo \
"<" \
#EqnOfState \
"<" \
#Specie \
">" \
">," \
#Type \
">>>", \
( \
#Cthermo"<"#Mixture"<" \
+ Transport##Type##Thermo##EqnOfState##Specie::typeName() \
+ ">>" \
).c_str(), \
0 \
); \
\
addToRunTimeSelectionTable \
( \
BaseThermo, \
basicThermo, \
Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie, \
fvMesh \
); \
......@@ -93,6 +87,13 @@ addToRunTimeSelectionTable \
fluidThermo, \
Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie, \
fvMesh \
); \
\
addToRunTimeSelectionTable \
( \
BaseThermo, \
Cthermo##Mixture##Transport##Type##Thermo##EqnOfState##Specie, \
fvMesh \
);
......
chemistryModel/basicChemistryModel/basicChemistryModel.C
chemistryModel/psiChemistryModel/psiChemistryModel.C
chemistryModel/psiChemistryModel/psiChemistryModelNew.C
chemistryModel/psiChemistryModel/psiChemistryModels.C
chemistryModel/rhoChemistryModel/rhoChemistryModel.C
chemistryModel/rhoChemistryModel/rhoChemistryModelNew.C
chemistryModel/rhoChemistryModel/rhoChemistryModels.C
chemistrySolver/chemistrySolver/makeChemistrySolvers.C
......
......@@ -107,6 +107,13 @@ public:
basicChemistryModel(const fvMesh& mesh);
// Selectors
//- Generic New for each of the related chemistry model
template<class Thermo>
static autoPtr<Thermo> New(const fvMesh&);
//- Destructor
virtual ~basicChemistryModel();
......@@ -162,6 +169,10 @@ public:
#include "basicChemistryModelI.H"
#ifdef NoRepository
# include "basicChemistryModelTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
......
......@@ -46,19 +46,7 @@ namespace Foam
defineTemplateTypeNameAndDebugWithName \
( \
SS##Comp##Thermo, \
#SS"<"#Comp","#Thermo">", \
0 \
);
#define makeSolidChemistryModel(SS, Comp, SThermo, GThermo) \
\
typedef SS<Comp, SThermo, GThermo> SS##Comp##SThermo##GThermo; \
\
defineTemplateTypeNameAndDebugWithName \
( \
SS##Comp##SThermo##GThermo, \
#SS"<"#Comp","#SThermo","#GThermo">", \
(#SS"<"#Comp"," + Thermo::typeName() + ">").c_str(), \
0 \
);
......
......@@ -48,6 +48,17 @@ Foam::psiChemistryModel::psiChemistryModel
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New
(
const fvMesh& mesh
)
{
return basicChemistryModel::New<psiChemistryModel>(mesh);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::psiChemistryModel::~psiChemistryModel()
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "psiChemistryModel.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New
(
const fvMesh& mesh
)
{
IOdictionary chemistryPropertiesDict
(
IOobject
(
"chemistryProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
const word solver(chemistryPropertiesDict.lookup("chemistrySolver"));
wordList models = fvMeshConstructorTablePtr_->sortedToc();
wordHashSet validModels;
forAll(models, i)
{
label delim = models[i].find('<');
validModels.insert(models[i](0, delim));
}
wordHashSet::iterator solverIter = validModels.find(solver);
if (solverIter == validModels.end())
{
FatalErrorIn("psiChemistryModel::New(const fvMesh&)")
<< "Valid chemistrySolver types are:" << validModels
<< exit(FatalError);
}
const word userModel(chemistryPropertiesDict.lookup("psiChemistryModel"));
// construct chemistry model type name by inserting first template argument
const label tempOpen = userModel.find('<');
const label tempClose = userModel.find('>');
const word className = userModel(0, tempOpen);
const word thermoTypeName =
userModel(tempOpen + 1, tempClose - tempOpen - 1);
const word modelType =
solver + '<' + className + '<' + typeName + ',' + thermoTypeName + ">>";
if (debug)
{
Info<< "Selecting psiChemistryModel " << modelType << endl;
}
else
{
Info<< "Selecting psiChemistryModel " << userModel << endl;
}
fvMeshConstructorTable::iterator cstrIter =
fvMeshConstructorTablePtr_->find(modelType);
if (cstrIter == fvMeshConstructorTablePtr_->end())
{
if (debug)
{
FatalErrorIn("psiChemistryModel::New(const mesh&)")
<< "Unknown psiChemistryModel type "
<< modelType << nl << nl
<< "Valid psiChemistryModel types are:" << nl
<< fvMeshConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
else
{
wordList allModels(fvMeshConstructorTablePtr_->sortedToc());
wordHashSet models;
forAll(allModels, i)
{
const label tempOpen = allModels[i].find('<');
const label tempClose = allModels[i].rfind('>');
word modelName =
allModels[i](tempOpen + 1, tempClose - tempOpen - 1);
modelName = modelName.replace(typeName + ',', "");
models.insert(modelName);
}
FatalErrorIn("psiChemistryModel::New(const mesh&)")
<< "Unknown psiChemistryModel type " << userModel
<< nl << nl << "Valid psiChemistryModel types are:"
<< models << exit(FatalError);
}
}
return autoPtr<psiChemistryModel>
(cstrIter()(mesh, typeName, thermoTypeName));
}
// ************************************************************************* //
......@@ -48,6 +48,17 @@ Foam::rhoChemistryModel::rhoChemistryModel
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New
(
const fvMesh& mesh
)
{
return basicChemistryModel::New<rhoChemistryModel>(mesh);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rhoChemistryModel::~rhoChemistryModel()
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "rhoChemistryModel.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New
(
const fvMesh& mesh
)
{
IOdictionary chemistryPropertiesDict
(
IOobject
(
"chemistryProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
const word solver(chemistryPropertiesDict.lookup("chemistrySolver"));
wordList models = fvMeshConstructorTablePtr_->sortedToc();
wordHashSet validModels;
forAll(models, i)
{
label delim = models[i].find('<');
validModels.insert(models[i](0, delim));
}
wordHashSet::iterator solverIter = validModels.find(solver);
if (solverIter == validModels.end())
{
FatalErrorIn("rhoChemistryModel::New(const fvMesh&)")
<< "Valid chemistrySolver types are:" << validModels
<< exit(FatalError);
}
const word userModel(chemistryPropertiesDict.lookup("rhoChemistryModel"));
// construct chemistry model type name by inserting first template argument
const label tempOpen = userModel.find('<');
const label tempClose = userModel.find('>');
const word className = userModel(0, tempOpen);
const word thermoTypeName =
userModel(tempOpen + 1, tempClose - tempOpen - 1);
const word modelType =
solver + '<' + className + '<' + typeName + ',' + thermoTypeName + ">>";
if (debug)
{
Info<< "Selecting rhoChemistryModel " << modelType << endl;
}
else
{
Info<< "Selecting rhoChemistryModel " << userModel << endl;
}
fvMeshConstructorTable::iterator cstrIter =
fvMeshConstructorTablePtr_->find(modelType);
if (cstrIter == fvMeshConstructorTablePtr_->end())
{
if (debug)
{
FatalErrorIn("rhoChemistryModel::New(const mesh&)")
<< "Unknown rhoChemistryModel type "
<< modelType << nl << nl
<< "Valid rhoChemistryModel types are:" << nl
<< fvMeshConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
else
{
wordList allModels(fvMeshConstructorTablePtr_->sortedToc());
wordHashSet models;
forAll(allModels, i)
{
const label tempOpen = allModels[i].find('<');
const label tempClose = allModels[i].rfind('>');
word modelName =
allModels[i](tempOpen + 1, tempClose - tempOpen - 1);
modelName = modelName.replace(typeName + ',', "");
models.insert(modelName);
}
FatalErrorIn("rhoChemistryModel::New(const mesh&)")
<< "Unknown rhoChemistryModel type " << userModel
<< nl << nl << "Valid rhoChemistryModel types are:"
<< models << exit(FatalError);
}
}
return autoPtr<rhoChemistryModel>
(cstrIter()(mesh, typeName, thermoTypeName));
}
// ************************************************************************* //
......@@ -63,10 +63,6 @@ protected:
public:
//- Runtime type information
TypeName("chemistrySolver");
// Constructors
//- Construct from components
......@@ -100,37 +96,6 @@ public:
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeChemistrySolver(ODEChem) \
\
defineTemplateTypeNameAndDebugWithName \
( \
chemistrySolver<ODEChem>, \
"chemistrySolver<"#ODEChem">", \
0 \
);
#define makeChemistrySolverType(SS, ODEChem, Comp, Thermo) \
\
typedef SS<ODEChem<Comp, Thermo> > SS##ODEChem##Comp##Thermo; \
\
defineTemplateTypeNameAndDebugWithName \
( \
SS##ODEChem##Comp##Thermo, \
#SS"<"#ODEChem"<"#Comp","#Thermo">>", \
0 \
); \
\
addToRunTimeSelectionTable \
( \
Comp, \
SS##ODEChem##Comp##Thermo, \
fvMesh \
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
......
......@@ -37,11 +37,26 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeChemistrySolverTypes(CompChemModel,Thermo) \
#define makeChemistrySolverType(SS, ODEChem, Comp, Thermo) \
\
typedef ODEChemistryModel<CompChemModel, Thermo> CompChemModel##Thermo; \
typedef SS<ODEChem<Comp, Thermo> > SS##ODEChem##Comp##Thermo; \
\
makeChemistrySolver(CompChemModel##Thermo); \
defineTemplateTypeNameAndDebugWithName \
( \
SS##ODEChem##Comp##Thermo, \
(#SS"<"#ODEChem"<"#Comp"," + Thermo::typeName() + ">>").c_str(), \
0 \
); \
\
addToRunTimeSelectionTable \
( \
Comp, \
SS##ODEChem##Comp##Thermo, \
fvMesh \
);
#define makeChemistrySolverTypes(CompChemModel,Thermo) \
\
makeChemistrySolverType \
( \
......
......@@ -31,103 +31,76 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeReactionThermo(BaseThermo,CThermo,MixtureThermo,Mixture,Transport,Type,Thermo,EqnOfState,Specie) \
\
typedef MixtureThermo \
< \
SpecieMixture \