preCICE Initialization error

I was trying to couple an IB code with preCICE and added the following code:

#include “precice/SolverInterface.hpp”

int rank = 0;
int size = 1;
precice::SolverInterface precice(“FluidSolver”,“precice-config.xml”,rank,size);

double dt; // solver timestep size
double precice_dt; // maximum precice timestep size

precice_dt = precice.initialize();

However, it gives an initialization error:

/opt/apps/gcc/9.4.0/bin/ld: IBFoam.C:(.text+0x30b6): undefined reference to precice::SolverInterface::initialize()' /opt/apps/gcc/9.4.0/bin/ld: IBFoam.C:(.text+0x5fb8): undefined reference to precice::SolverInterface::~SolverInterface()’
/opt/apps/gcc/9.4.0/bin/ld: IBFoam.C:(.text+0x9306): undefined reference to `precice::SolverInterface::~SolverInterface()’
make: *** [/work/07083/kk0551/OpenFOAM/OpenFOAM-v2112/wmake/makefiles/general:150: /work/07083/kk0551/OpenFOAM/OpenFOAM-v2112/platforms/linux64IccDPInt64Opt/bin/ibFoam] Error 1

Could someone please elaborate on the meaning of rank and size and the reason for the generation of this error?

Would appreciate any help

The error you are getting is:

undefined reference to precice::SolverInterface::initialize()

this is originating from the linker: /opt/apps/gcc/9.4.0/bin/ld

Most probably, this means that you have not linked to preCICE when building your code. Usually, one needs to provide a -lprecice flag to the compiler/Makefile (together with a -L/path/to/precice).

These have to do with parallel simulations. rank is “which process am I?” and size is “how many processes are we, in total?”. 0 and 1 are the values you need for serial simulations.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.