• No results found

Open Foam-Meshing

N/A
N/A
Protected

Academic year: 2021

Share "Open Foam-Meshing"

Copied!
122
0
0

Loading.... (view fulltext now)

Full text

(1)

Disclaimer

“This offering is not approved or

endorsed by OpenCFD Limited, the

producer of the OpenFOAM software

and owner of the OPENFOAM® and

OpenCFD® trade marks.”

(2)

Introductory OpenFOAM® Course

University of Genoa, DICCA

Dipartimento di Ingegneria Civile, Chimica e Ambientale

(3)

Your Lecturer

Joel GUERRERO

[email protected]

 

 

[email protected]

 

Matteo BARGIACCHI

[email protected]

 

 

[email protected]

 

(4)

This lecture is about meshing and mesh quality

assessment for CFD computations

Generating high quality meshes is a critical step for CFD computations.

Depending on the quality of the mesh you can get very different results,

which can made post-processing and interpretation of the solution a

difficult task, due to contrasting or misleading results because of meshing

issues. This holds independently of the solver used.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(5)

This lecture is about meshing and mesh quality

assessment for CFD computations

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Meshing and mesh quality

I do not know how much I will stress this, but try to always

use a good quality mesh.

Have always in mind, garbage in - garbage out.

As I am a really positive guy, I rather say,

(6)

Today’s lecture

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

1.  Meshing preliminaries

2.  Mesh quality assessment

3.  Mesh conversion and manipulation utilities

4.  Mesh generation using blockMesh and

snappyHexMesh

5.  Mesh generation using open source tools

6.  Hands-on session

(7)

Today’s lecture

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

1.  Meshing preliminaries

2.

Mesh quality assessment

3.

Mesh conversion and manipulation utilities

4.

Mesh generation using blockMesh and

snappyHexMesh

5.

Mesh generation using open source tools

(8)

Meshing preliminaries

•  Mesh generation consist in dividing the physical domain into a finite

number of discrete regions, called control volumes or cells in which the

solution is sought (domain discretization).

•  Meshes used for the FVM method can consist of tetrahedras, pyramids,

prisms, hexahedras or any kind of polyhedral element (or a mix of all of

them).

•  The meshes can be unstructured or structured. In our discussion, when

we talk about unstructured or structured meshes we refer specifically to

the method used to generate them.

(9)

Meshing preliminaries

•  The data structure of the meshes used in the FVM is represented by the

points and faces that make up each control volume.

•  The connectivity information of each cell (how faces and cells are

connected) and cell/face neighbor information is also needed for FVM

unstructured meshes.

•  Meshes used for the FDM method are made of hexahedra and they are

known as single and/or multi-block structured meshes.

•  The connectivity information of the meshes used in the FDM is expressed

as a two or three dimensional array, this is highly memory efficient as we

do not need to store all the connectivity information of the faces and cells.

(10)

Meshing preliminaries

•  In the next slides, I will show a few meshes generated by using different

meshing methods.

•  Also, I will present a table with a comparison of four commonly used

mesh generation methods.

•  The figures of merit used to compare the meshes are related to the

method used to generate the mesh and not to the flow solver.

•  All the methods that we are going to talk about, can generate a valid

mesh to be used with the FVM. Remember, when we pass the mesh

information to an unstructured FVM solver, we pass the data structure

and connectivity information (points, faces and cells information).

(11)

Meshing preliminaries

(12)

Meshing preliminaries

(13)

Meshing preliminaries

(14)

Meshing preliminaries

(15)

Meshing preliminaries

(16)

Meshing preliminaries

STRUCTURED

UNSTRUCTURED

CARTESIAN

OVERLAPPING

Geometric Flexibility/

Adaptation

Grid Adaptation/

Local Refinement

Viscous Computation

Moving/Deforming

Meshes Quality

Interpolation/

Conservation

Grid generation

easiness

Memory

Requirements

CPU Requirements

(17)

Meshing preliminaries

(18)

Meshing preliminaries

