Tutorial for Joule Workshop

 

OpenFOAM for beginners

Xinyu Zhao, Aug. 10, 2016

The version of OpenFOAM demonstrated in this tutorial is downloaded from CFD support. It is a self-contained package that includes OpenFOAM–3.0, post processing software preview, as well as gnuplot– a linux based plotting software.

For instructions on installing a binary package on Mac, please jump to the end of the document.

Your first tutorial case: Cavity flow

 $  run (jumps to your working directory)
 $  cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity ./ (copy the cavity tutorial case here)
 $  cd cavity (change directory to cavity)
 $  blockMesh.exe (create the computational mesh)
 $  icoFoam.exe (run the solver)
 $  paraFoam (view results) 

A detailed explanation on this test case can be found here:
http://www.cfdsupport.com/OpenFOAM-Training-by-CFD-Support/node31.html

Example 2: back-ward-facing step

 $  run 
 $  cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily ./
 $  cd pitzDaily
 $  cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike/system/decomposeParDict ./system/
 $  blockMesh.exe
 $  decomposePar.exe
 $  mpiexec -n 6 simpleFoam -parallel
 $  reconstructPar.exe
 $  paraFoam

A detailed explanation on this test case can be found here:
http://www.cfdsupport.com/OpenFOAM-Training-by-CFD-Support/node60.html

Example 3: Creating Your Own Solver

$  mc  
$  run
$  mkdir myFirstOFSolver
$  cd myFirstOFSolver
$  cp -r $FOAM_SOLVERS/incompressible/icoFoam/* ./
$  sed -i "s/\/icoFoam/\/myFirstWindowsOpenFOAMSolver/g" Make/files
alternatively,
$  mcedit Make/files and make the change by yourself.
$  wmake
$  run
$  cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity ./
$  cd cavity/
$  blockMesh.exe
$  myFirstWindowsOpenFOAMSolver.exe
$  paraFoam

Note:

For text editing, if you are a vi user, you have to do the following to get vi inside cygwin to work with the arrow keys:
$ vi ~/.virc (This is the default editor in Linux)
$ type set nocompatible and Esc+:wp

A detailed explanation on adding additional solution variable can be found here:
http://www.cfdsupport.com/OpenFOAM-Training-by-CFD-Support/node177.html

Example 4: the Cool Case: Motorbike

$ run
$  cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike ./
$  cd motorBike
$  find ./ -type f | xargs sed -i "s/WM_PROJECT_DIR/OPENFOAM_INSTALL_PATH/g"
$  ./Allrun
$  paraFoam

Mac Installation

1   Download the sparse image from [SourceForge](https://sourceforge.net/projects/openfoam-extend/files/foam-extend-3.0/) 
2   Unpack and mount the image by clicking on the file
3   Open a terminal and run: mkdir foam
4   cd foam
5   ln -s /Volumes/foam-extend-3.0 .
6   . foam-extend-3.0/etc/bashrc

Now the environment for using OpenFOAM has been set up.
To make the folder where you should hold all your test cases and personalized solver:

$    mkdir -p $FOAM_RUN

Now you can follow the above four examples to explore OpenFOAM.