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

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

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By tomislav_maric

Reply
 
LinkBack Thread Tools Display Modes
Old   February 10, 2015, 10: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, 07:21
Default
  #2
Senior Member
 
Blanco
Join Date: Mar 2009
Location: Torino, Italy
Posts: 158
Rep Power: 10
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, 04:56
Default
  #3
Senior Member
 
Join Date: Jul 2011
Posts: 109
Rep Power: 8
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, 05:36
Default
  #4
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 281
Blog Entries: 5
Rep Power: 13
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?
rafa13 and Radunz like this.
__________________
Blog: sourceflux.de/blog
Trainings: sourceflux.de/services/training
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de

When asking a question, prepare a SSCCE.
tomislav_maric is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
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 22:25
parallel running - error while loading shared libraries: seami OpenFOAM Installation 1 December 9, 2011 05: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 08:09.