openfoam: an introductionpowerlab.fsb.hr/ped/kturbo/openfoam/workshopzagreb... · • openfoam user...

22
OpenFOAM: An Introduction Hrvoje Jasak [email protected] Wikki Ltd, United Kingdom FSB, University of Zagreb, Croatia 18/Nov/2005 OpenFOAM:An Introduction – p.1/22

Upload: trandung

Post on 02-May-2018

304 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

OpenFOAM:An Introduction

Hrvoje Jasak

[email protected]

Wikki Ltd, United Kingdom

FSB, University of Zagreb, Croatia

18/Nov/2005

OpenFOAM:An Introduction – p.1/22

Page 2: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Outline

Objective: A high-level overview of OpenFOAM

• Present a novel way of handling softwareimplementation in numerical mechanics

Topics

• Requirements on modern CFD software

• A new approach to model representation

• Mesh handling and polyhedral support

• Pre-implemented capabilities

OpenFOAM:An Introduction – p.2/22

Page 3: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Background

State of the Art

• Numerical modelling part of product design◦ Improvements in computer performance◦ Improved physical modelling and numerics◦ Sufficient validation and experience

• Two-fold requirements◦ Models for wide area of physics + coupling◦ Complex geometry, high-performance

computing, automatic meshing etc.

OpenFOAM:An Introduction – p.3/22

Page 4: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Background

Requirements on Software Design

• Industrial Environment◦ Integration into CAD-based process◦ Complex geometry and automatic meshing◦ Robust, fast and accurate solvers

• Research Organisations◦ Quick and reliable model implementation◦ Experimentation with various model forms◦ Separation between physics and numerics

OpenFOAM:An Introduction – p.4/22

Page 5: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Numerics for CCM

How to handle complex models in software?

• Natural language of continuum mechanics:partial differential equations

∂k

∂t+ ∇•(uk) −∇•[(ν + νt)∇k] =

νt

[

1

2(∇u + ∇u

T )

]2

−ǫo

ko

k

• Main object = operator, e.g. time derivative,convection, diffusion, gradient

OpenFOAM:An Introduction – p.5/22

Page 6: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

OpenFOAM: CCM in C++

OpenFOAM (Field Operation and Manipulation):Represent equations in their natural language

solve

(

fvm::ddt(k)

+ fvm::div(phi, k)

- fvm::laplacian(nu() + nut, k)

== nut*magSqr(symm(fvc::grad(U)))

- fvm::Sp(epsilon/k, k)

);

OpenFOAM:An Introduction – p.6/22

Page 7: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Object Orientation

Recognise main objects from the numericalmodelling viewpoint

• Computational domainObject Software representation C++ Class

Time Time steps (database) time

Tensor (List of) numbers + algebra vector, tensor

Mesh primitives Point, face, cell Point, face, cell

Space Computational mesh polyMesh

OpenFOAM:An Introduction – p.7/22

Page 8: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Object Orientation

• Field algebraObject Software representation C++ Class

Field List of values Field

Boundary condition Values + condition patchField

Dimensions Dimension Set dimensionSet

Geometric field Field + boundary conditions geometricField

Field algebra + − ∗ / tr(), sin(), exp() . . . field operators

• Matrix and solversObject Software representation C++ Class

Linear equation matrix Matrix coefficients lduMatrix

Solvers Iterative solvers lduMatrix::solver

OpenFOAM:An Introduction – p.8/22

Page 9: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Object Orientation

• NumericsObject Software representation C++ Class

Interpolation Differencing schemes interpolation

Differentiation ddt, div, grad, curl fvc, fec

Discretisation ddt, d2dt2, div, laplacian fvm, fem, fam

Implemented Methods: Finite Volume, FiniteElement, Finite Area and Lagrangian tracking

• Top-level organisationObject Software representation C++ Class

Model library Library turbulenceModel

Application main() –

OpenFOAM:An Introduction – p.9/22

Page 10: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Model Interaction

Common Interface for Related Models

class turbulenceModel

{

virtual volTensorField R() const = 0;

virtual fvVectorMatrix divR

(

volVectorField& U

) const = 0;

virtual void correct() = 0;

};

class SpalartAllmaras : public turbulenceModel{};

OpenFOAM:An Introduction – p.10/22

Page 11: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

FOAM: CCM in C++

Model-to-Model Interaction

fvVectorMatrix UEqn

(

fvm::ddt(rho, U)

+ fvm::div(phi, U)

+ turbulence->divR(U)

==

- fvc::grad(p)

);