A structured mesh requires as input

the blocking definition (blue lines in

the figure).

For complicated geometries, it can

be extremely difficult arrive to the

right blocking, it requires a lot user

experience.

After defining the blocking, the mesh

generation time is quite fast, in the

order of seconds or minutes.

Unstructured meshes, only requires

as input the element size on the lines

and surfaces that define the

geometry.

After defining the element size, the

meshing process can be quite time

consuming and memory expensive.

Meshing time is in the order of

minutes or hours, even days.

(19)

Meshing preliminaries

Unstructured Hybrid Mesh

(tetras, prisms and hexs)

Cell count:

approx. 5 000 000

Structured Mesh

(hexahedrals)

Cell count:

approx. 5 000 000

(20)

Meshing preliminaries

Unstructured Hybrid Mesh

(tetras, prisms and hexs)

Cell count:

approx. 5 000 000

Structured Mesh

(hexahedrals)

Cell count:

approx. 5 000 000

(21)

Meshing preliminaries

Unstructured Hybrid Mesh

(tetras, prisms and hexs)

Cell count:

approx. 5 000 000

Structured Mesh

(hexahedrals)

Cell count:

approx. 5 000 000

(22)

Meshing preliminaries

Unstructured Hybrid Mesh

(tetras, prisms and hexs)

Cell count:

approx. 5 000 000

Structured Mesh

(hexahedrals)

Cell count:

approx. 5 000 000

(23)

Meshing preliminaries

Unstructured Hybrid Mesh

(tetras, prisms and hexs)

Cell count:

approx. 5 000 000

Structured Mesh

(hexahedrals)

Cell count:

approx. 5 000 000

(24)

Meshing preliminaries

Unstructured Hybrid Mesh

(tetras, prisms and hexs)

Cell count:

approx. 5 000 000

Structured Mesh

(hexahedrals)

Cell count:

approx. 5 000 000

(25)

Meshing preliminaries

Unstructured

Vs.

Structured

meshes,

Who wins?

• 

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.

• 

Wait, but what is a good mesh?. Mesh quality and

smoothness will be studied in the next slides.

(26)

Today’s lecture

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

1.

Meshing preliminaries

2.  Mesh quality assessment

3.

Mesh conversion and manipulation utilities

4.

Mesh generation using blockMesh and

snappyHexMesh

5.

Mesh generation using open source tools

(27)

What is a good mesh?

• 

A standard rule of thumb is that the elements shape and distribution should

be pleasing to the eye.

• 

There is no written theory when it comes to mesh generation. Basically, 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.

• 

Hereafter, I will present you the most common mesh quality metrics:

• 

Orthogonality.

• 

Skewness.

• 

Aspect Ratio.

• 

Smoothness.

(28)

Mesh quality metrics. Mesh orthogonality

•  Mesh orthogonality 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

.

•  Affects the gradient of the face center

f

.

•  It adds diffusion to the solution.

(29)

Mesh quality metrics. 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 is the point where the vector d intersects the face

f

.

•  Affects the interpolation of the cell centered quantities to the face center

f

.

•  It adds diffusion to the solution.

Mesh quality assessment

(30)

Mesh quality metrics. Mesh aspect ratio AR

•  Mesh aspect ratio AR is the ratio between the longest side and the

shortest side .

•  Large AR are fine if gradients in the long direction are small.

•  High AR smear gradients.

Mesh quality assessment

x

(31)

Mesh quality metrics. 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%:

Mesh quality assessment

Smooth transition

Steep transition

y

2

(32)

Mesh quality assessment

f

=

P

+

⇥y

y +

O( y

2

)

f

=

P

+

⇥y

y +

O( y

2

)

P

f

P

f

Element type close to the walls -

Cell/Flow alignment

•  Hexahedrals, prisms, and quadrilaterals can be stretched easily to resolve

boundary layers without losing quality.

•  Triangular and tetrahedral meshes have inherently larger truncation error.

