Vous êtes sur la page 1sur 30

A tool for pre-processing: snappyHexMesh

Roberto Pieri - SCS Italy

16-18 June 2014


Overview

SnappyHexMeshDict
Geometry
CastellatedMesh
Surface Snapping
Layer addition

Mesh quality

Building 2D mesh

Tutorial session
SnappyHexMesh
I Mesh generation utility of OpenFOAM.
I Automatic generation of 3D hex-dominant meshes.
I Preservation of geometry edges.
I Addition of layers for wall resolution.
I Parallel.
How does snappyHexMesh work?
I Background mesh made of hexahedra generated by the utility
blockMesh.
I CastellatedMesh phase:
I Refinement in prescribed regions by the user.
I Detection of the fluid domain.
I Removal of cells outside the domain.
I SnapMesh phase:
I Mesh morphing to follow the provided geometry.
I Possibly, layers addition phase.
Dictionary definition
I Dictionary file in system/snappyHexMeshDict.
I Divided in five sections:
I geometry: input geometry;
I castellatedMeshControls: refinement regions and the fluid domain;
I snapControls: parameters related to morphing phase;
I addLayersControls: settings for the layer addition (number of layers,
grow rate, ...);
I MeshQualityControls: where the user defines the quality required for
the final mesh.
PAY ATTENTION IN REQUIRING QUALITY CONSTRAINTS
Geometry submission

I Geometry must be provided in Stereolithography (.stl) or Nastran


(.nas) format.
I Working with a good quality CAD is mandatory (snappyHexMesh is
not able to modify CAD)
I It has to be provided in the constant/triSurface directory.
I Other geometries (cylinder, box, sphere...) can be easily defined.
Geometry checking
I Before starting meshing it is important to check integrity of your
CAD.
I surfaceCheck name CAD.stl utility can check the geometry
submitted.
I Main issues related to CAD:
I non-closed CAD (snappyHexMesh will mesh inside the surface);
I overlapping triangles.
I With the same utility you can receive informations related to surface
bounding-box.
snappyHexMeshDict
geometry

geometry I Name of the surface.


{
NLR−7301. s t l
{
I Type definition.
type triSurfaceMesh ;
name a i r f o i l ; I Definition of the name of the
patchInfo derived patch.
{

}
type wall ; I Definition of the type of the
}
};
derived patch.
snappyHexMeshDict
refinement
The first step is the refinement of cells in prescribed regions in
castellatedMeshControls sub-dictionary.
snappyHexMeshDict
castellatedMesh (I)

castellatedMeshControls I Maximum number of cells.


