|
[Sponsors] |
March 25, 2017, 09:59 |
Including PETSc in an OF solver
|
#1 |
New Member
Basel Abu-sinni
Join Date: Mar 2017
Posts: 6
Rep Power: 9 |
Hello friends,
I'd like to include PETSc's headers in my solver but I can't figure out how to make it compile. A PETSc program's makefile is as follows: Code:
include ${PETSC_DIR}/lib/petsc/conf/variables include ${PETSC_DIR}/lib/petsc/conf/rules all: src/LinearSystemSolver.o chkopts -${CLINKER} -o LinearSystemSolver src/LinearSystemSolver.o ${PETSC_KSP_LIB} ${RM} LinearSystemSolver.o 'options': Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = -lfiniteVolume \ -lmeshTools Code:
myLaplacianFoam.C EXE = App/myLaplacianFoam I appreciate your time and thanks in advance! Basel |
|
April 1, 2019, 22:28 |
|
#2 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Hi Basel,
I am trying to do the same thing. Have you been able to link petsc with your solver? |
|
April 1, 2019, 23:41 |
|
#3 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
For someone who might need the answer, I was able to link the icoFoam solver with petsc by doing the following steps:
Note: I am using petsc-3.4.5 and it is installed in my /home directory. 1. Create a shared library of petsc by invoking the following command from any directory in the PETSc source Code:
make BOPT=O shared 2. Include petsc.h into icoFoam.C Code:
#include "petsc.h" Code:
PETSC_DIR=$(HOME)/petsc/petsc-3.4.5 EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(PETSC_DIR)/include \ -I$(PETSC_DIR)/include/mpiuni \ -I$(PETSC_DIR)/$(PETSC_ARCH)/include EXE_LIBS = \ -lfiniteVolume \ -lmeshTools \ -L$(PETSC_DIR)/$(PETSC_ARCH)/lib -lpetsc Code:
export PETSC_ARCH=arch-linux-cxx-opt wmake Hope this can helps |
|
April 10, 2019, 05:04 |
|
#4 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
I am sorry, eventhough the solver was successfully compiled, it does not work.
The error is that libpetsc.so could not be found, even though it is still exist in my $PETSC_ARCH/lib directory: Code:
icoPetscFoam: error while loading shared libraries: libpetsc.so: cannot open shared object file: No such file or directory |
|
April 10, 2019, 21:24 |
|
#5 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Problem solved!
Just need to define the LD_LIBRARY_PATH environmental variable in $HOME/.bashrc Code:
echo "export LD_LIBRARY_PATH=\$PETSC_DIR/\$PETSC_ARCH/lib">>$HOME/.bashrc |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Radiation Modeling Using Discrete Ordinates Method and Parallel Solver | malicemethods | FLUENT | 3 | May 25, 2018 15:25 |
Star cd es-ice solver error | ernarasimman | STAR-CD | 2 | September 12, 2014 01:01 |
thobois class engineTopoChangerMesh error | Peter_600 | OpenFOAM | 4 | August 2, 2014 10:52 |
Parallel solver for Poisson equation using PETSc | JackNapier | Main CFD Forum | 0 | July 5, 2012 17:53 |
why the solver reject it? Anyone with experience? | bearcat | CFX | 6 | April 28, 2008 15:08 |