Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling and Installing OpenFOAM

  1. Use PuTTY to log in to the server as the root user.
  2. Run the following command to install the system dependency package:
    yum install -y zlib-devel texinfo gstreamer-plugins-base-devel libXext-devel libGLU-devel libXt-devel libXrender-devel libXinerama-devel libpng-devel libXrandr-devel libXi-devel libXft-devel libjpeg-turbo-devel libXcursor-devel readline-devel ncurses-devel mpfr-devel gmp-devel libmpc*
  3. Run the following commands to go to the directory of the installation package, and decompress the OpenFOAM source code package and third-party software installation package:
    cd /path/to/OPENFOAM
    tar zxvf OpenFOAM-v1906.tgz
    tar zxvf ThirdParty-v1906.tgz
  4. Run the following command to edit the OpenFOAM installation configuration file:
    1. Open the OpenFOAM installation parameter file.
      vi /path/to/OPENFOAM/OpenFOAM-v1906/etc/bashrc
    2. Modify the compiler and MPI settings in the OpenFOAM installation configuration file.
      export WM_COMPILER_TYPE=system
      export WM_COMPILER=Gcc
      export WM_MPLIB=SYSTEMOPENMPI

      The three parameters indicate that the GNU compiler and Open MPI installed in the system are used for the compilation and installation. If you need to use another compiler or MPI, modify the parameters as prompted.

    3. Press Esc, type :wq!, and press Enter to save the changes and exit.
  5. Run the following commands to modify the compilation parameters:
    sed -i 's/\-O3/\-O3 \-march=armv8-a/g' /path/to/OPENFOAM/OpenFOAM-v1906/wmake/rules/linuxARM64Gcc/c++Opt
    sed -i 's/\-O3/\-O3 \-march=armv8-a/g' /path/to/OPENFOAM/OpenFOAM-v1906/wmake/rules/linuxARM64Gcc/cOpt
  6. Run the following command to make the OpenFOAM configuration file bashrc take effect:
    source /path/to/OPENFOAM/OpenFOAM-v1906/etc/bashrc
    No completion added for /path/to/OPENFOAM/OpenFOAM-v1906/platforms/linuxARM64GccDPInt32Opt/bin
    ... incorrect platform, or not yet compiled?
  7. Run the following commands to perform compilation and installation:
    cd /path/to/OPENFOAM/OpenFOAM-v1906/
    ./Allwmake -j 16 -s -k -q
    • -j indicates that all cores are used for the compilation. You can also specify the number of cores, for example, -j 8.
    • -s indicates that log printing is disabled.
    • -k indicates that errors during compilation are ignored.
    • -q indicates that subdirectories are collected to schedule and accelerate the compilation.
    • This step takes approximately 2.5 hours. After the step is complete, the bin and lib directories are generated in the /path/to/OPENFOAM/platforms/linuxARM64GccDPInt32Opt directory. The executable files and library files required for running are available in the two directories.