2. Mesh Generation
PICLas utilizes computational meshes from the high order preprocessor HOPR in the HDF5 format. It is available under GPLv3 at https://github.com/hopr-framework/hopr and is included as part of the PICLas installation. To compile HOPR together with PICLas, you can set the following CMake variable in the CMake GUI:
LIBS_BUILD_HOPR ON
or add the following variable to the console command:
cmake -DPICLAS_TIMEDISCMETHOD=DSMC -DLIBS_BUILD_HOPR=ON ..
The source code will be downloaded and built automatically, afterwards the executable hopr
will be placed in the build/bin/
folder next to the other executables.
If you would like to install HOPR directly from the repository by yourself (e.g. if you would like to join the development),
please refer to the HOPR documentation.
The design philosophy is that all tasks related to mesh organization, different input formats and the construction of high order geometrical mappings are separated from the parallel simulation code. These tasks are implemented most efficiently in a serial environment. The employed mesh format is designed to make the parallel read-in process as simple and fast as possible. For details concerning the mesh format please refer to the HOPR HDF5 Curved Mesh Format Documentation.
The basic command for either mesh generation or conversion of an external mesh is
hopr hopr.ini
Note that the path to the HOPR executable, which depends on whether HOPR was installed together with PICLas or separately, is omitted in the command. For the former, the path set in Section Directory paths for PICLas applies for the HOPR executable as well.
2.1. Mesh generation with HOPR
Using HOPR, simple, structured meshes can be directly created using an in-built mesh generator. A number of strategies to create curved boundaries are also included in HOPR.
2.2. Mesh conversion with HOPR
More complex geometries can be treated by importing meshes generated by external mesh generators in CGNS or GMSH format (Example parameter file). Detailed instructions for some mesh generators that we have experience with (Gmsh, Coreform Cubit, OMNIS/HEXPRESS, GridPro, CENTAUR, MeshGems within SALOME) are given below.
2.2.1. Mesh generation with Gmsh
Gmsh is an open-source mesh generator with a built-in CAD engine. As of Gmsh 4.11.0 (October 2022), meshes can be exported in the .msh
format. For the mesh conversion with HOPR, it is required to enable the option Save all elements
and chose the ASCII code for the file export. The mesh file can be converted with HOPR, using the corresponding mode:
Mode = 5
Tetrahedral or mixed meshes are created by default. Hexahedral meshes can be generated directly in gmsh by using the subdivision algorithm or by using the following option in HOPR for a tetrahedral mesh:
SplitToHex = TRUE
Boundary conditions have to be defined as physical groups. A tutorial for the mesh generation with gmsh can be found in the tutorial Hypersonic Flow around the 70° Cone (DSMC) - 3D Mesh with Gmsh, which requires hopr version v.1.1.0 or newer.
2.2.2. Mesh generation with Coreform Cubit
As of Coreform Cubit 2021.2 (November 2021), the CGNS export is not implemented for unstructured meshes. The Gambit file format can be utilized instead. Boundary conditions have to be defined as side sets first with the names as they will be used in the simulation. After the side set definitions, additional CFD BCs have to be mapped to the side sets (type is irrelevant, no name required: System-assigned ID
). The exported Gambit file (*.neu
) can be converted with HOPR, using the corresponding mode:
Mode = 2
2.2.3. Mesh generation with OMNIS/HEXPRESS
As of OMNIS Version 5.2 (November 2021), the CGNS export is not suitable for boundaries with more than one surface (even if they have been grouped together correctly in OMNIS). Instead, the mesh should be exported in the .sph
format. The following script can be utilized to merge the surfaces
####################################################
# Script to merge surfaces and CGNS export
####################################################
# Make sure to insert the correct file name
READMESH merge.sph
# First, all surfaces within "WALL_IN_OMNIS" BC (as defined in OMNIS) are summarized under the new BC "BC_WALL" (the name to use in HOPR)
UNITESELECTIONS BC_WALL 1 WALL_IN_OMNIS*
# Second, the original BC group and its surfaces should be deleted. These two commands can be repeated for multiple boundary conditions within a single script.
DELETESELECTION WALL_IN_OMNIS*
# Export the mesh as CGNS for the conversion with HOPR
WRITEMESH mesh.cgns
END
The above script can be saved in a text file (e.g. omnis_mergeBCs.conf
) and executed using the datamapper tool
hexpressdatamapper101 omnis_mergeBCs.conf
The resulting CGNS file can be converted with HOPR, using the corresponding mode:
Mode = 3
2.2.4. Mesh generation with GridPro
GridPro is a proprietary conforming multi-block mesh generator with hexahedral elements. However, a free academic version limited to 250 blocks is available.
After mesh generation, and before naming the boundaries in the Property Setter, you should set the output format to STARCD. Make sure to define not only labels but also different properties for the boundaries. Then export as STARCD and you will get four output files. During the export GridPro loses the label information, thus the boundary names have to be set again in the *.inp file. An example of a correct *.inp is given below:
TITLE
Converted from GridPro v4.1
CTAB 1 FLUI
CTNA 1 ZONE_VOL
RDEF 1 WALL $ $ $ $ $ $ $ $
RNAM 1 BC_WALL
RDEF 2 CYCL $ $ $ $ $ $ $ $
RNAM 2 BC_CYCL
VREAD,/home/user/mesh/test.vrt,,1,43770,CODE
CREAD,/home/user/mesh/test.cel,,1,21504,MODI,CODE
BREAD,/home/user/mesh/test.bnd,,1,43768,MODI,CODE
HOPR can then read-in the mesh with following mode option:
Mode = 4
More recent versions of GridPro also support a CGNS output. Here, the option Export -> Grid -> CGNS -> Elementary should be chosen. For different boundary labels, different property types have to be defined (Note: The property type Wall might be causing problems during the HOPR read-in and should be avoided). The following errors can be ignored as long as HOPR finishes successfully and a mesh file is written out
ERROR: number of zones in inifile does not correspond to number of zones in meshfile(s)
ERROR - Could not find corresponding boundary definition of ws.Interblck
2.2.5. Mesh generation with CENTAUR
A conventional tetrahedral mesh can be generated with CENTAUR. Boundaries have to be set in CENTAUR and accordingly in the HOPR parameter file. During the export as CGNS the following options are required:
Check “Only write out boundary faces”
Check “Write out boundary faces grouped by panels”
Read-in and convert with HOPR using the following options:
Mode = 3
BugFix_ANSA_CGNS = TRUE
SplitToHex = TRUE
Should problems occur, try to set SpaceQuandt to a higher value, e.g. 100. During the pre-processing step, every tetrahedron will be converted to 4 hexahedra resulting in increased number of elements.
2.2.6. Mesh generation with MeshGems/SALOME
Note: This tutorial was last updated/used: June 2016
MeshGems-Hexa is proprietary automated all-hex mesh generator. The algorithm can be used a plug-in within the open-source platform SALOME. Currently, we do not have a MeshGems-Hexa license and cannot give any support on mesh generation.
Import geometry as STEP or IGS
Create groups in Geometry module for the boundary conditions
Right-click on the imported file in Object Browser -> “Create Group”
Select faces as “Share Type” (2D object)
Choose appropriate name for the BC
Select one or many surfaces by (shift-) clicking on the surfaces
Click “Add” when finished for a single BC
“Apply” to save the BC and repeat the process (or “Apply and Close” at the end)
Create mesh in Mesh module: “Mesh” -> “Create mesh”
Choose the imported geometry in “Geometry” (if not already chosen, when geometry was highlighted previously)
Choose MG-Hexa for the 3D algorithm
Choose MG-CADsurf for the 2D algorithm
Assign boundary conditions to mesh
Right-click on created mesh
“Create groups from Geometry”
Click on the BC in “Object Browser” in the “Geometry”-tree
“Apply” and repeat with the next BC
“Apply and close” with the last BC
Export mesh as CGNS
Right-click on mesh, choose “Export” -> “CGNS file”
Import the exported CGNS file
Check the names of boundary conditions
Activate the BC by clicking on the visibility icon next to the name
Change the name to correspond to the entry in the preproc.ini
Export the modified mesh again as CGNS
Convert CGNS mesh from hdf to adf format Install cgns-tools (“sudo apt-get install cgns-tools”) “hdf2adf filename”
Read-in and convert with HOPR and the following options:
Mode = 3
BugFix_ANSA_CGNS = TRUE