|
[Sponsors] |
December 10, 2023, 10:18 |
What's the Eigen library setup for OpenFOAM?
|
#1 |
Senior Member
Klaus
Join Date: Mar 2009
Posts: 281
Rep Power: 22 |
I want to use the Eigen header file library in an OpenFOAM preconditioner but I keep getting compiler errors telling me, that Eigen is not found.
Eigen is "installed" i.e. header files are located in the directory: /home/klaus/Programme/eigen-3.4.0/Eigen I added the Eigen3_ROOT to the .bashrc and rebooted as shown below Code:
# set Eigen3_ROOT export Eigen3_ROOT=/home/klaus/Programme/eigen-3.4.0 Code:
#include <Eigen/Sparse> Online instructions tell me to add Code:
EXTERNAL_LIBS += -lEigen3 Code:
MYPreconditioner.C:32:10: Fatal error: Eigen/: File or directory not found 32 | #include <Eigen/Sparse> Eigen can be found at: HTML Code:
https://eigen.tuxfamily.org/index.php?title=Main_Page E.g. how to adjust the Make/options file: Code:
EXE_INC = \ -I$(OBJECTS_DIR) LIB_LIBS = \ $(FOAM_LIBBIN)/libOSspecific.o ifeq (libo,$(FOAM_LINK_DUMMY_PSTREAM)) LIB_LIBS += $(FOAM_LIBBIN)/dummy/libPstream.o else LIB_LIBS += -L$(FOAM_LIBBIN)/dummy -lPstream endif /* libz */ EXE_INC += -DHAVE_LIBZ LIB_LIBS += -lz /* Project lib dependencies. Never self-link (WM_PROJECT == OpenFOAM) */ PROJECT_LIBS = |
|
December 11, 2023, 15:14 |
|
#2 |
Senior Member
|
1/ Distinguish between compile and link stage.
2/ For compile stage: -I<dir> where <dir> is the directory where header files are located. 3/ For link stage: -L<dir> where <dir> is the directory where library files are located. |
|
December 12, 2023, 16:06 |
|
#3 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
Typically you would try something like "sh wmake/scripts/have_eigen -test" from the command-line to see how things work (or not). If you take a look through the file, you will see that it also likes to find its preferences via config.sh/eigen file, where it possibly obtains an EIGEN_ARCH_PATH. If this detection works OK, then you would add this detection in an src/OpenFOAM/Allwmake script (you need inject this yourself) and then pass through (see src/renumber/Allwmake for an example). Of course, you could also just define it all yourself in the OpenFOAM/Make/options (might actually be easier). For example (not tested): OpenFOAM/Make/options Code:
EXE_INC = \ -I$(OBJECTS_DIR) ifneq (,$(Eigen3_ROOT)) EXE_INC += -DHAVE_EIGEN -I$(Eigen3_ROOT)/include endif ... |
||
December 12, 2023, 17:37 |
|
#4 |
Senior Member
Klaus
Join Date: Mar 2009
Posts: 281
Rep Power: 22 |
I followed the setup for an OpenFOAM solver I found online:
Add the following to the .bashrc file: Code:
# set Eigen3_ROOT and EIGEN_LIBRARY_PATH export Eigen3_ROOT=$HOME/Programme/eigen-3.4.0 export EIGEN_LIBRARY_PATH=$HOME/Programme/eigen-3.4.0 Code:
EXE_INC = \ -I$(OBJECTS_DIR) \ -I$(EIGEN_LIBRARY_PATH) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Duplicate library entries when running a solver with custom library | francescomarra | OpenFOAM Programming & Development | 3 | May 17, 2022 09:37 |
[OpenFOAM.com] Compiling Scotch library error | fedez91 | OpenFOAM Installation | 6 | March 3, 2022 00:25 |
[Other] Multi species mass transport library [update] | novyno | OpenFOAM Community Contributions | 111 | November 10, 2021 00:37 |
Unable to use .so library in other folder than in $FOAM_USER_LIBBIN | Saideep | OpenFOAM Programming & Development | 1 | September 15, 2021 10:22 |
[swak4Foam] Installing swak4Foam to OpenFOAM in mac | Kaquesang | OpenFOAM Community Contributions | 22 | January 21, 2013 12:51 |