Install OpenFOAM v2006 on CentOS

This article is a memorandum of the procedure when installing version v2006 of OpenFOAM, which is open source software for fluid analysis, on CentOS 6.x.

Download OpenFOAM

The OpenFOAM binary package and source code can be obtained from the following site.

The first site is by the ESI group. On the other hand, the second site is from the OpenFOAM Foundation. The version with the release date, that is, v2006 (released in June 2020), can be obtained from the former ESI site.

Installation type

You can download Windows, Mac, and Linux binaries from the ESI site. On Windows, you can also install using Windows Subsystem for Linux (WSL). It has been officially confirmed that it can be installed on Ubuntu 16.04LTS, CentOS 7.4, and OpenSUSE Tumbleweed on how to build from source. This article attempts to build OpenFOAM from source on CentOS 6.x.

Installation policy

Overview of installation procedure

  1. Download and install the required rpm package with administrator privileges.
  2. Download and unzip the source packages required for OpenFOAM main body and third-party builds.
  3. Edit the environment setting file and build script.
  4. Build a third party (tool, library).
  5. Build the main body of OpenFOAM.
  6. Verify the operation of the built OpenFOAM main unit (solver).
  7. Build ParaView for visualization.
  8. Confirm that pre-processing (mesh generation), calculation execution, and post-processing (visualization), which are a series of fluid analysis flows, can be performed.

The ParaView build in step 7 often fails, and if it doesn't work, give up. ParaView can be installed separately on other than the CentOS server, so you can download the calculation data to your environment and visualize it.

Installation of required rpm packages

The required packages are as follows.

Install the above packages using yum with administrator privileges.

$ yum install gcc gcc-c++ bison flex m4 glibc-devel glibc-devel.i686 zlib-devel

Download and deploy OpenFOAM source package

The OpenFOAM package consists of two types: the main source code and a third-party package. Here, create a directory called / opt / OpenFOAM so that different versions can be managed, and download and extract it with wget under it.

$ mkdir /opt/OpenFOAM
$ cd /opt/OpenFOAM
$ wget https://sourceforge.net/projects/openfoam/files/v2006/OpenFOAM-v2006.tgz
$ tar zxvf OpenFOAM-v2006.tgz
$ wget https://sourceforge.net/projects/openfoam/files/v2006/ThirdParty-v2006.tgz
$ tar zxvf ThirdParty-v2006.tgz

If you cannot download HTTPS due to authentication, add the option --no-check-certificate or .wgetrc settings. Please avoid it.

The structure of the directory and file after extracting each package is as follows.

Allwmake         COPYING    README.md     bin  etc      src        wmake
CONTRIBUTORS.md  META-INFO  applications  doc  modules  tutorials
ADIOS2-2.4.0     etc             makeKAHIP            makeParaView
Allclean         fftw-3.3.7      makeLLVM             makeParaView.example
Allwmake         kahip-2.12      makeMETIS            makeQt
BUILD.md         makeAdios2      makeMGridGen         makeSCOTCH
CGAL-4.12.2      makeCCMIO       makeMPICH            makeVTK
COPYING          makeCGAL        makeMVAPICH          makeVTK.example
ParaView-v5.6.3  makeCmake       makeMesa             minCmake
README.md        makeFFTW        makeMesa.example     openmpi-4.0.3
Requirements.md  makeGcc         makeOPENMPI          scotch_6.0.9
SOURCES.txt      makeGperftools  makeOPENMPI.example
boost_1_66_0     makeHYPRE       makePETSC

How to build OpenFOAM is described in OpenFOAM® Quick Build Guide, but expanded ʻOpenFOAM-v2006 Carefully read README.md, Bequirements.md, and BUILD.md inandThirdParty-v2006, and check SOURCES.txt`.

Minimal system requirements

Requirements specified on the official website are as follows.

The version of Qt that is originally included in CentOS is old, and you need a new version of Qt to use the latest version of ParaView.

Download and deploy the sources required for third-party packages

The compiler libraries required under the above ThirdPart-v2006 are as follows: (There is a description of the download destination in BUILD.md).

The compiler can be an intel compiler other than GCC. It's okay if the GCC version is newer than 4.8.5, but you'll need to change the settings that come up later.

GCC

$ cd ThirdParty-v2006
$ wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz
$ tar zxvf gcc-4.8.5.tar.gz

** GNU library (gmp, mpfr, mpc) **

$ wget ftp://ftp.gnu.org/gnu/gmp/gmp-6.2.0.tar.xz
$ tar Jxvf gmp-6.2.0.tar.xz
$ wget ftp://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz
$ tar Jxvf mpfr-4.0.2.tar.xz
$ wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
$ tar zxvf mpc-1.1.0.tar.gz

OpenMPI

It's already in a third party dictator.

Scotch

It's already in a third party dictator.

Boost

It's already in a third party dictator.

CGAL

It's already in a third party dictator.

Cmake

$ wget https://cmake.org/files/v3.8/cmake-3.8.2.tar.gz
$ tar zxvf cmake-3.8.2.tar.gz

Qt (qmake)

$ wget http://download.qt.io/new_archive/qt/5.6/5.6.3/single/qt-everywhere-opensource-src-5.6.3.tar.xz
$ tar xvf qt-everywhere-opensource-src-5.6.3.tar.xz

FFTW

It's already in a third party dictator.

libccmio

Build only if you need the STAR-CCM + mesh converter. The download destination is different from before.

$ wget http://visit.ilight.com/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz
$ tar zxvf libccmio-2.6.1.tar.gz

Edit config file / build script

OpenFOAM main unit environment settings

Edit the environment settings of OpenFOAM with an appropriate editor such as vi or ʻemacs. The shell is explained using bash`.

