|
[Sponsors] |
List of chemical species from a boundary condition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 30, 2018, 08:06 |
List of chemical species from a boundary condition
|
#1 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
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 ? Last edited by Benben; August 31, 2018 at 06:35. |
|
August 30, 2018, 22:34 |
|
#2 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
Maybe you can get thermo by lookupObject?
|
|
August 31, 2018, 03:53 |
|
#3 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
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 \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ -I$(LIB_SRC)/ODE/lnInclude \ -I$(LIB_SRC)/combustionModels/lnInclude Then in the code of my boundary condition, i add : Code:
const psiReactionThermo& thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); const PtrList<volScalarField>& Y = thermo.composition().Y(); 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 ? Last edited by Benben; August 31, 2018 at 05:19. Reason: error in the code |
|
August 31, 2018, 04:03 |
|
#4 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
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. |
|
August 31, 2018, 05:35 |
|
#5 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
I have another issue :
when calling Code:
thermo.composition() Code:
pure virtual method called How should i proceed to get the composition object ? |
|
August 31, 2018, 05:50 |
|
#6 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
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 { type hePsiThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy sensibleEnthalpy; equationOfState perfectGas; specie specie; } |
|
August 31, 2018, 06:13 |
|
#7 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
"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' mutable ThermoType mixture_; ^ In file included from evaporatingZinc_RDMP/evaporatingZinc_RDMPFvPatchScalarField.H:81:0, from evaporatingZinc_RDMP/evaporatingZinc_RDMPFvPatchScalarField.C:26: /opt/openfoam6/src/thermophysicalModels/reactionThermo/lnInclude/psiReactionThermo.H:52:7: note: because the following virtual functions are pure within 'Foam::psiReactionThermo': class psiReactionThermo |
|
August 31, 2018, 07:37 |
|
#8 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
Try this?
Code:
const PtrList<volScalarField>& Y = dynamic_cast<hePsiThermo<psiReactionThermo,SpecieMixture<reactingMixture<gasHThermoPhysics>>>&> (this->db().lookupObject<psiReactionThermo>("thermo")).composition().Y(); |
|
August 31, 2018, 11:29 |
|
#9 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
I tried as you proposed :
Code:
const psiReactionThermo& hepsi_thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); const hePsiThermo<psiReactionThermo,SpecieMixture<reactingMixture<gasHThermoPhysics>>>& thermo = dynamic_cast<const hePsiThermo<psiReactionThermo,SpecieMixture<reactingMixture<gasHThermoPhysics>>>&>(hepsi_thermo); Code:
terminate called after throwing an instance of 'std::bad_cast' what(): 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)); psiReactionThermo& thermo = pThermo(); |
|
August 31, 2018, 11:54 |
|
#10 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
I tried by cheating with pointers :
Code:
const psiReactionThermo& hepsi_thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); hePsiThermo<psiReactionThermo,SpecieMixture<reactingMixture<gasHThermoPhysics>>> * thermo = & hepsi_thermo; Code:
error: cannot convert 'const Foam::psiReactionThermo*' to 'Foam::hePsiThermo<Foam::psiReactionThermo, Foam::SpecieMixture<Foam::reactingMixture<Foam::sutherlandTransport<Foam::species::thermo<Foam::janafThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleEnthalpy> > > > >*' in initialization hePsiThermo<psiReactionThermo,SpecieMixture<reactingMixture<gasHThermoPhysics>>> * thermo = & hepsi_thermo; |
|
September 3, 2018, 11:41 |
|
#11 |
Member
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9 |
I managed to solve my problem.
The right way to do it was to define Code:
#include "psiReactionThermo.H" const psiReactionThermo& thermo = this->db().lookupObject<psiReactionThermo>("thermophysicalProperties"); const PtrList<volScalarField>& Y = thermo.composition().Y(); Code:
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/chemistryModel/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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
Centrifugal fan-reverse flow in outlet lesds to a mass in flow field | xiexing | CFX | 3 | March 29, 2017 11:00 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |
External Radiation Boundary Condition (Two sided wall), Grid Interface | CFD XUE | FLUENT | 0 | July 8, 2010 07:49 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |