You are on page 1of 13

Introduction to OpenFOAM

Ole Lindberg
Section of Coastal, Maritime and Structural Engineering Department of Mechanical Engineering Technical University of Denmark

November 18, 2009

Ole Lindberg

Introduction to OpenFOAM

About OpenFOAM

OpenFOAM: Open Field Operation and Manipulation. A open source CFD toolbox written in C++ for the Linux operation system. It is produced by OpenCFD Ltd, freely available and open source. Licensed under the GNU General Public Licence. Homepage: http://www.opencfd.co.uk/

Ole Lindberg

Introduction to OpenFOAM

Why OpenFOAM?

OpenFOAM is open source. It is the best open source CFD program available. The quality of the C++ code is very high. OpenFOAM has almost all standard nite volume methods implemented. It comes with a fairly good documentation. OpenFOAM has an easy to use high level object-orientated programming interface. High licence fees on other commercial CFD packages like CFX or Fluent. The industry is very interested in OpenFOAM.

Ole Lindberg

Introduction to OpenFOAM

Numerical methods in OpenFOAM


OpenFOAM is a Finite Volume CFD program using both structured and unstructured meshes. Some of the numerical methods in OpenFOAM are: Time integration: Backward Euler: Crank-Nicholson:

Euler steadyState

Steady state solver:

CrankNicholson

Gradient, divergence, Laplacian and interpolation schemes: Second order central dierence: linear Fourth order central dierence: cubic First order upwind: upwind First/second order upwind:
linearUpwind

Ole Lindberg

Introduction to OpenFOAM

Numerical methods in OpenFOAM

Linear solvers: Preconditioned (bi-)conjugate gradient: PCG, PBiCG Basic iterative method (e.g. Gauss-Seidel): smoothSolver Geometric and algebraic multigrid: Turbulence models: k-: kEpsilon k-: kOmegaSST LES
GAMG

Ole Lindberg

Introduction to OpenFOAM

Boundary conditions in OpenFOAM

The boundary conditions are setup for each of the ow variables (U, p, etc). Some of the boundary types are: Base types: patch, wall, symmetry, empty, cyclic Primitive types: fixedValue, fixedGradient, mixed, Derived types:
calculated

inletOulet, outletInlet, movingWallVelocity, slip

Ole Lindberg

Introduction to OpenFOAM

Precompiled solvers
OpenFOAM comes with many of precompiled solvers ready for use. The most important of these are:
laplacianFoam potentialFoam scalarTransportFoam icoFoam simpleFoam pisoFoam sonicFoam interFoam dnsFoam electrostaticFoam Solves a simple Laplace equation, e.g. for thermal diusion. Potential ow solver. Solves a transport equation for a passive scalar. Transient solver for incompressible and laminar ow. Steady-state solver for incompressible and turbulent ow. Transient solver for incompressible and turbulent ow. Transient solver for sonic ow of a compressible gas. Two phase incompressible ow, using the VOF method. Direct numerical simulation of isotropic turbulence. Solver for electrostatics.

Ole Lindberg

Introduction to OpenFOAM

Mesh generation in OpenFOAM


OpenFOAM comes with a mesh generation tool:
blockMesh

Block structured meshes. Curved internal and external boundaries. The mesh is setup in a script (no GUI). Good for small grids. External mesh generation is also possible with the tools:
ansysToFoam, cfxToFoam, gmshToFoam and more ...

Block structured mesh. Unstructured mesh. Block structured mesh and unstructured mesh in combination. Large and complex grids can be made with a GUI in e.g. ANSYS ICEM (proprietary) or Gmsh (open source).

Ole Lindberg

Introduction to OpenFOAM

Installation of OpenFOAM
The latest ocial version of OpenFOAM is available on: http://www.opencfd.co.uk/openfoam/download.html Both 32bit or 64bit versions are available. Download the packages: OpenFOAM-1.6.General.gtgz OpenFOAM-1.6.linuxGccDPOpt.gtgz ThirdParty.General.gtgz ThirdParty.linuxGcc.gtgz and save the les in the directory structure as described on the download page. Unpack the les, e.g.:
tar xzf OpenFOAM-1.6.General.gtgz

Read the le
$HOME/OpenFOAM/OpenFOAM-1.6/README

and follow the instructions.

Ole Lindberg

Introduction to OpenFOAM

Installation of ParaView

OpenFOAM uses ParaView as ow visualisation tool, see http://www.paraview.org/. ParaView uses Qt (a C++ GUI library). Install Qt from the repository of your Linux distribution.

Ole Lindberg

Introduction to OpenFOAM

Setup a new OpenFOAM simulation


Start a new OpenFOAM case:
mkdir $HOME/OpenFOAM/$USER-1.6/run/MySimulation

Go to your new case directory:


cd $HOME/OpenFOAM/$USER-1.6/run/MySimulation

Copy one of the tutorials into your case:


cp -r $HOME/OpenFOAM/$USER-1.6/run/incompressible/icoFoam/cavity/* .

Set physical parameters in:


./constant/transportProperties

Setup the mesh in:


./constant/polyMesh/blockMeshDict

Setup the initial and boundary conditions in:


./0/U (and p, k, epsilon etc.)

Set the start time, end time and Courant number in:
./system/controlDict

Setup temporal schemes and spatial nite volume schemes in:


./system/fvSchemes

Setup linear solvers in:


./system/fvSolution
Ole Lindberg Introduction to OpenFOAM

Basic working cycle


Go to your case directory:
cd $HOME/OpenFOAM/$USER-1.6/run/MySimulation

Run the mesh generation:


blockMesh

Run the simulation:


icoFoam

Do some post-processing, e.g. calculation of vorticity:


vorticity

View the solution using paraView:


paraFoam

In trouble? Read the manual:


$HOME/OpenFOAM/OpenFOAM-1.6/doc/Guides-a4/UserGuide.pdf

look at the tutorials:


$HOME/OpenFOAM/OpenFOAM-1.6/tutorials

or search the OpenFOAM forum:


http://www.cfd-online.com/Forums/openfoam/
Ole Lindberg Introduction to OpenFOAM

Mesh generation with Gmsh


Install Gmsh from the repository of your Linux distribution or download it here http://www.geuz.org/gmsh/ For introductions to Gmsh see: http://www.geuz.org/gmsh/doc/texinfo/ http://www.geuz.org/gmsh/screencasts/ http://ffep.sourceforge.net/Download/gui_tutorial.pdf Go to your OpenFOAM case folder:
cd $HOME/OpenFOAM/$USER-1.6/run/MySimulation

Download the Gmsh le place it in the folder: Run Gmsh:

mesh.geo

from le sharing on Campusnet and

$HOME/OpenFOAM/$USER-1.6/MySimulation/constant/gmshMesh/

gmsh -3 constant/gmshMesh/mesh.geo -o constant/gmshMesh/mesh.msh

Convert the gmsh mesh to OpenFOAM format:


gmshToFoam constant/gmshMesh/mesh.msh

Setup the your OpenFOAM ow case, e.g. boundary conditions, and start calculating.
Ole Lindberg Introduction to OpenFOAM

You might also like