Hello 👋!
I've been trying to install the preCICE library and its adapter for OpenFOAM but did not succeed. I followed this guide for installing the library itself and this other for the adapter. I suspect that I'm not building correctly either Boost
or yaml-cpp
.
I'm using:
-
Ubuntu 16.04 LTS
-
OpenFOAMv17.12
Regarding the installation of the library I did the following:
# Installation script for preCICE on Ubuntu 16.04
# 1.- Install the required dependencies and make sure your environment is
# set appropriately (e.g. open a new terminal).
# 1.1: Install all the available dependencies through APT:
sudo apt install -y build-essential scons libeigen3-dev
sudo apt install -y libxml2-dev petsc-dev python-dev python-numpy
# 1.2: Install Boost. In the Ubuntu 16.04 repositories, only Boost 1.58
# is avaiable, in which the VMD library is missing. Building Boost 1.66
# from source.
# 1.2.1: Download and extract Boost into any directory. Switch to that
# directory.
wget --no-check-certificate https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0_rc2.tar.gz
tar -xvf "boost_1_66_rc2.tar.gz" > log.Boost-tar
rm boost_1_66_rc2.tar.gz
cd boost_*
# 1.2.2: Prepare the installation, selecting only the libraries that need
# to be built (this does not affect the header-only libraries). We will
# later move these files to the system directory /usr/local. Execute:
./bootstrap.sh --with-libraries=log,thread,system,filesystem,program_options,test --prefix=/usr/local > log.Boost-install1
# 1.2.3: Install the libraries. Since /usr/local is a system directory,
# we need root access:
sudo ./b2 -j 12 install > log.Boost-install2
# 1.2.4: Update the dynamic linker's run-time bindings:
sudo ldconfig
cd ..
# 1.3: Add the following in your ~/.bashrc:
echo "# Eigen" >> ~/.bashrc
echo "export CPLUS_INCLUDE_PATH="/usr/include/eigen3:$CPLUS_INCLUDE_PATH"" >> ~/.bashrc
echo "# PETSc" >> ~/.bashrc
echo "export PETSC_DIR=/usr/lib/petscdir/3.6.2/" >> ~/.bashrc
echo "export PETSC_ARCH=x86_64-linux-gnu-real" >> ~/.bashrc
source ~/.bashrc
# 2.- Download and unpack the latest release of preCICE:
wget --no-check-certificate https://github.com/precice/precice/archive/v1.1.1.tar.gz
tar -xzvf v1.1.1.tar.gz > log.preCICE-tar
rm v1.1.1.tar.gz
cd precice-1.1.1
# 3.- This directory is your PRECICE_ROOT. Get the absolute path with pwd
# and add it in your environment:
path=$PWD
echo "# preCICE" >> ~/.bashrc
echo "export PRECICE_ROOT="$path"" >> ~/.bashrc
source ~/.bashrc
# 4.- Use SCons to build preCICE without the tests target:
scons petsc=yes python=no -j 12 solib symlink > log.preCICE-build
# 5.- After building succesfully
# 5.1: Did NOT run the tests
# 5.2: Add $PRECICE_ROOT/build/last to your dynamic library path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PRECICE_ROOT/build/last/
And got no errors, everything seemed fine to me. Regarding the adapter I did the following:
# 1.- Clone the adapter from github
git clone https://github.com/precice/openfoam-adapter.git
cd openfoam-adapter
# 2.- Install the latest yaml-cpp headers and shared library from the
# distribution's repository
sudo apt-get install -y libyaml-cpp-dev
# Install the preCICE headers and library:
./installPreCICE.sh
# 5.- Execute the build script ./Allwmake
./Allwmake
The build seemed ok and the tutorial case ran, but there was no heat exchange between the fluid and the solid. Upon close inspection of Fluid.log
I found this:
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
Valid function types :
7
(
patchProbes
probes
psiReactionThermoMoleFractions
rhoReactionThermoMoleFractions
sets
surfMeshes
surfaces
)
From function static Foam::autoPtr<Foam::functionObject> Foam::functionObject::New(const Foam::word&, const Foam::Time&, const Foam::dictionary&)
in file db/functionObjects/functionObject/functionObject.C at line 107.
From function bool Foam::functionObjectList::read()
in file db/functionObjects/functionObjectList/functionObjectList.C at line 840
Then, I rebuilt the adapter (./Allclean
and ./Allwmake
) and stored the output in a log file:
Compiling enabled on 12 cores
wmake libso (openfoam-adapter-master)
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file preciceAdapterFunctionObject.C
Making dependency list for source file Adapter.C
Making dependency list for source file CHT.C
Making dependency list for source file SinkTemperature.C
Making dependency list for source file HeatTransferCoefficient.C
Making dependency list for source file HeatFlux.C
Making dependency list for source file KappaEffective.C
Making dependency list for source file Temperature.C
Making dependency list for source file CouplingDataUser.C
Making dependency list for source file Interface.C
Making dependency list for source file Utilities.C
wmkdep: could not open file 'yaml-cpp/yaml.h' for source file 'Adapter.C'wmkdep: could not open **file 'yaml-cpp/yaml.h' for source file 'CHT/CHT.C': No such file or directory: No such file or directory**
wmkdep: could not open file 'yaml-cpp/yaml.h' for source file 'preciceAdapterFunctionObject.C': No such file or directory
g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1712 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I/home/andreuber nadserra/OpenFOAM/OpenFOAM-v1712/src/finiteVolume/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/meshTools/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/transportModels/ -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/transpo rtModels/compressible/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/thermophysicalModels/basic/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/TurbulenceModels/turbulenceModels/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v 1712/src/TurbulenceModels/compressible/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/TurbulenceModels/incompressible/lnInclude -I/usr/include/eigen3 -I/home/andreubernadserra/precice-1.1.1/src/precice -I../ -DADAPTER_DEBUG_MODE -IlnInclude -I. -I /home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/OpenFOAM/lnInclude -I/home/andreubernadserra/OpenFOAM/OpenFOAM-v1712/src/OSspecific/POSIX/lnInclude -fPIC -c Utilities.C -o Make/linux64GccDPInt32Opt/Utilities.o
...
At this point I thought that the error was caused by the yams-cpp library not being found, but I can call it in a cpp script and there is no error when compiling. Now my questions, is there anything I'm doing wrong in terms of building the library or the adapter? Perhaps, is there an incompatibility between the Boost
and yalm-cpp
versions? Maybe I didn't install correctly the Boost
library.
By any means I'm an expert in Linux or cpp (more of a Python guy), and most likely there is something I'm doing terribly wrong rather than this being a bug. I'm sorry if this is the case.
Thank you in advance!
Andreu