List of chemical species from a boundary condition
Hello,
I am coding a new boundary condition in OpenFoam 6. This boundary condition is to be used with the "reactingFoam" solver. I want to acces the list of chemical species defined from this boundary condition. I can access the mass fraction of a single specie using : Code:
const Foam::fvPatchField<scalar>& W_N2 = this->patch().lookupPatchField<volScalarField, scalar>("N2"); Code:
const PtrList<volScalarField>& Y = thermo.composition().Y(); Is there anyway to get access to it from the boundary condition ? |
Maybe you can get thermo by lookupObject?
|
Hello, thank you for your interest in my problem.
It seems like it worked. To create a "psiReactionThermo" object (which is the type of thermo), i have to include "psiReactionThermo.H" in my boundary condition header file, and add the lines : Code:
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ Then in the code of my boundary condition, i add : Code:
const psiReactionThermo& thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); However i have no clue on why i have access to it from the "ObjectRegistry". I am not very familiar with this class. In the declaration of "thermo", nothing is done to add it to a registry. What other variables do we have access to from there ? every variable created ? |
https://openfoam.top/en/thermodynamicLIB/
You can have a look at this UML, and you'll find that IOdictionary is the topmost base class of psiReactionThermo. Since IOdictionary is often registried to the mesh, so will psiReactionThermo. |
I have another issue :
when calling Code:
thermo.composition() Code:
pure virtual method called How should i proceed to get the composition object ? |
It's probable that i should define it as an "hePsiThermo" (documentation here) as this is what i am asking openfoam to use in my dictionnary in "constant/thermophysicalProperties":
Code:
thermoType |
"hePsiThermo" takes two templates class, and i can't manage to declare a instance of the class :/
i Tried : Code:
const hePsiThermo<psiReactionThermo, reactingMixture<psiReactionThermo>>& thermo = this->db().lookupObject<hePsiThermo<psiReactionThermo, reactingMixture<psiReactionThermo>>("t"); Code:
/opt/openfoam6/src/thermophysicalModels/reactionThermo/lnInclude/multiComponentMixture.H:61:28: error: cannot declare field 'Foam::multiComponentMixture<Foam::psiReactionThermo>::mixture_' to be of abstract type 'Foam::psiReactionThermo' |
Try this?
Code:
const PtrList<volScalarField>& Y = |
I tried as you proposed :
Code:
const psiReactionThermo& hepsi_thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); Code:
terminate called after throwing an instance of 'std::bad_cast' How did you know what types should be used for the cast ? In the code I only found the definition of "thermo" in "createFields.H". And it is defined as a psiReactionThermo : Code:
autoPtr<psiReactionThermo> pThermo(psiReactionThermo::New(mesh)); |
I tried by cheating with pointers :
Code:
const psiReactionThermo& hepsi_thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); Code:
error: cannot convert |
I managed to solve my problem.
The right way to do it was to define Code:
#include "psiReactionThermo.H" Code:
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ However, the first call of the boundary conditions is made when thermo is beeing built (as mass fractions, rho, and T are initialized by thermo). So, when the boundary condition is called for the first time, thermo is not completly initialized yet. So i had to implement a bypass so that the first call to the boundary condition initializes to some garbage, and doesnt call "thermo.composition()". The boundary condition is still updated before solving the first time step, so no problem for the resolution (i verified this by outputing some text in the console). The only thing is that paraFoam will show some garbage for the boundary condition at time t=0. |
All times are GMT -4. The time now is 04:38. |