20
CEE 618 Scientific Parallel Computing (Lecture 10) Computational Fluid Mechanics using OpenFOAM: Cavity (2) Albert S. Kim Department of Civil and Environmental Engineering University of Hawai‘i at Manoa 2540 Dole Street, Holmes 383, Honolulu, Hawaii 96822 1 / 20

pCEE618-SP13-10 - Computational Environmental Physics Lab

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

CEE 618 Scientific Parallel Computing (Lecture 10)Computational Fluid Mechanics using OpenFOAM: Cavity (2)

Albert S. Kim

Department of Civil and Environmental EngineeringUniversity of Hawai‘i at Manoa

2540 Dole Street, Holmes 383, Honolulu, Hawaii 96822

1 / 20

Table of Contents

1 OpenFOAM: Overview

2 Mesh generation

3 OpenFOAM runsOriginal tutorial case as it isOriginal tutorial case using parallel

4 Lab work

2 / 20

OpenFOAM: Overview

Tool chain of Open-source CFD, OpenFOAM

In our case, blockMesh & gmsh→ OpenFOAM→ Paraview

3 / 20

OpenFOAM: Overview

Specific Procedures

1 Mesh generation (gmsh)1 Generate or modify geometry (.geo) file2 Open geometry file and customize it if necessary3 Generate mesh (.msh) file

2 OpenFOAM simulation1 Convert .msh file (from gmsh) to OpenFOAM form using

gmshToFOAM2 set boundary conditions3 set initial conditions4 adjust simulation parameters5 run serial/parallel simulation using PBS

3 Paraview visualization1 transfer compressed data file from server to your local computer2 start Paraview and load .foam file (which has zero byte).3 generate plots, e.g., color plot for pressure, vector plot for velocity

vectors, and streamlines4 / 20

Mesh generation

gmsh tutorials

1 Manual1

2 Gmsh tutorial2

3 Gmsh-cavity tutorial3

1http://albertsk.files.wordpress.com/2011/12/gmsh.pdf

2http://albertsk.files.wordpress.com/2012/12/gmsh_tutorial.pdf

3http://albertsk.files.wordpress.com/2012/12/gmsh-cavity-tutorial.pdf

5 / 20

OpenFOAM runs Original tutorial case as it is

Simulation steps using cavity example

1 Log in fractal.eng.hawaii.edu using your private ssh-key.2 Make OpenFOAM-Cases directory under your home dir.:$tmkdirtOpenFOAM-Cases

3 Go to OpenFOAM-Cases and make/go to ‘cavity’ dir.:$tcdtOpenFOAM-Cases$tmkdirtcavity$tcdtcavity

