The psiReactionThermo class in OpenFOAM
In the createFieds.H
in coalChemistryFoam
solver, a psiReactionThermo
object is defined as:
1 | autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(mesh)); |
The object pThermo
is initialized using the New
function defined in psiReactionThermo.C
as:
1 | Foam::autoPtr<Foam::psiReactionThermo> Foam::psiReactionThermo::New |
Here the phaseName
is defined as word::null
. The return of this New
function is defined in basicThermoTemplates.C
:
1 | template<class Thermo> |
The dictName
here is defined in basicThermo.C
as:
1 | const Foam::word Foam::basicThermo::dictName("thermophysicalProperties"); |
The phasePropertyName
function is defined in basicThermo.H
as:
1 | static word phasePropertyName |
Here in the New
function the phasePropertyName
will be thermophysicalProperties
as the phaseName
here is a word::null
. The two parameters in New
function are all settled, then we can go through the function body. First an IOdictionary
object is built called thermoDict
. This object will search the file which has a name of phasePropertyName
in the constant
folder. Then the cstrIter
will be assigned with a function called lookupThermo
. The types fvMeshConstructorTable
and fvMeshConstructorTablePtr_
are all defined in the declareRunTimeSelectionTable
in the psiReactionThermo.H
:
1 | declareRunTimeSelectionTable |
This is a run time selection macro, we will not explain this in detail here. The function lookupThermo
will be called then:
1 | template<class Thermo, class Table> |
First it goes into the isDict
function, which is used to check if a certain sub-dict is existing or not. The curly bracket {}
is necessary for checking if the dict exists or not. If the thermoType
sub-dict exists, a new dictionary called thermoTypeDict
is built. And the Info
will also show this sub-dict. In the tutorial simplifiedSiwek
, this thermoTypeDict
is:
1 | { |
Then we will check if the properties
is found in this dictionary. Of course it is not found in this dictionary, therefore the else loop will be conducted. The thermoTypeName
in this tutorial is:
1 | hePsiThermo<reactingMixture<sutherland<janaf<perfectGas<specie>>,sensibleEnthalpy>>> |
Then the function will search this thermoTypeName
in the table built in the run time selection part. First the function lookupThermo
will be called:
1 | template<class Thermo, class Table> |
In this function, the cstrIter
will be initialized from the object tablePtr
. Here a initialization flow will be conducted as the inheritance relationship of the psiReactionThermo
class.