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
mesh2flac3d model.msh --check         # exit non-zero if any zone has bad volume
mesh2flac3d model.msh --json          # machine-readable grid summary

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)
  total volume: 900000   negative-volume zones: 0 [OK]

negative-volume zones: 0 certifies the grid imports into FLAC3D without a volume error — computed here, so you don't have to open FLAC3D to find out. Use --check to turn that into an exit code for CI/pipelines.

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'])

s = grid.summary()
print(s["total_volume"], s["negative_volume_zones"])  # 900000.0 0

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};

Entities you don't assign to a group are imported anyway — they just land in no ZGROUP/FGROUP. (meshio alone aborts a Gmsh 4.1 file when only some element blocks carry a Physical Group — Incompatible cell data 'gmsh:physical'; mesh2flac3d falls back to a built-in tolerant Gmsh 4.1 ASCII reader in that case. If your .msh is binary or an older version, re-export it as "Version 4.1 ASCII" — the Gmsh default.)

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.4.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.4.0
File Size Uploaded
mesh2flac3d-0.4.0.tar.gz 21.2 kB Details

Built distribution (wheel)

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

Total release size: 38.0 kB

Release files / mesh2flac3d-0.4.0.tar.gz

Download URL mesh2flac3d-0.4.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
686100c8151fd6970d8fbdf9d4265beedbab9138104f881bc49932bdb3fb4078
BLAKE2b-256 checksum
How to use checksums
dc214b150a074c93a56ab1b7ffc3522bee5e7aa081e5e1b1af09e12b0c99dc6a
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 26, 2026.

Transparency log

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

Download URL mesh2flac3d-0.4.0-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c8cb5a20626ce3f6c1b1dd5e1afe8d835a6cbd8d9992f1ec9a98fdcbb78090d
BLAKE2b-256 checksum
How to use checksums
60027476605397419c7e28155dd17f71d7677175a26135799cf0bf53579be022
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 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

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