Skip to content

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:

At startup, the initial CAD is composed of one volume bounded by multiple surfaces:

OneVolume

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:

OneVolume

The target is to partition the geometry into multiple sub-volumes with 6 surfaces:

OneVolume

When all volumes are green, click Mesh CAD to generate a 3D structured hexahedral mesh:

OneVolume

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:

hexamsh <study_name>

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:

python replay.py

This is useful to automate mesh generation for design-of-experiments workflows.