SnappyHexMesh is a convenient tool to generate high-quality meshes for complex geometries. Before using snappyHexMesh, a background mesh should be ready, which could be generated using blockMesh
or external meshers like ICEM CFD, SALOME and Gmsh. The background mesh must consist purely of hexes, with cell aspect ratio being approximately 1, and at least one edge intersecting the STL surface.
Today I tried using the opensource software SALOME to generate the mesh, which I regard as more convenient than using ICEM.
Import The STL of the background
- Enter the
Geometry
module in SALOME, and import the STL file by choosingFile
>Import
>STL
from the drop-down menu. - Press the
Fit All
button to see the geometry and theInteraction Style Switch
button to rotate.
Create a Box and Assign Patches
- Press the
Create a Box
button to open theBox Construction
window. - In the window, click the box construction method on the left, give it a name, and then choose two points on the geometry to define the box. Apply and close.
- Find the box we just created in the
Object Browser
, right click it, click theCreate Group
item and see theCreate Group
window. - Choose
face
as the shape type, give the patch a name, select the face to assign and click theAdd
button. - Right-click the patches in the
Object Browser
and clickshow only
to check whether they are correctly assigned.
Generate the Mesh
- Enter the
Mesh
module and click thecreate mesh
bottom. - Give the mesh a name, choose the box we just created in the
Object Browser
and then assign3D: Automatic Hexahedralization
the set of hypothesis, where gFortran is needed in the system. - In the
1D
tag, set the hypothesis aslocal length
and input a required step length like 0.2. Apply and Close. - Right-click the mesh in the
Object Browser
and clickCompute
. - Right-click the mesh in the
Object Browser
, clickCreate Groups from Geometry
and choose all the patches in the box we created. Apply and Close.
Export the Mesh and convert to blockMesh files
- Right-click the mesh in the
Object Browser
and thenExport
>UNV
file to the OpenFOAM working directory. - In the Terminal, use command
ideasUnvToFoam filename.unv
to convert it into blockMesh files.