•  Less truncation error when faces aligned with flow direction and gradients.

(33)

Striving for 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 low, 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 and increase the computing time.

(34)

Striving for quality

•  Use hexahedral meshes whenever is possible, specially if high accuracy in

predicting forces is your goal (drag prediction) or for turbo machinery

applications.

•  For complex flows without dominant flow direction, quad and hex meshes

loose their advantages.

•  Keep orthogonality, skewness, and aspect ratio to a minimum.

•  Change in cell size should be smooth.

Remember, a poor quality mesh will generate

inaccurate solutions and/or will slow down

solution convergence.

(35)

Mesh quality metrics in OpenFOAM®

•  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;

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(36)

Checking mesh quality in OpenFOAM®

•  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, and so on)

•  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/

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(37)

Checking mesh quality in OpenFOAM®

•  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 made the solver

blow-up.

•  Unfortunately,

checkMesh

does not repair these errors. You will need to

check the geometry for possible errors and generate a new mesh.

•  To visualize the failed sets you can use the utility

foamToVTK

. This utility

converts the failed sets to VTK format.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(38)

Checking mesh quality in OpenFOAM®

•  To visualize the failed faces/cells/points in

paraFoam

you will need to

proceed as follows:

• 

foamToVTK

-set_type name_of_sets

where

set_type

is the type of sets ( faceSet, cellSet, pointSet,

surfaceFields) and

name_of_sets

is the name of the set in the directory

constant/polyMesh/sets (

highAspectRatioCells

,

nonOrthoFaces

,

wrongOrientedFaces

,

skewFaces

,

unusedPoints

)

•  At the end,

foamToVTK

will create a directory named VTK, where you will find the

failed faces/cells/points in VTK format. At this point you can use paraFoam to

visualize the failed sets.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(39)

Checking mesh quality in OpenFOAM®

We will now check the mesh quality of a sample case. From now on follow me.

• 

Go to the directory $ptofc/mesh_conversion_manipulation/M2_wingbody. In the

terminal type:

cd

$ptofc/mesh_conversion_manipulation/M2_wingbody

fluent3DMeshToFoam ./mesh/ascii.msh

checkMesh

At this point check the output of the utility

checkMesh

. To write the failed sets to VTK format:

foamToVTK

-faceSet nonOrthoFaces

mv

VTK VTK1

foamToVTK

-pointSet unusedPoints

Now you can visualize the faulty sets by using paraFoam.

Remember, each time you use the utility

foamToVTK

it will overwrite the directory VTK

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(40)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Non orthogonal faces (green) and unused points (yellow)

By following the instructions, you should get something like this

(41)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

By following the instructions, you should get something like this

Mesh quality assessment

(42)

Today’s lecture

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

1.

Meshing preliminaries

2.

Mesh quality assessment

3.  Mesh conversion and manipulation utilities

4.

Mesh generation using blockMesh and

snappyHexMesh

5.

Mesh generation using open source tools

(43)

Mesh conversion and manipulation utilities

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

use it in OpenFOAM®. Some of the utilities available for mesh 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.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(44)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh conversion and manipulation utilities

•  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 interactively.

refineWallLayer

: utility to refine cells next to patches.

(45)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh conversion and manipulation utilities

•  In OpenFOAM® it is also possible to manipulate the geometries in STL

format. Some of the utilities available are listed below:

surfaceTransformPoints

: transform (scale/rotate) a surface. Like

transformPoints

but for surfaces.

surfaceCheck

: checks geometric and topological quality of a surface.

surfaceClean

: removes baffles and collapses small edges, by removing

triangles. Converts sliver triangles into split edges.

surfaceFeatureExtract

: extracts and writes surface edge features to file.

surfaceMeshInfo

: miscellaneous information about surface.

surfaceMeshTriangulate

: extracts triSurface from a polyMesh.

(46)

Geometry and mesh manipulation in OpenFOAM®

We will now manipulate a STL geometry and a mesh. From now on follow me.

• 

