Skip to main content

mesh2flac3d

CI License: MIT

Convert meshes (Gmsh .msh, VTK, and anything meshio reads) to Itasca FLAC3D .f3grid grids — preserving physical groups:

  • Volume physical groups → ZGROUP (zone groups)
  • Surface physical groups → FGROUP (face groups, for boundary conditions)
  • Correct zone winding: every zone is reordered to FLAC3D's convention, so you never get negative-volume zone errors on import.

It reads meshes through meshio (MIT) and does not import gmsh, so it carries no GPL obligation — you can use it freely, including in commercial workflows.

Why not just use meshio?

meshio has a FLAC3D writer, but for a typical geomechanics mesh (volume and surface physical groups) it currently:

  • crashes (TypeError in split_f_z) when both zone and face groups are present, and
  • drops all 2D groups ("FLAC3D format only supports 3D cells. Skipping triangle…"), so you lose the face groups you need for boundary conditions, and
  • does not guarantee zone orientation.

mesh2flac3d is a focused, correct writer built for that exact case.

Install

pip install mesh2flac3d

Quickstart

A ready-to-run example mesh lives in examples/ — install, then:

mesh2flac3d examples/three_layer_box.msh out.f3grid

See examples/README.md for the full 30-second walkthrough, or examples/dean/ for the Dean (2006) SPE-79709 reservoir benchmark meshes (problems 1–4, SI units).

Slots (overlapping groups)

A cell often belongs to several groups at once — a well cell is also part of a reservoir and of a geological layer. FLAC3D handles this with slots (one group per slot per zone). Name a physical group name@slot and mesh2flac3d writes it to that slot:

Physical Volume("well@Well")        = { ... };   // ZGROUP "well"      SLOT "Well"
Physical Volume("reservoir@Region") = { ... };   // ZGROUP "reservoir" SLOT "Region"

The well cells then stay part of the reservoir. A name without @ uses the default slot.

Command line

mesh2flac3d model.msh model.f3grid
mesh2flac3d model.msh                 # -> model.f3grid
mesh2flac3d model.msh out.f3grid --dat out.dat   # also write a FLAC3D command skeleton
mesh2flac3d model.msh --no-faces      # zones only

Example output:

[mesh2flac3d] model.msh -> model.f3grid
  points: 350  zones: 1218  faces: 522
  zone groups: Underburden(401), Salt(414), Overburden(403)
  face groups: Top(90), Bottom(90), Sides(342)

Python API

import mesh2flac3d as m2f

grid = m2f.convert("model.msh", "model.f3grid")
print(grid.zone_groups.keys())   # dict_keys(['Underburden', 'Salt', 'Overburden'])
print(grid.face_groups.keys())   # dict_keys(['Top', 'Bottom', 'Sides'])

Supported elements

Family Gmsh / meshio FLAC3D
Zones tetra T4
pyramid P5
wedge / prism W6
hexahedron B8
Faces triangle T3
quad Q4

High-order variants (tetra10, hexahedron20, …) are exported using their linear corner nodes.

In Gmsh, name your groups

Give your regions and boundaries Physical Groups with names — those names become the FLAC3D group names:

Physical Volume("Salt")  = {2};
Physical Surface("Top")  = {4};

Development

pip install -e ".[test]"
pytest -q

The test fixture is generated with Gmsh (tests/fixtures/make_testmesh.py); Gmsh is a test-only dependency, never used by the package at runtime.

Reporting a bug

Open an issue: https://github.com/Jeanbjoseph/mesh2flac3d/issues/new/choose. The guided form asks for your command, the full output, versions, and — most useful of all — the input .msh that reproduces the problem (zip it if GitHub blocks the extension). A small reproducing mesh gets things fixed fastest.

License

MIT © AI SIM Engenharia Geotécnica. FLAC3D and Itasca are trademarks of Itasca Consulting Group; this project is independent and not affiliated with Itasca.

Metadata

Release files for mesh2flac3d 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mesh2flac3d 0.2.0
File Size Uploaded
mesh2flac3d-0.2.0.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mesh2flac3d 0.2.0
File Interpreter ABI Platform
mesh2flac3d-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.9 kB

Release files / mesh2flac3d-0.2.0.tar.gz

Download URL mesh2flac3d-0.2.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bd6d527c381bd5bf251c75d51c98f9560155958d2de368d1831e01eafe64654f
BLAKE2b-256 checksum
How to use checksums
dcba88c633f0341f40ccb98f43d45d15f69d5bad5cd3001e6b0b0fe1a06ba655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 21, 2026.

Transparency log

Release files / mesh2flac3d-0.2.0-py3-none-any.whl

Download URL mesh2flac3d-0.2.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b79c0a421d7ed785739617c0e93e11bbc3aebe0455fd4b84f8b699be41a743df
BLAKE2b-256 checksum
How to use checksums
3a0fb16adfb4df780c2f38007c19d0c3227b3d5ed7845f1bfa4917a486d13d0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page