Hello everyone,
I am trying to do an FSI with MBDyn and OpenFOAM, as part of my thesis, but I am facing an issue with coupling.
In my system, OpenFOAM 2306 was already installed and for preCICE, I installed the ‘libprecice3_3.1.2_jammy.deb’ version followed by installing the openFOAM-preCICE adapter, as explained in the preCICE ‘quickstart’ page.
The ‘quickstart’ tutorial ran without any issue, which leads me to believe that preCICE and required dependencies have been properly installed.
For the MBDyn adapter, I am using the ‘develop’ version and the default Makefile for it, is as below:
debug: all
release: all
CXXFLAGS := -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_
ifeq ($(MAKECMDGOALS),debug)
CXXFLAGS := -g3 -O0 -std=c++17 -D_DEBUG -D_GLIBCXX_DEBUG -Wall -Wno-unknown-pragmas -Wno-format
endif
MBDYN_ROOT = /usr/local/mbdyn
VTK_ROOT = /usr/include/vtk-9.1
EIGEN_ROOT = /usr/include/eigen3
PRECICE_ROOT = /usr/local/precice
XML_ROOT = /usr/include/libxml2
#include paths
PRECICE_INCLUDE := /usr/include #$(shell pkg-config --cflags libprecice)
INCLUDE_DIRS := -I$(MBDYN_ROOT)/include -I$(VTK_ROOT) -I$(EIGEN_ROOT) -I$(XML_ROOT) -I$(PRECICE_INCLUDE)
PRECICE_LIBS := -L/usr/local/lib -lprecice #$(shell pkg-config --libs libprecice)
#PRECICE_LIBS := -L/usr/lib64/ -lprecice #$(shell pkg-config --libs libprecice)
#VTK_LIBS := -L/usr/lib64 -lvtkCommonCore -lvtkCommonDataModel -lvtkFiltersGeneral \
-lvtkIOXML -lvtkInteractionStyle
VTK_LIBS := -L/usr/lib/x86_64-linux-gnu/ -lvtkCommonCore-9.1 -lvtkCommonDataModel-9.1 -lvtkFiltersGeneral-9.1 \
-lvtkIOXML-9.1 -lvtkInteractionStyle-9.1
XML_LIBS := -lxml2
# libraries
LIBS = -L$(MBDYN_ROOT)/lib -lmbc \
$(VTK_LIBS) \
$(XML_LIBS) \
$(PRECICE_LIBS)
# project directories
SRC_DIR = ./src
OBJ_DIR = ./build
DEP_DIR = ./depend
# project sources
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
# project dependencies
DEP_FILES:=$(patsubst $(SRC_DIR)/%.cpp,$(DEP_DIR)/%.d,$(SRC_FILES))
PROGRAM = mbdyn-esm-adapter
all: $(PROGRAM)
# phony targets
.PHONY: clean
NO_DEPS := clean
# the program build just objects to be linked to the examples
$(PROGRAM): $(OBJ_FILES)
@echo "Program files"
@echo $(MAKECMDGOALS)
@echo $(SRC_FILES)
@echo $(OBJ_FILES)
g++ $(CXXFLAGS) -o $@ $(OBJ_FILES) $(LIBS)
# build program objects
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(DEP_DIR)/%.d
g++ $(CXXFLAGS) $(INCLUDE_DIRS) -c -o $@ $<
# -MM dependencies excluding system deps
# -MT ovveride target dependency, otherwise it would be *.o
# -MF file to write the dependency to
$(DEP_DIR)/%.d: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -MM -MT $(OBJ_DIR)/$(patsubst %.cpp,%.o,$(notdir $<)) $< -MF $@
# $(CXX) $(CXXFLAGS) -MM -MT $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(patsubst %.cpp,%.o,$<)) $< -MF $@
# $(CXX) $(CXXFLAGS) -MM -MT '$(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$<)' $< -MF $@
# create depenency files
depend: $(DEP_FILES)
@echo "make dependencies"
#Don't create dependencies when we're cleaning, for instance
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NO_DEPS))))
#Chances are, these files don't exist. GMake will create them and
#clean up automatically afterwards
-include $(DEP_FILES)
endif
CPP_FILES := $(shell find ./src -name "*.cpp")
HEADER_FILES := $(shell find ./src -name "*.h")
cppcheck:
cppcheck --enable=all --suppress=missingIncludeSystem --inconclusive --std=c++17 --force $(CPP_FILES) $(HEADER_FILES)
# clean everything
clean:
@echo "remove program"
rm -f $(PROGRAM)
@echo "remove example objects"
rm -f $(OBJS)
@echo "remove project objects"
rm -f $(OBJ_FILES)
@echo "remove dependencies"
rm -f $(DEP_FILES)
There are two issues I am seeing here (not sure if there are more).
- No folder named ‘precice’ exists in the default path given in PRECICE_ROOT.
and I do not know how to locate the precice root folder (precice was installed with ‘sudo apt install’).
- When I try to extract the flags with the mentioned commands, I am getting an output like this:
joseph@joseph:~$ pkg-config --cflags libprecice
pkg-config --libs libprecice
-lprecice
which do not resemble the expected output.
The generated ‘libprecice.pc’ file has the following content:
includedir=/usr/include
libdir=/usr/lib/x86_64-linux-gnu
Name: preCICE
Description: preCICE coupling library
Version: 3.1.2
URL: https://www.precice.org
Libs: -L${libdir} -lprecice
Cflags: -I${includedir}
I manually entered the paths given in the libprecice.pc file into the MBDyn adapter Makefile and it seemed to compile without any apparent issues:
joseph@joseph:~/mbdyn-esm-adapter/adapter$ make release
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/Adapter.o src/Adapter.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynAdapter.o src/MBDynAdapter.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynAdapterRestart.o src/MBDynAdapterRestart.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynAdapterTimeStep.o src/MBDynAdapterTimeStep.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynBeamConnector.o src/MBDynBeamConnector.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynConnector.o src/MBDynConnector.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynConnectorInOut.o src/MBDynConnectorInOut.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynMapConnector.o src/MBDynMapConnector.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynNodeConnector.o src/MBDynNodeConnector.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MBDynRigidConnector.o src/MBDynRigidConnector.cpp
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -I/usr/local/mbdyn/include -I/usr/include/vtk-9.1 -I/usr/include/eigen3 -I/usr/include/libxml2 -I/usr/include -c -o build/MovingAverage.o src/MovingAverage.cpp
Program files
release
./src/Adapter.cpp ./src/MBDynAdapter.cpp ./src/MBDynAdapterRestart.cpp ./src/MBDynAdapterTimeStep.cpp ./src/MBDynBeamConnector.cpp ./src/MBDynConnector.cpp ./src/MBDynConnectorInOut.cpp ./src/MBDynMapConnector.cpp ./src/MBDynNodeConnector.cpp ./src/MBDynRigidConnector.cpp ./src/MovingAverage.cpp
./build/Adapter.o ./build/MBDynAdapter.o ./build/MBDynAdapterRestart.o ./build/MBDynAdapterTimeStep.o ./build/MBDynBeamConnector.o ./build/MBDynConnector.o ./build/MBDynConnectorInOut.o ./build/MBDynMapConnector.o ./build/MBDynNodeConnector.o ./build/MBDynRigidConnector.o ./build/MovingAverage.o
g++ -O2 -g -Wall -fmessage-length=0 -Wall -std=c++17 -D_USE_VTK_ -o mbdyn-esm-adapter ./build/Adapter.o ./build/MBDynAdapter.o ./build/MBDynAdapterRestart.o ./build/MBDynAdapterTimeStep.o ./build/MBDynBeamConnector.o ./build/MBDynConnector.o ./build/MBDynConnectorInOut.o ./build/MBDynMapConnector.o ./build/MBDynNodeConnector.o ./build/MBDynRigidConnector.o ./build/MovingAverage.o -L/usr/local/mbdyn/lib -lmbc -L/usr/lib/x86_64-linux-gnu/ -lvtkCommonCore-9.1 -lvtkCommonDataModel-9.1 -lvtkFiltersGeneral-9.1 -lvtkIOXML-9.1 -lvtkInteractionStyle-9.1 -lxml2 -L/usr/lib/x86_64-linux-gnu -lprecice
But when I try running any included example case with the adapter, it fails and gives a message similar to the following one:
joseph@joseph:~/mbdyn-esm-adapter/testcases/TurekHron/FSI/FSI1$ mbdyn-esm-adapter -f config_new.json
Using config_new.json configuration file
[MBDyn-adapter] WARNING: using OLD definition of connector
[MBDyn-adapter] set up MAPPING connection to MBDyn
[MBDyn-adapter] finished setting up interface named flap
[MBDyn-adapter] set up DISPLACEMENT as exchange data
[MBDyn-adapter] setup base-name for VTU output: MBDyn_OF_
[MBDyn-adapter] setup name for PVD output: 00_out.pvd
[MBDyn-adapter] setup name for resultant file: resultant.txt
[MBDyn-adapter] setup ASCII format for VTU files: 1
[MBDyn-adapter] setup write output for every iteration: 0
[MBDyn-Connector] ERROR opening resultant file
[MBDyn-adapter] WARNING: defaulting to mapping without REFERENCE NODE
[MBDyn-connector] Reading mesh file: ./MBDyn/mesh/root0.dat
[MBDyn-connector] Number of points in the mesh: 182
[MBDyn-connector] Number of cells in the mesh: 90
I/O error : No such file or directory
I/O error : No such file or directory
[MBDyn-adapter] set directory for MBDyn log file...
[MBDyn-connector] Error opening log file.: No such file or directory
[MBDyn-adapter] MBDyn started with input file: ./MBDyn/map_5n_3x_11j.mbd
[MBDyn-adapter] Checking for time step parameters...
[MBDyn-adapter] NO variable time step is required
[MBDyn-adapter] Socket defined in config file.
unable to connect to peer (111: Connection refused)
[MBDyn-connector] Init NODE_SOCK_PATH:/tmp/mbdyn3.node.sock failed. Exiting...
[MBDyn-adapter] Error in MBDyn sockets for interfaces. Exiting...
Adapter not Initialized. Exiting...
I am not sure whether this is an issue of the adapter not getting properly linked with preCICE or is there something that I am missing?
Uninstalled and re-installed preCICE, but I am getting the same output.
Sorry for the long message but any help with this would be appreciated
Thank you and kind regards,
Joseph