solidChemistryModel: Updated runtime selection mechanism

This commit is contained in:
Henry
2012-10-08 10:36:27 +01:00
parent 19a6e2cd48
commit cf2783348d
19 changed files with 137 additions and 863226 deletions

View File

@ -45,7 +45,8 @@ namespace Foam
defineTemplateTypeNameAndDebugWithName \
( \
SS##Comp##SThermo##GThermo, \
#SS"<"#Comp","#SThermo","#GThermo">", \
(#SS"<"#Comp"," + SThermo::typeName() + "," + GThermo::typeName() + \
">").c_str(), \
0 \
);

View File

@ -79,7 +79,7 @@ protected:
public:
//- Runtime type information
TypeName("solidChemistryModel");
TypeName("solid");
//- Declare run-time constructor selection tables

View File

@ -32,7 +32,7 @@ Foam::autoPtr<Foam::solidChemistryModel> Foam::solidChemistryModel::New
const fvMesh& mesh
)
{
IOdictionary chemistryPropertiesDict
IOdictionary chemistryDict
(
IOobject
(
@ -45,63 +45,119 @@ Foam::autoPtr<Foam::solidChemistryModel> Foam::solidChemistryModel::New
)
);
const word userModel(chemistryPropertiesDict.lookup("solidChemistryModel"));
const dictionary& chemistryTypeDict
(
chemistryDict.subDict("chemistryType")
);
const word ODEModelName(chemistryPropertiesDict.lookup("chemistrySolver"));
const word gasThermoName(chemistryPropertiesDict.lookup("gasThermoModel"));
Info<< "Selecting chemistry type " << chemistryTypeDict << endl;
// 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 =
ODEModelName + '<' + className
+ '<' + typeName + ',' + thermoTypeName + ',' + gasThermoName + ">>";
if (debug)
const int nCmpt = 12;
const char* cmptNames[nCmpt] =
{
Info<< "Selecting solidChemistryModel " << modelType << endl;
}
else
{
Info<< "Selecting solidChemistryModel " << userModel + gasThermoName
<< endl;
}
"chemistrySolver",
"chemistryThermo",
"transport",
"thermo",
"equationOfState",
"specie",
"energy",
"transport",
"thermo",
"equationOfState",
"specie",
"energy"
};
IOdictionary thermoDict
(
IOobject
(
"thermophysicalProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
const dictionary& solidThermoTypeDict(thermoDict.subDict("thermoType"));
word solidThermoTypeName
(
word(solidThermoTypeDict.lookup("transport")) + '<'
+ word(solidThermoTypeDict.lookup("thermo")) + '<'
+ word(solidThermoTypeDict.lookup("equationOfState")) + '<'
+ word(solidThermoTypeDict.lookup("specie")) + ">>,"
+ word(solidThermoTypeDict.lookup("energy")) + ">"
);
const dictionary& gasThermoTypeDict(chemistryDict.subDict("gasThermoType"));
word gasThermoTypeName
(
word(gasThermoTypeDict.lookup("transport")) + '<'
+ word(gasThermoTypeDict.lookup("thermo")) + '<'
+ word(gasThermoTypeDict.lookup("equationOfState")) + '<'
+ word(gasThermoTypeDict.lookup("specie")) + ">>,"
+ word(gasThermoTypeDict.lookup("energy")) + ">"
);
// Construct the name of the chemistry type from the components
word chemistryTypeName
(
word(chemistryTypeDict.lookup("chemistrySolver")) + '<'
+ word(chemistryTypeDict.lookup("chemistryThermo")) + ','
+ solidThermoTypeName + ',' + gasThermoTypeName + ">"
);
Info<< "chemistryTypeName " << chemistryTypeName << endl;
fvMeshConstructorTable::iterator cstrIter =
fvMeshConstructorTablePtr_->find(modelType);
fvMeshConstructorTablePtr_->find(chemistryTypeName);
if (cstrIter == fvMeshConstructorTablePtr_->end())
{
if (debug)
FatalErrorIn(typeName + "::New(const mesh&)")
<< "Unknown " << typeName << " type " << nl
<< "chemistryType" << chemistryTypeDict << nl << nl
<< "Valid " << typeName << " types are:"
<< nl << nl;
// Get the list of all the suitable chemistry packages available
wordList validChemistryTypeNames
(
fvMeshConstructorTablePtr_->sortedToc()
);
Info<< validChemistryTypeNames << endl;
// Build a table of the thermo packages constituent parts
// Note: row-0 contains the names of constituent parts
List<wordList> validChemistryTypeNameCmpts
(
validChemistryTypeNames.size() + 1
);
validChemistryTypeNameCmpts[0].setSize(nCmpt);
forAll(validChemistryTypeNameCmpts[0], j)
{
FatalErrorIn("solidChemistryModel::New(const mesh&)")
<< "Unknown solidChemistryModel type "
<< modelType << nl << nl
<< "Valid solidChemistryModel types are:" << nl
<< fvMeshConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
else
{
wordList models = fvMeshConstructorTablePtr_->sortedToc();
forAll(models, i)
{
models[i] = models[i].replace(typeName + ',', "");
validChemistryTypeNameCmpts[0][j] = cmptNames[j];
}
FatalErrorIn("solidChemistryModel::New(const mesh&)")
<< "Unknown solidChemistryModel type "
<< userModel << nl << nl
<< "Valid solidChemistryModel types are:" << nl
<< models << nl
<< exit(FatalError);
// Split the thermo package names into their constituent parts
forAll(validChemistryTypeNames, i)
{
validChemistryTypeNameCmpts[i+1] = basicThermo::splitThermoName
(
validChemistryTypeNames[i],
nCmpt
);
}
// Print the table of available packages
// in terms of their constituent parts
printTable(validChemistryTypeNameCmpts, FatalError);
FatalError<< exit(FatalError);
}
return autoPtr<solidChemistryModel>(cstrIter()(mesh));

View File

@ -39,22 +39,23 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeSolidChemistrySolverType(SS, ODEChem, Comp, SThermo, GThermo) \
#define makeSolidChemistrySolverType(SS, Comp, SThermo, GThermo) \
\
typedef SS<ODEChem<Comp, SThermo, GThermo> > \
SS##ODEChem##Comp##SThermo##GThermo; \
typedef SS<ODESolidChemistryModel<Comp, SThermo, GThermo> > \
SS##Comp##SThermo##GThermo; \
\
defineTemplateTypeNameAndDebugWithName \
( \
SS##ODEChem##Comp##SThermo##GThermo, \
#SS"<"#ODEChem"<"#Comp","#SThermo","#GThermo">>", \
SS##Comp##SThermo##GThermo, \
(#SS"<" + word(Comp::typeName_()) \
+ "," + SThermo::typeName() + "," + GThermo::typeName() + ">").c_str(), \
0 \
); \
\
addToRunTimeSelectionTable \
( \
Comp, \
SS##ODEChem##Comp##SThermo##GThermo, \
SS##Comp##SThermo##GThermo, \
fvMesh \
);

View File

@ -39,7 +39,6 @@ namespace Foam
makeSolidChemistrySolverType
(
ode,
ODESolidChemistryModel,
solidChemistryModel,
hConstSolidThermoPhysics,
gasThermoPhysics
@ -48,7 +47,6 @@ namespace Foam
makeSolidChemistrySolverType
(
ode,
ODESolidChemistryModel,
solidChemistryModel,
hExponentialSolidThermoPhysics,
gasThermoPhysics

View File

@ -15,13 +15,22 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solidChemistryModel ODESolidChemistryModel<hConstSolidThermoPhysics>;
gasThermoModel gasThermoPhysics;
chemistryType
{
chemistrySolver ode;
chemistryThermo solid;
}
chemistry on;
chemistrySolver ode;
gasThermoType
{
transport sutherland;
thermo janaf;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}
initialChemicalTimeStep 1e-07;
@ -36,14 +45,6 @@ species
gas
);
reactions
(
irreversibleSolidArrheniusReaction
v = gas + char
(7.83e10 15274.57 400 4.86)
);
gas
{
specie
@ -66,4 +67,13 @@ gas
}
}
reactions
(
irreversibleSolidArrheniusReaction
v = gas + char
(7.83e10 15274.57 400 4.86)
);
// ************************************************************************* //

View File

@ -1,21 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object cellZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
()
// ************************************************************************* //

View File

@ -1,21 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object faceZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
()
// ************************************************************************* //

View File

@ -1,21 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object pointZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
()
// ************************************************************************* //

View File

@ -74,4 +74,5 @@ charCoeffs
}
};
// ************************************************************************* //