Go to the directory $ptofc/mesh_conversion_manipulation/

M6_ahmed_body_transform

In the terminal type:

cd

$ptofc/mesh_conversion_manipulation/M6_ahmed_body_transform

blockMesh

surfaceCheck

./constant/triSurface/

ahmed_body.stl

surfaceTransformPoints

-rollPitchYaw '(0 0 15)' ./constant/

triSurface/ahmed_body.stl ./constant/triSurface/

rotated.stl

surfaceTransformPoints

-translate '(0 0.12 0)' ./constant/

triSurface/rotated.stl ./constant/triSurface/

translated.stl

surfaceTransformPoints

-scale '(0.9 1.1 1.3)' ./constant/

triSurface/translated.stl ./constant/triSurface/

scaled.stl

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(47)

Geometry and mesh manipulation in OpenFOAM®

We will now manipulate a STL geometry and a mesh. From now on follow me.

• 

Go to the directory $ptofc/mesh_conversion_manipulation/

M6_ahmed_body_transform

In the terminal type:

cd

$ptofc/mesh_conversion_manipulation/M6_ahmed_body_transform

surfaceSmooth

./constant/triSurface/scaled.stl 0.3 100 ./constant/

triSurface/

smooth.stl

surfaceFeatureExtract

snappyHexMesh

-overwrite

transformPoints

-rollPitchYaw '(0 10 -15)'

transformPoints

-scale '(2 1 1)’

checkMesh

paraFoam

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(48)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

By following the instructions, you should get something like this

STL surface manipulation

(49)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

By following the instructions, you should get something like this

Mesh conversion and manipulation utilities

(50)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

By following the instructions, you should get something like this

Mesh conversion and manipulation utilities

(51)

Today’s lecture

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

1.

Meshing preliminaries

2.

Mesh quality assessment

3.

Mesh conversion and manipulation utilities

4.  Mesh generation using blockMesh and

snappyHexMesh

5.

Mesh generation using open source tools

(52)

Mesh generation using blockMesh and snappyHexMesh

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.

(53)

Mesh generation using blockMesh and snappyHexMesh

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

blockMesh block topology

(54)

Mesh 1. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M1_cyl

blockMesh

snappyHexMesh

(And by the way, take a look at the

snappyHexMeshDict

dictionary)

checkMesh

paraFoam

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(55)

Mesh 1. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

(56)

Mesh 1. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

So… What did we do?

or

What did

snappyHexMesh

do?

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(57)

So… What did we do?

SnappyHexMesh mesh generation process

Mesh generation with the snappyHexMesh utility

•  The process of generating a mesh using

snappyHexMesh

will be described using

this figure.

•  The objective is to mesh a rectangular shaped region (shaded grey in the figure)

surrounding an object described by and STL surface (external aerodynamics)

•  You can also generate the mesh for an internal aerodynamics simulation.

•  Note that the schematic is 2D to make it easier to understand, even though

snappyHexMesh

is a 3D meshing tool.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(58)

Creating the background hexahedral mesh

Before

snappyHexMesh

is executed the user must create a background mesh of

hexahedral cells that fills the entire region as shown in the figure. This can be done by

using

blockMesh

.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(59)

Cell splitting at feature edges

Cell splitting is performed according to the specification supplied by the user in the

snappyHexMeshDict

dictionary. The splitting process begins with cells being selected

according to specified edge features as illustrated in the figure.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(60)

Cell splitting at surfaces

Following feature edges refinement, cells are selected for splitting in the locality of

specified surfaces as illustrated in the figure. The surface refinement (splitting) is

performed according to the specification supplied by the user in the

snappyHexMeshDict

dictionary.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(61)

Cell removal

Once the feature edges and surface splitting is complete, a process of cell removal

begins. The region in which cells are retained are simply identified by a location vector

within the region, this information is supplied by the user in the

snappyHexMeshDict

dictionary.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(62)

Cell splitting in specified regions

Those cells that lie within one or more specified volume regions can be further split by a

