lectureslides10_openfoam

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

Upload: suekrue-ayhan-baydir

Post on 22-Oct-2014

308 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: LectureSlides10_openfoam

Introduction to OpenFOAM

Ole Lindberg

Section of Coastal, Maritime and Structural Engineering

Department of Mechanical EngineeringTechnical University of Denmark

November 18, 2009

Ole Lindberg Introduction to OpenFOAM

Page 2: LectureSlides10_openfoam

About OpenFOAM

OpenFOAM: Open Field Operation and Manipulation.

A open source CFD toolbox written in C++ for the Linux operationsystem.

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

Page 3: LectureSlides10_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 finite volume methodsimplemented.

It comes with a fairly good documentation.

OpenFOAM has an easy to use high level object-orientatedprogramming interface.

High licence fees on other commercial CFD packages like CFX orFluent.

The industry is very interested in OpenFOAM.

Ole Lindberg Introduction to OpenFOAM

Page 4: LectureSlides10_openfoam

Numerical methods in OpenFOAM

OpenFOAM is a Finite Volume CFD program using both structured andunstructured meshes.

Some of the numerical methods in OpenFOAM are:

Time integration:

Backward Euler: Euler

Steady state solver: steadyState

Crank-Nicholson: CrankNicholson

Gradient, divergence, Laplacian and interpolation schemes:

Second order central difference: linear

Fourth order central difference: cubic

First order upwind: upwind

First/second order upwind: linearUpwind

Ole Lindberg Introduction to OpenFOAM

Page 5: LectureSlides10_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: GAMG

Turbulence models:

k-ε: kEpsilon

k-ω: kOmegaSST

LES

Ole Lindberg Introduction to OpenFOAM

Page 6: LectureSlides10_openfoam

Boundary conditions in OpenFOAM

The boundary conditions are setup for each of the flow variables (U, p,etc).

Some of the boundary types are:

Base types: patch, wall, symmetry, empty, cyclic

Primitive types: fixedValue, fixedGradient, mixed, calculated

Derived types: inletOulet, outletInlet, movingWallVelocity, slip

Ole Lindberg Introduction to OpenFOAM

Page 7: LectureSlides10_openfoam

Precompiled solvers

OpenFOAM comes with many of precompiled solvers ready for use.

The most important of these are:

laplacianFoam Solves a simple Laplace equation, e.g. for thermal diffusion.

potentialFoam Potential flow solver.

scalarTransportFoam Solves a transport equation for a passive scalar.

icoFoam Transient solver for incompressible and laminar flow.

simpleFoam Steady-state solver for incompressible and turbulent flow.

pisoFoam Transient solver for incompressible and turbulent flow.

sonicFoam Transient solver for sonic flow of a compressible gas.

interFoam Two phase incompressible flow, using the VOF method.

dnsFoam Direct numerical simulation of isotropic turbulence.

electrostaticFoam Solver for electrostatics.

Ole Lindberg Introduction to OpenFOAM

Page 8: LectureSlides10_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. ANSYSICEM (proprietary) or Gmsh (open source).

Ole Lindberg Introduction to OpenFOAM

Page 9: LectureSlides10_openfoam

Installation of OpenFOAM

The latest official 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 files in the directory structure as described on the downloadpage.Unpack the files, e.g.:tar xzf OpenFOAM-1.6.General.gtgz

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

and follow the instructions.

Ole Lindberg Introduction to OpenFOAM

Page 10: LectureSlides10_openfoam

Installation of ParaView

OpenFOAM uses ParaView as flow visualisation tool, seehttp://www.paraview.org/.

ParaView uses Qt (a C++ GUI library).

Install Qt from the repository of your Linux distribution.

Ole Lindberg Introduction to OpenFOAM

Page 11: LectureSlides10_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 finite volume schemes in:./system/fvSchemes

Setup linear solvers in:./system/fvSolution

Ole Lindberg Introduction to OpenFOAM

Page 12: LectureSlides10_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

Page 13: LectureSlides10_openfoam

Mesh generation with Gmsh

Install Gmsh from the repository of your Linux distribution or download ithere 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 file mesh.geo from file sharing on Campusnet andplace it in the folder:$HOME/OpenFOAM/$USER-1.6/MySimulation/constant/gmshMesh/

Run Gmsh: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 flow case, e.g. boundary conditions, andstart calculating.

Ole Lindberg Introduction to OpenFOAM