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

How to get access to the functions inside the shared libraries in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 6 Post By tomislav_maric

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 10, 2015, 09:24
Default How to get access to the functions inside the shared libraries in OpenFOAM
  #1
New Member
 
Mohsen Ranjbaran
Join Date: Feb 2015
Posts: 1
Rep Power: 0
mohsenCFDonline is on a distinguished road
Dear all
Does anyone knows how I can get access to the functions inside the shared libraries (.so) in OpenFOAM?

Regards
Mohsen
mohsenCFDonline is offline   Reply With Quote

Old   February 11, 2015, 06:21
Default
  #2
Senior Member
 
Blanco
Join Date: Mar 2009
Location: Torino, Italy
Posts: 193
Rep Power: 17
Blanco is on a distinguished road
Yes, you can find the source of the lib under the src dir.
Use this as an example:

Code:
grep -R libforces.so $FOAM_SRC
You will get many results that can be used to identify "where" is the source code for libforces.so (in this case src/postProcessing/functionObjects/forces)

Regards
Blanco is offline   Reply With Quote

Old   March 25, 2015, 03:56
Default
  #3
Senior Member
 
Join Date: Jul 2011
Posts: 120
Rep Power: 14
haze_1986 is on a distinguished road
Hi, I think he meant accessing variables of the objects created in the libraries?
haze_1986 is offline   Reply With Quote

Old   March 25, 2015, 04:36
Default
  #4
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
A library is a bunch of object code, containing the translation of the C++ we humans write to machine language. Basically, every OpenFOAM utility accesses library functions, whose implementation is stored in the .so file.

If you are writing your utility, all you need to do is to include the header:

Code:
#include "someClass.H"
use the library in the utiliity application

Code:
someClass someObject; 

someObject.someMemberFunction();
And that is it. The linker program will take care of linking your utility application with the appropriate .so object file. That is why you need to edit `Make/options` and provide something along these lines:

Code:
-I/path/to/library/lnInclude


-L/path/to/library/file
-lsomeLibrary
In order for `wmake` to tell the linker where the library file is located, and set up the compiler to know where to find `someLibrary.H`.

If you are using function objects, you will be doing this automatically. Still, you need to add something like `functionObjectsLibs ("libsomeLibrary.so")` in the control dict.

Btw, what exactly do you want to do?
Elham, rafa13, elmo555 and 3 others like this.
__________________
When asking a question, prepare a SSCCE.
tomislav_maric 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
time functions in openFoam? cyberbrain OpenFOAM Running, Solving & CFD 6 November 2, 2015 21:25
parallel running - error while loading shared libraries: seami OpenFOAM Installation 1 December 9, 2011 04:39
Access source code of OpenFOAM nmansouri OpenFOAM 1 October 14, 2010 02:17
Can't profile shared libraries rsamuel OpenFOAM Programming & Development 1 August 3, 2009 09:58
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07


All times are GMT -4. The time now is 00:23.