week 03 - mesh quality

9
9/24/2013 1 Computational Fluid Dynamics Structured Vs. Unstructured Mesh A single block structured mesh may comprise of square elements (2D) or hexahedral elements (3D) which are orthogonal in i, j space (2D) or i, j, k space (3D). Although is also possible to have wedges (3D), triangles (2D) and pyramids (3D) in a structured mesh. Looking at a 2D example, for simplicity: Every node in a 2D structured mesh has a corresponding integer i and j index value which is unique. The physical locations of the nodes are stored in a table or are functionally related to the mesh space (ie (x,y)= f(i,j)). The neigbours of node (i,j) are (i-1,j), (i+1,j), (i,j-1), (i,j+1), (i-1,j-1), and (i+1,j+1). A structured mesh makes it very easy to loop through neighbours and can be efficient with memory. A structured mesh has many coding advantages, but it may be difficult to conform a single block to a complicated shape. Code developers have got around this by allowing multiple blocks (multiblock unstructured), but this can make the internal memory strucutres more inefficient. Another way to make the mesh generation simpler, and improve code performance is to throw away the block structure and replace indices with node numbers and a connectivity table. This is known as an unstructured mesh, because it lacks the i,j,k structure. 24-Sep-13 25 Computational Fluid Dynamics Structured Vs. Unstructured Mesh A structured mesh requires the blocking as input. Unstructured meshes, only requires the element size on the lines and surfaces that define the geometry as input. 24-Sep-13 26

Upload: sksiddique

Post on 21-Jan-2016

16 views

Category:

Documents


0 download

DESCRIPTION

Meshing in CFD packages

TRANSCRIPT

Page 1: Week 03 - Mesh Quality

9/24/2013

1

Computational Fluid Dynamics

Structured Vs. Unstructured Mesh • A single block structured mesh may comprise of square elements (2D) or hexahedral elements

(3D) which are orthogonal in i, j space (2D) or i, j, k space (3D). Although is also possible to have

wedges (3D), triangles (2D) and pyramids (3D) in a structured mesh.

• Looking at a 2D example, for simplicity:

– Every node in a 2D structured mesh has a corresponding integer i and j index value which is unique.

– The physical locations of the nodes are stored in a table or are functionally related to the mesh space (ie

(x,y)= f(i,j)).

– The neigbours of node (i,j) are (i-1,j), (i+1,j), (i,j-1), (i,j+1), (i-1,j-1), and (i+1,j+1).

– A structured mesh makes it very easy to loop through neighbours and can be efficient with memory.

• A structured mesh has many coding advantages, but it may be difficult to conform a single block

to a complicated shape. Code developers have got around this by allowing multiple blocks

(multiblock unstructured), but this can make the internal memory strucutres more inefficient.

• Another way to make the mesh generation simpler, and improve code performance is to throw

away the block structure and replace indices with node numbers and a connectivity table. This is

known as an unstructured mesh, because it lacks the i,j,k structure.

24

-Sep

-13

25

Computational Fluid Dynamics

Structured Vs. Unstructured Mesh

• A structured mesh requires the blocking as input.

• Unstructured meshes, only requires the element size on the lines and surfaces that define the geometry as input.

24

-Sep

-13

26

Page 2: Week 03 - Mesh Quality

9/24/2013

2

Computational Fluid Dynamics

Structured Vs. Unstructured Mesh

• Unstructured

Hybrid Mesh

(tetras, prisms

and hexs)

• Cell count:

approx. 5 000 000

• Structured Mesh

(hexahedrals)

• Cell count:

approx. 5 000 000

24

-Sep

-13

27

Computational Fluid Dynamics

Structured Vs. Unstructured Mesh

24

-Sep

-13

28

Page 3: Week 03 - Mesh Quality

9/24/2013

3

Computational Fluid Dynamics

Structured Vs. Unstructured Mesh

• Each mesh type has its advantages and

disadvantages.

• At the end of the day, the mesh you use must

has a good overall quality and must be

smooth.

• The mesh density should be high enough to

capture all relevant flow features.

24

-Sep

-13

29

Computational Fluid Dynamics

Mesh Quality

• Rule of thumb: ‘the elements shape and

distribution should be pleasing to the eye’.

• There is no written theory when it comes to

mesh generation and the whole process

depends on user experience.

• The user can rely on grid dependency studies,

but they are time consuming and expensive.

• No single standard benchmark or metric exists

that can effectively assess the quality of a mesh,

but you can rely on suggested best practices.

24

-Sep

-13

31

Page 4: Week 03 - Mesh Quality

9/24/2013

4

Computational Fluid Dynamics

Mesh Quality

• The most common mesh quality metrics are:

– Orthogonality.

– Skewness.

– Aspect Ratio.

– Smoothness.

24

-Sep

-13

32

Computational Fluid Dynamics

Mesh Quality

• Mesh orthogonality

– It is the angular deviation of the vector S (located

at the face center f ) from the vector d connecting

the two cell centers P and N.

– It affects the gradient of the face center f.

– It adds diffusion to the solution.

24

-Sep

-13

33

Page 5: Week 03 - Mesh Quality

9/24/2013

5

Computational Fluid Dynamics

Mesh Quality

• Mesh skewness – Skewness is the deviation of the vector d that

connects the two cells P and N, from the face center f. The deviation vector is represented with and the point where the vector d intersects the face f is fi.

– It affects the interpolation of the cell centered quantities to the face center f.

– It adds diffusion to the solution.

24

-Sep

-13

34

Computational Fluid Dynamics

Mesh Quality

• Mesh aspect ratio AR

– Mesh aspect ratio AR is the ratio between the

longest side x and the shortest side y .

