openfoam tutorials

Upload: kushvverma2003

Post on 01-Jun-2018

312 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 OpenFoam Tutorials

    1/233

    INTRODUCTION TO OPEN-FOAM

    Chapter 1 IntroductionThis guide accompanies the release of version 2.3.1 of the Open Source Field Operation andManipulation (OpenFOAM) !! li"raries. #t provides a description of the "asic operation ofOpenFOAM$ first through a set of tutorial e%ercises in chapter 2and later "& a more detaileddescription of the individual components that ma'e up OpenFOAM.

    OpenFOAM is first and foremost a !! li"rar&$ used primaril& to create e%ecuta"les$ 'non asapplications. The applications fall into to categories solvers$ that are each designed to solve aspecific pro"lem in continuum mechanics* and utilities$ that are designed to perform tas's thatinvolve data manipulation. The OpenFOAM distri"ution contains numerous solvers and utilitiescovering a ide range of pro"lems$ as descri"ed in chapter 3.

    One of the strengths of OpenFOAM is that ne solvers and utilities can "e created "& its users ith

    some pre+re,uisite 'noledge of the underl&ing method$ ph&sics and programming techni,uesinvolved.

    OpenFOAM is supplied ith pre+ and post+processing environments. The interface to the pre+ andpost+processing are themselves OpenFOAM utilities$ there"& ensuring consistent data handlingacross all environments. The overall structure of OpenFOAM is shon in Figure1.1.

    Figure 1.1 Overvie of OpenFOAM structure.

    The pre+processing and running of OpenFOAM cases is descri"ed in chapter -.#n chapter$ ecover "oth the generation of meshes using the mesh generator supplied ith OpenFOAM andconversion of mesh data generated "& third+part& products. /ost+processing is descri"ed inchapter 0.

    Chapter 2 Tutorials#n this chapter e shall descri"e in detail the process of setup$ simulation and post+processing forsome OpenFOAM test cases$ ith the principal aim of introducing a user to the "asic procedures ofrunning OpenFOAM. The FOAMTTO4#A5S director& contains man& more cases that

    demonstrate the use of all the solvers and man& utilities supplied ith OpenFOAM. 6eforeattempting to run the tutorials$ the user must first ma'e sure that the& have installed OpenFOAMcorrectl&.

    http://openfoam.org/docs/user/tutorials.php#x4-30002http://openfoam.org/docs/user/applications.php#x8-630003http://openfoam.org/docs/user/applications.php#x8-630003http://openfoam.org/docs/user/userch1.php#x3-20011http://openfoam.org/docs/user/userch1.php#x3-20011http://openfoam.org/docs/user/cases.php#x16-920004http://openfoam.org/docs/user/cases.php#x16-920004http://openfoam.org/docs/user/mesh.php#x22-1270005http://openfoam.org/docs/user/mesh.php#x22-1270005http://openfoam.org/docs/user/postprocessing.php#x29-1770006http://openfoam.org/docs/user/tutorials.php#x4-30002http://openfoam.org/docs/user/applications.php#x8-630003http://openfoam.org/docs/user/userch1.php#x3-20011http://openfoam.org/docs/user/cases.php#x16-920004http://openfoam.org/docs/user/mesh.php#x22-1270005http://openfoam.org/docs/user/postprocessing.php#x29-1770006
  • 8/9/2019 OpenFoam Tutorials

    2/233

    The tutorial cases descri"e the use of the "loc'Mesh pre+processing tool$ case setup and runningOpenFOAM solvers and post+processing using paraFoam. Those users ith access to third+part&post+processing tools supported in OpenFOAM have an option either the& can follo the tutorialsusing paraFoam* or refer to the description of the use of the third+part& product in chapter 0henpost+processing is re,uired.

    opies of all tutorials are availa"le from the tutorials director& of the OpenFOAM installation. The

    tutorials are organised into a set of directories according to the t&pe of flo and then su"directoriesaccording to solver. For e%ample$ all the icoFoam cases are stored ithin a su"director&incompressi"le7icoFoam$ here incompressi"le indicates the t&pe of flo. #f the user ishes to runa range of e%ample cases$ it is recommended that the user cop& the tutorials director& into their localrun director&. The& can "e easil& copied "& t&ping

    m'dir +p FOAM48cp +r FOAMTTO4#A5S FOAM48

    2.1 5id+driven cavit& flo2.1.1 /re+processing

    2.1.2 9ieing the mesh2.1.3 4unning an application2.1.- /ost+processing2.1. #ncreasing the mesh resolution2.1.0 #ntroducing mesh grading2.1.: #ncreasing the 4e&nolds num"er2.1.; /ost+processing2.3.11 4unning in parallel2.3.12 /ost+processing a case run in parallel

    21 !id-dri"en ca"it# $lo%

    This tutorial ill descri"e ho to pre+process$ run and post+process a case involving isothermal$incompressi"le flo in a to+dimensional s,uare domain. The geometr& is shon in Figure 2.1inhich all the "oundaries of the s,uare are alls. The top all moves in the +direction at a speed of1 m7s hile the other 3 are stationar&. #nitiall&$ the flo ill "e assumed laminar and ill "e solvedon a uniform mesh using the icoFoam solver for laminar$ isothermal$ incompressi"le flo. @uringthe course of the tutorial$ the effect of increased mesh resolution and mesh grading toards the

    http://openfoam.org/docs/user/postprocessing.php#x29-1770006http://openfoam.org/docs/user/cavity.php#x5-40002.1http://openfoam.org/docs/user/cavity.php#x5-50002.1.1http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/cavity.php#x5-120002.1.3http://openfoam.org/docs/user/cavity.php#x5-130002.1.4http://openfoam.org/docs/user/cavity.php#x5-170002.1.5http://openfoam.org/docs/user/cavity.php#x5-250002.1.6http://openfoam.org/docs/user/cavity.php#x5-290002.1.7http://openfoam.org/docs/user/cavity.php#x5-290002.1.7http://openfoam.org/docs/user/cavity.php#x5-320002.1.8http://openfoam.org/docs/user/cavity.php#x5-350002.1.9http://openfoam.org/docs/user/cavity.php#x5-360002.1.10http://openfoam.org/docs/user/plateHole.php#x6-370002.2http://openfoam.org/docs/user/plateHole.php#x6-380002.2.1http://openfoam.org/docs/user/plateHole.php#x6-440002.2.2http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/plateHole.php#x6-460002.2.4http://openfoam.org/docs/user/damBreak.php#x7-500002.3http://openfoam.org/docs/user/damBreak.php#x7-510002.3.1http://openfoam.org/docs/user/damBreak.php#x7-520002.3.2http://openfoam.org/docs/user/damBreak.php#x7-530002.3.3http://openfoam.org/docs/user/damBreak.php#x7-540002.3.4http://openfoam.org/docs/user/damBreak.php#x7-550002.3.5http://openfoam.org/docs/user/damBreak.php#x7-560002.3.6http://openfoam.org/docs/user/damBreak.php#x7-570002.3.7http://openfoam.org/docs/user/damBreak.php#x7-580002.3.8http://openfoam.org/docs/user/damBreak.php#x7-590002.3.9http://openfoam.org/docs/user/damBreak.php#x7-600002.3.10http://openfoam.org/docs/user/damBreak.php#x7-610002.3.11http://openfoam.org/docs/user/damBreak.php#x7-620002.3.12http://openfoam.org/docs/user/cavity.php#x5-40111http://openfoam.org/docs/user/postprocessing.php#x29-1770006http://openfoam.org/docs/user/cavity.php#x5-40002.1http://openfoam.org/docs/user/cavity.php#x5-50002.1.1http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/cavity.php#x5-120002.1.3http://openfoam.org/docs/user/cavity.php#x5-130002.1.4http://openfoam.org/docs/user/cavity.php#x5-170002.1.5http://openfoam.org/docs/user/cavity.php#x5-250002.1.6http://openfoam.org/docs/user/cavity.php#x5-290002.1.7http://openfoam.org/docs/user/cavity.php#x5-320002.1.8http://openfoam.org/docs/user/cavity.php#x5-350002.1.9http://openfoam.org/docs/user/cavity.php#x5-360002.1.10http://openfoam.org/docs/user/plateHole.php#x6-370002.2http://openfoam.org/docs/user/plateHole.php#x6-380002.2.1http://openfoam.org/docs/user/plateHole.php#x6-440002.2.2http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/plateHole.php#x6-460002.2.4http://openfoam.org/docs/user/damBreak.php#x7-500002.3http://openfoam.org/docs/user/damBreak.php#x7-510002.3.1http://openfoam.org/docs/user/damBreak.php#x7-520002.3.2http://openfoam.org/docs/user/damBreak.php#x7-530002.3.3http://openfoam.org/docs/user/damBreak.php#x7-540002.3.4http://openfoam.org/docs/user/damBreak.php#x7-550002.3.5http://openfoam.org/docs/user/damBreak.php#x7-560002.3.6http://openfoam.org/docs/user/damBreak.php#x7-570002.3.7http://openfoam.org/docs/user/damBreak.php#x7-580002.3.8http://openfoam.org/docs/user/damBreak.php#x7-590002.3.9http://openfoam.org/docs/user/damBreak.php#x7-600002.3.10http://openfoam.org/docs/user/damBreak.php#x7-610002.3.11http://openfoam.org/docs/user/damBreak.php#x7-620002.3.12http://openfoam.org/docs/user/cavity.php#x5-40111
  • 8/9/2019 OpenFoam Tutorials

    3/233

    alls ill "e investigated. Finall&$ the flo 4e&nolds num"er ill "e increased and the pisoFoamsolver ill "e used for tur"ulent$ isothermal$ incompressi"le flo.

    Figure 2.1 eometr& of the lid driven cavit&.

    211 Pre-processin&

    ases are setup in OpenFOAM "& editing case files. sers should select an %editor of choice ithhich to do this$ such as emacs$ vi$ gedit$ 'ate$ nedit$ etc. ?diting files is possi"le in OpenFOAM"ecause the #7O uses a dictionar& format ith 'e&ords that conve& sufficient meaning to "eunderstood "& even the least e%perienced users.

    A case "eing simulated involves data for mesh$ fields$ properties$ control parameters$ etc. Asdescri"ed in section -.1$ in OpenFOAM this data is stored in a set of files ithin a case director&rather than in a single case file$ as in man& other F@ pac'ages. The case director& is given asuita"l& descriptive name$ e.g. the first e%ample case for this tutorial is simpl& named cavit&. #npreparation of editing case files and running the first cavit& case$ the user should change to the casedirector&

    cd FOAM487tutorials7incompressi"le7icoFoam7cavit&

    2111 Mesh &eneration

    OpenFOAM ala&s operates in a 3 dimensional artesian coordinate s&stem and all geometries aregenerated in 3 dimensions. OpenFOAM solves the case in 3 dimensions "& default "ut can "einstructed to solve in 2 dimensions "& specif&ing a BspecialC empt& "oundar& condition on"oundaries normal to the (3rd) dimension for hich no solution is re,uired.

    The cavit& domain consists of a s,uare of side length in the + plane. A uniform meshof 2> "& 2> cells ill "e used initiall&. The "loc' structure is shon in Figure 2.2.

    http://openfoam.org/docs/user/case-file-structure.php#x17-930004.1http://openfoam.org/docs/user/cavity.php#x5-60052http://openfoam.org/docs/user/cavity.php#x5-60052http://openfoam.org/docs/user/case-file-structure.php#x17-930004.1http://openfoam.org/docs/user/cavity.php#x5-60052
  • 8/9/2019 OpenFoam Tutorials

    4/233

    Figure 2.2 6loc' structure of the mesh for the cavit&.

    The mesh generator supplied ith OpenFOAM$ "loc'Mesh$ generates meshes from a descriptionspecified in an input dictionar&$ "loc'Mesh@ict located in the constant7pol&Mesh director& for agiven case. The "loc'Mesh@ict entries for this case are as follos

    7D++++++++++++++++++++++++++++++++D+ !! +D++++++++++++++++++++++++++++++++++DE2 GGGGGGGGG 3 EE 7 F ield OpenFOAM The Open Source F@ Tool"o% - EE 7 O peration 9ersion 2.3.1 EE 7 A nd He" .OpenFOAM.org

    0 EE7 M anipulation : ED+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++D7; FoamFile= I1> version 2.>*11 format ascii*12 class dictionar&*13 o"Ject "loc'Mesh@ict*1- K1 77 D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D 7710

    1: convertToMeters >.1*1;1= vertices2> (21 (> > >)22 (1 > >)23 (1 1 >)2- (> 1 >)2 (> > >.1)20 (1 > >.1)2: (1 1 >.1)

    2; (> 1 >.1)2= )*3>

  • 8/9/2019 OpenFoam Tutorials

    5/233

    31 "loc's32 (33 he% (> 1 2 3 - 0 :) (2> 2> 1) simplerading (1 1 1)3- )*330 edges

    3: (3; )*3=-> "oundar&-1 (-2 movingHall-3 I-- t&pe all*- faces-0 (-: (3 : 0 2)

    -; )*-= K> fi%edHalls1 I2 t&pe all*3 faces- ( (> - : 3)0 (2 0 1): (1 - >); )*= K0> frontAnd6ac'01 I02 t&pe empt&*03 faces0- (0 (> 3 2 1)00 (- 0 :)0: )*0; K

    0= )*:>:1 merge/atch/airs:2 (:3 )*:-: 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    The file first contains header information in the form of a "anner (lines 1+:)$ then file informationcontained in a FoamFile su"+dictionar&$ delimited "& curl& "races (ILK).

    For the remainder of the manual

    For the sa'e of clarit& and to save space$ file headers$ including the "anner and FoamFile su"+dictionar&$ ill "e removed from ver"atim ,uoting of case files

    The file first specifies coordinates of the "loc' vertices* it then defines the "loc's (here$ onl& 1)

  • 8/9/2019 OpenFoam Tutorials

    6/233

    from the verte% la"els and the num"er of cells ithin it* and finall&$ it defines the "oundar& patches.The user is encouraged to consult section .3to understand the meaning of the entries in the"loc'Mesh@ict file.

    The mesh is generated "& running "loc'Mesh on this "loc'Mesh@ict file. From ithin the casedirector&$ this is done$ simpl& "& t&ping in the terminal

    "loc'Mesh

    The running status of "loc'Mesh is reported in the terminal indo. An& mista'es in the"loc'Mesh@ict file are pic'ed up "& "loc'Mesh and the resulting error message directs the user tothe line in the file here the pro"lem occurred. There should "e no error messages at this stage.

    2112 'oundar# and initial conditions

    Once the mesh generation is complete$ the user can loo' at this initial fields set up for this case. Thecase is set up to start at time s$ so the initial field data is stored in a > su"+director& of thecavit& director&. The > su"+director& contains 2 files$ p and $ one for each of the pressure ( ) and

    velocit& ( ) fields hose initial values and "oundar& conditions must "e set. 5et us e%amine file p

    1: dimensions > 2 +2 > > > >N*1;1= internalField uniform >*2>21 "oundar&Field22 I23 movingHall2- I2 t&pe eroradient*

    20 K2:2; fi%edHalls2= I3> t&pe eroradient*31 K3233 frontAnd6ac'3- I3 t&pe empt&*30 K

    3: K3;3= 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    There are 3 principal entries in field data files

    dimensionsspecifies the dimensions of the field$ here 'inematic pressure$ i.e. (see section -.2.0formore information)*

    internalFieldthe internal field data hich can "e uniform$ descri"ed "& a single value* or nonuniform$here all the values of the field must "e specified (see section-.2.;for more information)*

    "oundar&Fieldthe "oundar& field data that includes "oundar& conditions and data for all the "oundar&patches (see section-.2.;for more information).

    http://openfoam.org/docs/user/blockMesh.php#x25-1420005.3http://openfoam.org/docs/user/basic-file-format.php#x18-1000004.2.6http://openfoam.org/docs/user/basic-file-format.php#x18-1020004.2.8http://openfoam.org/docs/user/basic-file-format.php#x18-1020004.2.8http://openfoam.org/docs/user/basic-file-format.php#x18-1020004.2.8http://openfoam.org/docs/user/basic-file-format.php#x18-1020004.2.8http://openfoam.org/docs/user/blockMesh.php#x25-1420005.3http://openfoam.org/docs/user/basic-file-format.php#x18-1000004.2.6http://openfoam.org/docs/user/basic-file-format.php#x18-1020004.2.8http://openfoam.org/docs/user/basic-file-format.php#x18-1020004.2.8
  • 8/9/2019 OpenFoam Tutorials

    7/233

    For this case cavit&$ the "oundar& consists of alls onl&$ split into 2 patches named (1) fi%edHallsfor the fi%ed sides and "ase of the cavit&* (2) movingHall for the moving top of the cavit&. As alls$"oth are given a eroradient "oundar& condition for p$ meaning Pthe normal gradient of pressure iseroQ. The frontAnd6ac' patch represents the front and "ac' planes of the 2@ case and thereforemust "e set as empt&.

    #n this case$ as in most e encounter$ the initial fields are set to "e uniform. > >). The top surface moves at a speed of 1 m7s in the +direction so re,uires a fi%ed9alue condition also "ut ith uniform (1 > >).

    211( Ph#sical properties

    The ph&sical properties for the case are stored in dictionaries hose names are given the suffi% L/roperties$ located in the @ictionaries director& tree. For an icoFoam case$ the onl& propert& thatmust "e specified is the 'inematic viscosit& hich is stored from the transport/roperties dictionar&.The user can chec' that the 'inematic viscosit& is set correctl& "& opening the transport/ropertiesdictionar& to vie7edit its entries. The 'e&ord for 'inematic viscosit& is nu$ the phonetic la"el forthe ree' s&m"ol "& hich it is represented in e,uations. #nitiall& this case ill "e run ith a4e&nolds num"er of 1>$ here the 4e&nolds num"er is defined as

    (2.1)

    here and are the characteristic length and velocit& respectivel& and is the 'inematic

    viscosit&. .1 $ 1 $ so that for 1>$ >.>1 . The correct fileentr& for 'inematic viscosit& is thus specified "elo

    1:1; nu nu > 2 +1 > > > > N >.>1*1=2>21 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    211) Control

    #nput data relating to the control of time and reading and riting of the solution data are read infrom the control@ict dictionar&. The user should vie this file* as a case control file$ it is located inthe s&stem director&.

    The start7stop times and the time step for the run must "e set. OpenFOAM offers great fle%i"ilit&ith time control hich is descri"ed in full in section -.3. #n this tutorial e ish to start the run attime hich means that OpenFOAM needs to read field data from a director& named > R seesection -.1for more information of the case file structure. Therefore e set the startFrom 'e&ordto startTime and then specif& the startTime 'e&ord to "e >.

    For the end time$ e ish to reach the stead& state solution here the flo is circulating around the

    cavit&. As a general rule$ the fluid should pass through the domain 1> times to reach stead& state inlaminar flo. #n this case the flo does not pass through this domain as there is no inlet or outlet$ soinstead the end time can "e set to the time ta'en for the lid to travel ten times across the cavit&$ i.e.

    http://openfoam.org/docs/user/basic-file-format.php#x18-990004.2.5http://openfoam.org/docs/user/basic-file-format.php#x18-990004.2.5http://openfoam.org/docs/user/controlDict.php#x19-1060004.3http://openfoam.org/docs/user/case-file-structure.php#x17-930004.1http://openfoam.org/docs/user/basic-file-format.php#x18-990004.2.5http://openfoam.org/docs/user/controlDict.php#x19-1060004.3http://openfoam.org/docs/user/case-file-structure.php#x17-930004.1
  • 8/9/2019 OpenFoam Tutorials

    8/233

    1 s* in fact$ ith hindsight$ e discover that >. s is sufficient so e shall adopt this value. Tospecif& this end time$ e must specif& the stopAt 'e&ord as endTime and then set the endTime'e&ord to >..

    8o e need to set the time step$ represented "& the 'e&ord deltaT. To achieve temporal accurac&and numerical sta"ilit& hen running icoFoam$ a ourant num"er of less than 1 is re,uired. Theourant num"er is defined for one cell as

    (2.2)

    here is the time step$ is the magnitude of the velocit& through that cell and is the cell siein the direction of the velocit&. The flo velocit& varies across the domain and e must ensure

    ever&here. He therefore choose "ased on the orst case the ma%imumcorresponding to the com"ined effect of a large flo velocit& and small cell sie.

  • 8/9/2019 OpenFoam Tutorials

    9/233

    330 riteFormat ascii*3:3; rite/recision 0*3=-> riteompression off*

    -1-2 timeFormat general*-3-- time/recision 0*--0 runTimeModifia"le true*-:-;-= 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    211* Discretisation and linear-sol"er settin&s

    The user specifies the choice of finite volume discretisation schemes in the fvSchemes dictionar& inthe s&stem director&. The specification of the linear e,uation solvers and tolerances and otheralgorithm controls is made in the fvSolution dictionar&$ similarl& in the s&stem director&. The user isfree to vie these dictionaries "ut e do not need to discuss all their entries at this stage e%cept forp4efell and p4ef9alue in the /#SO su"+dictionar& of the fvSolution dictionar&. #n a closedincompressi"le s&stem such as the cavit&$ pressure is relative it is the pressure range that mattersnot the a"solute values. #n cases such as this$ the solver sets a reference level "& p4ef9alue in cellp4efell. #n this e%ample "oth are set to >. hanging either of these values ill change the a"solutepressure field$ "ut not$ of course$ the relative pressures or velocit& field.

    212 +ie%in& the ,esh6efore the case is run it is a good idea to vie the mesh to chec' for an& errors. The mesh is vieedin paraFoam$ the post+processing tool supplied ith OpenFOAM. The paraFoam post+processing isstarted "& t&ping in the terminal from ithin the case director&

    paraFoam

    Alternativel&$ it can "e launched from another director& location ith an optional +case argumentgiving the case director&$ e.g.

    paraFoam +case FOAM487tutorials7incompressi"le7icoFoam7cavit&

    This launches the /ara9ie indo as shon in Figure 0.1. #n the /ipeline 6roser$ the user cansee that /ara9ie has opened cavit&.OpenFOAM$ the module for the cavit& case. 6efore clic'ingthe Appl& "utton$ the user needs to select some geometr& from the Mesh /arts panel. 6ecause thecase is small$ it is easiest to select all the data "& chec'ing the "o% adJacent to the Mesh /arts paneltitle$ hich automaticall& chec's all individual components ithin the respective panel. The usershould then clic' the Appl& "utton to load the geometr& into /ara9ie.

    The user should then open the @ispla& panel that controls the visual representation of the selectedmodule. Hithin the @ispla& panel the user should do the folloing as shon in Figure 2.3 (1) setolor 6& Solid olor* (2) clic' Set Am"ient olor and select an appropriate colour e.g. "lac' (for a

    hite "ac'ground)* (3) in the St&le panel$ select Hireframe from the 4epresentation menu. The"ac'ground colour can "e set "& selecting 9ie SettingsL from ?dit in the top menu panel.

    http://openfoam.org/docs/user/paraview.php#x30-1790011http://openfoam.org/docs/user/cavity.php#x5-110123http://openfoam.org/docs/user/paraview.php#x30-1790011http://openfoam.org/docs/user/cavity.php#x5-110123
  • 8/9/2019 OpenFoam Tutorials

    10/233

    Figure 2.3 9ieing the mesh in paraFoam.

    ?speciall& the first time the user starts /ara9ie$ it is recommended that the& manipulate the vieas descri"ed in section 0.1.. #n particular$ since this is a 2@ case$ it is recommended that se/arallel /roJection is selected in the eneral panel of 9ie Settings indo selected from the ?ditmenu. The Orientation A%es can "e toggled on and off in the Annotation indo or moved "& dragand drop ith the mouse.

    21( Runnin& an application

    5i'e an& 8#75inu% e%ecuta"le$ OpenFOAM applications can "e run in to a&s as aforeground process$ i.e. one in hich the shell aits until the command has finished "efore giving acommand prompt* as a "ac'ground process$ one hich does not have to "e completed "efore theshell accepts additional commands.

    On this occasion$ e ill run icoFoam in the foreground. The icoFoam solver is e%ecuted either "&entering the case director& and t&ping

    icoFoamat the command prompt$ or ith the optional +case argument giving the case director&$ e.g.

    icoFoam +case FOAM487tutorials7incompressi"le7icoFoam7cavit&

    http://openfoam.org/docs/user/paraview.php#x30-1830006.1.5http://openfoam.org/docs/user/paraview.php#x30-1830006.1.5
  • 8/9/2019 OpenFoam Tutorials

    11/233

    The progress of the Jo" is ritten to the terminal indo. #t tells the user the current time$ma%imum ourant num"er$ initial and final residuals for all fields.

    Figure 2.- @ispla&ing pressure contours for the cavit& case.

  • 8/9/2019 OpenFoam Tutorials

    12/233

    Figure 2. /ressures in the cavit& case.

    21) Post-processin&

    As soon as results are ritten to time directories$ the& can "e vieed using paraFoam. 4eturn to theparaFoam indo and select the /roperties panel for the cavit&.OpenFOAM case module. #f thecorrect indo panels for the case module do not seem to "e present at an& time$ please ensurethat cavit&.OpenFOAM is highlighted in "lue* e&e "utton alongside it is sitched on to sho thegraphics are ena"led*

    To prepare paraFoam to displa& the data of interest$ e must first load the data at the re,uired runtime of >. s. #f the case as run hile /ara9ie as open$ the output data in time directories illnot "e automaticall& loaded ithin /ara9ie. To load the data the user should clic' 4efresh Timesin the /roperties indo. The time data ill "e loaded into /ara9ie.

    21)1 Isosur$ace and contour plots

    To vie pressure$ the user should open the @ispla& panel since it controls the visual representationof the selected module. To ma'e a simple plot of pressure$ the user should select the folloing$ asdescri"ed in detail in Figure2.- in the St&le panel$ select Surface from the 4epresentation menu* inthe olor panel$ select olor "& and 4escale to @ata 4ange. 8o in order to vie the solution at

    s$ the user can use the 94 ontrols or urrent Time ontrols to change the current time to>.. These are located in the tool"ars "elo the menus at the top of the /ara9ie indo$ as shonin Figure0.-. The pressure field solution has$ as e%pected$ a region of lo pressure at the top left ofthe cavit& and one of high pressure at the top right of the cavit& as shon in Figure 2..

    Hith the point icon ( ) the pressure field is interpolated across each cell to give a continuousappearance. #nstead if the user selects the cell icon$ $ from the olor "& menu$ a single value forpressure ill "e attri"uted to each cell so that each cell ill "e denoted "& a single colour ith nograding.

    A colour "ar can "e included "& either "& clic'ing the Toggle olor 5egend 9isi"ilit& "utton in theActive 9aria"le ontrols tool"ar$ or "& selecting Sho olor 5egend from the 9ie menu. lic'ing

    the ?dit olor Map "utton$ either in the Active 9aria"le ontrols tool"ar or in the olor panel of the@ispla& indo$ the user can set a range of attri"utes of the colour "ar$ such as te%t sie$ fontselection and num"ering format for the scale. The colour "ar can "e located in the image indo "&

    http://openfoam.org/docs/user/cavity.php#x5-120074http://openfoam.org/docs/user/cavity.php#x5-120074http://openfoam.org/docs/user/paraview.php#x30-1820074http://openfoam.org/docs/user/paraview.php#x30-1820074http://openfoam.org/docs/user/cavity.php#x5-120085http://openfoam.org/docs/user/cavity.php#x5-120074http://openfoam.org/docs/user/paraview.php#x30-1820074http://openfoam.org/docs/user/cavity.php#x5-120085
  • 8/9/2019 OpenFoam Tutorials

    13/233

    drag and drop ith the mouse.

    8e versions of /ara9ie default to using a colour scale of "lue to hite to red rather than themore common "lue to green to red (rain"o). Therefore the first time that the user e%ecutes/ara9ie$ the& ma& ish to change the colour scale. This can "e done "& selecting hoose /reset inthe olor Scale ?ditor and selecting 6lue to 4ed 4ain"o. After clic'ing the O confirmation"utton$ the user can clic' the Ma'e @efault "utton so that /ara9ie ill ala&s adopt this t&pe of

    colour "ar.

    #f the user rotates the image$ the& can see that the& have no coloured the complete geometr&surface "& the pressure. #n order to produce a genuine contour plot the user should first create acutting plane$ or BsliceC$ through the geometr& using the Slice filter as descri"ed in section0.1.0.1.

    The cutting plane should "e centred at and its normal should "e set to(clic' the U 8ormal "utton).

  • 8/9/2019 OpenFoam Tutorials

    14/233

    Figure 2.: 9elocities in the cavit& case.

    21)2 +ector plots

    6efore e start to plot the vectors of the flo velocit&$ it ma& "e useful to remove other modulesthat have "een created$ e.g. using the Slice and ontour filters descri"ed a"ove. These can either "edeleted entirel&$ "& highlighting the relevant module in the /ipeline 6roser and clic'ing @elete intheir respective /roperties panel* or$ "e disa"led "& toggling the e&e "utton for the relevant modulein the /ipeline 6roser.

    He no ish to generate a vector gl&ph for velocit& at the centre of each cell. He first need to filterthe data to cell centres as descri"ed in section 0.1.:.1.Hith the cavit&.OpenFOAM modulehighlighted in the /ipeline 6roser$ the user should select ell enters from the Filter+VAlpha"etical menu and then clic' Appl&.

    Hith these enters highlighted in the /ipeline 6roser$ the user should then select l&ph from theFilter+VAlpha"etical menu. The /roperties indo panel should appear as shon in Figure 2.0. #nthe resulting /roperties panel$ the velocit& field$ $ is automaticall& selected in the vectors menu$since it is the onl& vector field present. 6& default the Scale Mode for the gl&phs ill "e 9ectorMagnitude of velocit& "ut$ since the e ma& ish to vie the velocities throughout the domain$ theuser should instead select off and Set Scale Factor to >.>>. On clic'ing Appl&$ the gl&phs appear"ut$ pro"a"l& as a single colour$ e.g. hite. The user should colour the gl&phs "& velocit&magnitude hich$ as usual$ is controlled "& setting olor "& in the @ispla& panel. The user shouldalso select Sho olor 5egend in ?dit olor Map. The output is shon in Figure 2.:$ in hichuppercase Times 4oman fonts are selected for the olor 5egend headings and the la"els arespecified to 2 fi%ed significant figures "& deselecting Automatic 5a"el Format and entering W+X0.2fin the 5a"el Format te%t "o%. The "ac'ground colour is set to hite in the eneral panel of 9ieSettings as descri"ed in section 0.1..1.

    8ote that at the left and right alls$ gl&phs appear to indicate flo through the alls. On closere%amination$ hoever$ the user can see that hile the flo direction is normal to the all$ itsmagnitude is >. This slightl& confusing situation is caused "& /ara9ie choosing to orientate the

    gl&phs in the +direction hen the gl&ph scaling off and the velocit& magnitude is >.

    http://openfoam.org/docs/user/paraview.php#x30-1890006.1.7.1http://openfoam.org/docs/user/paraview.php#x30-1890006.1.7.1http://openfoam.org/docs/user/cavity.php#x5-140116http://openfoam.org/docs/user/cavity.php#x5-140127http://openfoam.org/docs/user/paraview.php#x30-1840006.1.5.1http://openfoam.org/docs/user/paraview.php#x30-1890006.1.7.1http://openfoam.org/docs/user/cavity.php#x5-140116http://openfoam.org/docs/user/cavity.php#x5-140127http://openfoam.org/docs/user/paraview.php#x30-1840006.1.5.1
  • 8/9/2019 OpenFoam Tutorials

    15/233

    Figure 2.; /roperties panel for the Stream Tracer filter.

    Figure 2.= Streamlines in the cavit& case.

  • 8/9/2019 OpenFoam Tutorials

    16/233

    21)( trea,line plots

    Again$ "efore the user continues to post+process in /ara9ie$ the& should disa"le modules such asthose for the vector plot descri"ed a"ove. He no ish to plot streamlines of velocit& as descri"edin section 0.1.;.

    Hith the cavit&.OpenFOAM module highlighted in the /ipeline 6roser$ the user should then selectStream Tracer from the Filter menu and then clic' Appl&. The /roperties indo panel shouldappear as shon in Figure 2.;. The Seed points should "e specified along a 5ine Source running

    verticall& through the centre of the geometr&$ i.e. from to . For theimage in this guide e used a point 4esolution of 21* Ma% /ropagation "& 5ength >.* #nitial Step5ength "& ell 5ength >.>1* and$ #ntegration @irection 6OT

  • 8/9/2019 OpenFoam Tutorials

    17/233

    geometr& and the "oundar& t&pes$ or conditions$ of "oth source and target fields are identical. Heuse the +consistent command line option hen e%ecuting mapFields in this e%ample.

    The field data that mapFields maps is read from the time director& specified "& startFrom7startTimein the control@ict of the target case$ i.e. those into hich the results are "eing mapped. #n thise%ample$ e ish to map the final results of the coarser mesh from case cavit& onto the finer meshof case cavit&Fine. Therefore$ since these results are stored in the >. director& of cavit&$ the

    startTime should "e set to >. s in the control@ict dictionar& and startFrom should "e set tostartTime.

    The case is read& to run mapFields. T&ping mapFields +help ,uic'l& shos that mapFields re,uiresthe source case director& as an argument. He are using the +consistent option$ so the utilit& ise%ecuted from ithing the cavit&Fine director& "&

    mapFields ..7cavit& +consistentThe utilit& should run ith output to the terminal including

    Source Y..Y Ycavit&YTarget Y.Y Ycavit&FineY

    reate data"ases as timease ..7cavit&n/rocs 1

    Source time >.Target time >.

    reate meshes

    Source mesh sie ->> Target mesh sie 10>>

    onsistentl& creating and mapping fields for time >.

    reating mesh+to+mesh addressing ...Overlap volume >.>>>1

    reating AM# "eteen source patch movingHall and target patch movingHall ...

    interpolating pinterpolating

    ?nd

    21*) Control ad/ust,ents

    To maintain a ourant num"er of less that 1$ as discussed in section 2.1.1.-$ the time step must no"e halved since the sie of all cells has halved. Therefore deltaT should "e set to to >.>>2 s in thecontrol@ict dictionar&. Field data is currentl& ritten out at an interval of a fi%ed num"er of timesteps.

  • 8/9/2019 OpenFoam Tutorials

    18/233

    are correct and then save the file.

    21** Runnin& the code as a 0ac&round process

    The user should e%perience running icoFoam as a "ac'ground process$ redirecting the terminaloutput to a log file that can "e vieed later. From the cavit&Fine director&$ the user should e%ecute

    icoFoam V log Zcat log

    21* +ector plot %ith the re$ined ,esh

    The user can open multiple cases simultaneousl& in /ara9ie* essentiall& "ecause each ne case issimpl& another module that appears in the /ipeline 6roser. There is one minor inconveniencehen opening a ne case in /ara9ie "ecause there is a prere,uisite that the selected data is a fileith a name that has an e%tension.

  • 8/9/2019 OpenFoam Tutorials

    19/233

    Figure 2.1> Selecting fields for graph plotting.

    21*3 Plottin& &raphs

    The user ma& ish to visualise the results "& e%tracting some scalar measure of velocit& andplotting 2+dimensional graphs along lines through the domain. OpenFOAM is ell e,uipped forthis 'ind of data manipulation. There are numerous utilities that do specialised data manipulations$and some$ simpler calculations are incorporated into a single utilit& foamalc. As a utilit&$ it isuni,ue in that it is e%ecuted "&

    foamalc [calcT&peV [field8ame1 L field8ame8VThe calculator operation is specified in [calcT&peV* at the time of riting$ the folloing operationsare implemented addSu"tract* randomise* div* components* mag* magrad* magS,r* interpolate.The user can o"tain the list of [calcT&peV "& deli"eratel& calling one that does not e%ist$ so thatfoamalc thros up an error message and lists the t&pes availa"le$ e.g.

    VV foamalc %%%%Selecting calcT&pe %%%%

    un'non calcT&pe t&pe %%%%$ constructor not in hash ta"le9alid calcT&pe selections are

    ;

    (randomisemagS,r

  • 8/9/2019 OpenFoam Tutorials

    20/233

    magradaddSu"tractdivmaginterpolatecomponents

    )The components and mag calcT&pes provide useful scalar measures of velocit&. Hhen Pfoamalccomponents Q is run on a case$ sa& cavit&$ it reads in the velocit& vector field from each timedirector& and$ in the corresponding time directories$ rites scalar fields %$ & and representingthe $ and components of velocit&. Similarl& Pfoamalc mag Q rites a scalar field mag toeach time director& representing the magnitude of velocit&.

    The user can run foamalc ith the components calcT&pe on "oth cavit& and cavit&Fine cases. Fore%ample$ for the cavit& case the user should do into the cavit& director& and e%ecute foamalc asfollos

    cd FOAM487tutorials7incompressi"le7icoFoam7cavit&foamalc components

    The individual components can "e plotted as a graph in /ara9ie. #t is ,uic'$ convenient and hasreasona"l& good control over la"elling and formatting$ so the printed output is a fairl& goodstandard.

  • 8/9/2019 OpenFoam Tutorials

    21/233

    namel& 5ine olor$ 5ine Thic'ness$ 5ine St&le$ Mar'er St&le and hart A%es.

    Also the user can clic' one of the "uttons a"ove the top left corner of the \ /lot. The third "utton$for e%ample$ allos the user to control 9ie Settings in hich the user can set title and legend foreach a%is$ for e%ample. Also$ the user can set font$ colour and alignment of the a%es titles$ and hasseveral options for a%is range and la"els in linear or logarithmic scales.

    Figure 2.11is a graph produced using /ara9ie. The user can produce a graph hoever he7sheishes. For information$ the graph in Figure2.11as produced ith the options for a%es ofStandard t&pe of 8otation* Specif& A%is 4ange selected* titles in Sans Serif 12 font. The graph isdispla&ed as a set of points rather than a line "& activating the ?na"le 5ine Series "utton in the@ispla& indo. 8ote if this "utton appears to "e inactive "& "eing Pgre&ed outQ$ it can "e madeactive "& selecting and deselecting the sets of varia"les in the 5ine Series panel. Once the ?na"le5ine Series "utton is selected$ the 5ine St&le and Mar'er St&le can "e adJusted to the userCspreference.

    Figure 2.11 /lotting graphs in paraFoam.

    21 Introducin& ,esh &radin&

    The error in an& solution ill "e more pronounced in regions here the form of the true solutiondiffer idel& from the form assumed in the chosen numerical schemes. For e%ample a numericalscheme "ased on linear variations of varia"les over cells can onl& generate an e%act solution if the

    true solution is itself linear in form. The error is largest in regions here the true solution deviatesgreatest from linear form$ i.e. here the change in gradient is largest. ?rror decreases ith cell sie.

    #t is useful to have an intuitive appreciation of the form of the solution "efore setting up an&pro"lem. #t is then possi"le to anticipate here the errors ill "e largest and to grade the mesh sothat the smallest cells are in these regions. #n the cavit& case the large variations in velocit& can "ee%pected near a all and so in this part of the tutorial the mesh ill "e graded to "e smaller in thisregion. 6& using the same num"er of cells$ greater accurac& can "e achieved ithout a significantincrease in computational cost.

    A mesh of cells ith grading toards the alls ill "e created for the lid+driven cavit&pro"lem and the results from the finer mesh of section 2.1..2ill then "e mapped onto the graded

    mesh to use as an initial condition. The results from the graded mesh ill "e compared ith thosefrom the previous meshes. Since the changes to the "loc'Mesh@ict dictionar& are fairl& su"stantial$the case used for this part of the tutorial$ cavit&rade$ is supplied in the

    http://openfoam.org/docs/user/cavity.php#x5-2404511http://openfoam.org/docs/user/cavity.php#x5-2404511http://openfoam.org/docs/user/cavity.php#x5-2404511http://openfoam.org/docs/user/cavity.php#x5-190002.1.5.2http://openfoam.org/docs/user/cavity.php#x5-2404511http://openfoam.org/docs/user/cavity.php#x5-2404511http://openfoam.org/docs/user/cavity.php#x5-190002.1.5.2
  • 8/9/2019 OpenFoam Tutorials

    22/233

    FOAM487tutorials7incompressi"le7icoFoam director&.

    211 Creatin& the &raded ,esh

    The mesh no needs - "loc's as different mesh grading is needed on the left and right and top and"ottom of the domain. The "loc' structure for this mesh is shon in Figure 2.12.

    Figure 2.12 6loc' structure of the graded mesh for the cavit& ("loc' num"ers encircled).

    The user can vie the "loc'Mesh@ict file in the constant7pol&Mesh su"director& of cavit&rade*for completeness the 'e& elements of the "loc'Mesh@ict file are also reproduced "elo. ?ach "loc'

    no has cells in the and directions and the ratio "eteen largest and smallest cells is .

    1: convertToMeters >.1*1;1= vertices2> (21 (> > >)22 (>. > >)23 (1 > >)2- (> >. >)2 (>. >. >)

    20 (1 >. >)2: (> 1 >)2; (>. 1 >)2= (1 1 >)3> (> > >.1)31 (>. > >.1)32 (1 > >.1)33 (> >. >.1)3- (>. >. >.1)3 (1 >. >.1)30 (> 1 >.1)

    3: (>. 1 >.1)3; (1 1 >.1)3= )*

    http://openfoam.org/docs/user/cavity.php#x5-2600112http://openfoam.org/docs/user/cavity.php#x5-2600112
  • 8/9/2019 OpenFoam Tutorials

    23/233

    ->-1 "loc's-2 (-3 he% (> 1 - 3 = 1> 13 12) (1> 1> 1) simplerading (2 2 1)-- he% (1 2 - 1> 11 1- 13) (1> 1> 1) simplerading (>. 2 1)- he% (3 - : 0 12 13 10 1) (1> 1> 1) simplerading (2 >. 1)

    -0 he% (- ; : 13 1- 1: 10) (1> 1> 1) simplerading (>. >. 1)-: )*-;-= edges> (1 )*23 "oundar&- ( movingHall0 I

    : t&pe all*; faces= (0> (0 1 10 :)01 (: 10 1: ;)02 )*03 K0- fi%edHalls0 I00 t&pe all*0: faces0; (0= (3 12 1 0):> (> = 12 3):1 (> 1 1> =):2 (1 2 11 1>):3 (2 1- 11):- ( ; 1: 1-): )*:0 K:: frontAnd6ac'

    :; I:= t&pe empt&*;> faces;1 (;2 (> 3 - 1);3 (1 - 2);- (3 0 : -); (- : ; );0 (= 1> 13 12);: (1> 11 1- 13);; (12 13 10 1)

    ;= (13 1- 1: 10)=> )*=1 K

  • 8/9/2019 OpenFoam Tutorials

    24/233

    =2 )*=3=- merge/atch/airs= (=0 )*=:

    =; 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77Once familiar ith the "loc'Mesh@ict file for this case$ the user can e%ecute "loc'Mesh from thecommand line. The graded mesh can "e vieed as "efore using paraFoam as descri"ed insection 2.1.2.

    212 Chan&in& ti,e and ti,e step

    The highest velocities and smallest cells are ne%t to the lid$ therefore the highest ourant num"erill "e generated ne%t to the lid$ for reasons given in section 2.1.1.-. #t is therefore useful toestimate the sie of the cells ne%t to the lid to calculate an appropriate time step for this case.

    Hhen a nonuniform mesh grading is used$ "loc'Mesh calculates the cell sies using a geometricprogression. Along a length $ if cells are re,uested ith a ratio of "eteen the last and firstcells$ the sie of the smallest cell$ $ is given "&

    (2.)

    here is the ratio "eteen one cell sie and the ne%t hich is given "&

    (2.0)

    and

    (2.:)

    For the cavit&rade case the num"er of cells in each direction in a "loc' is 1>$ the ratio "eteenlargest and smallest cells is and the "loc' height and idth is >.> . Therefore the smallest celllength is 3.- . From ?,uation2.2$ the time step should "e less than 3.- to maintain aourant of less than 1. To ensure that results are ritten out at convenient time intervals$ the timestep deltaT should "e reduced to 2. and the rite#nterval set to -> so that results are ritten outever& >.1 s. These settings can "e vieed in the cavit&rade7s&stem7control@ict file.

    The startTime needs to "e set to that of the final conditions of the case cavit&Fine$ i.e.>.:. Sincecavit& and cavit&Fine converged ell ithin the prescri"ed run time$ e can set the run time forcase cavit&rade to >.1 s$ i.e. the endTime should "e >.;.

    21( Mappin& $ields

    As in section2.1..3$ use mapFields to map the final results from case cavit&Fine onto the mesh forcase cavit&rade. ?nter the cavit&rade director& and e%ecute mapFields "&

    cd FOAM487tutorials7incompressi"le7icoFoam7cavit&rademapFields ..7cavit&Fine +consistent

    8o run icoFoam from the case director& and monitor the run time information. 9ie theconverged results for this case and compare ith other results using post+processing tools descri"edpreviousl& in section 2.1..0and section 2.1..:.

    http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/cavity.php#x5-90002.1.1.4http://openfoam.org/docs/user/cavity.php#x5-9016r2http://openfoam.org/docs/user/cavity.php#x5-9016r2http://openfoam.org/docs/user/cavity.php#x5-200002.1.5.3http://openfoam.org/docs/user/cavity.php#x5-200002.1.5.3http://openfoam.org/docs/user/cavity.php#x5-230002.1.5.6http://openfoam.org/docs/user/cavity.php#x5-240002.1.5.7http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/cavity.php#x5-90002.1.1.4http://openfoam.org/docs/user/cavity.php#x5-9016r2http://openfoam.org/docs/user/cavity.php#x5-200002.1.5.3http://openfoam.org/docs/user/cavity.php#x5-230002.1.5.6http://openfoam.org/docs/user/cavity.php#x5-240002.1.5.7
  • 8/9/2019 OpenFoam Tutorials

    25/233

    213 Increasin& the Re#nolds nu,0er

    The cases solved so far have had a 4e&nolds num"er of 1>. This is ver& lo and leads to a sta"lesolution ,uic'l& ith onl& small secondar& vortices at the "ottom corners of the cavit&. He ill noincrease the 4e&nolds num"er to 1>>$ at hich point the solution ta'es a noticea"l& longer time toconverge. The coarsest mesh in case cavit& ill "e used initiall&. The user should ma'e a cop& ofthe cavit& case and name it cavit&

  • 8/9/2019 OpenFoam Tutorials

    26/233

    terations >0 @#/ Solving for p$ #nitial residual G 3.0:>0e+>0$ Final residual G ;.02=;0e+>:$ 8o #terations -: time step continuit& errors sum local G 0.:=-:e+>=$ glo"al G +0.00:=e+1=$ cumulative G +0.23=e+1;; @#/ Solving for p$ #nitial residual G 2.0>;=;e+>0$ Final residual G :.=232e+>:$ 8o #teratio

    ns 3= time step continuit& errors sum local G 0.201==e+>=$ glo"al G +1.>2=;-e+1;$ cumulative G +:.2;3:-e+1;1> ?%ecutionTime G >.3: s loc'Time G > s1112 Time G 1.-3131- ourant 8um"er mean >.221=23 ma% >.;3==>31 smoothSolver Solving for %$ #nitial residual G ;.3=3e+>0$ Final residual G ;.3=3e+>0$ 8o#terations >10 smoothSolver Solving for &$ #nitial residual G =.:1->e+>0$ Final residual G =.:1->e+>0$ 8o

    #terations >1: @#/ Solving for p$ #nitial residual G -.>223e+>0$ Final residual G =.;=0=3e+>:$ 8o #terations 31; time step continuit& errors sum local G ;.11==e+>=$ glo"al G .3301-e+1=$ cumulative G +0.:>12e+1;1= @#/ Solving for p$ #nitial residual G 2.3;;>:e+>0$ Final residual G ;.--=e+>:$ 8o #terations 32> time step continuit& errors sum local G :.-;:1e+>=$ glo"al G +-.-2:>:e+1=$ cumulative G +:.1=2;3e+1;21 ?%ecutionTime G >.3: s loc'Time G > s

    214 5i&h Re#nolds nu,0er $lo%

    9ie the results in paraFoam and displa& the velocit& vectors. The secondar& vortices in the cornershave increased in sie somehat. The user can then increase the 4e&nolds num"er further "&decreasing the viscosit& and then rerun the case. The num"er of vortices increases so the meshresolution around them ill need to increase in order to resolve the more complicated flo patterns.#n addition$ as the 4e&nolds num"er increases the time to convergence increases. The user shouldmonitor residuals and e%tend the endTime accordingl& to ensure convergence.

    The need to increase spatial and temporal resolution then "ecomes impractical as the flo movesinto the tur"ulent regime$ here pro"lems of solution sta"ilit& ma& also occur. Of course$ man&engineering pro"lems have ver& high 4e&nolds num"ers and it is infeasi"le to "ear the huge cost ofsolving the tur"ulent "ehaviour directl&. #nstead 4e&nolds+averaged simulation (4AS) tur"ulencemodels are used to solve for the mean flo "ehaviour and calculate the statistics of the fluctuations.The standard model ith all functions ill "e used in this tutorial to solve the lid+drivencavit& case ith a 4e&nolds num"er of . To e%tra varia"les are solved for $ the tur"ulent'inetic energ&* and$ $ the tur"ulent dissipation rate. The additional e,uations and models fortur"ulent flo are implemented into a OpenFOAM solver called pisoFoam.

    2141 Pre-processin&

    hange director& to the cavit& case in the FOAM487tutorials7incompressi"le7pisoFoam7rasdirector& (8.6 the pisoFoam7ras director&). enerate the mesh "& running "loc'Mesh as "efore.

    Mesh grading toards the all is not necessar& hen using the standard model ith allfunctions since the flo in the near all cell is modelled$ rather than having to "e resolved.

    A range of all function models is availa"le in OpenFOAM that are applied as "oundar& conditions

  • 8/9/2019 OpenFoam Tutorials

    27/233

    on individual patches. This ena"les different all function models to "e applied to different allregions. The choice of all function models are specified through the tur"ulent viscosit& field$ inthe >7nut file

    1:1; dimensions > 2 +1 > > > >N*1=

    2> internalField uniform >*2122 "oundar&Field23 I2- movingHall2 I20 t&pe nut'HallFunction*2: value uniform >*2; K2= fi%edHalls

    3> I31 t&pe nut'HallFunction*32 value uniform >*33 K3- frontAnd6ac'3 I30 t&pe empt&*3: K3; K3=->

    -1 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77This case uses standard all functions$ specified "& the nutHallFunction t&pe on the movingHalland fi%edHalls patches. Other all function models include the rough all functions$ specifiedthough the nut4oughHallFunction 'e&ord.

    The user should no open the field files for and (>7' and >7epsilon) and e%amine their "oundar&conditions. For a all "oundar& condition$ is assigned a epsilonHallFunction "oundar& conditionand a ',4allFunction "oundar& condition is assigned to . The latter is a generic "oundar&condition that can "e applied to an& field that are of a tur"ulent 'inetic energ& t&pe$ e.g. $ or4e&nolds Stress . The initial values for and are set using an estimated fluctuating componentof velocit& and a tur"ulent length scale$ . and are defined in terms of these parameters as

    follos

    here is a constant of the model e,ual to >.>=. For a artesian coordinate s&stem$ isgiven "&

    (2.1>)

    here $ and are the fluctuating components of velocit& in the $ and directionsrespectivel&. 5et us assume the initial tur"ulence is isotropic$ i.e. $ and e,ual toW of the lid velocit& and that $ is e,ual to 2>W of the "o% idth$ >.1 $ then and are given "&

  • 8/9/2019 OpenFoam Tutorials

    28/233

    These form the initial conditions for and . The initial conditions for and are and >respectivel& as "efore.

    Tur"ulence modelling includes a range of methods$ e.g. 4AS or large+edd& simulation (5?S)$ thatare provided in OpenFOAM. #n most transient solvers$ the choice of tur"ulence modelling methodis selecta"le at run+time through the simulationT&pe 'e&ord in tur"ulence/roperties dictionar&.The user can vie this file in the constant director&

    1:1; simulationT&pe 4ASModel*1=

    2>21 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    The options for simulationT&pe are laminar$ 4ASModel and 5?SModel. Hith 4ASModel selectedin this case$ the choice of 4AS modelling is specified in a 4AS/roperties file$ also in the constantdirector&. The tur"ulence model is selected "& the 4ASModel entr& from a long list of availa"lemodels that are listed in Ta"le3.=. The '?psilon model should "e selected hich is is the standard

    model* the user should also ensure that tur"ulence calculation is sitched on.

    The coefficients for each tur"ulence model are stored ithin the respective code ith a set ofdefault values. Setting the optional sitch called printoeffs to on ill ma'e the default values "eprinted to standard output$ i.e. the terminal$ hen the model is called at run time. The coefficients

    are printed out as a su"+dictionar& hose name is that of the model name ith the ord oeffsappended$ e.g. '?psilonoeffs in the case of the '?psilon model. The coefficients of the model$e.g. '?psilon$ can "e modified "& optionall& including (cop&ing and pasting) that su"+dictionar&ithin the 4AS/roperties dictionar& and adJusting values accordingl&.

    The user should ne%t set the laminar 'inematic viscosit& in the transport/roperties dictionar&. Toachieve a 4e&nolds num"er of $ a 'inematic viscosit& of is re,uired "ased on the4e&nolds num"er definition given in ?,uation 2.1.

    Finall& the user should set the startTime$ stopTime$ deltaT and the rite#nterval in the [email protected] deltaT to >.>> s to satisf& the ourant num"er restriction and the endTime to 1> s.

    2142 Runnin& the code

    ?%ecute pisoFoam "& entering the case director& and t&ping PpisoFoamQ in a terminal. #n this case$here the viscosit& is lo$ the "oundar& la&er ne%t to the moving lid is ver& thin and the cells ne%tto the lid are comparativel& large so the velocit& at their centres are much less than the lid velocit&.#n fact$ after 1>> time steps it "ecomes apparent that the velocit& in the cells adJacent to the lidreaches an upper limit of around >.2 hence the ma%imum ourant num"er does not rise mucha"ove >.2. #t is sensi"le to increase the solution time "& increasing the time step to a level here theourant num"er is much closer to 1. Therefore reset deltaT to >.>2 s and$ on this occasion$ setstartFrom to latestTime. This instructs pisoFoam to read the start data from the latest time director&$i.e.1>.>. The endTime should "e set to 2> s since the run converges a lot sloer than the laminar

    case. 4estart the run as "efore and monitor the convergence of the solution. 9ie the results atconsecutive time steps as the solution progresses to see if the solution converges to a stead&+state orperhaps reaches some periodicall& oscillating state. #n the latter case$ convergence ma& never occur

    http://openfoam.org/docs/user/standard-libraries.php#x15-91267r9http://openfoam.org/docs/user/standard-libraries.php#x15-91267r9http://openfoam.org/docs/user/cavity.php#x5-8006r1http://openfoam.org/docs/user/standard-libraries.php#x15-91267r9http://openfoam.org/docs/user/cavity.php#x5-8006r1
  • 8/9/2019 OpenFoam Tutorials

    29/233

    "ut this does not mean the results are inaccurate.

    216 Chan&in& the case &eo,etr#

    A user ma& ish to ma'e changes to the geometr& of a case and perform a ne simulation. #t ma&"e useful to retain some or all of the original solution as the starting conditions for the ne

    simulation. This is a little comple% "ecause the fields of the original solution are not consistent iththe fields of the ne case. .1*1;1= vertices2> (

    21 (> > >)22 (>.0 > >)23 (> >.- >)2- (>.0 >.- >)2 (1 >.- >)20 (> 1 >)2: (>.0 1 >)2; (1 1 >)2=3> (> > >.1)31 (>.0 > >.1)

    32 (> >.- >.1)33 (>.0 >.- >.1)3- (1 >.- >.1)3 (> 1 >.1)30 (>.0 1 >.1)3: (1 1 >.1)3;3= )*->-1 "loc's-2 (-3 he% (> 1 3 2 ; = 11 1>) (12 ; 1) simplerading (1 1 1)-- he% (2 3 0 1> 11 1- 13) (12 12 1) simplerading (1 1 1)- he% (3 - : 0 11 12 1 1-) (; 12 1) simplerading (1 1 1)-0 )*-:-; edges-= (> )*12 "oundar&

    3 (- lid I0 t&pe all*

  • 8/9/2019 OpenFoam Tutorials

    30/233

    : faces; (= ( 13 1- 0)0> (0 1- 1 :)01 )*02 K

    03 fi%edHalls0- I0 t&pe all*00 faces0: (0; (> ; 1> 2)0= (2 1> 13 ):> (: 1 12 -):1 (- 12 11 3):2 (3 11 = 1):3 (1 = ; >)

    :- )*: K:0 frontAnd6ac':: I:; t&pe empt&*:= faces;> (;1 (> 2 3 1);2 (2 0 3);3 (3 0 : -);- (; = 11 1>); (1> 11 1- 13);0 (11 12 1 1-);: )*;; K;= )*=>=1 merge/atch/airs=2 (=3 )*=-

    = 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77enerate the mesh ith "loc'Mesh. The patches are set accordingl& as in previous cavit& cases. Forthe sa'e of clarit& in descri"ing the field mapping process$ the upper all patch is renamed lid$previousl& the movingHall patch of the original cavit&.

    #n an inconsistent mapping$ there is no guarantee that all the field data can "e mapped from thesource case. The remaining data must come from field files in the target case itself. Therefore fielddata must e%ist in the time director& of the target case "efore mapping ta'es place. #n thecavit&lipped case the mapping is set to occur at time >. s$ since the startTime is set to >. s in thecontrol@ict. Therefore the user needs to cop& initial field data to that director&$ e.g. from time >

    cd FOAM487tutorials7incompressi"le7icoFoam7cavit&lippedcp +r > >.

    6efore mapping the data$ the user should vie the geometr& and fields at >. s.

  • 8/9/2019 OpenFoam Tutorials

    31/233

    8o e ish to map the velocit& and pressure fields from cavit& onto the ne fields ofcavit&lipped. Since the mapping is inconsistent$ e need to edit the mapFields@ict dictionar&$located in the s&stem director&. The dictionar& contains 2 'e&ord entries patchMap andcutting/atches. The patchMap list contains a mapping of patches from the source fields to the targetfields. #t is used if the user ishes a patch in the target field to inherit values from a correspondingpatch in the source field. #n cavit&lipped$ e ish to inherit the "oundar& values on the lid patch

    from movingHall in cavit& so e must set the patchMap as

    patchMap(

    lid movingHall)*

    Figure 2.13 cavit& solution velocit& field mapped onto cavit&lipped.

  • 8/9/2019 OpenFoam Tutorials

    32/233

    Figure 2.1- cavit&lipped solution for velocit& field.

    The cutting/atches list contains names of target patches hose values are to "e mapped from thesource internal field through hich the target patch cuts. #n this case e ill include the fi%edHallsto demonstrate the interpolation process.

    cutting/atches

    ( fi%edHalls)*

    8o the user should run mapFields$ from ithin the cavit&lipped director&

    mapFields ..7cavit&The user can vie the mapped field as shon in Figure 2.13. The "oundar& patches have inheritedvalues from the source case as e e%pected.

  • 8/9/2019 OpenFoam Tutorials

    33/233

    stead&+state stress anal&sis on a s,uare plate ith a circular hole at its centre. The plate dimensionsare side length - and radius >. . #t is loaded ith a uniform traction of 1> overits left and right faces as shon in Figure 2.1. To s&mmetr& planes can "e identified for thisgeometr& and therefore the solution domain need onl& cover a ,uarter of the geometr&$ shon "&the shaded area in Figure 2.1.

    Figure 2.1 eometr& of the plate ith a hole.

    The pro"lem can "e appro%imated as 2+dimensional since the load is applied in the plane of theplate. #n a artesian coordinate s&stem there are to possi"le assumptions to ta'e in regard to the"ehaviour of the structure in the third dimension (1) the plane stress condition$ in hich the stresscomponents acting out of the 2@ plane are assumed to "e negligi"le* (2) the plane strain condition$in hich the strain components out of the 2@ plane are assumed negligi"le. The plane stresscondition is appropriate for solids hose third dimension is thin as in this case* the plane straincondition is applica"le for solids here the third dimension is thic'.

    An anal&tical solution e%ists for loading of an infinitel& large$ thin plate ith a circular hole. Thesolution for the stress normal to the vertical plane of s&mmetr& is

    (2.1-)

    4esults from the simulation ill "e compared ith this solution. At the end of the tutorial$ the usercan investigate the sensitivit& of the solution to mesh resolution and mesh grading* and$ increasethe sie of the plate in comparison to the hole to tr& to estimate the error in comparing the anal&ticalsolution for an infinite plate to the solution of this pro"lem of a finite plate.

    221 Mesh &eneration

    The domain consists of four "loc's$ some of hich have arc+shaped edges. The "loc' structure for

    http://openfoam.org/docs/user/plateHole.php#x6-3700315http://openfoam.org/docs/user/plateHole.php#x6-3700315http://openfoam.org/docs/user/plateHole.php#x6-3700315http://openfoam.org/docs/user/plateHole.php#x6-3700315http://openfoam.org/docs/user/plateHole.php#x6-3700315
  • 8/9/2019 OpenFoam Tutorials

    34/233

    the part of the mesh in the plane is shon in Figure 2.10. As alread& mentioned insection 2.1.1.1$ all geometries are generated in 3 dimensions in OpenFOAM even if the case is to "eas a 2 dimensional pro"lem. Therefore a dimension of the "loc' in the direction has to "e chosen*here$ >. is selected. #t does not affect the solution since the traction "oundar& condition isspecified as a stress rather than a force$ there"& ma'ing the solution independent of the cross+sectional area.

    Figure 2.10 6loc' structure of the mesh for the plate ith a hole.

    The user should change into the plate (21 (>. > >)22 (1 > >)23 (2 > >)2- (2 >.:>:1>: >)

    2 (>.:>:1>: >.:>:1>: >)20 (>.333 >.333 >)2: (2 2 >)

    http://openfoam.org/docs/user/plateHole.php#x6-3800116http://openfoam.org/docs/user/cavity.php#x5-60002.1.1.1http://openfoam.org/docs/user/plateHole.php#x6-3800116http://openfoam.org/docs/user/cavity.php#x5-60002.1.1.1
  • 8/9/2019 OpenFoam Tutorials

    35/233

    2; (>.:>:1>: 2 >)2= (> 2 >)3> (> 1 >)31 (> >. >)32 (>. > >.)33 (1 > >.)

    3- (2 > >.)3 (2 >.:>:1>: >.)30 (>.:>:1>: >.:>:1>: >.)3: (>.333 >.333 >.)3; (2 2 >.)3= (>.:>:1>: 2 >.)-> (> 2 >.)-1 (> 1 >.)-2 (> >. >.)-3 )*--

    - "loc's-0 (-: he% ( - = 1> 10 1 2> 21) (1> 1> 1) simplerading (1 1 1)-; he% (> 1 - 11 12 1 10) (1> 1> 1) simplerading (1 1 1)-= he% (1 2 3 - 12 13 1- 1) (2> 1> 1) simplerading (1 1 1)> he% (- 3 0 : 1 1- 1: 1;) (2> 2> 1) simplerading (1 1 1)1 he% (= - : ; 2> 1 1; 1=) (1> 2> 1) simplerading (1 1 1)2 )*3- edges (0 arc > (>.-0=;-0 >.1:1>1 >): arc 1> (>.1:1>1 >.-0=;-0 >); arc 1 - (>.=3=0=3 >.3-2>2 >)= arc - = (>.3-2>2 >.=3=0=3 >)0> arc 11 10 (>.-0=;-0 >.1:1>1 >.)01 arc 10 21 (>.1:1>1 >.-0=;-0 >.)02 arc 12 1 (>.=3=0=3 >.3-2>2 >.)03 arc 1 2> (>.3-2>2 >.=3=0=3 >.)0- )*0

    00 "oundar&0: (0; left0= I:> t&pe s&mmetr&/lane*:1 faces:2 (:3 (; = 2> 1=):- (= 1> 21 2>): )*:0 K

    :: right:; I:= t&pe patch*

  • 8/9/2019 OpenFoam Tutorials

    36/233

    ;> faces;1 (;2 (2 3 1- 13);3 (3 0 1: 1-);- )*; K

    ;0 don;: I;; t&pe s&mmetr&/lane*;= faces=> (=1 (> 1 12 11)=2 (1 2 13 12)=3 )*=- K= up=0 I

    =: t&pe patch*=; faces== (1>> (: ; 1= 1;)1>1 (0 : 1; 1:)1>2 )*1>3 K1>- hole1> I1>0 t&pe patch*1>: faces1>; (1>= (1> 10 21)11> ( > 11 10)111 )*112 K113 frontAnd6ac'11- I11 t&pe empt&*110 faces11: (

    11; (1> = - )11= ( - 1 >)12> (1 - 3 2)121 (- : 0 3)122 (- = ; :)123 (21 10 1 2>)12- (10 11 12 1)12 (12 13 1- 1)120 (1 1- 1: 1;)12: (1 1; 1= 2>)12; )*

    12= K13> )*131

  • 8/9/2019 OpenFoam Tutorials

    37/233

    132 merge/atch/airs133 (13- )*13130 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    ntil no$ e have onl& specified straight edges in the geometries of previous tutorials "ut here e

    need to specif& curved edges. These are specified under the edges 'e&ord entr& hich is a list ofnon+straight edges. The s&nta% of each list entr& "egins ith the t&pe of curve$ including arc$simpleSpline$ pol&5ine etc.$ descri"ed further in section.3.1. #n this e%ample$ all the edges arecircular and so can "e specified "& the arc 'e&ord entr&. The folloing entries are the la"els of thestart and end vertices of the arc and a point vector through hich the circular arc passes.

    The "loc's in this "loc'Mesh@ict do not all have the same orientation. As can "e seen inFigure 2.10the direction of "loc' > is e,uivalent to the direction for "loc' -. This meanscare must "e ta'en hen defining the num"er and distri"ution of cells in each "loc' so that the cellsmatch up at the "loc' faces.

    0 patches are defined one for each side of the plate$ one for the hole and one for the front and "ac'planes. The left and don patches are "oth a s&mmetr& plane. Since this is a geometric constraint$ itis included in the definition of the mesh$ rather than "eing purel& a specification on the "oundar&condition of the fields. Therefore the& are defined as such using a special s&mmetr&/lane t&pe asshon in the "loc'Mesh@ict.

    The frontAnd6ac' patch represents the plane hich is ignored in a 2@ case. Again this is ageometric constraint so is defined ithin the mesh$ using the empt& t&pe as shon in the"loc'Mesh@ict. For further details of "oundar& t&pes and geometric constraints$ the user shouldrefer to section .2.1.

    The remaining patches are of the regular patch t&pe. The mesh should "e generated using"loc'Mesh and can "e vieed in paraFoam as descri"ed in section2.1.2. #t should appear as inFigure 2.1:.

    Figure 2.1: Mesh of the hole in a plate pro"lem.

    http://openfoam.org/docs/user/blockMesh.php#x25-1430005.3.1http://openfoam.org/docs/user/blockMesh.php#x25-1430005.3.1http://openfoam.org/docs/user/plateHole.php#x6-3800116http://openfoam.org/docs/user/boundaries.php#x24-1380005.2.1http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/plateHole.php#x6-3824417http://openfoam.org/docs/user/blockMesh.php#x25-1430005.3.1http://openfoam.org/docs/user/plateHole.php#x6-3800116http://openfoam.org/docs/user/boundaries.php#x24-1380005.2.1http://openfoam.org/docs/user/cavity.php#x5-110002.1.2http://openfoam.org/docs/user/plateHole.php#x6-3824417
  • 8/9/2019 OpenFoam Tutorials

    38/233

    2211 'oundar# and initial conditions

    Once the mesh generation is complete$ the initial field ith "oundar& conditions must "e set. For astress anal&sis case ithout thermal stresses$ onl& displacement @ needs to "e set. The >7@ is asfollos

    1: dimensions > 1 > > > > >N*

    1;1= internalField uniform (> > >)*2>21 "oundar&Field22 I23 left2- I2 t&pe s&mmetr&/lane*20 K2: right2; I2= t&pe traction@isplacement*3> traction uniform ( 1>>>> > > )*31 pressure uniform >*32 value uniform (> > >)*33 K3- don3 I30 t&pe s&mmetr&/lane*3: K3; up

    3= I-> t&pe traction@isplacement*-1 traction uniform ( > > > )*-2 pressure uniform >*-3 value uniform (> > >)*-- K- hole-0 I-: t&pe traction@isplacement*-; traction uniform ( > > > )*-= pressure uniform >*

    > value uniform (> > >)*1 K2 frontAnd6ac'3 I- t&pe empt&* K0 K:; 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    Firstl&$ it can "e seen that the displacement initial conditions are set to . The left and

    don patches must "e "oth of s&mmetr&/lane t&pe since the& are specified as such in the meshdescription in the constant7pol&Mesh7"oundar& file. Similarl& the frontAnd6ac' patch is declaredempt&.

  • 8/9/2019 OpenFoam Tutorials

    39/233

    The other patches are traction "oundar& conditions$ set "& a specialist traction "oundar& t&pe. Thetraction "oundar& conditions are specified "& a linear com"ination of (1) a "oundar& traction vectorunder 'e&ord traction* (2) a pressure that produces a traction normal to the "oundar& surface thatis defined as negative hen pointing out of the surface$ under 'e&ord pressure. The up and holepatches are ero traction so the "oundar& traction and pressure are set to ero. For the right patch

    the traction should "e and the pressure should "e > .

    2212 Mechanical properties

    The ph&sical properties for the case are set in the mechanical/roperties dictionar& in the constantdirector&. For this pro"lem$ e need to specif& the mechanical properties of steel given in Ta"le2.1.#n the mechanical properties dictionar&$ the user must also set planeStress to &es.

    /ropert& nits e&ord 9alue

    @ensit& rho :;-

    \oungCs modulus ?/oissonCs ratio R nu >.3

    Ta"le 2.1 Mechanical properties for steel

    221( Ther,al properties

    The temperature field varia"le T is present in the solid@isplacementFoam solver since the user ma&opt to solve a thermal e,uation that is coupled ith the momentum e,uation through the thermalstresses that are generated. The user specifies at run time hether OpenFOAM should solve thethermal e,uation "& the thermalStress sitch in the thermal/roperties dictionar&. This dictionar&also sets the thermal properties for the case$ e.g. for steel as listed in Ta"le2.2.

    /ropert& nits e&ord 9alue

    Specific heat capacit& -3-

    Thermal conductivit& ' 0>.

    Thermal e%pansion coeff. alpha

    Ta"le 2.2 Thermal properties for steel

    #n this case e do not ant to solve for the thermal e,uation. Therefore e must set thethermalStress 'e&ord entr& to no in the thermal/roperties dictionar&.

    221) Control

    As "efore$ the information relating to the control of the solution procedure are read in from thecontrol@ict dictionar&. For this case$ the startTime is > . The time step is not important since this isa stead& state case* in this situation it is "est to set the time step deltaT to 1 so it simpl& acts as aniteration counter for the stead&+state case. The endTime$ set to 1>>$ then acts as a limit on the

    http://openfoam.org/docs/user/plateHole.php#x6-400031http://openfoam.org/docs/user/plateHole.php#x6-400031http://openfoam.org/docs/user/plateHole.php#x6-410052http://openfoam.org/docs/user/plateHole.php#x6-410052http://openfoam.org/docs/user/plateHole.php#x6-400031http://openfoam.org/docs/user/plateHole.php#x6-410052
  • 8/9/2019 OpenFoam Tutorials

    40/233

    num"er of iterations. The rite#nterval can "e set to .

    The control@ict entries are as follos

    1:1; application solid@isplacementFoam*1=

    2> startFrom startTime*2122 startTime >*232- stopAt endTime*220 endTime 1>>*2:2; deltaT 1*2=3> riteontrol timeStep*

    3132 rite#nterval 2>*333- purgeHrite >*330 riteFormat ascii*3:3; rite/recision 0*3=-> riteompression off*-1

    -2 timeFormat general*-3-- time/recision 0*--0 graphFormat ra*-:-; runTimeModifia"le true*-=>1 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    221* Discretisation sche,es and linear-sol"er control

    5et us turn our attention to the fvSchemes dictionar&. Firstl&$ the pro"lem e are anal&sing isstead&+state so the user should select Stead&State for the time derivatives in timeScheme. Thisessentiall& sitches off the time derivative terms. 8ot all solvers$ especiall& in fluid d&namics$or' for "oth stead&+state and transient pro"lems "ut solid@isplacementFoam does or'$ since the"ase algorithm is the same for "oth t&pes of simulation.

    The momentum e,uation in linear+elastic stress anal&sis includes several e%plicit terms containingthe gradient of displacement. The calculations "enefit from accurate and smooth evaluation of thegradient. 8ormall&$ in the finite volume method the discretisation is "ased on aussCs theorem Theauss method is sufficientl& accurate for most purposes "ut$ in this case$ the least s,uares methodill "e used. The user should therefore open the fvSchemes dictionar& in the s&stem director& andensure the leastS,uares method is selected for the grad() gradient discretisation scheme in thegradSchemes su"+dictionar&

  • 8/9/2019 OpenFoam Tutorials

    41/233

    1:1; d2dt2Schemes1= I2> default stead&State*21 K22

    23 ddtSchemes2- I2 default ?uler*20 K2:2; gradSchemes2= I3> default leastS,uares*31 grad(@) leastS,uares*32 grad(T) leastS,uares*33 K

    3-3 divSchemes30 I3: default none*3; div(sigma@) auss linear*3= K->-1 laplacianSchemes-2 I-3 default none*-- laplacian(@@$@) auss linear corrected*- laplacian(@T$T) auss linear corrected*-0 K-:-; interpolationSchemes-= I> default linear*1 K23 snradSchemes- I

    default none*0 K:; flu%4e,uired= I0> default no*01 @ &es*02 T no*03 K0-0

    00 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77The fvSolution dictionar& in the s&stem director& controls the linear e,uation solvers andalgorithms used in the solution. The user should first loo' at the solvers su"+dictionar& and notice

  • 8/9/2019 OpenFoam Tutorials

    42/233

    that the choice of solver for @ is AM. The solver tolerance should "e set to for thispro"lem. The solver relative tolerance$ denoted "& relTol$ sets the re,uired reduction in the residualsithin each iteration. #t is uneconomical to set a tight (lo) relative tolerance ithin each iterationsince a lot of terms in each e,uation are e%plicit and are updated as part of the segregated iterativeprocedure. Therefore a reasona"le value for the relative tolerance is $ or possi"l& even higher$sa& $ or in some cases even (as in this case).

    1:1; solvers1= I2> Y(@T)Y21 I22 solver AM*23 tolerance 1e+>0*2- relTol >.=*2 smoother aussSeidel*20 cacheAgglomeration true*

    2: nells#noarsest5evel 2>*2; agglomerator faceArea/air*2= merge5evels 1*3> K31 K3233 stressAnal&sis3- I3 compact8ormalStress &es*30 norrectors 1*3: @ 1e+>0*

    3; K3=->-1 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    The fvSolution dictionar& contains a su"+dictionar&$ stressAnal&sis that contains some controlparameters specific to the application solver. Firstl& there is norrectors hich specifies the num"erof outer loops around the complete s&stem of e,uations$ including traction "oundar& conditionsithin each time step. Since this pro"lem is stead&+state$ e are performing a set of iterationstoards a converged solution ith the Ctime stepC acting as an iteration counter. He can therefore setnorrectors to 1.

    The @ 'e&ord specifies a convergence tolerance for the outer iteration loop$ i.e. sets a level ofinitial residual "elo hich solving ill cease. #t should "e set to the desired solver tolerancespecified earlier$ for this pro"lem.

    222 Runnin& the code

    The user should run the code here in the "ac'ground from the command line as specified "elo$ sohe7she can loo' at convergence information in the log file afterards.

    cd FOAM487tutorials7stressAnal&sis7solid@isplacementFoam7plate

  • 8/9/2019 OpenFoam Tutorials

    43/233

    iteration tolerance set. Once "oth initial residuals have dropped "elo the convergence tolerance ofthe run has converged and can "e stopped "& 'illing the "atch Jo".

    22( Post-processin&

    /ost processing can "e performed as in section 2.1.-. The solid@isplacementFoam solver outputs

    the stress field as a s&mmetric tensor field sigma. This is consistent ith the a& varia"les areusuall& represented in OpenFOAM solvers "& the mathematical s&m"ol "& hich the& arerepresented* in the case of ree' s&m"ols$ the varia"le is named phoneticall&.

    For post+processing individual scalar field components$ $ etc.$ can "e generated "& runningthe foamalc utilit& as "efore in section 2.1..:$ this time on sigma

    foamalc components sigmaomponents named sigma%%$ sigma%& etc. are ritten to time directories of the case. Thestresses can "e vieed in paraFoam as shon in Figure 2.1;.

    Figure 2.1; stress field in the plate ith hole.

    He ould li'e to compare the anal&tical solution of ?,uation 2.1-to our solution. He thereforemust output a set of data of along the left edge s&mmetr& plane of our domain. The user ma&

    generate the re,uired graph data using the sample utilit&. The utilit& uses a sample@ict dictionar&located in the s&stem director&$ hose entries are summarised in Ta"le 0.3. The sample line

    specified in sets is set "eteen and $ and the fields are specified in thefields list

    1:1; interpolationScheme cell/oint*1=2> setFormat ra*2122 sets

    23 (2- left/atch2 I

    http://openfoam.org/docs/user/cavity.php#x5-130002.1.4http://openfoam.org/docs/user/cavity.php#x5-240002.1.5.7http://openfoam.org/docs/user/plateHole.php#x6-4500118http://openfoam.org/docs/user/plateHole.php#x6-4500118http://openfoam.org/docs/user/plateHole.php#x6-37004r14http://openfoam.org/docs/user/plateHole.php#x6-37004r14http://openfoam.org/docs/user/sample.php#x34-2000833http://openfoam.org/docs/user/cavity.php#x5-130002.1.4http://openfoam.org/docs/user/cavity.php#x5-240002.1.5.7http://openfoam.org/docs/user/plateHole.php#x6-4500118http://openfoam.org/docs/user/plateHole.php#x6-37004r14http://openfoam.org/docs/user/sample.php#x34-2000833
  • 8/9/2019 OpenFoam Tutorials

    44/233

    20 t&pe uniform*2: a%is &*2; start ( > >. >.2 )*2= end ( > 2 >.2 )*3> n/oints 1>>*31 K

    32 )*333- fields ( sigma%% )*3303: 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    The user should e%ecute sample as normal. The riteFormat is ra 2 column format. The data isritten into files ithin time su"directories of a post/rocessing7sets director&$ e.g. the data at

    s is found ithin the file sets71>>7left/atchsigma%%.%&. #n an application such as nu/lot$one could t&pe the folloing at the command prompt ould "e sufficient to plot "oth the numerical

    data and anal&tical solution

    plot >.2N >N ]post/rocessing7sets71>>7left/atch sigma%%.%&]$1e-D(1!(>.127(%DD2))!(>.>=3:7(%DD-)))

    An e%ample plot is shon in Figure 2.1=.

    Figure 2.1= 8ormal stress along the vertical s&mmetr&

    22) E.ercises

    The user ma& ish to e%periment ith solid@isplacementFoam "& tr&ing the folloing e%ercises

    22)1 Increasin& ,esh resolution

    #ncrease the mesh resolution in each of the and directions. se mapFields to map the finalcoarse mesh results from section 2.2.3to the initial conditions for the fine mesh.

    http://openfoam.org/docs/user/plateHole.php#x6-4504619http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/plateHole.php#x6-4504619http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3
  • 8/9/2019 OpenFoam Tutorials

    45/233

    22)2 Introducin& ,esh &radin&

    rade the mesh so that the cells near the hole are finer than those aa& from the hole. @esign themesh so that the ratio of sies "eteen adJacent cells is no more than 1.1 and so that the ratio of cellsies "eteen "loc's is similar to the ratios ithin "loc's. Mesh grading is descri"ed insection 2.1.0. Again use mapFields to map the final coarse mesh results from section2.2.3to theinitial conditions for the graded mesh. ompare the results ith those from the anal&tical solution

    and previous calculations. an this solution "e improved upon using the same num"er of cells itha different solution^

    22)( Chan&in& the plate si8e

    The anal&tical solution is for an infinitel& large plate ith a finite sied hole in it. Therefore thissolution is not completel& accurate for a finite sied plate. To estimate the error$ increase the platesie hile maintaining the hole sie at the same value.

    2( 'reain& o$ a da,

    #n this tutorial e shall solve a pro"lem of simplified dam "rea' in 2 dimensions using theinterFoam.The feature of the pro"lem is a transient flo of to fluids separated "& a sharpinterface$ or free surface. The to+phase algorithm in interFoam is "ased on the volume of fluid(9OF) method in hich a specie transport e,uation is used to determine the relative volumefraction of the to phases$ or phase fraction $ in each computational cell. /h&sical properties arecalculated as eighted averages "ased on this fraction. The nature of the 9OF method means thatan interface "eteen the species is not e%plicitl& computed$ "ut rather emerges as a propert& of thephase fraction field. Since the phase fraction can have an& value "eteen > and 1$ the interface isnever sharpl& defined$ "ut occupies a volume around the region here a sharp interface shoulde%ist.

    The test setup consists of a column of ater at rest located "ehind a mem"rane on the left side of a

    tan'. At time $ the mem"rane is removed and the column of ater collapses. @uring thecollapse$ the ater impacts an o"stacle at the "ottom of the tan' and creates a complicated flostructure$ including several captured poc'ets of air. The geometr& and the initial setup is shon inFigure 2.2>.

    http://openfoam.org/docs/user/cavity.php#x5-250002.1.6http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/damBreak.php#x7-5000520http://openfoam.org/docs/user/cavity.php#x5-250002.1.6http://openfoam.org/docs/user/plateHole.php#x6-450002.2.3http://openfoam.org/docs/user/damBreak.php#x7-5000520
  • 8/9/2019 OpenFoam Tutorials

    46/233

    Figure 2.2> eometr& of the dam "rea'.

    2(1 Mesh &eneration

    The user should go to the dam6rea' case in theirFOAM487tutorials7multiphase7interFoam7laminar director&. enerate the mesh running"loc'Mesh as descri"ed previousl&. The dam6rea' mesh consist of "loc's* the "loc'Mesh@ictentries are given "elo.

    1: convertToMeters >.1-0*1;1= vertices2> (21 (> > >)22 (2 > >)23 (2.10-3; > >)2- (- > >)

    2 (> >.32;:0 >)20 (2 >.32;:0 >)2: (2.10-3; >.32;:0 >)2; (- >.32;:0 >)2= (> - >)3> (2 - >)31 (2.10-3; - >)32 (- - >)33 (> > >.1)3- (2 > >.1)3 (2.10-3; > >.1)

    30 (- > >.1)3: (> >.32;:0 >.1)3; (2 >.32;:0 >.1)

  • 8/9/2019 OpenFoam Tutorials

    47/233

    3= (2.10-3; >.32;:0 >.1)-> (- >.32;:0 >.1)-1 (> - >.1)-2 (2 - >.1)-3 (2.10-3; - >.1)-- (- - >.1)

    - )*-0-: "loc's-; (-= he% (> 1 - 12 13 1: 10) (23 ; 1) simplerading (1 1 1)> he% (2 3 : 0 1- 1 1= 1;) (1= ; 1) simplerading (1 1 1)1 he% (- = ; 10 1: 21 2>) (23 -2 1) simplerading (1 1 1)2 he% ( 0 1> = 1: 1; 22 21) (- -2 1) simplerading (1 1 1)3 he% (0 : 11 1> 1; 1= 23 22) (1= -2 1) simplerading (1 1 1)- )*

    0 edges: (; )*=0> "oundar&01 (02 leftHall03 I0- t&pe all*0 faces00 (0: (> 12 10 -)0; (- 10 2> ;)0= )*:> K:1 rightHall:2 I:3 t&pe all*:- faces: (:0 (: 1= 1 3)

    :: (11 23 1= :):; )*:= K;> loerHall;1 I;2 t&pe all*;3 faces;- (; (> 1 13 12);0 (1 1: 13);: ( 0 1; 1:)

    ;; (2 1- 1; 0);= (2 3 1 1-)=> )*

  • 8/9/2019 OpenFoam Tutorials

    48/233

    =1 K=2 atmosphere=3 I=- t&pe patch*= faces=0 (

    =: (; 2> 21 =)=; (= 21 22 1>)== (1> 22 23 11)1>> )*1>1 K1>2 )*1>31>- merge/atch/airs1> (1>0 )*1>:

    1>; 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    2(2 'oundar# conditions

    The user can e%amine the "oundar& geometr& generated "& "loc'Mesh "& vieing the "oundar& filein the constant7pol&Mesh director&. The file contains a list of "oundar& patches leftHall$rightHall$ loerHall$ atmosphere and defaultFaces. The user should notice the t&pe of the patches.The atmosphere is a standard patch$ i.e. has no special attri"utes$ merel& an entit& on hich"oundar& conditions can "e specified. The defaultFaces patch is empt& since the patch normal is inthe direction e ill not solve in this 2@ case. The leftHall$ rightHall and loerHall patches areeach a all. 5i'e the plain patch$ the all t&pe contains no geometric or topological information

    a"out the mesh and onl& differs from the plain patch in that it identifies the patch as a all$ shouldan application need to 'no$ e.g. to appl& special all surface modelling.

    A good e%ample is that the interFoam solver includes modelling of surface tension at the contactpoint "eteen the interface and all surface. The models are applied "& specif&ing thealphaontactAngle "oundar& condition on the alpha ( ) field. Hith it$ the user must specif& thefolloing a static contact angle$ theta> * leading and trailing edge d&namic contact angles$ thetaA

    and theta4 respectivel&* and a velocit& scaling function for d&namic contact angle$ uTheta.

    #n this tutorial e ould li'e to ignore surface tension effects "eteen the all and interface. Hecan do this "& setting the static contact angle$ and the velocit& scaling function to >. andlocal velocit& *

    pressure#nletOutlet9elocit&$ hich applies eroradient on all components$ e%cept herethere is inflo$ in hich case a fi%ed9alue condition is applied to the tangential component*

    inletOutlet$ hich is a eroradient condition hen flo outards$ fi%ed9alue hen flo isinards.

    At all all "oundaries$ the fi%edFlu%/ressure "oundar& condition is applied to the pressure field$hich adJusts the pressure gradient so that the "oundar& flu% matches the velocit& "oundar&

  • 8/9/2019 OpenFoam Tutorials

    49/233

    condition.

    The default Faces patch representing the front and "ac' planes of the 2@ pro"lem$ is$ as usual$ anempt& t&pe.

    2(( ettin& initial $ield

    nli'e the previous cases$ e shall no specif& a non+uniform initial condition for the phasefraction here

    (2.1)

    This ill "e done "& running the setFields utilit&. #t re,uires a setFields@ict dictionar&$ located inthe s&stem director&$ hose entries for this case are shon "elo.

    1:1; defaultField9alues1= (

    2> volScalarField9alue alpha.ater >21 )*2223 regions2- (2 "o%Toell20 I2: "o% (> > +1) (>.1-01 >.2=2 1)*2; field9alues2= (3> volScalarField9alue alpha.ater 131 )*32 K33 )*3-330 77 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 77

    The