$ vi ../OpenFOAM-v2006/etc/bashrc

Modification place

# [WM_COMPILER_TYPE] - Compiler location:
# = system | ThirdParty
export WM_COMPILER_TYPE=ThirdParty

If you want to change the label size of the mesh from 32 bits to 64 bits, change it as follows.

# [WM_LABEL_SIZE] - Label size in bits:
# = 32 | 64
export WM_LABEL_SIZE=64
# [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
#   HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
# Also possible to use INTELMPI-xyz etc and define your own wmake rule
export WM_MPLIB=OPENMPI
# [projectDir] - directory containing this OpenFOAM version.
# \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines
#    should work when sourced by BASH or ZSH shells. If this however fails,
#    set one of the fallback values to an appropriate path.
#
#    This can be removed if an absolute path is provided for WM_PROJECT_DIR
#    later on in this file
# --
projectDir="${BASH_SOURCE:-${ZSH_NAME:+$0}}";
[ -n "$projectDir" ] && projectDir="$(\cd $(dirname $projectDir)/.. && \pwd -L)" ||\
# projectDir="$HOME/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
projectDir="/opt/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
# projectDir="/usr/local/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"

Regarding the specification of the compiler / GNU library, change the specification of the GNU library.

$ vi ../OpenFOAM-v2006/etc/config.sh/compiler

changes

case "$WM_COMPILER_TYPE" in
ThirdParty)
    # Default versions of GMP, MPFR, MPC - override as necessary
    gmp_version=gmp-6.2.0
    mpfr_version=mpfr-4.0.2
    mpc_version=mpc-1.1.0

GCC build settings

$ vi makeGcc

** Confirmation point ** 先ほど編集したconfig.sh/compilerからコンパイラ・GNUライブラリのバージョンを参照するので, The following is just a confirmation.

[ "${WM_COMPILER#Gcc}" = "$WM_COMPILER" ] && WM_COMPILER=Gcc        # Force gcc
WM_COMPILER_TYPE=ThirdParty                # Ensure we get the correct settings

# Default GCC, mpfr, gmp and mpc versions from OpenFOAM etc/config.sh file:
_foamConfig compiler

gmpPACKAGE=${gmp_version:-gmp-system}
mpfrPACKAGE=${mpfr_version:-mpfr-system}
mpcPACKAGE=${mpc_version:-mpc-system}
gccPACKAGE=$gcc_version

CGAL build settings

Check the CGAL build script in the same way as above.

$ vi makeCGAL

** Confirmation point **

# CGAL, boost and gmp/mpfr versions from OpenFOAM etc/config.sh files.
# Get compiler first and let CGAL config override GMP and MPFR
_foamConfig compiler
_foamConfig CGAL

boostPACKAGE=${boost_version:-boost-system}
gmpPACKAGE=${gmp_version:-gmp-system}
mpfrPACKAGE=${mpfr_version:-mpfr-system}
cgalPACKAGE=$cgal_version

Check the CGAL settings on the OpenFOAM main unit.

vi ../OpenFOAM-v2006/etc/config.sh/CGAL

** Confirmation point **

boost_version=boost_1_66_0
cgal_version=CGAL-4.12.2

FFTW build settings

Check the FFTW build script.

vi makeFFTW

** Confirmation point **

# FFTW version from OpenFOAM etc/config.sh file:
_foamConfig FFTW

fftwPACKAGE=${fftw_version:-fftw-system}

Check the FFTW settings on the OpenFOAM main unit.

vi ../OpenFOAM-v2006/etc/config.sh/FFTW

** Confirmation point **

fftw_version=fftw-3.3.7
export FFTW_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version

Third party build

GCC build

First, load the OpenFOAM environment settings.

$ . /opt/OpenFOAM/OpenFOAM-v2006/etc/bashrc

