Compile from sources

Setup the environment

We start by getting the software, organizing file structure and setting up the environment.

  • As a prerequisite for the OpenFOAM® installation you need to download and install additional software packages (see the OpenFOAM webpage for more details). On Ubuntu 22.04 and newer execute the following command in a terminal:

    sudo apt-get install build-essential cmake git ca-certificates flex libfl-dev bison \
    zlib1g-dev libboost-system-dev libboost-thread-dev libopenmpi-dev openmpi-bin gnuplot \
    libreadline-dev libncurses-dev libxt-dev
    
  • Retrieve the source code. The following commands will create the required folders in an OpenFOAM directory in your HOME folder and download the desired version:

    cd $HOME
    mkdir OpenFOAM
    cd OpenFOAM
    git clone https://github.com/OpenFOAM/OpenFOAM-10.git
    git clone https://github.com/OpenFOAM/ThirdParty-10.git
    cd OpenFOAM-10
    git checkout 362b7b6bb8eb5c4ac92e12856b3455cdacc1166a
    cd ../ThirdParty-10
    git checkout ae545a01baf66780285a2015da8a23c0a2dda5de
    
  • Unzip the CFDEMcoupling archive you received into the folder $HOME/DCS-Computing.

  • Source the bashrc file for CFDEMcoupling. It takes care of setting up the environment variables for OpenFOAM and CFDEMcoupling:

    source $HOME/DCS-Computing/CFDEMcoupling-|package|-|version|/etc/bashrc
    

    Note

    If you are running on a zsh, source zshrc from the same location.

    Note

    If you have not copied files to the default locations, you may need to set the CFDEM_OF_DIR or CFDEM_ASX_INSTALL_DIR environment variables to set the OpenFOAM and / or Aspherix install directories.

  • Test your setup using the system test command:

    cfdemSysTest
    

    Note

    Please note the output of the number of threads per core and the recommendation for the CFD-DEM hyperthreading setting.

Compile OpenFOAM

  • In the same terminal as you used to set the environment, compile OpenFOAM by executing the following steps:

    cd $WM_PROJECT_DIR
    ./Allwmake
    

    If you opened a new terminal, you first need to source the bashrc again.. Depending on your hardware and the amount of cores used, compilation of OpenFOAM can take an hour or more.

    Note

    By default the compilation will use all cores available on your machine. You can set the number of cores used by setting the variable WM_NCOMPPROCS.

  • To test your installation, check that the simpleFoam application is found:

    simpleFoam -help
    

    This command should print a “Usage” message to screen.

Compile CFDEMcoupling

  • Still in the same terminal, compile CFDEMcoupling by executing

    cfdemCompCFDEM
    

    from any location. This command automatically compiles all the CFDEM®coupling libraries, CFDEM®coupling solvers and CFDEM®coupling utilities. The compilation will stop, if build errors occur.

    The compilation is automatically logged and the logs can be found in:

    $CFDEM_ETC_DIR/log
    

    Note

    If compiling on a different Linux distribution than Ubuntu, further settings may be required.

  • In case questions concerning the installation arise, please feel free to contact DCS Computing.

  • Proceed to next step.