{

// R e f i n e m e n t p a r a m e t e r s
I Minimum number of cells for
// ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜
the surface refinement loop to
maxLocalCells 1000000;
stop.
maxGlobalCells 10000000;
I Number of cells between two
minRefinementCells 0;
adjacent refinement regions.
maxLoadUnbalance 0 . 1 0 ;

nCellsBetweenLevels 6;
snappyHexMeshDict
castellatedMesh (II)

// E x p l i c i t f e a t u r e e d g e r e f i n e m e n t
I Refinment in proximity of
// ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ edges.
features
( I Meshing with snappy may
{
f i l e ”NLR−7301. eMesh ” ; generate difficulties in reaching
l e v e l 6;
} good resolution on edges.
);

The generation of the .eMesh file is obtained using the command


surfaceFeatureExtract.
snappyHexMeshDict
castellatedMesh (III)

// S u r f a c e b a s e d r e f i n e m e n t
// ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜

refinementSurfaces
{
airfoil
{
l e v e l (6 6 ) ;
}
}

resolveFeatureAngle 50;

Feature angle refinement


snappyHexMeshDict
castellatedMesh (IV)

// R e g i o n−w i s e r e f i n e m e n t
I The keyword levels specifies per
// ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ ˜ distance to the surface the
refinementRegions
{
wanted refinement level.
airfoil
{
I Other ways for refinement
mode d i s t a n c e ;
levels ((0.5 5)(0.8 4));
region:
}
}
I inside
I outside
snappyHexMeshDict
castellatedMesh (V)
// Mesh s e l e c t i o n
I Definition of a point inside the
// ˜˜ ˜˜˜˜˜˜˜ ˜˜˜˜˜ fluid domain.
locationInMesh (0.1 2 0.0);

Definition of fluid domain


snappyHexMeshDict
castellatedMesh (VI)

Castellated phase Levels in castellated phase


snappyHexMeshDict
castellatedMesh (VII)

Mesh s t a t s
points : 2027850
faces : 5760631
internal faces : 5529545
cells : 1867241
faces per c e l l : 6.04645
boundary patches : 7
point zones : 0
face zones : 0
c e l l zones : 0

O v e r a l l number o f c e l l s o f e a c h t y p e :
hexahedra : 1838095
prisms : 0
wedges : 0
pyramids : 0
t e t wedges : 0
tetrahedra : 0
polyhedra : 29146
snappyHexMeshDict
Surface Snapping (I)

// S e t t i n g s f o r t h e s n a p p i n g .
I Number of patch smoothing
snapControls
{
before projecting on the surface.
nSmoothPatch 3 ; I Scale factor of edge length for
tolerance 4.0; points to be attracted by
nSolveIter 50; surface.
nRelaxIter 5; I Smoothing iterations for mesh
} displacement relaxation.
I Maximum number of snapping
iterations.
snappyHexMeshDict
Surface Snapping (III)

Mesh s t a t s
points : 2019140
faces : 5752055
internal faces : 5529545
cells : 1867241
faces per c e l l : 6.04186
boundary patches : 7
point zones : 0
face zones : 0
c e l l zones : 0

O v e r a l l number o f c e l l s o f e a c h t y p e :
hexahedra : 1829519
prisms : 8576
wedges : 0
pyramids : 0
t e t wedges : 0
tetrahedra : 0
polyhedra : 29146
snappyHexMeshDict
Surface Snapping (II)

Leading edge snap Trailing edge snap


snappyHexMeshDict
Layer Addition (I)

// S e t t i n g s f o r t h e l a y e r a d d i t i o n .
I Number of layers on selected
addLayersControls
{
patches.
r e l a t i v e S i z e s true ; I Expansion ratio of layers.
layers
{
I Minimum layer thickness below
airfoil
{
which leyers are not added.
nSurfaceLayers 10;
}
}

expansionRatio 1.1;

finalLayerThickness 0.5;

minThickness 0 . 0 5 ;
snappyHexMeshDict
Layer Addition (II)

L2 L3
expansionRatio = = = ...
L1 L2

L4
finalLayerThickness =
∆s
snappyHexMeshDict
Layer Addition (III)

Layers on leading edge Layers on trailing edge


snappyHexMeshDict
Layer Addition (IV)

Mesh s t a t s
points : 2246380
faces : 6426783
internal faces : 6197281
cells : 2090985
faces per c e l l : 6.03738
boundary patches : 7
point zones : 0
face zones : 0
c e l l zones : 0

O v e r a l l number o f c e l l s o f e a c h t y p e :
hexahedra : 2053263
prisms : 8576
wedges : 0
pyramids : 0
t e t wedges : 0
tetrahedra : 0
polyhedra : 29146
Final mesh quality
Orthogonality in OpenFOAM

Non orthogonal faces


Final mesh quality
Skewness in OpenFOAM

Skew faces
Final mesh quality
Mesh checking in OpenFOAM (I)

Mesh s t a t s
points : 2246380
I checkMesh is an OpenFOAM
faces :
internal faces :
6426783
6197281
utility to check the mesh
cells :
faces per c e l l :
2090985
6.03738
quality.
boundary patches : 7
point zones : 0 I Number of cells.
face zones : 0
c e l l zones : 0 I Number of patches.
O v e r a l l number o f c e l l s o f e a c h t y p e :
hexahedra : 2053263 I Cells divided by type.
prisms : 8576
wedges : 0
pyramids : 0
t e t wedges : 0
tetrahedra : 0
polyhedra : 29146
Final mesh quality
Mesh checking in OpenFOAM (II)

Checking geometry . . .
O v e r a l l domain b o u n d i n g box (−6.8 −9.6 −0.075) ( 2 0 . 8 9 . 6 0 . 0 7 5 )
Mesh ( non−empty , non−wedge ) d i r e c t i o n s ( 1 1 0 )
Mesh ( non−empty ) d i r e c t i o n s ( 1 1 0 )
∗∗∗Number o f e d g e s no t a l i g n e d w i t h o r p e r p e n d i c u l a r t o non−empty d i r e c t i o n s : 1021342
<<W r i t i n g 1419579 p o i n t s on non−a l i g n e d e d g e s t o s e t n o n A l i g n e d E d g e s
Boundary o p e n n e s s ( 3 . 1 2 2 5 e−19 −2.28772 e−18 −3.18147 e −14) OK.
Max c e l l o p e n n e s s = 3 . 1 5 7 3 7 e−16 OK.
Max a s p e c t r a t i o = 5 . 5 8 5 4 7 OK.
Minimum f a c e a r e a = 6 . 2 0 6 7 9 e −07. Maximum f a c e a r e a = 0 . 0 2 2 8 2 5 . Face a r e a m a g n i t u d e s OK.
Min volume = 1 . 4 6 4 1 4 e −09. Max volume = 0 . 0 0 3 4 2 3 7 6 . T o t a l volume = 7 9 . 4 6 9 8 . C e l l v o l u m e s OK.
Mesh non−o r t h o g o n a l i t y Max : 6 4 . 3 5 3 7 a v e r a g e : 3 . 9 0 3 8 3
Non−o r t h o g o n a l i t y c h e c k OK.
Face p y r a m i d s OK.
Max s k e w n e s s = 2 . 3 8 1 8 6 OK.
C o u p l e d p o i n t l o c a t i o n match ( a v e r a g e 0 ) OK.

F a i l e d 1 mesh c h e c k s .

End
How can I build 2D meshes?

I OpenFOAM always works with 3D meshes (even in case you want to


simulate a 2D phenomenon).
I In case you want to simulate a 2D case you have to build a mesh
with only one cell in the uniform direction.
I Using extrudeMesh tool is possible to obtain 2D meshes (extrusion
of 1 cell).
I It is necessary to define an extrudeMeshDict dictionary to tell
OpenFOAM which patch has to be extruded.
extrudeMeshDict
constructFrom patch ;
s o u r c e C a s e ” . . / t u t o r i a l N L R −7301 s n a p p y ” ;
sourcePatches ( front ) ;

// I f c o n s t r u c t from p a t c h : p a t c h t o u s e f o r b a c k ( can be same a s s o u r c e P a t c h )


exposedPatchName b a c k ;

// F l i p s u r f a c e n o r m a l s b e f o r e u s a g e . V a l i d o n l y f o r e x t r u d e from s u r f a c e o r
// p a t c h .
flipNormals false ;

//− L i n e a r e x t r u s i o n i n p o i n t−n o r m a l d i r e c t i o n
extrudeModel linearNormal ;

nLayers 1;

expansionRatio 1.0;

linearNormalCoeffs
{
thickness 0.05;
}

// Do f r o n t and b a c k n e e d t o be merged ? U s u a l l y o n l y makes s e n s e f o r 360


// d e g r e e wedges .
mergeFaces f a l s e ; // t r u e ;

// Merge s m a l l e d g e s . F r a c t i o n o f b o u n d i n g box .
mergeTol 0 ;
snappyHexMesh tutorial
I Copy the CAD into the right directory.
I Extract edges from CAD using the appropriate tool.
I Open snappyHexMesh dictionary to set right refinement and layers
options.
I Build background mesh.
I Run snappyHexMesh (use the flag -overwrite).
I Check the mesh quality
I Edit the extrudeMeshDict to extrude front patch.
I Extrude one patch from the previous mesh to build a 2D mesh.
I Check the mesh quality of the last mesh.
I Run the command renumberMesh -overwrite, discussion n this tool...

Vous aimerez peut-être aussi