region (in the figure, the rectangular dark shaded region). This information is supplied by

the user in the

snappyHexMeshDict

dictionary.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(63)

Snapping to surfaces

After deleting the cells in the region specified and refining the volume mesh, the points

are snapped on the surface to create a conforming mesh.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(64)

Mesh layers

The mesh output from the snapping stage may be suitable for simulation, although it can

produce some irregular cells along boundary surfaces. There is an optional stage of the

meshing process which introduces boundary layer meshing in selected parts of the

mesh. This information is supplied by the user in the

snappyHexMeshDict

dictionary.

So… What did we do?

SnappyHexMesh mesh generation process

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(65)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M2_cyl_er

blockMesh

surfaceFeatureExtract

(This utility uses

surfaceFeatureExtractDict

dictionary which is located in the system directory)

paraview

(Take a look at the

.obj

files created by

surfaceFeatureExtract

, we use

paraview

instead of

paraFoam

because by default

paraFoam

reads the mesh generated by

blockMesh

. The

.obj

files are located in the directory

constant/extendedFeatureEdgeMesh)

snappyHexMesh

checkMesh

paraFoam

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(66)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

•  The utility

surfaceFeatureExtract

will create a file named

*.eMesh

(e.g.

banana.eMesh

), this file will be saved in the directory constant/triSurface

This file contains the information of the feature edges. By the way, try to read the file,

it is easy to understand.

•  Next, you should tell to

snappyHexMesh

that you want to use refinement in the

feature edges, and this is done by pointing to the

*.eMesh

file

in the

snappyHexMeshDict

dictionary

// Explicit feature edge refinement

features

(

{

file “banana.eMesh”;

level 4;

}

);

snappyHexMesh

knows that the

*.eMesh

file is in constant/triSurface

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(67)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

•  At this point, you should have in your case directory two time directories 1 and 2 (if

you chose a time step of 1 in your

controlDict

).

•  In the time directory 1, you should have the mesh with the castellated mesh.

•  In the time directory 2 you should have the mesh with the conforming mesh (the

mesh after snapping).

•  Additionally, if you chose to generate the boundary layer mesh, you should have a

time directory 3, where you should have the mesh with the inflation layer.

•  We are going to deal with boundary layer meshing later on.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(68)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

•  Now you must copy the mesh from the time directory 2 (or 3) to your constant

directory. In the terminal type:

mv

constant/polyMesh constant/polyMesh.org

(To rename the background mesh folder, this is optional, but I highly recommended it)

cp

-r 2/polyMesh constant/polyMesh

(To copy the new mesh to your constant/polyMesh directory, this is compulsory)

rm

-r 1

(If you do not want to keep this time folder)

rm

-r 2

(If you do not want to keep this time folder)

•  Now you are ready to run.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(69)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

•  Alternatively,

snappyHexMesh

can automatically overwrite the original background

mesh contained in constant/polyMesh. In the terminal type:

snappyHexMesh

-overwrite

•  If you use this option, you will not be able to visualize the intermediate steps.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(70)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

(71)

Mesh 2. 3D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh with feature edge

refinement.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

Feature edge refinement

No feature edge refinement

(72)

Mesh 3. Mixing elbow (internal mesh).

Initial mesh

.

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M3_mixing_elbow1

blockMesh

surfaceFeatureExtract

(It will use an

includedAngle

of 130 degrees as defined in the dictionary)

paraview

(Take a look at the

.obj

files created by

surfaceFeatureExtract

, we use

paraview

instead of

paraFoam

because by default

paraFoam

reads the mesh generated by

blockMesh

. The

.obj

files are located in the directory

constant/extendedFeatureEdgeMesh)

snappyHexMesh

checkMesh

paraFoam

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(73)

Mesh 3. Mixing elbow (internal mesh).

Initial mesh

.

Let us generate the mesh by using SnappyHexMesh.

•  Alternatively,

snappyHexMesh

can automatically overwrite the original background

