1

Previous: Structure and compilation Up: Structure and compilation Next: Specie
This is an automatically generated documentation by LaTeX2HTML utility. In case of any issue, please, contact us at info@cfdsupport.com.

Settings and compilation

By looking into some compressible solver (in listing below, it is rhoSimpleFoam, file createFields.H) which can be found in

$FOAM_APP/solvers/compressible/rhoSimpleFoam/

one can see, that the thermodynamics is solved using object of type psiThermo.

Info<< "Reading thermophysical properties\n" << endl;

autoPtr pThermo
(
    psiThermo::New(mesh)
);
psiThermo& thermo = pThermo();

However, this object is quite complicated one. Let’s inspect this object in detail.
Rather than following it in its full generality, let us pick an example.

In tutorial squareBend, which can be found in

$FOAM_TUTORIALS/compressible/rhoSimpleFoam/squareBend/

in file constant/thermophysicalProperties we can see following:

thermoType
{
    type            hePsiThermo;
    mixture         pureMixture;
    transport       sutherland;
    thermo          hConst;
    equationOfState perfectGas;
    specie          specie;
    energy          sensibleInternalEnergy;
}

This is a setup of the thermodynamics for the one specicific CFD simulation. To learn an exact meaning of those keywords and its parameters, we have to inspect the file psiThermos.C, which can be found in

$FOAM_SRC/thermophysicalModels/basic/psiThermo/psiThermos.C

Following excerpt shows corresponding part of makeThermo:

makeThermo
(
    psiThermo,
    hePsiThermo,
    pureMixture,
    sutherlandTransport,
    sensibleInternalEnergy,
    hConstThermo,
    perfectGas,
    specie
);

The makeThermo is a C++ preprocessor macro, that is responsible for creating the psiThermo object. The exact function is quite complicated, but the basic function is to make explicit declaration of the object, as discussed in section crossref 3. This enables user to use the instantiated combination in her case. Note, that not all possible combinations of keywords are allowed, i.e. not all possible combinations of template parameters are used to instantiate an object. Definition of the makeThermo macro can be found in the file makeThermo.H:

$FOAM_SRC/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H

Lets explore little bit further and expand the macro. Expanding macros is discussed in crossref 3. Here, in this specific case, you also need to provide paths to all files that are included in the file. The easiest way to do that is to run wmake and copy all the paths used in compilation (i.e. all the -I switches). The resulting command will look like this:

# g++ -E \
-I/$FOAM_SRC/transportModels/compressible/lnInclude \
-I/$FOAM_SRC/thermophysicalModels/specie/lnInclude \
-I/$FOAM_SRC/thermophysicalModels/thermophysicalProperties/lnInclude \
-I/$FOAM_SRC/finiteVolume/lnInclude \
-I/$FOAM_SRC/meshTools/lnInclude \
-I/$FOAM_SRC/OpenFOAM/lnInclude \
-I/$FOAM_SRC/OSspecific/POSIX/lnInclude \
-IlnInclude \
psiThermos.C \
> psiThermos.expanded

Of course, the $FOAM_SRC will be expanded to the path of your src directory. While the command seems to be horrible, it is simple in its nature. The first line is familiar one, this calls the compiler and the -E switch tells the compiler only to preprocess. The second to nine-th lines starting with the -I provide the paths to files, that are included in the psiThermos.C. On the tenth line is the target file and finally on the eleventh line, there is redirection of the output into file psiThermos.expanded. The command will produce some error, but it is not relevant for only expanding macros. Looking in the file psiThermos.expanded (and little manual editing to increase readability), one can find following part, that is corresponding to expanded macro makeThermo:

typedef sutherlandTransport 
< 
  species::thermo 
  < 
    hConstThermo 
    <
      perfectGas < specie > 
    >,
    sensibleInternalEnergy 
  > 
>
sutherlandTransportsensibleInternalEnergyhConstThermoperfectGasspecie;

typedef hePsiThermo 
<
  psiThermo, 
  pureMixture
  < sutherlandTransportsensibleInternalEnergyhConstThermoperfectGasspecie > 
> 
hePsiThermopureMixturesutherlandTransportsensibleInternalEnergyhConstThermoperfectGasspecie;

One can see that the resulting object hePsiThermopureMixturesutherlandTransportsensibleInternalEnergyhConstThermoperfectGasspecie has a rich template structure, which is a mere typedef for instance of template class hePsiThermo. Purpose of this code snippet is to make sure, that instances of template classes sutherlandTransport and hePsiThermo with proper template parameters will be compiled, because in C++, compiler must see both the definition of the template and the used type. So while one wants to use a different setup of thermophysical properties in different cases, corresponding template instances cannot be created during runtime. Files psiThermos.C and rhoThermos.C solve this problem by offering array of precompiled options. If user happens to need some combination of parameters not used here, it is possible to add it in psiThermos.C or rhoThermos.C and recompile.