New components do not disturb existing code

OpenFOAM:An Introduction – p.11/22

Page 12: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Run-Time Selection

• Model-to-model interaction through commoninterfaces (virtual base classes)

• New components do not disturb existing code

• Run-time selection tables: dynamic binding

• Used for every implementation: “user-coding”◦ Convection differencing schemes

◦ Gradient calculation

◦ Boundary conditions

◦ Linear equation solvers

◦ Physical modelling, e.g. evaporation model, etc.

OpenFOAM:An Introduction – p.12/22

Page 13: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Geometry Handling

Complex Geometry: Meshing Issues

• Complex geometry is a rule, not exception

• Polyhedral cell support◦ Cell is a polyhedron bounded by polygons◦ Consistent handling of all cell types◦ More freedom in mesh generation

• Automatic motion solver + topo morph engine

OpenFOAM:An Introduction – p.13/22

Page 14: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Geometry Handling

Time-Varying Geometry

• Automatic mesh motion solver

• Topological mesh changes with poly support

OpenFOAM:An Introduction – p.14/22

Page 15: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Speed of Execution

Handling large-scale computations

• Efficient numerics◦ Best discretisation practice for a given

problem◦ Iterative solvers almost inevitable◦ Careful analysis of non-linearity and

inter-equation coupling

• Massive parallelism: domain decomposition

OpenFOAM:An Introduction – p.15/22

Page 16: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Layered Development

• Design encourages code re-use: shared tools

• Code developed and tested in isolation◦ Vectors, tensors and field algebra◦ Mesh handling, refinement, topo changes◦ Discretisation, boundary conditions◦ Matrices and solver technology◦ Physics by segment◦ Custom applications

• Ultimate user-coding capabilities!

OpenFOAM:An Introduction – p.16/22

Page 17: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Implemented Capabilities

Discretisation

• Polyhedral Finite Volume Method with movingmesh support (second and fourth-order)

• Finite Element Method on polyhedral cells

• Finite Area Method (2-D FVM on a surface)

• Lagrangian particle tracking model

• Ordinary differential equation solver

OpenFOAM:An Introduction – p.17/22

Page 18: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Implemented Capabilities

Model and Utility Libraries

• Thermo-physical models (liquids and gasses)

• Chemical properties

• Non-Newtonian viscosity models

• Turbulence models (RANS and LES)

• Dynamic mesh and topology changes

• A-posteriori error estimation

• Diesel spray (atomisation, dispersion, heattransfer, evaporation, spray-wall etc.)

OpenFOAM:An Introduction – p.18/22

Page 19: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Implemented Capabilities

Top-Level Solvers

• Top-level applications: provided withOpenFOAM or developed for the purpose

• Should be considered as both◦ Pre-packaged functionality◦ Examples of library use

• . . . in short, this is a small subset of all solversimplemented in OpenFOAM

OpenFOAM:An Introduction – p.19/22

Page 20: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Implemented Capabilities

Top-Level Solvers

• Basic: Laplace, potential flow, transport

• Incompressible flow, compressible flow

• Heat transfer: buoyancy-driven flows

• Multiphase: Euler-Euler, surface capturingand tracking

• DNS and LES turbulent flows

• Combustion, spray and in-cylinder flows

• Stress analysis, electromagnetics, MHD, etc.OpenFOAM:An Introduction – p.20/22

Page 21: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

Summary

• Object-oriented approach facilitates modelimplementation: layered design + re-use

• Equation mimicking opens new CCM grounds

• Extensive capabilities already implemented

• Open design for easy user customisation

Acknowledgements and Further Info

• For more info on OpenFOAM, please visit http://www.openfoam.org

• OpenFOAM resources: http://www.foamcfd.org

• OpenFOAM User Group: http://openfoam.cfd-online.com

• OpenFOAM Workshops and Seminars

OpenFOAM:An Introduction – p.21/22

Page 22: OpenFOAM: An Introductionpowerlab.fsb.hr/ped/kturbo/OpenFOAM/WorkshopZagreb... · • OpenFOAM User Group: • OpenFOAM Workshops and Seminars OpenFOAM:An Introduction – p.21/22

FOAM: CCM in C++

Main characteristics

• Wide area of applications: all of CCM!

• Shared tools and code re-use

Versatility

• Unstructured meshes, automatic meshmotion + topological changes

• Finite Volume, Finite Element, Lagrangiantracking and Finite Area methods

• Efficiency through massive parallelism

OpenFOAM:An Introduction – p.22/22