4 Copy cavity files:$tcpt-rt/̃OpenFOAM/OpenFOAM-2.1.1/tutorials/incompressible/icoFoam/cavity/*t./

5 Run OpenFOAM simulation: (for large scale simulation, use PBS)$ touch cavity.foam$ blockMesh$ icoFoam

6 Zip simulation directory to a file cavitydata.zip:$tcdt..$tzipt-rtcavitydata.ziptcavity

6 / 20

OpenFOAM runs Original tutorial case as it is

blockMesh & icoFoam

1 The mesh generator supplied with OpenFOAM, blockMesh,generates meshes from a description specified in an inputdictionary, blockMeshDict located in the constant/polyMeshdirectory for a given case.

2 As ./constant/polyMesh/blockMeshDict exists,$tblockMesh

3 This will generate ’faces’, ’neighbour’, ’owner’, ’points’ under./constant/polyMesh/.

4 Although blockMesh is a solid mesh generator, it is difficult forbeginners.

5 Initially, the flow will be assumed laminar and will be solved on auniform mesh using the icoFoam solver for laminar, isothermal,incompressible flow.

7 / 20

OpenFOAM runs Original tutorial case as it is

Before and After ’blockMesh’

8 / 20

OpenFOAM runs Original tutorial case as it is

9 / 20

OpenFOAM runs Original tutorial case as it is

running ’icoFoam’

10 / 20

OpenFOAM runs Original tutorial case as it is

Paraview-Visualization

Figure: Pressure, velocity, and streamlines

11 / 20

OpenFOAM runs Original tutorial case using parallel

Parallel running of ‘icoFoam’ after ‘blockMesh’

1 Generate ‘decomposeParDict’ file under ‘system’.2 numberOfSubdomains = nx × ny × nz: 4 = 2× 2× 13 We will use the ‘simple’ method. ‘delta’ is the cell skewed number, default=0.001.

http://www.openfoam.org/docs/user/running-applications-parallel.php#x12-820003.4

1 /*−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−*− C++ −*−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−*\2 | ========= | |3 | \ \ / F i e l d | OpenFOAM: The Open Source CFD Toolbox |4 | \ \ / O pera t i on | Version : 2 .1 .1 |5 | \ \ / A nd | Web: www.OpenFOAM. org |6 | \ \ / M a n i p u l a t i o n | |7 \*−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−*/8 FoamFile9 {

10 vers ion 2 . 0 ;11 format a s c i i ;12 c lass d i c t i o n a r y ;13 l o c a t i o n " system " ;14 ob jec t decomposeParDict ;15 }16 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / /1718 numberOfSubdomains 4 ;1920 method simple ;2122 simpleCoef fs23 {24 n ( 2 2 1 ) ;25 de l t a 0 .001;26 }2728 h i e r a r c h i c a l C o e f f s29 {30 n ( 1 1 1 ) ;31 de l t a 0 .001;32 order xyz ;33 }3435 manualCoeffs36 {37 da taF i l e " " ;38 }3940 d i s t r i b u t e d no ;4142 roo ts ( ) ;434445 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / /

12 / 20

OpenFOAM runs Original tutorial case using parallel

decomposePar→ mpirun→ reconstructPar

13 / 20

OpenFOAM runs Original tutorial case using parallel

decomposePar→ mpirun→ reconstructPar

1 Four directories are generated: processor0, processor1,processor2, and processor3.

14 / 20

OpenFOAM runs Original tutorial case using parallel

decomposePar→ mpirun→ reconstructPar

1 format: mpirunany.sht<Foam-Command>t-parallel2 PBS script is below.

1 # ! / b in / bash2 #PBS − l wa l l t ime =01:00:003 #PBS −q batch4 #PBS − l nodes=04:ppn=15 #PBS −N PRL−icoFoam6 #PBS −V7 cd $PBS_O_WORKDIR8 mpirunany . sh icoFoam −p a r a l l e l

3 Note that node=04 because numberOfSubdomains=4 = 2× 2× 1.

15 / 20

OpenFOAM runs Original tutorial case using parallel

decomposePar→ mpirun→ reconstructPar

After the parallel run isfinished, under each of‘processori’ directory, createddirectories are: 0, 0.1, 0.2,0.3, 0.4, 0.5, andconstant.Type/Enter:$treconstructPar

16 / 20

OpenFOAM runs Original tutorial case using parallel

decomposePar→ mpirun→ reconstructPar

Directories of 0.1, ..., and 0.5are ‘reconstructed’ in the casedirectory.

17 / 20

OpenFOAM runs Original tutorial case using parallel

Visualization

1 Paraview visualization is same as the previous discussion.

Figure: Pressure, velocity, and streamlines

18 / 20

OpenFOAM runs Original tutorial case using parallel

OpenFOAM: dimension setting

1 OpenFOAM dimension setting4

2 Examplesp dimensions [0 2 -2 0 0 0 0]: m2s−2 = m2/s2

p =Force

Area× Density=

kg m s−2

m2 kg/m3=

m2

s2

U dimensions [0 1 -1 0 0 0 0]; m1s−1 = m/snu [ 0 2 -1 0 0 0 0 ] 0.01; m2s−1 = m2/sν=kinematic viscosity = absolute viscosity / density

4http://www.openfoam.org/docs/user/basic-file-format.php

19 / 20

Lab work

Labwork: Non-cubic cavity

1 Use Gmsh to generate a mesh. You can edit .geo file for the cubiccavity, load it to gmsh, and generate a mesh.

2 Use OpenFoam for flow simulation. Run in (a) serial mode and (b)parallel mode using 4 (or more) processors.

3 Use Paraview for visualization and movie making.20 / 20