openfoam introduction - uliege · openfoam what's openfoam? openfoam: open source field...

39
OpenFOAM Introduction Speakers: Francois Rigo [email protected] José Rothkegel [email protected] Amandine GUISSART [email protected] February 2016

Upload: dinhdiep

Post on 11-Apr-2018

294 views

Category:

Documents


3 download

TRANSCRIPT

Page 2: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFoam

What's OpenFOAM? OpenFOAM: Open source Field Operation And

Manipulation C++ toolbox for the development of customized

numerical solvers, and pre-/post-processing utilitiesfor the solution of continuum mechanics problems,including computational fluid dynamics (CFD).

Page 3: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFoam

What comes with OpenFOAM? Basic CFD solvers

Incompressible flow with RANS and LES Advanced CFD solvers

Compressible flow solvers with RANS and LES Buoyancy-driven flow solvers Multiphase flow solvers Combustion problems Solvers for conjugate heat transfer

Particle Tracking

Molecular dynamics solvers[28]

Electromagnetics solvers

Solid dynamics solvers

Page 4: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFoam

What are the applications of OpenFOAM?

Page 5: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

CATIA Room

Ubuntu Login User: foam Pass: catia1135

Page 6: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Linux Basics

Open Terminal: In gnome 2.x:

Applications → Accesories → Terminal In KDE 4.x:

Applications menu → Systems → Konsole

Page 7: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Linux Basics

Create Folder ~$mkdir name

Copy files ~$cp name destination

Delete files(attention: no undelete option) ~$rm name

Rename file ~$mv name_original name_new

To edit a file, we'll use Gedit $gedit filename

Page 8: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Linux Basics

Change directory ~$cd folder

Go to home directory ~$cd

See working directory ~$pwd

See working directory's content ~$ls

Page 9: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

Create a directory named student_work_2016_A in the OpenFOAM workdirectory

~$cd

~$cd OpenFOAM/foam-2.1.1/run

Note: you can use the <tab> key to autocomplete the line ~$mkdir student_work_2016_A

Copy the cavity problem to the created directory ~$cp -r tutorials/incompressible/icoFoam/cavity student_work_2016_A/

Go to student_work_2016_A ~$cd student_work_2016_A

Rename the folder to Cavity_original ~$mv cavity cavity_original

Go to cavity_original folder ~$cd cavity_original

Page 10: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

Folder structure

Page 11: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

Test case problem: lid-driven cavity

Page 12: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

Block Structure of of mesh

Page 13: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

blockMeshDictconvertToMeters 0.1;

vertices ( (0 0 0) (1 0 0) (1 1 0) (0 1 0) (0 0 0.1) (1 0 0.1) (1 1 0.1) (0 1 0.1));

Page 14: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

blockMeshDictblocks ( hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1));

Page 15: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

blockMeshDictboundary( movingWall { type wall; faces ( (3 7 6 2) ); }

fixedWalls { type wall; faces ( (0 4 7 3) (2 6 5 1) (1 5 4 0) ); }

...

...

frontAndBack { type empty; faces ( (0 3 2 1) (4 5 6 7) ); });

Page 16: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

To generate the mesh from the blockMeshDict: ~$blockMesh

To visualize the mesh: ~$paraFoam

Page 17: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

In paraFoam:a) Apply in the Object Inspector

b) Surface With edges in the representation menu

a

b

Page 18: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

Problem set-up Initial values: Folder ”0”

U p

Properties: Folder ”constant” TransportProperties

Numerical Control: Folder ”system” controlDict fvSchemes fvSolution

Page 19: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

File: ”p”dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField{ movingWall { type zeroGradient; }

fixedWalls { type zeroGradient; }

frontAndBack { type empty; }}

Page 20: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

File: ”U”dimensions [0 1 -1 0 0 0 0];internalField uniform (0 0 0);boundaryField{ movingWall { type fixedValue; value uniform (1 0 0); }

fixedWalls { type fixedValue; value uniform (0 0 0); }

frontAndBack { type empty; }}

Page 21: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

File: ”U” For external flows

dimensions [0 1 -1 0 0 0 0];internalField uniform (0 0 0);boundaryField{ dummyWall { type freestream; freestreamValue uniform (1 0 0); }

}

Page 22: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

File: ”transportProperties”nu [ 0 2 -1 0 0 0 0 ] 0.01;

Page 23: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

File: ”controlDict”application icoFoam;

startFrom startTime;startTime 0;stopAt endTime;endTime 0.5;

DeltaT 0.005; // CFL is imposed through δt

writeControl timeStep;writeInterval 20;purgeWrite 0;writeFormat ascii;writePrecision 6;writeCompression off;