mesh contained in constant/polyMesh. In the terminal type:

snappyHexMesh

-overwrite

•  If you use this option, you will not be able to visualize the intermediate steps.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(74)

Mesh 3. Mixing elbow (internal mesh).

Initial mesh

.

Let us generate the mesh by using SnappyHexMesh.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

An

includedAngle

of 130 degrees does not resolve well the intersection between the

two pipes.  

(75)

Mesh 4. Mixing elbow (internal mesh).

Improved mesh

.

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M3_mixing_elbow2

blockMesh

surfaceFeatureExtract

(It will use an

includedAngle

of 150 degrees as defined in the dictionary)

paraview

(Take a look at the

.obj

files created by

surfaceFeatureExtract

, we use

paraview

instead of

paraFoam

because by default

paraFoam

reads the mesh generated by

blockMesh

. The

.obj

files are located in the directory

constant/extendedFeatureEdgeMesh)

snappyHexMesh

checkMesh

paraFoam

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(76)

Mesh 4. Mixing elbow (internal mesh).

Improved mesh

.

Let us generate the mesh by using SnappyHexMesh.

•  Alternatively,

snappyHexMesh

can automatically overwrite the original background

mesh contained in constant/polyMesh. In the terminal type:

snappyHexMesh

-overwrite

•  If you use this option, you will not be able to visualize the intermediate steps.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(77)

Mesh 4. Mixing elbow (internal mesh).

Improved mesh

.

Let us generate the mesh by using SnappyHexMesh.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

By increasing the

includedAngle

to 150 degrees we are able to resolve well the

(78)

Mesh 5. Sphere (external mesh).

Let us generate first the geometry using blender (or whatever you want to

use) and then the mesh by using SnappyHexMesh.

From now on, follow me.

For this tutorial you will first need to generate the geometry using blender or whatever

you want to use, I will use blender. In the terminal type:

cd

$ptofc/sHM_1/M4_sphere_sHM

(The blender file and STL file are in the directory geometry)

blender

(For geometry modeling.

Do not forget to export the geometry in ascii STL format

)

blockMesh

snappyHexMesh

checkMesh

paraFoam

cp

-r 3/polyMesh constant/polyMesh

