From Documentation
Revision as of 09:34, 3 May 2011 by Isaac (Talk | contribs) (Created page with "==What is OpenFoam?== OpenFOAM is a free, open source CFD software package produced by a commercial company, OpenCFD Ltd (http://www.openfoam.com/). It has a large user base acr...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

What is OpenFoam?

OpenFOAM is a free, open source CFD software package produced by a commercial company, OpenCFD Ltd (http://www.openfoam.com/). It has a large user base across most areas of engineering and science, from both commercial and academic organisations.


OpenFoam v1.7 Installation

Module loading

In this installation, Gcc compiler is used in conjunction with Openmpi. So, you should load appropriate modules like

module load gcc/4.3.4 
module load openmpi/gcc/1.4.2

Please note that you may have to 'unload' the default settings like

module unload intel/11.0.083 
module unload openmpi/intel/1.4.2

Unpacking the source files

The package requires two parts; one is a main solver part and the other is a third-party. Two gtgz files can be downloaded from the website above.

[isaac@hnd50:/work/isaac/hound/builds/OpenFOAM] ls -lrt
total 92196
-rwxr-xr-x  1 isaac isaac 38998257 Nov  3 01:27 OpenFOAM-1.7.0.gtgz
-rwxr-xr-x  1 isaac isaac 55390881 Nov  3 01:27 ThirdParty-1.7.0.gtgz

As shown, the mother directory is made in '/work/isaac/hound/builds/OpenFOAM' and unpacked all files there like;

[isaac@hnd50:/work/isaac/hound/builds/OpenFOAM] ls -lrt
drwxrwxr-x 10 isaac isaac     4096 Nov  3 02:19 ThirdParty-1.7.0
drwxrwxr-x 10 isaac isaac     4096 Nov  9 11:46 OpenFOAM-1.7.0

Setting Environment Variables

The environment variable settings are contained in files in an OpenFOAM-1.7.0/etc directory in the OpenFOAM release. Basically two environment files ('bashrc' and 'settings.sh') must be adjusted to the system.

In 'bashrc', there are some changes;

# Installation location
NEWHOME=/work/isaac/hound/OpenFOAM
..
foamInstall=$NEWHOME/$WM_PROJECT
..
export WM_PROJECT_USER_DIR=$NEWHOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
...
# Compiler: set to Gcc, Gcc43, Gcc44, or Icc (for Intel's icc)
: ${WM_COMPILER:=Gcc43}; export WM_COMPILER
# WM_MPLIB = SYSTEMOPENMPI | OPENMPI | MPICH | MPICH-GM | HPMPI | GAMMA | MPI | QSMPI
: ${WM_MPLIB:=OPENMPI}; export WM_MPLIB

# Detect system type and set environment variables appropriately
# 11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)~~
export WM_ARCH=`uname -s`
case $WM_ARCH in
Linux)
    WM_ARCH=linux
    
    # compiler specifics
    case `uname -m` in
     ... 

        64)
            WM_ARCH=linux64
            export WM_COMPILER_LIB_ARCH=64
            export WM_CC='/opt/sharcnet/gcc/4.3.4/bin/gcc'
            export WM_CXX='/opt/sharcnet/gcc/4.3.4/bin/g++'
            ...

In 'settings.sh',

# Select compiler installation
# 11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)Isaac
# compilerInstall = OpenFOAM | system 
 
    if [ -n "$gcc_version" ]
    then
        gccDir=/opt/sharcnet/gcc/4.3.4
# Communications library
# 11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)11:05, 14 February 2011 (EST)~~
        
unset MPI_ARCH_PATH MPI_HOME
            
case "$WM_MPLIB" in
OPENMPI)    
    mpi_version=openmpi-1.4.2
    export MPI_ARCH_PATH=/opt/sharcnet/openmpi/current/gcc
        
    # Tell OpenMPI where to find its install directory
    export OPAL_PREFIX=$MPI_ARCH_PATH
       
    _foamAddPath    $MPI_ARCH_PATH/bin
    _foamAddLib     $MPI_ARCH_PATH/lib
    _foamAddMan     $MPI_ARCH_PATH/man
        
    export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
    unset mpi_version
    ...

User environment setup

The environment variable FOAM_INST_DIR can be used to find and source the appropriate resource file. Here is a bash/ksh/sh example:

    * export FOAM_INST_DIR=/data/app/OpenFOAM
    * foamDotFile=$FOAM_INST_DIR/OpenFOAM-1.7.1/etc/bashrc
    * [ -f $foamDotFile ] && . $foamDotFile

and a csh/tcsh example:

    * setenv FOAM_INST_DIR /data/app/OpenFOAM
    * foamDotFile=$FOAM_INST_DIR/OpenFOAM-1.7.1/etc/cshrc
    * if ( -f $foamDotFile ) source $foamDotFile

The value set in $FOAM_INST_DIR will be used to locate the remaining parts of the OpenFOAM installation.

Building the Sources

Go to the top-level source directory $WM_PROJECT_DIR and execute the top-level build script

[isaac@hnd50:/work/isaac/hound/builds/OpenFOAM/OpenFOAM-1.7.0]./Allwmake