At this time, the following message is output, but since GCC has not been built yet, it is a natural error and the GCC build will proceed.

===============================================================================
Warning in /opt/OpenFOAM/OpenFOAM-v2006/etc/config.sh/settings:
Cannot find 'Gcc' compiler installation
    /opt/OpenFOAM/ThirdParty-v2006/platforms/linux64/gcc-4.8.5

    Either install this compiler version, or use the system compiler by setting
    WM_COMPILER_TYPE to 'system' in $WM_PROJECT_DIR/etc/bashrc.
===============================================================================
$ ./makeGcc

Reload the OpenFOAM environment settings to enable the built Gcc.

$ . /opt/OpenFOAM/OpenFOAM-v2006/etc/bashrc

Build cmake

Build Cmake. You need to specify the version as an option.

./makeCmake cmake-3.8.2

Build a third party package

After building Cmake, build the rest of the packages with ʻAllwmake`. Load the OpenFOAM environment settings again before executing.

$ . /opt/OpenFOAM/OpenFOAM-v2006/etc/bashrc 
$ ./Allwmake

I get the following error when building ADIOS2.

no patch found for ADIOS2-2.4.0
Using cmake=/usr/bin/cmake
CMake Error at CMakeLists.txt:6 (cmake_minimum_required):
  CMake 3.6 or higher is required.  You are running version 2.6.4

-- Configuring incomplete, errors occurred!
Error building: ADIOS2-2.4.0
    ---------------------------------------------------
    Optional component (ADIOS2) had build issues
    OpenFOAM will nonetheless remain largely functional
    ---------------------------------------------------

It seems that you are not using CMake built under a third party, so set PATH explicitly and rebuild ADIOS2.

$ ./makeAdios2 -cmake $WM_THIRD_PARTY_DIR/platforms/linux64Gcc/cmake-3.8.2/bin/

After the above third-party build is completed, check whether the conditions for building the OpenFOAM main body are met with the following command.

$ foamSystemCheck
System check: PASS
==================
Can continue OpenFOAM installation.

When PASS is displayed, move on to the build of OpenFOAM itself.

Build the main body of OpenFOAM

Load the OpenFOAM environment settings again and then build. ʻThe Allwmakescript is used, but the number of cpu for parallel compilation can be specified with the-joption, so set it according to the environment. You can also use the alias commandfoam to move to the OpenFOAM project directory (installation directory) $ WM_PROJECT_DIR`.

$ . /opt/OpenFOAM/OpenFOAM-v2006/etc/bashrc
$ foam
$ ./Allwmake –j4

If an error occurs and it does not end normally, check the error message to see if there are any missing libraries.

Build verification of OpenFOAM main body

When the build of OpenFOAM itself is completed normally, read the environment settings again and execute the test program.

$ . /opt/OpenFOAM/OpenFOAM-v2006j/etc/bashrc 
$ foamInstallationTest

It is OK if the confirmation result such as the library path is output and the following summary is output at the end.

Summary
-------------------------------------------------------------------------------
Base configuration ok.
Critical systems ok.

Done

If Japanese is included in the version output of gcc -v, the above foamInstallationTest will result in an error, so before that

export LANG=C

Please do not use Japanese as such.

ParaView build

Build Qt

Check how to specify the version package in makeQt.

$ more makeQt

** Confirmation point **

# Description
#     Build script for QT (the qt-everywhere-opensource-src package)
#
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
#------------------------------------------------------------------------------
# Run from third-party directory only
cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
    echo "    Check your OpenFOAM environment and installation"
    exit 1
}
. etc/tools/ThirdPartyFunctions
. etc/tools/QtFunctions

In previous versions of OpenFOAM, the user could specify it in makeQt, but the setting cannot be changed here. For the time being, I will give you help for makeQt.

$ ./makeQt -h
usage: makeQt [OPTION] [qt-VERSION] [-- configure-options]
options:
  -gcc              Force gcc/g++ instead of the values from $WM_CC, $WM_CXX
  -help

* build qt-everywhere-opensource-src, version undefined

It seems that you can specify the version and execute it, so let's compile 5.9.3.

$ ./makeQt 5.6.3

It takes a little time to compile, and it fails with the following error.

/opt/OpenFOAM/ThirdParty-v2006/qt-everywhere-opensource-src-5.6.3/qtconnectivity/src/tools/sdpscanner/main.cpp:321:30: error: ‘htonl’ was not declared in this scope

If you search for the error message on Google, there is a workaround in stack overflow, so in the source as follows Make corrections.

$ vi qt-everwhere-opensource-src-5.6.3/qtconnectivity/src/tools/sdpscanner/main.cpp

** Additional part **

#include <arpa/inet.h>

If you compile it again and no error occurs, it is successful.