(To copy the new mesh to your constant/polyMesh directory, this is compulsory

rm

-r 1,

rm

-r 2,

rm

-r 3

(If you do not want to keep these time folders)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(79)

Mesh 5. Sphere (external mesh).

Let us generate first the geometry using blender (or whatever you want to

use) and then the mesh by using SnappyHexMesh.

•  Alternatively,

snappyHexMesh

can automatically overwrite the original background

mesh contained in constant/polyMesh. In the terminal type:

snappyHexMesh

-overwrite

•  If you use this option, you will not be able to visualize the intermediate steps.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(80)

Mesh 5. Sphere (external mesh).

Let us generate first the geometry using blender (or whatever you want to

use) and then the mesh by using SnappyHexMesh.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

Mesh with no inflation layer.

(81)

Mesh 5. Sphere (external mesh).

Let us generate first the geometry using blender (or whatever you want to

use) and then the mesh by using SnappyHexMesh.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

Mesh with inflation layer.

(82)

Mesh 5. Sphere (external mesh).

Let us generate first the geometry using blender (or whatever you want to

use) and then the mesh by using SnappyHexMesh.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

Mesh generation using blockMesh and snappyHexMesh

(83)

Mesh 5. Sphere (external mesh).

Inflation layers with different control parameters

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(84)

Mesh 6. 2D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M5_2d_cylinder

blockMesh

snappyHexMesh

checkMesh

extrudeMesh

(Take a look at the dictionary

extrudeMeshDict

, this dictionary tells OpenFOAM® to create the 2D mesh)

checkMesh

paraFoam

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(85)

Mesh 6. 2D Cylinder (external mesh).

Let us generate the mesh by using SnappyHexMesh.

•  Alternatively,

snappyHexMesh

can automatically overwrite the original background

mesh contained in constant/polyMesh. In the terminal type:

snappyHexMesh

-overwrite

•  If you use this option, you will not be able to visualize the intermediate steps.

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(86)

Mesh 6. 2D Cylinder (external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(87)

Mesh 6. 2D Cylinder (external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(88)

Mesh 6. 2D Cylinder (external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(89)

Mesh 7. 3D Cylinder with periodic boundary conditions

(external mesh).

Let us generate the mesh by using SnappyHexMesh.

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M8_periodic_cylinder

blockMesh

snappyHexMesh

checkMesh

-latestTime

createPatch

(Take a look at the dictionary

createPatchDict

, this dictionary will create two patches named periodic1 and

periodic2

, which contain the information regarding to the periodic bcs)

checkMesh

-latestTime

paraFoam

Note: the

createPatch

utility will create a new mesh in the time directory 3 (if you chose a deltaT equal to 1 in

controlDict

).

This mesh has the periodic patches, now you can copy it to the folder constant/polyMesh

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(90)

Mesh 7. 3D Cylinder with periodic boundary conditions

(external mesh).

•  Alternatively,

snappyHexMesh

can automatically overwrite the original background

mesh contained in constant/polyMesh. In the terminal type:

snappyHexMesh

-overwrite

•  If you use this option, you will not be able to visualize the intermediate steps.

•  In the same way,

createPatch

can overwrite the final mesh. In the terminal type:

createPatch

-overwrite

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(91)

Mesh 7. 3D Cylinder with periodic boundary conditions

(external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(92)

Mesh 7. 3D Cylinder with periodic boundary conditions

(external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(93)

Mesh 7. 3D Cylinder with periodic boundary conditions

(external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(94)

Mesh 7. 3D Cylinder with periodic boundary conditions

(external mesh).

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(95)

Mesh 8. Meshing in parallel using snappyHexMesh.

BWB body (external mesh)

From now on, follow me.

In the terminal window type:

cd

$ptofc/sHM_1/M9_bwb_parallel

cp

constant/triSurface/N2A_Hybrid.stl constant/triSurface/

surfacemesh.stl

(The geometry was generated using

openvsp

)

surfaceTransformPoints –scale ‘(0.3048 0.3048 0.048)’

constant/triSurface/N2A_Hybrid.stl constant/triSurface/

surfacemesh.stl

(The geometry was generated using

openvsp

)

surfaceFeatureExtract

blockMesh

decomposePar

(Take a look at the dictionary

decomposeParDict

, here you need to specify the decomposition method and the number

of partitions. Later on we are going to deal with running in parallel)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(96)

Mesh 8. Meshing in parallel using snappyHexMesh.

BWB body (external mesh)

From now on, follow me.

In the terminal window type:

•  mpirun –np 8

snappyHexMesh

–parallel –overwrite

Notice the syntax used to run

snappyHexMesh

in parallel:

mpirun -np 8

snappyHexMesh

–parallel –overwrite

where mpirun is a shell script to use the mpi library (you need to install mpi), -np

is the number of processors you want to use, -parallel is a flag that you shall

always use if you want to run in parallel, and –overwrite

is an option specific to

snappyHexMesh

.

paraFoam

–builtin

(To visualize the decomposed mesh)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(97)

Mesh 8. Meshing in parallel using snappyHexMesh.

BWB body (external mesh)

From now on, follow me.

In the terminal window type:

•  mpirun –np 8

checkMesh

–parallel

(To run

checkMesh

in parallel)

reconstructParMesh

–mergeTol 1e-06 –constant

(Reconstruct the mesh using geometry information only)

At this point you are ready to run the simulation, but first you will need to transfer the

boundary and initial conditions to the decomposed mesh, to do this

decomposePar

-fields

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(98)

Mesh 8. Meshing in parallel using snappyHexMesh.

BWB body (external mesh)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

(99)

Mesh 8. Meshing in parallel using snappyHexMesh.

BWB body (external mesh)

“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”

References

Related documents