CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Linking ALGLIB to OpenFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/89963-linking-alglib-openfoam.html)

Phicau June 27, 2011 13:02

Linking ALGLIB to OpenFOAM
 
Hi,

I've been doing some BC programming and now I got to the point where I need specific functions, not implemented in OpenFOAM.

My goal is to make cnoidal waves, and as a result I need complete elliptic integrals and so on.

My intention is to use existing code instead of having to program the functions if possible. I found a C++ (and more) library with all the functions I need which is called ALGLIB, so I tried linking it to my BC file:

Code:

#include "specialfunctions.h"

...

KElliptic = alglib::ellipticintegralk(mElliptic);

It compiles with a couple of minor warnings, but when I get to run the model and it reaches that line of code the simulation stops and I get the following error:

Code:

interFoam: symbol lookup error: /home/phicau/OpenFOAM/phicau-1.7.1/lib/linux64GccDPOpt/libIHWavesAlpha.so: undefined symbol: _ZN6alglib17ellipticintegralkEd
Any thoughts on how to make it work?

Thanks in advance

Pablo

cosimobianchini June 28, 2011 04:27

Hi Picau,
I also encurred in the need for linking the alglib libraries to some applications in OpenFOAM.
In particular I included the ap.h and the matinv.h headers in the source code of my application and add the reference to the alglib source files and to the object in the Make/options file as follows:

EXE_INC = \
-I$(LIB_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I/usr/local/src/alglib/cpp/out

EXE_LIBS = \
$(FOAM_LIBBIN)/postCalc.o \
-L/usr/local/src/alglib/cpp/out/ -lalglib \
-lfiniteVolume

Hope you find this helpful

Phicau June 28, 2011 13:40

Hey thanks a lot! Things are easier now:

Fool of me I did not include all the files I needed, since you have to include both the .h and .cpp on the header, so to make "specialfunctions" to work you just need the following includes:

Code:

#include "./cpp/src/specialfunctions.h"
#include "./cpp/src/ap.h"
#include "./cpp/src/alglibinternal.h"

#include "./cpp/src/specialfunctions.cpp"
#include "./cpp/src/ap.cpp"
#include "./cpp/src/alglibinternal.cpp"

Piece of cake

Betsy January 11, 2012 16:52

Quote:

Originally Posted by Phicau (Post 313761)
Hi,

I've been doing some BC programming and now I got to the point where I need specific functions, not implemented in OpenFOAM.

My goal is to make cnoidal waves, and as a result I need complete elliptic integrals and so on.

My intention is to use existing code instead of having to program the functions if possible. I found a C++ (and more) library with all the functions I need which is called ALGLIB, so I tried linking it to my BC file:

Code:

#include "specialfunctions.h"

...

KElliptic = alglib::ellipticintegralk(mElliptic);

It compiles with a couple of minor warnings, but when I get to run the model and it reaches that line of code the simulation stops and I get the following error:

Code:

interFoam: symbol lookup error: /home/phicau/OpenFOAM/phicau-1.7.1/lib/linux64GccDPOpt/libIHWavesAlpha.so: undefined symbol: _ZN6alglib17ellipticintegralkEd
Any thoughts on how to make it work?

Thanks in advance

Pablo

Hi Pablo - were you able to successfully create cnoidal waves in OF? If so, do you mind sharing your code?
Thanks,
Betsy

Phicau January 11, 2012 17:07

Hi

yes I currently have a boundary condition that generates cnoidal waves along with several other theories, and includes simultaneous active wave absorption.

However I am in the process of publishing a couple of papers and I cannot give further details for the moment. As soon as the papers are in press I will give some references. I still don't know if the BC code will be available in the future, but I hope it will.

Regards

ngj January 12, 2012 02:45

Hi Betsy

You might find the following toolbox interesting:

http://openfoamwiki.net/index.php/Contrib/waves2Foam

(Please note that I make commercial for my own work). The toolbox includes a method for generating cnoidal waves.

Kind regards,

Niels

Betsy January 12, 2012 16:15

Thanks Pablo and Niels for the references, I will take a look at these.
Betsy


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