HexaMSH 1.0.1
HexaMSH is a Python library and CLI tool to generate structured hexahedral meshes for Finite Element Analysis (FEA).
It is built on top of the Gmsh Python API and GUI.
Getting started
Install HexaMSH from PyPI:
pip install hexamsh
You can start by playing the three tutorials available here:
Principle
HexaMSH aims at partitioning a geometry into sub-volumes. The geometry editing features available in the GUI are listed below:
- Back to previous CAD
- Project a point on a curve
- Project a surface on a surface
- Add a point on a curve
- Add a surface by curve loop
- Add a surface by point loop
- Add a volume between two surfaces
- Split all volumes by a plane (3 points)
- Split all volumes by a finite surface (4 points)
- Split a surface by a curve
- Split a volume by a point loop
- Split a triangle surface
- Split a wedge volume
- Merge 2 curves
- Merge 2 surfaces
- Remove all duplicates
- Remove curves
- Remove orphan curves
- Remove surfaces
At startup, the initial CAD is composed of one volume bounded by multiple surfaces:
All surfaces appear orange, as not meshable with the transfinite method provided by Gmsh. Thanks to the different geometry features, the user can split the volume into sub-volumes.
While a sub-volume is composed by 6 surfaces, Gmsh is able to mesh according to the transfinite method. That volume appears green in the GUI:
The target is to partition the geometry into multiple sub-volumes with 6 surfaces:
When all volumes are green, click Mesh CAD to generate a 3D structured hexahedral mesh:
By default, all the edges are meshed by the transfinite method with 5 nodes.
You can then modify the mesh, through the GUI, with:
Command-line usage
Run HexaMSH from a terminal:
Where study_name is the base name of the STEP file to open (HexaMSH reads <study_name>.stp/step or <study_name>.brep).
Replay feature
HexaMSH writes GUI geometry and meshing actions to a replay.py script.
This script provides reproducibility and lets you run the same workflow again programmatically.
Replay File Location
replay.py is automatically created and updated in the directory that contains the STEP CAD file.
Replay to Resume GUI Operations
You can replay the script from the GUI to continue a previously executed hex-meshing process.
Remark
replay.py is also used for partial replay when undoing the latest operation in the GUI.
Replay on Parametric CAD Variants
If you generate multiple CAD models with the same topology (parametric variants), you can replay the same script for each model:
This is useful to automate mesh generation for design-of-experiments workflows.