Skip to content

Building

Gerasimos Chourdakis edited this page Jun 23, 2018 · 26 revisions

To build the adapter, you need to install a few dependencies and then execute the Allwmake script.

  1. Download the adapter or (better) install git and clone this repository: git clone https://github.com/precice/openfoam-adapter.git.
  2. Install the latest yaml-cpp headers and shared library, preferably from your Linux distribution's repository. (at least yaml-cpp 0.5.x)
    • If you use Boost >= 1.67, you also need yaml-cpp >= 0.6 (read more here).
    • If you are using Ubuntu (and Boost < 1.67), you are looking for the package libyaml-cpp-dev. For example, run sudo apt install libyaml-cpp-dev.
    • If you want to build yaml-cpp from source, you need to build it as a shared library (cmake -DBUILD_SHARED_LIBS=ON). You also need to set it in your CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH:
      export CPLUS_INCLUDE_PATH="path/to/yaml-cpp/include:${CPLUS_INCLUDE_PATH}"
      export LD_LIBRARY_PATH="path/to/yaml-cpp/build:${LD_LIBRARY_PATH}"
      
  3. Install the preCICE headers and library, following its building instructions.
    • If you want to use preCICE as a static library, check and adjust its dependencies in Allwmake (ADAPTER_PRECICE_DEP).
  4. Install an OpenFOAM distribution. For example, read the instructions for openfoam.org on Ubuntu. See also the sections "User Configuration" and "Getting Started". Read more in Notes on OpenFOAM.
  5. Execute the build script: ./Allwmake.
    • See and adjust the configuration in the beginning of the script first, if needed.
    • If everything goes well, you will receive a success message.
    • If you receive a message that there were undefined symbols, this probably means that you used preCICE as a static library, but you didn't specify its dependencies correctly.
    • In any case, make sure that your OpenFOAM environment is loaded correctly (e.g. see the WM_PROJECT_VERSION value in the beginning of the Allwmake output).

Note: If any dependencies are not installed in the standard system paths, the locations of their headers need to be specified in the CPLUS_INCLUDE_PATH and of their libraries in the LIBRARY_PATH or LD_LIBRARY_PATH.

The -DADAPTER_DEBUG_MODE flag inside ADAPTER_PREP_FLAGS activates additional debug messages. You may also change the target directory or specify the number of threads to use for the compilation. See the comments in Allwmake for more.

In order to upgrade the adapter, or before you build for another OpenFOAM version, run ./Allclean first. Get the latest version using git pull.

Next: configure and load the adapter or run a tutorial.

Troubleshooting

The following are common problems that may appear during building the OpenFOAM adapter if something went wrong in the described steps. Make sure to always check for error messages at every step before continuing to the next.

The Allwmake script prints the environment variables it uses in the beginning and it writes the building commands in the file wmake.log. Afterwards, it checks (using ldd) if the library was linked correctly and writes the output to ldd.log. Please check these files and send them to us through Gitter if you have need help.

The most important information in these files is the -I and -L flags used during compilation and linking.

Unknown function type preciceAdapterFunctionObject

If in the beginning of the simulation you get the following warning:

Starting time loop
 
 --> FOAM Warning :
     From function void* Foam::dlOpen(const Foam::fileName&, bool)
     in file POSIX.C at line 1604
     dlopen error : libprecice.so: cannot open shared object file: No such file or directory
 --> FOAM Warning :
     From function bool Foam::dlLibraryTable::open(const Foam::fileName&, bool)
     in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 105
     **could not load "libpreciceAdapterFunctionObject.so"**
 --> FOAM Warning :
     From function bool Foam::dlLibraryTable::open(const Foam::dictionary&, const Foam::word&, const TablePtr&) [with TablePtr = Foam::HashTable<Foam::autoPtr<Foam::functionObject> (*)(const Foam::word&, const Foam::Time&, const Foam::dictionary&), Foam::word, Foam:     :string::hash>*]
     in file lnInclude/dlLibraryTableTemplates.C at line 62
     Could not open library "libpreciceAdapterFunctionObject.so"
 
 --> FOAM Warning :
 Unknown function type preciceAdapterFunctionObject

then this probably means that something went wrong during the building of the OpenFOAM adapter. Check the files wmake.log and ldd.log. Note that the simulation will continue without loading the adapter, but there will be no coupling.

wmkdep: could not open file X

This is an info/warning message that is printed when WMake tries to distinguish between the object files it already has (and can save time by not recompiling them) and the files it needs to compile. You can safely ignore this message.

A header file cannot be found (during compilation)

This is a common problem e.g. when installing dependencies in non-system directories. Make sure to follow the steps described to add your paths to CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH.

Boost-related errors

Make sure to install a Boost version compatible with your yaml-cpp version (see the building instructions).

Rellocation-related errors

Make sure to build both preCICE and yaml-cpp as a shared library (i.e. .so, not .a).