pCEE618-SP13-10 - Computational Environmental Physics Lab

25 downloads 189 Views 1MB Size Report
Table of Contents. 1. OpenFOAM: Overview. 2. Mesh generation. 3. OpenFOAM runs. Original tutorial case as it is. Original tutorial case using parallel. 4.
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

Table of Contents

1

OpenFOAM: Overview

2

Mesh generation

3

OpenFOAM runs Original tutorial case as it is Original 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 2 3

2

OpenFOAM simulation 1

2 3 4 5

3

Generate or modify geometry (.geo) file Open geometry file and customize it if necessary Generate mesh (.msh) file

Convert .msh file (from gmsh) to OpenFOAM form using gmshToFOAM set boundary conditions set initial conditions adjust simulation parameters run serial/parallel simulation using PBS

Paraview visualization 1 2 3

transfer compressed data file from server to your local computer start Paraview and load .foam file (which has zero byte). generate plots, e.g., color plot for pressure, vector plot for velocity vectors, and streamlines 4 / 20

Mesh generation

gmsh tutorials

1

Manual1

2

Gmsh tutorial2

3

Gmsh-cavity tutorial3

1 2 3

http://albertsk.files.wordpress.com/2011/12/gmsh.pdf http://albertsk.files.wordpress.com/2012/12/gmsh_tutorial.pdf http://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 2

3

4

Log in fractal.eng.hawaii.edu using your private ssh-key. Make OpenFOAM-Cases directory under your home dir.: $t mkdirt OpenFOAM-Cases Go to OpenFOAM-Cases and make/go to ‘cavity’ dir.: $t cdt OpenFOAM-Cases $t mkdirt cavity $t cdt cavity Copy cavity files: $t cpt -rt ˜ /OpenFOAM/OpenFOAM-2.1.1/tutorials/incompressible/icoFoam/cavity/*t ./

5

6

Run OpenFOAM simulation: (for large scale simulation, use PBS) $ touch cavity.foam $ blockMesh $ icoFoam Zip simulation directory to a file cavitydata.zip: $t cdt .. $t zipt -rt cavitydata.zipt cavity 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 input dictionary, blockMeshDict located in the constant/polyMesh directory for a given case.

2

As ./constant/polyMesh/blockMeshDict exists, $t blockMesh

3

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

4

Although blockMesh is a solid mesh generator, it is difficult for beginners.

5

Initially, the flow will be assumed laminar and will be solved on a uniform 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 2 3

Generate ‘decomposeParDict’ file under ‘system’. numberOfSubdomains = nx × ny × nz : 4 = 2 × 2 × 1 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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

/*−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−*− C++ −*−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−*\ | ========= | | | \\ / F ield | OpenFOAM : The Open Source CFD Toolbox | | \\ / O peration | Version : 2.1.1 | | \\ / A nd | Web: www. OpenFOAM . org | | \\/ M anipulation | | \*−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−*/ FoamFile { version 2.0; format ascii ; class dictionary ; location " system " ; object decomposeParDict ; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // numberOfSubdomains 4 ; method simpleCoeffs { n delta }

simple ;

( 2 2 1 ); 0.001; 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 t -parallel

2

PBS script is below.

1 2 3 4 5 6 7 8 3

# ! / b i n / bash #PBS − l w a l l t i m e =01:00:00 #PBS −q batch #PBS − l nodes =04: ppn=1 #PBS −N PRL−icoFoam #PBS −V cd $PBS_O_WORKDIR mpirunany . sh icoFoam − p a r a l l e l

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 is finished, under each of ‘processori’ directory, created directories are: 0, 0.1, 0.2, 0.3, 0.4, 0.5, and constant. Type/Enter: $t reconstructPar

16 / 20

OpenFOAM runs

Original tutorial case using parallel

decomposePar → mpirun → reconstructPar

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

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

Examples p dimensions [0 2 -2 0 0 0 0]: m2 s−2 = m2 /s2 p=

Force kg m s−2 m2 = 2 = 2 3 Area × Density m kg/m s

U dimensions [0 1 -1 0 0 0 0]; m1 s−1 = m/s nu [ 0 2 -1 0 0 0 0 ] 0.01; m2 s−1 = m2 /s ν=kinematic viscosity = absolute viscosity / density 4

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

Lab work

Labwork: Non-cubic cavity

1

2

3

Use Gmsh to generate a mesh. You can edit .geo file for the cubic cavity, load it to gmsh, and generate a mesh. Use OpenFoam for flow simulation. Run in (a) serial mode and (b) parallel mode using 4 (or more) processors. Use Paraview for visualization and movie making. 20 / 20