$ ./makeQt 5.6.3

ParaView build

Next, build ParaView. Since the path of qmake (Qt) and Cmake is not set, specify it in the script option. Also, execute it with the option of not using the functions of OpenGL library 2.x or higher (-no-gl2) (because the CentOS 6 driver does not support it).

$ ./makeParaView -no-gl2 -qmake platforms/linux64Gcc/qt-5.6.3/bin -cmake platforms/linux64Gcc/cmake-3.8.2/bin

The module paraview is created and the build is complete.

$ ls platforms/linux64Gcc/ParaView-5.6.0/bin/paraview
platforms/linux64Gcc/ParaView-5.6.0/bin/paraview

This completes the ParaView installation. In previous versions, it was necessary to build ParaView Reader to use the paraFoam command after this, but it seems that it is not necessary because the corresponding PVReader is not found.

Operation check of pre-processing, calculation execution, and post-processing in OpenFOAM

After all the above installation work is completed, the tutorial case pitzDaily will check whether OpenFOAM can normally perform the flow of fluid analysis, pre-processing (mesh creation), calculation execution, and post-processing (visualization). Check using.

$ . /opt/OpenFOAM/OpenFOAM-v2006/etc/bashrc
$ mkdir –p $FOAM_RUN
$ run
$ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily ./
$ cd pitzDaily
$ blockMesh
$ simpleFoam
$ paraFoam

The meanings of the OpenFOAM commands that appear here are as follows.

The operation check performed here does not confirm the parallel calculation. It is not easy to check the operation of all tutorial cases that perform parallel calculation because it takes a long time to calculate, but let's execute pipeCyclic as a relatively light calculation (the number of parallels is 5 by default).

$ run
$ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pipeCyclic ./
$ cd pipeCyclic
$ ./Allrun

ʻAllrunis a script that automatically sets analysis conditions and executes calculations from mesh generation. IfpitzDaily and pipeCyclic` can execute the calculation without error, the installation is completed successfully.

Recommended Posts

Install OpenFOAM v2006 on CentOS
Install Golang on CentOS 8
Install Neo4j 4.1.3 on centOS
Tomcat v8 on CentOS7
Install PostgreSQL 12 on Centos8
Install nginx on centOS7
Install Python 3 on CentOS 7
Install kuromoji on CentOS7
Jetty v8 on CentOS7
Install Mattermost on CentOS 7
Install PostGIS 2.5.5 on CentOS7
Install jpndistrict on CentOS 7
Install Redmine 4.1.1 on CentOS 7
Smokeping Install on CentOS7
Install PostgreSQL 13 on CentOS 7.5
Install CMS Made Simple v2.2.2 on LAMP on CentOS 7.3
Install Jenkins on Docker's CentOS
Install Apache on CentOS on VirtualBox
Install Ruby 2.7 on CentOS 7 (SCL)
Try DPDK20 SDK on CentOS7 ①Install
Install Ruby 2.5 on CentOS 7 using SCL
Install Java Open JDK 8 on CentOS 7
How to install MariaDB 10.4 on CentOS 8
Install apache 2.4.46 from source on CentOS7
Steps to install MySQL 8 on CentOS 8
Steps to install devtoolset-6 on CentOS 7
Install Java 9 on windows 10 and CentOS 7
Install MariaDB (CentOS 8)
Install samba4 from source code on CentOS8
Customize OpenFOAM v8 Docker Image on Mac
Install the webmail client Rainloop on CentOS 8
How to install beta php8.0 on CentOS8
[CentOS] Install apache-loggen
OpenVPN on CentOS 8
Install CentOS 7 on Raspberry pi 4 Model B
Install NextCloud on CentOS 7 with Alibaba Cloud ECS
Command to install nginx / PHP7 / php-fpm on CentOS7
Install GitLab on CentOS 8 with no internet connection
Install gradle on mac
Install Corretto 8 on Windows
Maven on CentOS 7 tutorial
Install OpenJDK on macOS
Install Java on Mac
Docker installation on CentOS 6
Use perltidy on CentOS 8
Try OpenLiteSpeed on CentOS8
[CentOS7] Install aws cli
Install Docker on Manjaro
Zabbix 5 installation on CentOS 8
Install Ruby on Ubuntu 20.04
Use mod_auth_cas on CentOS 8
Install lombok on SpringToolSuite4
Use bat on Centos.
Install Autoware on Ubuntu 18.04.5
OpenJDK installation on CentOS 7
Install openjdk11 on mac
Install Homebrew on Ubuntu 20.04
Install OpenJDK 8 on mac
Install BookStack Documentation Wiki on Elastic Compute Service on CentOS 7
Install the latest hardware drivers from ELRepo on CentOS
Install MySQL 5.6 on CentOS6 [How to specify the version]