########################## INSTALL PRECICE - CENTOS 7 ########################## ========================= Building: Using CMake ========================= You could find the Roadmap in - follow the instructions on the right side of the page:: https://github.com/precice/precice/wiki/Roadmap And you could find the binaries in - if you have Ubuntu it is easy to install the .deb file:: https://github.com/precice/precice/releases Install the required dependencies and make sure you are using a recent CMake version. For Ubuntu 18.04 or newer:: sudo apt update && \ sudo apt install build-essential cmake libeigen3-dev libxml2-dev petsc-dev libboost-all-dev python-dev python-numpy To build precice:: mkdir build && cd build cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo .. make -j $(nproc) to test precice:: make test_base and:: make test Now go to Linking to preCICE with:: cmake CMAKE_PREFIX_PATH=~/software . or to use preCICE from it's build directory:: cmake -Dprecice_DIR=/precice/build/dir . Depending on the configuration of ld it might look by default into /usr/local/lib or not. This might lead to linking problems and can be either solved by adding /usr/local/lib to the LD_LIBRARY_PATH Now go to tutorials. Install openFoam 5.x ====================== Install Calculix ================= Dependencies ============ For CENTOS and other distributions CMake versions can easily be added via the binaries here. - C++ compiler (with support for C++11, GCC version >= 5) - CMake (version high enough to support your boost version) - Eigen3: Download the latest epel-release:: http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/ rpm -Uvh epel-release*rpm yum install eigen3-devel Make a soft link of Eigen folder into /usr/local/bin/ Test Eigen with the code:: #include #include using Eigen::MatrixXd; int main() { MatrixXd m(2,2); m(0,0) = 3; m(1,0) = 2.5; m(0,1) = -1; m(1,1) = m(1,0) + m(0,1); std::cout << m << std::endl; } Save the file into my_program.cpp and run it by:: g++ my_program.cpp -o my_program When you run the program, it produces the following output:: 3 -1 2.5 1.5 - Boost (version >= 1.65.1) https://pkgs.org/download/boost:: wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz tar -xzf boost_1_* cd boost_1_* ./bootstrap.sh ./b2 install --with=all This install boost in user local, if you want to install in a different place i.e /opt/boost use:: wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz tar -xzf boost_1_* cd boost_1_* ./bootstrap.sh --prefix=/opt/boost ./b2 install --prefix=/opt/boost --with=all I had a lot of problems with precice 1.4.1 becuase it did't find the path for boost include To keep things simple, let's start by using a header-only library. The following program reads a sequence of integers from standard input, uses Boost.Lambda to multiply each number by three, and writes them to standard output:: #include #include #include #include int main() { using namespace boost::lambda; typedef std::istream_iterator in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " ); } Copy the text of this program into a file called example.cpp. Now, in the directory where you saved example.cpp, issue the following command::: c++ -I path/to/boost_1_65_0 example.cpp -o example To test the result, type::: echo 1 2 3 | ./example If you instal boost in /opt/bosst Set the PATH into .bashrc appending the line:: export PATH=opt/boost/include/${PATH:+:${PATH}} export LD_LIBRARY_PATH=/opt/boost/lib - libxml2 - PETSc (optional) (version >= 3.6):: git clone -b maint https://bitbucket.org/petsc/petsc cd petsc export PETSC_DIR=`pwd` export PETSC_ARCH=x86_64 ./config/configure.py --with-shared=1 --with-x=0 --with-mpi=1 --download-hypre=1 make PETSC_DIR=/opt/petsc PETSC_ARCH=x86_64 all make PETSC_DIR=/opt/petsc PETSC_ARCH=x86_64 check If occurs the error:: *******************Error detected during compile or link!******************* See http://www.mcs.anl.gov/petsc/documentation/faq.html /opt/petsc/src/snes/examples/tutorials ex19 ********************************************************************************* ping `hostname` If it fails The machine has a funky network configuration and for some reason MPICH is unable to communicate between processes with the socket connections it has established. This can happen even if you are running MPICH on just one machine. Often you will find that ping `hostname` fails with this network configuration; that is processes on the machine cannot even connect to the same machine. You can try completely disconnecting your machine from the network and see if make test then works or speaking with your system adminstrator. - Python (optional) (with NumPy) - MPI (optional) (warning: problems with MPI_Ports using OpenMPI >= 2) - SCons (deprecated) - yaml-cpp 0.51 from https://github.com/jbeder/yaml-cpp/releases - OpenFoam6 Download preCICE ================ Download and unpack the latest release of preCICE (replace x.y.z with the actual version):: wget https://github.com/precice/precice/archive/vx.y.z.tar.gz tar -xzvf vx.y.z.tar.gz cd precice-x.y.z Or from the installatoion directory (i.e. /opt):: git clone https://github.com/precice/precice.git I also downloaded and tar libprecice1.4.0-bionic.tar.gz Build preCICE ============= Use CMake to configure and build preCICE. See CMake Options for a list of common options to use and Troubleshooting in case of any issues. We strongly recommend to build preCICE as a shared library. Note that the default prefix is /usr/local and you may want to change that.:: mkdir build && cd build scl enable devtoolset-7 bash # To run gcc 7 instead 4.8.5 # unset ELPA # To avoid compiling warning cmake3 -DBUILD_SHARED_LIBS=ON .. # this build libraries as dynamic sudo make install test preCICE ============ run:: make test_base This executes the base test set. To execute all tests, including tests known to hang or fail due to dependency issues, run:: make test Also run this test:: $PRECICE_ROOT/tools/compileAndTest.py -t --run_test="\!@MPI_Ports" When I ran this test, I received the error message: /opt/precice-1.4.1/build/testprecice: error while loading shared libraries: libboost_timer.so.1.65.1: cannot open shared object file: No such file or directory To solve this:: echo -e "\n/usr/local/lib" | sudo tee -a /etc/ld.so.conf sudo ldconfig install preCICE to the prefix =============================== To install preCICE to the prefix run:: make install You may have to add /lib/pkconfig to your PKG_CONFIG_PATH in order for pkgconfig to be able to locate it. I have to use:: # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH export PATH="$PATH:/usr/lib64/openmpi-2.1.1/bin" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/openmpi-2.1.1/lib/openmpi" #export BOOST_ROOT=/usr/local/boost/ export LD_LIBRARY_PATH="usr/local/lib:$LD_LIBRARY_PATH" export PATH=/usr/local/bin/eigen3/${PATH:+:${PATH}} export PETSC_DIR=/opt/petsc/ export PETSC_ARCH=x86_64 export LD_LIBRARY_PATH=/opt/libprecice1.4.1-bionic/bin:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=/opt/libprecice1.4.1/build:${LD_LIBRARY_PATH} export PRECICE_ROOT=/opt/precice-1.4.1 # User specific aliases and functions alias rapid='source /opt/RapidCFD/RapidCFD-dev/etc/bashrc WM_COMPILER_TYPE=system WM_COMPILER=Gcc48 WM_LABEL_SIZE=64 WM_MPLIB=OPENMPI FOAMY_HEX_MESH=yes' alias rapid='source /opt/RapidCFD/RapidCFD-dev/etc/bashrc WM_LABEL_SIZE=64 WM_MPLIB=OPENMPI FOAMY_HEX_MESH=yes' alias of5x='source \/opt/OpenFOAM/OpenFOAM-5.x/etc/bashrc $FOAM_SETTINGS' Pages for installation help =========================== - `Building the precice openfoam adapter `_ - `libprecice-cannot-be-found-at-runtime `_ - `static-libraries-vs-dynamic-libraries `_ - `gitter, Good help from Gerasimos `_ - `yaml-cpp `_ - `petsc `_ - `Fedora packages `_ - `Boost `_ - `pkgs yaml-cpp `_ yaml-cpp install ================= Download yaml-cpp 0.6.2:: yaml-cpp-yaml-cpp-0.6.2.tar.gz tar xf yaml-cpp-yaml-cpp-0.6.2.tar.gz scl enable devtoolset-7 bashrc cd yamy-cpp-yaml-cpp-0.6.2 mkdir build cd build sudo chown -R hgasca:users . cmake3 -DBOOST_ROOT=$BOOST_ROOT -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo .. sudo make install Plate duct openfoam-openfoam ============================= Clone and `download The adapter `_: then go to openfoam-adapter-OpenFOAM5.x folder and run:: scl enable devtoolset-7 bash of5x ./Allclean ./Allwmake If errors review the .log file and use `Precice Lobby `_ for the fastest solution. Run tutorial case ------------------ go to the folder and run:: cd tutorials/CHT/flow-over-plate/buoyantPimpleFoam-laplacianFoam of6 ./Allclean ./Allrun To understand:: https://github.com/precice/openfoam-adapter/wiki/OpenFOAM-setup-(fluid) - Review Fluid.log in order to see if the adapter is running. - Open paraview - Open /CHT/flow-over-plate/buoyantPimpleFoam-laplacianFoam/Fluid/Fluid.foam and - /CHT/flow-over-plate/buoyantPimpleFoam-laplacianFoam/Solid/Solid.foam to postprocess .. The below lines are copied from the precice page for future review. To use preCICE in your project, Linking to preCICE. ===================================================== Note: here it is assumed that you installed a binary package for your linux distribution or built preCICE with CMake and installed it. Depending on what build system your adapter/solver uses, linking to preCICE can differ, but it is very easy in everycase. In any case, please include e.g. the SolverInterface.hpp file as precice/SolverInterface.hpp You have now installed preCICE somewhere on your system, either with e.g. a Debian package or with running make install. As you want to use preCICE in your solver, your project/adapter should know where preCICE is installed. This mainly means: where are the header files that I need? (namely precice/SolverInterface.hpp or precice/SolverInterfaceC.h etc). where is the library binary (namely libprecice.so or libprecice.a). in case I am using preCICE as a static library (not recommended if you don't know why you need it), which other dependencies do I need to link against? Since preCICE is a CMake project, other CMake projects can easily use it, if they know where it is installed. For Autotools or any other build system, you can get all the information you need through pkg-config, a simple and widely used tool for this purpose. When installing preCICE, you also get a file named libprecice.pc, which mainly provides two important variables: the CFLAGS (where to find the headers) and the LIBS (where to find the library and dependencies). Running pkg-config --cflags --libs libprecice should give you this information, if pkg-config can find libprecice.pc. In case you installed preCICE in a directory different than /usr/lib/, you need to set your PKG_CONFIG_PATH variable to point to the path where libprecice.pc is located. If, at runtime, the shared library cannot be found, have a look into the troubleshooting. Please note that, as of preCICE v1.4.0, we don't yet provide the dependency information there yet, so linking to a static libprecice.a may require some tinkering. Linking from CMake --------------------- Linking to preCICE from a CMake project is simple. Use find_package(precice) and link precice::precice to your target: .. code-block:: bash find_package(precice REQUIRED CONFIG) add_executable(myTarget main.cpp) target_link_libraries(myTarget PRIVATE precice::precice) This works out-of-the-box if you installed preCICE using the debian package. If you built preCICE and installed it into a custom prefix e.g. ~/software/, you can set the following cmake option: .. code-block:: bash $ cmake CMAKE_PREFIX_PATH=~/software . To use preCICE directly from its build directory, set the following cmake option: .. code-block:: bash $ cmake -Dprecice_DIR=/prefice/build/bir . ========================== PRECICE-OPENFOAM ADAPTER ========================== Building ========= 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 For openFoam6 openfoam-adapter-OpenFOAM6.zip 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). Similarly, if you use Boost < 1.67, you also need yaml-cpp < 0.6. - 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}" In my case for centos 7 and Boost 1.65 I used .. code-block:: bash https://centos.pkgs.org/7/epel-x86_64/yaml-cpp-devel-0.5.1-1.el7.2.x86_64.rpm.html a. Download latest epel-release rpm from .. code-block:: bash http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/ b. Install epel-release rpm: .. code-block:: bash # rpm -Uvh epel-release*rpm c. Install yaml-cpp-devel rpm package: .. code-block:: bash # yum install yaml-cpp-devel NOTE: I have any doubts about it, because when i run the last install it installed also Boost 1.53. 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 a compatible OpenFOAM distribution. We are looking for a nice way to support multiple versions at the same time. In the meantime, the following OpenFOAM versions work but are seen as special cases: OpenFOAM 6 - openfoam.org: A compatible variant of the adapter is provided in the OpenFOAM6 branch (see this pull request). OpenFOAM-dev - openfoam.org (at least version 20190204): A compatible variant of the adapter is provided in the OpenFOAMdev branch. (see this pull request). Compatible OpenFOAM solvers The following OpenFOAM solvers (in the respective OpenFOAM versions) are known to work with the adapter. However, more solvers may be compatible. See also the section "Solver requirements". Conjugate heat transfer Compressible buoyantPimpleFoam buoyantSimpleFoam Incompressible buoyantBoussinesqPimpleFoam Basic laplacianFoam Fluid-structure interaction Incompressible pimpleFoam / pimpleDyMFoam .. note:: the \*DyMFoam dynamic mesh solvers were deprecated and merged into the respective standard solvers in OpenFOAM 6 and OpenFOAM v1806. The adapter-specific configuration is not affected, but you need to choose the correct one for your OpenFOAM version. Solver requirements The adapter can be loaded by any official OpenFOAM solver, but there are some requirements to use a solver for conjugate heat transfer simulations. See also Configuration. First of all, the solver needs to be able to simulate heat transfer. This means that the solver should create a Temperature field (named T) and provide thermal conductivity or diffusivity fields. Three categories of solvers are assumed: compressible, incompressible and basic solvers. Compressible turbulent flow solvers For example buoyantPimpleFoam or buoyantSimpleFoam. These solvers simulate heat transfer and compute the effective thermal conductivity automatically. They include the file turbulentFluidThermoModel.H and instantiate a compressible::turbulenceModel. This is needed in the adapter as a part of the effective conductivity is affected by the turbulence. Assumptions: Temperature is a registered IOObject named T. The dictionaries turbulenceProperties and thermophysicalProperties are provided. Incompressible turbulent flow solvers Conjugate heat transfer For example buoyantBoussinesqPimpleFoam or buoyantBoussinesqSimpleFoam. These solvers simulate heat transfer but do not compute the effective thermal conductivity, as they don't know the density of the fluid or the heat capacity. Therefore, values for these need to be provided. The adapter looks for them in the transportProperties dictionary. For example, the following lines need to be added in the constant/transportProperties file: rho rho [ 1 -3 0 0 0 0 0 ] 50; Cp Cp [ 0 2 -2 -1 0 0 0 ] 5; The solver itself does not need to read these values. Assumptions: Temperature is a registered IOObject named T. The dictionaries turbulenceProperties and transportProperties are provided. transportProperties contains density rho and heat capacity Cp. The turbulent thermal diffusivity is a registered IOObject named alphat. If it is not found, then only the laminar part of the thermal diffusivity is used (a warning is triggered in this case). Fluid-structure interaction For incompressible solvers (e.g. pimpleFoam), the adapter tries expects the kinematic viscosity nu and the density rho in the constant/transportProperties file. See also Configuration. Basic solvers For example laplacianFoam can simulate heat transfer, using a thermal diffusion parameter DT. The adapter additionally expects a value for the conductivity k in the transportProperties dictionary. For example, the following lines need to be present in the constant/transportProperties file for the laplacianFoam: DT DT [ 0 2 -1 0 0 0 0 ] 1; k k [ 1 1 -3 -1 0 0 0 ] 100; Do not delete the, already provided in the pure solver, DT, as laplacianFoam expects it. The value of k is connected to the one of DT and depends on the density (rho [ 1 -3 0 0 0 0 0 ]) and heat capacity (Cp [ 0 2 -2 -1 0 0 0 ]). It needs to hold DT = k / rho / Cp. The solver itself does not need to read the additional parameter. Assumptions: Temperature is a registered IOObject named T. The dictionary transportProperties is provided. transportProperties contains the conductivity k. Other solvers If a solver uses different variable names, or if its type is not determined automatically, you may define these in the adapter's configuration file. Notes on OpenFOAM features End of the simulation The adapter (by default) ignores the endTime set in the controlDict and stops the simulation when preCICE says so. Let's see this with more details. During the simulation, both the solver and preCICE try to control when the simulation should end. While in an explicit coupling scenario this is clearly defined, in an implicit coupling scenario the solver may schedule its exit (and therefore the last call to the adapter) before the coupling is complete. See how function objects are called for more details on this. In order to prevent early exits from the solver, the solver's endTime is set to infinity and it is later set to the current time when the simulation needs to end. This has the side effect of not calling any function object's end() method normally, so these are triggered explicitly at the end of the simulation. In order to disable this behavior, you may define the option preventEarlyExit: No in the adapter's configuration file. Still, if the solver exits before the coupling completes, a warning will be reported. Function Objects In principle, using other function objects alongside the preCICE adapter is possible. They should be defined before the adapter in the system/controlDict, as (by default and opt-out) the adapter controls when the simulation should end and explicitly triggers (only) the end() methods of any other function objects at the end of the simulation. If the end() of a function object depends on its execute(), then the latter should have been called before the preCICE adapter's execute(). If you want to test this behavior, you may also include e.g. the ``systemCall`` function object in your system/controlDict:: functions { systemCall1 { type systemCall; libs ("libutilityFunctionObjects.so"); executeCalls ( "echo \*\*\* systemCall execute \*\*\*" ); writeCalls ( "echo \*\*\* systemCall write \*\*\*" ); endCalls ( "echo \*\*\* systemCall end \*\*\*" ); } preCICE_Adapter { type preciceAdapterFunctionObject; libs ("libpreciceAdapterFunctionObject.so"); } } Writing results As soon as OpenFOAM writes the results, it will not try to write again if the time takes the same value again. Therefore, during an implicit coupling, we write again when the coupling timestep is complete. See also a relevant issue. Adjustable timestep and modifiable runTime In the system/controlDict, you may optionally specify the following: adjustTimeStep yes; maxCo 0.5; runTimeModifiable yes; The adapter works both with fixed and adjustable timestep and it supports the runTimeModifiable feature. However, if you set a fixed timestep and runTimeModifiable, changing the configured timestep during the simulation will not affect the timestep used. A warning will be shown in this case. Disclaimer This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trade marks. 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. Configuration =============== In order to run a coupled simulation, you need to: - prepare a preCICE configuration file (described in the preCICE configuration), - prepare an adapter's configuration file, - set the coupling boundaries in the OpenFOAM case, - load the adapter, and - start all the solvers normally, from the same directory, e.g. in two different terminals.