MTEX2Gmsh for Python
Generate a conforming mesh from EBSD data processed with Python and MTEX.
MTEX2Gmsh (Python package mtex2gmsh, this repository pyMTEX2Gmsh) is a 100% Python port of the Matlab toolbox
MTEX2Gmsh (Depriester & Kubler,
JOSS 2020, doi:10.21105/joss.02094). It
converts grains reconstructed with the Python port of
MTEX (pip install mtex) into a Gmsh-readable
geometry, then meshes it with Gmsh through its official
Python SDK (pip install gmsh) — no Matlab, no external binary required.
It is intended to perform Finite Element Analysis (FEA) at grain scale on polycrystals imaged by EBSD.
📖 Documentation (with executed examples): https://pymtex2gmsh.readthedocs.io/
Install
pip install mtex2gmsh # everything included: mtex, numpy, scipy, Gmsh SDK, matplotlib
Requirements: Python >= 3.12 (required by mtex 1.0). On headless machines, also
install the GL libraries used by the Gmsh SDK (sudo apt-get install libgl1 libglu1-mesa).
Quickstart
import mtex
from mtex2gmsh import GmshGeo, plot_mesh
ebsd = mtex.mtexdata('small') # example dataset shipped with MTEX
grains = mtex.calcGrains(ebsd[ebsd.isIndexed])
G = GmshGeo(grains) # Gmsh-readable description of the grains
print(G.size()) # number of grains and ROI size
G.mesh('small.msh') # 3D mesh of linear wedge elements (default)
G.mesh('small_tri.msh', element_type='Tri', element_size=100) # 2D triangular mesh
plot_mesh('small_tri.msh', output_file='small_tri.png') # visualize the mesh, export a PNG
G.savegeo('geometry.geo') # dump only the Gmsh geometry
G.export_grain_props('grains.csv') # grain ids, phases, Euler orientations
G.plot() # plot the B-spline geometry (matplotlib)
A complete runnable script is provided in examples/example.py;
the full documentation (installation, all meshing options, API reference, executed
examples) lives in docs/ and is built with Sphinx on
ReadTheDocs.
Citation
If you use this toolbox, please cite the original paper (Depriester & Kubler, JOSS 2020, doi:10.21105/joss.02094) — see CITATION.cff, which GitHub picks up for its “Cite this repository” button.
License
MIT (see LICENSE).
Metadata
Release files for mtex2gmsh 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mtex2gmsh-1.0.0.tar.gz | 39.0 kB | With provenance | Details for mtex2gmsh-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mtex2gmsh-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for mtex2gmsh-1.0.0-py3-none-any.whl |
Total release size: 78.6 kB
Release files / mtex2gmsh-1.0.0.tar.gz
| Download URL | mtex2gmsh-1.0.0.tar.gz |
|---|---|
| Size | 39.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6ed2d97134ceb6f12606126181e78c824abf4f1236419a208bb060dd481075c
|
|
BLAKE2b-256 checksum How to use checksums |
2d587d6f15851161677e94e2b9a8e42cc1cfd338a08098447099fb067f1d0db6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / mtex2gmsh-1.0.0-py3-none-any.whl
| Download URL | mtex2gmsh-1.0.0-py3-none-any.whl |
|---|---|
| Size | 39.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27d3e64f9dd506aa8473e0763f9019f53ed8c98ed2443e91283a2dce11c9d246
|
|
BLAKE2b-256 checksum How to use checksums |
538ac30184ed5c9e065ddc146adf27a4b9c09d6bdb0d08eeb4ba33344e67bc80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for mtex2gmsh 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mtex2gmsh-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.