|
[Sponsors] |
April 30, 2013, 11:00 |
Accessing specie data in OF2.2
|
#1 |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi,
I want to write a new boundary condition for which I have to access specie data (specific gas constant). I added #include "specie.H" at the top of the myBC.C and tried to get the data with specie::R() but obviously that does not work. During compilation I get the following: error: cannot call member function āFoam::scalar Foam::specie::R() constā without object Can anybody tell me how it can be done? Thanks a lot Hannes |
|
May 1, 2013, 16:44 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Hannes,
I've finished just now writing a post on how to calculate entropy, which requires direct access to the full thermodynamic model that was chosen in the file "constant/thermophysicalProperties". It's this thread: Entropy calculation in OpenFoam - specifically the post #11. You better read the whole post very carefully, because it can get a bit confusing! Now, in case you're wondering how exactly you're going to access the "R()" method from the species in question, you'll see the following code in "entropy.C": Code:
S[celli] = thermo.cellMixture(celli).S(thermo.p()[celli], thermo.T()[celli]); Code:
Rfield[celli] = thermo.cellMixture(celli).R(); For the patches, you can change: Code:
pS[facei] = thermo.patchFaceMixture(patchi, facei).S(pp[facei], pT[facei]); Code:
pRfield[facei] = thermo.patchFaceMixture(patchi, facei).R(); And there you have it! If you have questions about this, please ask it here on your thread, so that things don't get very confusing on the other thread... Best regards, Bruno
__________________
|
|
May 2, 2013, 04:27 |
|
#3 |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi Bruno,
this seems to be a powerful tool. However, to me it seems a little bit too complex as in my simulation there is only one fluid (namely air) and thus the specific gas constant does not change and could be calculated by use of the molar mass which is given in the thermophysicalProperties file. As far as I understand this is done in the specieI.H which is called from specie.H. So, is there really no easy way to access those constants? Best regards Hannes |
|
May 2, 2013, 08:56 |
|
#4 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Hannes,
This was an interesting exercise OK, so here are the steps that need to be taken:
Best regards, Bruno
__________________
Last edited by wyldckat; May 6, 2013 at 17:58. Reason: see "edit:" |
|
May 2, 2013, 10:54 |
|
#5 |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi Bruno,
thanks a lot - that's exactly what I've been looking for. I had to load the dictionary according to your description 3.2 and additionally I had to locally define the mesh: Code:
const fvMesh& mesh_ = patch().boundaryMesh().mesh(); Best regards, Hannes |
|
May 6, 2013, 04:44 |
|
#6 |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi,
unfortunately I still got a small problem with the code. The boundary condition works perfectly, but whenever "libmyBCs.so" is loaded (whether for blockMesh or decomposePar etc.) I get a warning: Code:
Create time --> FOAM Warning : From function dlOpen(const fileName&, const bool) in file POSIX.C at line 1179 dlopen error : /home/hs/OpenFOAM/hs-2.2.0/platforms/linux64GccDPOpt/lib/libmyBCs.so: undefined symbol: _ZN4Foam6specie2RRE --> FOAM Warning : From function dlLibraryTable::open(const fileName&, const bool) in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99 could not load "libmyBCs.so" The problem occurs as soon as the call to Code:
theSpecie.R() Code:
operator==... Thanks a lot Hannes |
|
May 6, 2013, 18:01 |
|
#7 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Hannes,
I've edited my previous post. I had forgotten to mention the dependency on "libspecie.so", which is added in "Make/options": Code:
EXE_LIBS = \ [...] -lspecie \ [...] Best regards, Bruno
__________________
|
|
May 7, 2013, 10:59 |
|
#8 |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi Bruno,
unfortunately it still does not work. I tried the reference to lspecie before but since the boundary condition does what it is supposed to without putting anything in the Make/options I'm not quite sure what happens. Currently the files looks like that: Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude EXE_LIBS = \ -lmeshTools \ -lfluidThermophysicalModels \ -lspecie \ -lfiniteVolume \ -lgenericPatchFields \ -L$(FOAM_USER_LIBBIN) \ -lmyBCs Code:
totalPressureRGHFvPatchScalarField.C LIB = $(FOAM_USER_LIBBIN)/libmyBCs Hannes |
|
May 7, 2013, 11:37 |
|
#9 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi Hannes,
You said that it goes wrong, when you are trying to use Code:
operator==<something with theSpecies.R()> Code:
scalar R = theSpecies.R(); operator==<the same something with R> Well, I would like you to put the following in the command line, before you are running your program: Code:
export FOAM_ABORT=1 Kind regards Niels |
|
May 7, 2013, 17:42 |
|
#10 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Hannes: There is something very strange going on... Niels is probably right, but I still suspect something very strange is going on Here's why: Quote:
So, just for the sake of making sure that something strange doesn't happen later on, edit the file "myBCs/Make/options" to look something like this: Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude EXE_LIBS = \ -lmeshTools \ -lfluidThermophysicalModels \ -lspecie \ -lfiniteVolume \ -lgenericPatchFields Bruno
__________________
|
||
May 8, 2013, 03:41 |
|
#11 | |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi,
@Bruno: I found the reference to itself in some of the other posts so that's why I tried it, but basically I don't know what I have to include in the Make/options EXE_LIBS part. The behaviour is the same whether I include nothing or whether I include the libraries as supposed in your posts. @Niels: Probably I've been a little bit unclear so far. It compiles without error (code below) and when using the boundary condition the behaviour is as wanted - no problems with the solver, no error (and no warning!) during solver run. I only get the warning when any of the additional tools is used (blockMesh, mapFields, wallHeatFlux, yPlusRAS, ...) which does not affect the results - it is just annoying because I don't understand the reason for it. That's why I don't get any additional output when setting FOAM_ABORT=1 Concerning your second question, this Quote:
Code:
scalar R = theSpecies.R(); operator==<something with 287.0> So as mentioned above here my compiler output: Code:
hs@Computer:~/OpenFOAM/hs-2.2.0/src/finiteVolume/fields/fvPatchFields/derived/totalPressureRGH> wmake libso wmakeLnInclude: linking include files to ./lnInclude SOURCE=totalPressureRGHFvPatchScalarField.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM-2.2.0/src/finiteVolume/lnInclude -I/opt/OpenFOAM-2.2.0/src/thermophysicalModels/basic/lnInclude -I/opt/OpenFOAM-2.2.0/src/thermophysicalModels/specie/lnInclude -IlnInclude -I. -I/opt/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude -I/opt/OpenFOAM-2.2.0/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/totalPressureRGHFvPatchScalarField.o '/home/hs/OpenFOAM/hs-2.2.0/platforms/linux64GccDPOpt/lib/libmyBCs.so' is up to date. Best regards Hannes |
||
May 8, 2013, 04:09 |
|
#12 | |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Good morning,
Quote:
With respect to the warning, when you use blockMesh, you should not be bothered with that. My understanding of this warning is: Since blockMesh is not compiled with thermo* libraries, then it does not know how to handle the linking to these libraries are thereby your libmyBCs.so. Kind regards Niels |
||
May 8, 2013, 12:14 |
|
#13 |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi Niels,
I attached the entire BC. Basically it's the same as totalPressure but reduced to a single case with a given pressure profile for p_rgh. Thanks Hannes |
|
May 8, 2013, 12:47 |
|
#14 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi Hannes,
I have had a look on the code, and there is only one detail, which bothers me. But first a question: "Are the thermophysicalProperties defined in the solver as well?". If yes: By construction of the thermoProps you add a second dictionary with the same name to the object registry, however, one of these will be deleted when going out of scope. This might give rise to some nasty problems. Therefore, I suggest that you do the following instead, and see if this helps: Code:
// Reference to the sub-dictionary called mixture const dictionary & subDictThermo = mesh_.thisDb().lookupObject<dictionary>("thermophysicalProperties").subDict("mixture"); // Construct your species specie theSpecie( subDictThermo ); Code:
const scalar RM = theSpecie.R(); Info << "Reading RM: " << tab << RM << tab << theSpecie.R() << endl; Furthermore, a small note on the readability of the source code, then the underscore ("_") after the variable name is by convention reserved to variables, which belong to the class itself. A variable defined inside a scope in one of the methods in the class should be without underscore. Thus in this case: Code:
const scalar RM_ = theSpecie.R(); // Wrong / unconventional const scalar RM = theSpecie.R(); // Conventional / correct Niels |
|
May 9, 2013, 11:07 |
|
#15 | |
Member
hannes
Join Date: Mar 2013
Posts: 47
Rep Power: 13 |
Hi Niels,
thanks again for your input. I changed the code according to your suggestions and I'm sort of surprised that it compiles and runs because your approach seems to be very similar to the one suggested by Bruno in his second post in this thread: Quote:
Now referring directly to the subdictionary works, however, the behaviour remains the same - the boundary condition compiles and runs, but the warnings are still there. I think I'll just live with those (ugly) warnings. Concerning your suggestion to write out the values of RM and theSpecie.R() - they are indeed the same. Best regards, Hannes |
||
May 9, 2013, 11:22 |
|
#16 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Congrats It is nice to hear that you sorted it out.
Happy Foaming, Niels P.S. Yes, forget about the warnings; they are merely warnings. |
|
September 23, 2020, 10:11 |
|
#17 |
New Member
Elina
Join Date: Jul 2019
Location: Ufa
Posts: 4
Rep Power: 7 |
Greetings to all!
I'm trying to calculate the strainrate function inside my transport model located in the specie/transport folder and need to call the velocity field. Could you be so kind to give me some tips how to call the volVectorField U from the specie folder (if it's possible in OpenFOAM)? Maybe I can do it somehow using objectRegistry function? Kind regards, Elina |
|
Tags |
gas constant, specie.h |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how can see Cp values? | immortality | OpenFOAM Post-Processing | 51 | June 18, 2021 08:19 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
Accessing species thermo data in OF 1.6 | dominik_christ | OpenFOAM Programming & Development | 0 | August 16, 2009 05:02 |
How to update polyPatchbs localPoints | liu | OpenFOAM Running, Solving & CFD | 6 | December 30, 2005 18:27 |
Accessing solution data in UDF | Ale | FLUENT | 1 | June 12, 2002 01:25 |