timeFormat general;timePrecision 6;runTimeModifiable true;

CFL=δ t|U|δ x

Page 24: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Basics

To run the case ~$icoFoam

To visualize the results: ~$paraFoam

Page 25: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

paraFoam Basics

a

Page 26: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

paraFoam Basics

b

c d

Page 27: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

paraFoam Basics

Common toolbar

Glyph: to show arrows

Stream tracer: to showstreamlines

Page 28: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

Mesh Grading Problem is based on the lid-driven cavity tutorial It introduces the mesh grading feature

Page 29: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

Test case problem: lid-driven cavity

Page 30: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

Page 31: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

Create a directory named student_work_2016_A in theOpenFOAM work directory

~$cd

~$cd OpenFOAM/foam-2.1.1/run

Note: you can use the <tab> key to autocomplete the line Copy the cavity problem to the created directory

~$cp -rtutorials/incompressible/icoFoam/cavitystudent_work_2016_A/

Go to student_work_2016_A

~$cd student_work_2016_A/

Rename the folder to cavity_grading

~$mv cavity cavity_grading

Page 32: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

blockMeshDictvertices( (0.0 0.0 0.0) (0.5 0.0 0.0) (1.0 0.0 0.0)

(0.0 0.5 0.0) (0.5 0.5 0.0) (1.0 0.5 0.0)

(0.0 1.0 0.0) (0.5 1.0 0.0) (1.0 1.0 0.0)

(0.0 0.0 0.1) (0.5 0.0 0.1) (1.0 0.0 0.1) (0.0 0.5 0.1) (0.5 0.5 0.1) (1.0 0.5 0.1) (0.0 1.0 0.1) (0.5 1.0 0.1) (1.0 1.0 0.1));

Page 33: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

blockMeshDictblocks( hex (0 1 4 3 9 10 13 12) (10 10 1) simpleGrading (2 2 1) hex (1 2 5 4 10 11 14 13) (10 10 1) simpleGrading (0.5 2 1) hex (3 4 7 6 12 13 16 15) (10 10 1) simpleGrading (2 0.5 1) hex (4 5 8 7 13 14 17 16) (10 10 1) simpleGrading (0.5 0.5 1));

Page 34: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Workboundary( movingWall { type wall; faces ( (6 15 16 7) (7 16 17 8) ); }

fixedWalls { type wall; faces ( (3 12 15 6) (0 9 12 3) (0 1 10 9) (1 2 11 10) (2 5 14 11) (5 8 17 14) ); }...

...

frontAndBack { type empty; faces ( (0 3 4 1) (1 4 5 2) (3 6 7 4) (4 7 8 5) (9 10 13 12) (10 11 14 13) (12 13 16 15) (13 14 17 16) ); });

Page 35: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

Student Work

Build mesh ~$blockMesh

Run the files: ~$icoFoam

View the results: ~$paraFoam

Page 36: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Integrals

To calculate the integral of variable over apatch

General structure ~$ patchIntegrate <variable> <patch>

For example: ~$ patchIntegrate U movingWall

Page 37: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Integrals

To calculate forces controlDict...timeFormat general;

timePrecision 6;

runTimeModifiable true;

functions{

#include "forceCoeffs"}

Page 38: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

OpenFOAM Integrals

To calculate forces forceCoeffs Adapted from

tutorials/incompressible/simpleFoam/motorBike/system/forceCoeffs

/*--------------------------------*- C++ -*----------------------------------*\| ========= | || \\ / F ield | OpenFOAM: The Open Source CFD Toolbox || \\ / O peration | Version: v3.0+ || \\ / A nd | Web: www.OpenFOAM.com || \\/ M anipulation | |\*---------------------------------------------------------------------------*/

forceCoeffs1{ type forceCoeffs;

functionObjectLibs ( "libforces.so" );

outputControl timeStep; timeInterval 1;

log yes;

patches ( patchesName ); rhoName rhoInf; // Indicates incompressible rhoInf 1; // Redundant for incompressible liftDir (0 0 1); dragDir (1 0 0); CofR (1 0 0); // Axle midpoint on ground pitchAxis (0 1 0); magUInf 20; lRef 1.0; // Reference length Aref 1.0; // Reference Area}

Remember to set the correct values!!!

C L=2FL

ρU∞2 A

CD=2FD

ρU∞2 A

Page 39: OpenFOAM Introduction - ULiege · OpenFoam What's OpenFOAM? OpenFOAM: Open source Field Operation And Manipulation C++ toolbox for the development of customized numerical solvers,

References

Linux Just google:”linux commands”

OpenFOAM OpenFoam User Guide

Installing OpenFOAM http://www.openfoam.com/version-v3.0+/