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

Dlopen vs foamUser for 141

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 20, 2007, 11:22
Default In the release notes of 1.4.1,
  #1
egp
Senior Member
 
egp's Avatar
 
Eric Paterson
Join Date: Mar 2009
Location: Blacksburg, VA
Posts: 197
Blog Entries: 1
Rep Power: 18
egp is on a distinguished road
In the release notes of 1.4.1, there is a note about foamUser being replaced,

"foamUser and foamUtil libraries replaced by the more general dlopen method in which any libraries may be included at run-time using the optional 'libs' entry in the case controlDict, e.g. to replicate previous automatic inclusion of the foamUser and foamUtil libraries include libs ("libfoamUser.so" "libfoamUtil.so"); in controlDict."

This is a bit too cryptic for me, and unfortunately, section 3.2.6 of the 1.4.1 userGuide (dated 1 Aug 2007) has not been updated to reflect this change.

As such, does anyone have an example of how to use dlopen to link in a user library? I looked on the wiki, and no luck. A nice example of a new boundary condition, or something similar, would be cool.

Thanks, Eric
egp is offline   Reply With Quote

Old   August 20, 2007, 12:07
Default Hello Eric, There are two e
  #2
Senior Member
 
Martin Beaudoin
Join Date: Mar 2009
Posts: 332
Rep Power: 22
mbeaudoin will become famous soon enough
Hello Eric,

There are two examples in the tutorials directory that explicitly use the dlopen mechanism in the controlDict file:

$FOAM_TUTORIALS/simpleFoam/pitzDaily/system/controlDict
$FOAM_TUTORIALS/oodles/pitzDaily/system/controlDict

I am still exploring this part of OF 1.4.1, so I cannot help you a whole lot more than this for now.

But since we are still using the foamUser trick for loading and using our own development with OF, I guess we will have to adjust as well ..

Martin
mbeaudoin is offline   Reply With Quote

Old   August 20, 2007, 12:59
Default Hi Martin, I don't see the
  #3
egp
Senior Member
 
egp's Avatar
 
Eric Paterson
Join Date: Mar 2009
Location: Blacksburg, VA
Posts: 197
Blog Entries: 1
Rep Power: 18
egp is on a distinguished road
Hi Martin,

I don't see the dlopen mechanism being used in either of these cases. For the simpleFoam/pitzDaily example, it looks unchanged from earlier versions. For oodles/pitzDaily, controlDict has been modified to use the probe interface of 1.4.1.

Am I missing something? I was expecting to see a "libs" entry in controlDict with options.

Eric
egp is offline   Reply With Quote

Old   August 20, 2007, 13:12
Default What happens if you add li
  #4
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
What happens if you add

libs ("libXXXX.so");

to your controlDict?

where libXXXX.so is your library. When it loads the libraries it (dlopen) will call any static constructors. This is the mechanism used in the OpenFOAM libraries for most user settings (turbulence models, discretisation schemes etc.) so if you stick to that framework it should work.

But then this all is no different from linking in libraries during link time.
mattijs is offline   Reply With Quote

Old   August 20, 2007, 13:25
Default Hi Eric! For a vanilla case
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Eric!

For a vanilla case, the libs-mechanism shouldn't make any difference (using only stock-turbulence-models etc).
Havn't any experience with this implementation, but it seems to me, that libs obsoletes
http://openfoamwiki.net/index.php/Contrib_plugInPatch
(in earlier versions of OF, if you wanted to introduce your own boundary conditions/turbulence models/etc to a unmodified solver you had to include them all in the sources of the foamUser-library, now you can mix and match theCrazyTurbulenceModelHugoSentMe.so with myPersonalBoundaryConditionsForSinkingShips.so in earlier versions you had to include myPersonalBoundaryConditionsForSinkingShips.C and theCrazyTurbulenceModelHugoSentMe.C into the sources for foamUser.so and if they contradicted sigournysBoundaryConditionsForSinkingShips.C you were in deep trouble)

Anyway. This is mostly of interest for those who program (or use) run-time-selectable models (turbulence, boundary conditions) that are not part of the OF-distribution.

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 20, 2007, 13:37
Default Hi Eric, Sorry, my mistake
  #6
Senior Member
 
Martin Beaudoin
Join Date: Mar 2009
Posts: 332
Rep Power: 22
mbeaudoin will become famous soon enough
Hi Eric,

Sorry, my mistake about the simpleFoam/pitzDaily example, you are quite right.

But in $FOAM_TUTORIALS/oodles/pitzDaily/system/controlDict, there is an entry that looks like this in the probe interface:

functionObjectLibs ("libsampling.so");

I would think that this is the way to dynamically load the library libsampling.so at runtime with your simulation.


Now, what would be the proper syntax for simply loading your libfoamUser_version_xyz.so library instead, I don't know yet. Maybe someone from this forum could quickly provide you with a simple example?

As a side note, I sure hope that the usage of libfoamUser.so will remain as a default mechanism for loading libraries in OpenFOAM because otherwise, we will have to modify a lot of controlDict files in our different simulations in order to plug our code back in.

Martin
mbeaudoin is offline   Reply With Quote

Old   August 20, 2007, 16:59
Default Perhaps there might be a means
  #7
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Perhaps there might be a means of tapping into the Debug mechanism with something like the following hand-waving:

dictionary& debug::controlDict()
{
if (!controlDictPtr_)
{
...
dlLibraryTable::readDlLibrary foo(*controlDictPtr_, "libs");
}

return *controlDictPtr_;
}
olesen 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
FoamUser and steady STOCKES Lam Main CFD Forum 0 June 8, 2007 04:20
Undefined reference dlopen dlerror fred OpenFOAM Installation 0 July 19, 2006 02:00


All times are GMT -4. The time now is 18:53.