CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to have access a variable from (LIB_SRC) for main solver

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Mehdi3031

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2016, 10:48
Default How to have access a variable from (LIB_SRC) for main solver
  #1
New Member
 
Ehsan
Join Date: Aug 2010
Location: QC, Canada
Posts: 29
Rep Power: 15
ehsan_am86 is on a distinguished road
Hi dear foamers,

I have recently developed my population balance model for gas-liquid flow in OpenFOAM 2.3 but I am not able to couple it to other equations inside main solver.

In fact, I have mentioned the relevant header files regarding to my library, but I got error like this:

error: ‘d32_’ was not declared in this scope

In spite of including relevant header files in main source file and definition d32_ , I got this bug.

In other words, I am interested in using my variable calculated by my own library, inside other solver.

Thank you very much for helping a beginner user in OpenFOAM in advance.

Please save me!
ehsan_am86 is offline   Reply With Quote

Old   April 5, 2016, 13:13
Default
  #2
Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 35
Rep Power: 10
Mehdi3031 is on a distinguished road
To be honest the explanation is not sufficient at all, you should be more clear with the case/solver name and files being modified etc.

But in concern of using an external file in your mainfun.C of your solver, beside declaring (#include) the name in the
mainfun.C, you should give the path to access that function also in the Make/options file of the solver, did you do that?
as an example, the solver reactingFoam.C that has this header:
#include "psiCombustionModel.H"
which, its path is given in Make/options file of the solver as:
EXE_INC = \
...
-I$(LIB_SRC)/combustionModels/lnInclude
...
EXE_LIBS = \
...
-lcombustionModels
...

I am not sure if this was your issue, But I hope that it helps.

Regards
Mehdi
Mehdi3031 is offline   Reply With Quote

Old   April 5, 2016, 13:56
Default
  #3
New Member
 
Ehsan
Join Date: Aug 2010
Location: QC, Canada
Posts: 29
Rep Power: 15
ehsan_am86 is on a distinguished road
Quote:
Originally Posted by Mehdi3031 View Post
To be honest the explanation is not sufficient at all, you should be more clear with the case/solver name and files being modified etc.

But in concern of using an external file in your mainfun.C of your solver, beside declaring (#include) the name in the
mainfun.C, you should give the path to access that function also in the Make/options file of the solver, did you do that?
as an example, the solver reactingFoam.C that has this header:
#include "psiCombustionModel.H"
which, its path is given in Make/options file of the solver as:
EXE_INC = \
...
-I$(LIB_SRC)/combustionModels/lnInclude
...
EXE_LIBS = \
...
-lcombustionModels
...

I am not sure if this was your issue, But I hope that it helps.

Regards
Mehdi
Thank you Dear Mehdi for answer and sorry about lack of good description.

In fact, I have modified make/options file as follows:

EXE_INC = \
-I../twoPhaseSystem \
-I../interfacialModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \
-I$(LIB_SRC)/populationModels/lnInclude

LIB_LIBS = \
-lincompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-lpopulationModels

Let me explain the problem more clear.

Honestly, the populationModels (costume library) has truly compiled but there is function named: correct() which as follows:


void classMethod::correct()
{
....
....
....
classMethod::adjust(source,f,alpha);

// update Sauter diameter d32, relax and correct BC
d32_ = SauterDiameter(f,alpha);
d32_.relax();
d32_.correctBoundaryConditions();
}

I need to have this d32_ in my main solver. As it is observed, it is inside a function of costume library.

Now, the solver and library is working together but they are not coupled with each other.

I believe that it is required to define a variable and store d32_ on that. And finally, use that in main solver where I need to call that. Do you think am I right?

Thank you in advance
ehsan_am86 is offline   Reply With Quote

Old   April 5, 2016, 15:15
Default
  #4
Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 35
Rep Power: 10
Mehdi3031 is on a distinguished road
Ok, first of all, if this library of "populationModels" is a costume library that u developed or took from somewhere, it is highly recommended not to put and compile it in the main path of OpenFoam!($WM_PROJECT_DIR/src) but in the USER path ($WM_PROJECT_USER_DIR/src) ; in this way you'll never mess with the main solver if you are a new user like me, unless you really know what you doing, then feel free...

For the answer, Honestly I am also a new user, so for sure what I suggest wont be the best way!
about what you suggest, my point is that where do you want to define this new variable to store d32 in it?? inside the custom library? if your solver could see that, then it could see directly the d32 itself, no?
I THINK, one way maybe to make a intermediate library (super small and short) which both the custom library and solver can have access to it, and use it. then use this new library as a platform where it has a "setter" and "getter" function that once you'll call the setter in the custom library and pas the value of d32 to it and then you'll call the getter function in the solver to take back the stored value of d32!

Honestly, not sure if it will work, but based on my basic knowledge in C++ and OpenFoam, this is the best I could come up with...
I hope it would help you and let me know please if you managed to solve it.

Cheers
Mehdi
ehsan_am86 likes this.
Mehdi3031 is offline   Reply With Quote

Old   April 5, 2016, 15:52
Default
  #5
New Member
 
Ehsan
Join Date: Aug 2010
Location: QC, Canada
Posts: 29
Rep Power: 15
ehsan_am86 is on a distinguished road
Quote:
Originally Posted by Mehdi3031 View Post
Ok, first of all, if this library of "populationModels" is a costume library that u developed or took from somewhere, it is highly recommended not to put and compile it in the main path of OpenFoam!($WM_PROJECT_DIR/src) but in the USER path ($WM_PROJECT_USER_DIR/src) ; in this way you'll never mess with the main solver if you are a new user like me, unless you really know what you doing, then feel free...

For the answer, Honestly I am also a new user, so for sure what I suggest wont be the best way!
about what you suggest, my point is that where do you want to define this new variable to store d32 in it?? inside the custom library? if your solver could see that, then it could see directly the d32 itself, no?
I THINK, one way maybe to make a intermediate library (super small and short) which both the custom library and solver can have access to it, and use it. then use this new library as a platform where it has a "setter" and "getter" function that once you'll call the setter in the custom library and pas the value of d32 to it and then you'll call the getter function in the solver to take back the stored value of d32!

Honestly, not sure if it will work, but based on my basic knowledge in C++ and OpenFoam, this is the best I could come up with...
I hope it would help you and let me know please if you managed to solve it.

Cheers
Mehdi
Dear Mehdi,

Such a nice suggestion!

I ll try it and I ll post it here if it is worked.

In order to understand better and write this short library, do you know any example for doing that?

I think I got your main point about that, but I am wondering how I could write that. Maybe, a similar library could help me better.

Anyway, thanks a lot for your useful and helpful comments.
ehsan_am86 is offline   Reply With Quote

Old   April 5, 2016, 16:38
Default
  #6
Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 35
Rep Power: 10
Mehdi3031 is on a distinguished road
Not really, Sorry, as I said I am very new to C++.
In FORTRAN it can be done by having a Module.f90 file and then you declare the function setter() and function getter() in that module.
Look for it online, should be something like a class or template in C++! No idea...
Good luck!
Mehdi3031 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access orientation tensor from top-level of solver? clarence_carter OpenFOAM Programming & Development 0 October 10, 2014 09:28
Star cd es-ice solver error ernarasimman STAR-CD 2 September 12, 2014 00:01
Solver STOP with a variable Roland R CFX 3 March 10, 2010 18:38
Error : access : Unknown variable & Phase-domain MKP FLUENT 0 August 28, 2006 03:40
CFX 5.5 Roued CFX 1 October 2, 2001 16:49


All times are GMT -4. The time now is 05:30.