– Large AR are fine if gradients in the long direction

are small.

– High AR smear gradients.

24

-Sep

-13

35

Page 6: Week 03 - Mesh Quality

9/24/2013

6

Computational Fluid Dynamics

Mesh Quality

• Smoothness – Smoothness, also known as expansion rate, growth factor

or uniformity, defines the transition in size between contiguous cells.

– Large transition ratios between cells add diffusion to the solution.

– Ideally, the maximum change in mesh spacing should be less than 20%: ∆𝑦2 ∆𝑦1 ≤ 1.2

24

-Sep

-13

36

Steep Transition Smooth Transition

Computational Fluid Dynamics

Mesh Quality

• For the same cell count, hexahedral meshes will give more accurate solutions, especially if the grid lines are aligned with the flow.

• The mesh density should be high enough to capture all relevant flow features. In areas where the solution change slowly, you can use larger elements.

• To keep cell count down, use non-uniform meshes to cluster cells only where they are needed. Use local refinements and solution adaption to further refine only on selected areas.

• In boundary layers, quad, hex, and prism/wedge cells are preferred over triangles, tetrahedras, or pyramids.

• If you are not using wall functions (turbulence modeling), the mesh adjacent to the walls should be fine enough to resolve the boundary layer flow. This will rocket the cell count.

24

-Sep

-13

37

Page 7: Week 03 - Mesh Quality

9/24/2013

7

Computational Fluid Dynamics

Mesh Quality

• In

– WM_PROJECT_DIR/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C

you will find the quality metrics used in OpenFOAM.

• Their maximum (or minimum) values are defined as follows:

Foam::scalar Foam::primitiveMesh::closedThreshold_ = 1.0e-6;

Foam::scalar Foam::primitiveMesh::aspectThreshold_ = 1000;

Foam::scalar Foam::primitiveMesh::nonOrthThreshold_ = 70; // deg

Foam::scalar Foam::primitiveMesh::skewThreshold_ = 4;

Foam::scalar Foam::primitiveMesh::planarCosAngle_ = 1.0e-6;

24

-Sep

-13

38

Computational Fluid Dynamics

Mesh Quality

• OpenFOAM comes with the utility checkMesh which

checks the validity of the mesh.

• checkMesh will look for/check for:

– Mesh stats and overall number of cells of each type.

– Check topology (boundary conditions definitions).

– Check geometry and mesh quality (bounding box, cell

volumes, skewness, orthogonality, aspect ratio)

• If for any reason checkMesh finds errors, it will give

you a message and it will tell you what check failed.

• It will also write a set with the faulty cells, faces,

points. These sets are saved in the directory

constant/polyMesh/sets/

24

-Sep

-13

39

Page 8: Week 03 - Mesh Quality

9/24/2013

8

Computational Fluid Dynamics

Mesh Quality

• Mesh topology and patch topology errors must

be repaired.

• You will be able to run with mesh quality errors

such as skewness, aspect ratio, minimum face

area, and non-orthogonality. But remember, they

will severely tamper the solution accuracy and

eventually can make the solver blow-up.

• checkMesh does not repair these errors. You will

need to check the geometry for possible errors

and generate a new mesh.

24

-Sep

-13

40

Computational Fluid Dynamics

Mesh Conversion

• It is also possible to export a mesh generated with a third party

software and use it in OpenFOAM. Some of the utilities available

formesh conversion are listed below:

– ansysToFoam: converts an ANSYS input mesh file OpenFOAM

format.

– cfx4ToFoam: converts a CFX 4 mesh to OpenFOAM format.

– fluent3DMeshToFoam: converts a Fluent mesh to OpenFOAM format.

– gambitToFoam: converts a GAMBIT mesh to OpenFOAM format.

– gmshToFoam: reads .msh file as written by Gmsh.

– ideasUnvToFoam: I-Deas unv format mesh conversion.

– plot3dToFoam: plot3d mesh (ascii/formatted format) converter.

– star4ToFoam: converts a STAR-CD (v4) PROSTAR mesh into

OpenFOAM format.

– tetgenToFoam: Converts .ele and .node and .face files, written by

tetgen.

24

-Sep

-13

41

Page 9: Week 03 - Mesh Quality

9/24/2013

9

Computational Fluid Dynamics

Mesh Conversion

• OpenFOAM also comes with many mesh manipulation utilities.

• Some of them are listed below: – checkMesh: checks validity of a mesh.

– refineMesh: utility to refine cells in multiple directions.

– renumberMesh: renumbers the cell list in order to reduce the bandwidth, reading and renumbering all fields from all the time directories

– transformPoints: transforms the mesh points in the polyMesh directory according to the translate, rotate and scale options.

– mirrorMesh: mirrors a mesh around a given plane.

– setSet: manipulate a cell/face/point/ set or zone intera

– refineWallLayer: utility to refine cells next to patches.

24

-Sep

-13

42

Computational Fluid Dynamics

Mesh Conversion

• blockMesh

– For simple geometries, the mesh generation utility blockMesh

(supplied with OpenFOAM), can be used. The blockMesh utility

creates multiblock meshes. The mesh is generated from a dictionary

file named blockMeshDict located in the constant/polyMesh

directory.

• snappyHexMesh

– For complex geometries, the mesh generation utility snappyHexMesh

(supplied with OpenFOAM), can be used. The snappyHexMesh utility

generates 3D meshes containing hexahedra and split-hexahedra

from a triangulated surface geometry in Stereolithography (STL)

format. The mesh is generated from a dictionary file named

snappyHexMeshDict located in the system directory and a

triangulated surface geometry file located in the directory

constant/triSurface.

24

-Sep

-13

43