ADMESH: an advanced, automatic unstructured mesh generator for 2D shallow-water models.
Project description
ADMESH
An ADvanced, automatic unstructured MESH generator for 2D shallow-water models.
A faithful Python port of the MATLAB ADMESH library, with a Pythonic API.
Dominik Mattioli1†, Colton Conroy, Dustin West, Ethan Kubatko2
†Corresponding author | 1Unaffiliated | 2Ohio State University (CHIL)
A graded Delaware Bay mesh — fine in the upper river, coarse in the open bay — evolving through the pipeline: 1. initialization → 2. DistMesh truss solver → 3. FEM smoothing. Element color tracks quality (magenta = poor → cyan = equilateral).
MATLAB users: This library is the actively-developed successor to the original MATLAB codebase by Conroy et al. (no longer maintained). An unmaintained copy of that original is kept in-repo at
src/matlab/for provenance.
Table of Contents
- Why ADMESH
- Installation
- Quick start
- Pipeline
- Performance
- Status & roadmap
- Citation
- Contributing · Documentation · License
Why ADMESH
For shallow-water modelers who need ADCIRC-ready meshes from Python:
- The port does not change your meshes. Thirteen stages reproduced 1:1 from the OSU CHIL Lab
01_ADMESH_Library, with a 430-test suite tracking numerical agreement against the MATLAB reference. - Native ADCIRC
fort.14I/O. Bit-faithful read/mesh/write round-trip, including paired-edge boundary records (IBTYPE 3/4/13/24). ADCIRC format only — not gmsh, not generic. - Element size follows the physics. Size adapts to boundary curvature, channel width, bathymetric gradient, and tidal wavelength through automatic
min-stack composition; custom contributions layer on top. No hand-tuned scalar. - An adaptive background grid for multiscale domains.
triangulate(background="octree")refines the size field on a quadtree instead of a uniform grid, concentrating evaluation where the geometry demands it — opt-in; the uniform grid remains the default. - Pythonic surface, faithful internals.
Domain/Mesh/BoundarySegmentare frozen, typed dataclasses; the numerics stay inside the locked faithful-port modules.
Not the right tool for 3-D, anisotropic, or non-triangular elements — use gmsh for those.
Installation
pip install admesh2D # core
pip install admesh2D[viz] # adds chilmesh for mesh.plot() / plot_quality()
⚠️ Install
admesh2D, notadmesh. The distribution name isadmesh2D; the import name staysadmesh(import admesh).pip install admeshpulls an unrelated C STL-repair library that needsadmesh/stl.hat build time and will fail.
Requires Python ≥ 3.10. Core dependencies: NumPy, SciPy, Numba, Shapely. From source:
git clone https://github.com/domattioli/ADMESH.git
cd ADMESH && pip install -e ".[dev]"
Quick start
import admesh
from admesh import domains
# Uniform sizing
mesh = admesh.triangulate(domains.UNIT_DISK, h_max=0.1)
mesh.to_fort14("disk.14")
# Graded sizing: fine features, coarse interior
mesh = admesh.triangulate(domains.NOTCHED_RECTANGLE, h_max=0.2, h_min=0.02)
mesh.to_fort14("notched.14")
mesh is a frozen Mesh dataclass: typed nodes, elements, boundaries (each a BoundarySegment carrying a BoundaryType code), optional bathymetry, and per-element quality. h_min / h_max set the size bounds; pass a size_field callable to grade explicitly. fort.14 boundary labels round-trip through BoundaryType, an IntEnum over ADCIRC IBTYPE codes (OPEN=0, MAINLAND=1, ISLAND=11, MAINLAND_FLUX=20); paired-edge and weir codes (3/4/13/24) preserve as plain int.
See docs/ for fort.14 round-trip, re-meshing, custom size-field, and SDF-domain examples.
Pipeline
triangulate(...) runs the 13-stage ADMESH pipeline; a Numba-JIT solver replaces the original C MEX, so there is no compile step at install.
flowchart LR
A["SDF / fort.14"] --> B["Domain"]
B --> C["Size field<br>(curvature + medial axis<br>+ bathymetry + tide)"]
C --> D["distmesh2d<br>(truss equilibrium)"]
D --> E["Mesh<br>(fort.14 out)"]
Performance
The Numba-JIT SDF kernel and solve_iter smoother cut end-to-end mesh generation on the Western North Atlantic benchmark from 1257.5 s to 47.2 s — a 26.7× speedup at unchanged quality (mean 0.963), measured at hmin=0.05 / g=0.10 / niter=120.
| v0.2.1 | v0.5.0 (Numba) | |
|---|---|---|
| total | 1257.5 s | 47.2 s |
| nodes / elements | 49 377 / 93 655 | 49 377 / 93 642 |
| mean element quality | 0.963 | 0.962 |
The C++ force kernel and full-stage native rewrite (v1.0.0 / v1.1.0) are in flight; the per-stage breakdown and the version-comparison harness live in benchmarks/. The forward benchmark standard is the ENPAC 2003 tidal database (272,913 nodes), replacing WNAT for large-domain timing.
Reproduce or extend:
python benchmarks/compare_versions.py --hist \
--mesh tests/fixtures/fort14/adcirc_examples/wnat_test.14 \
--domain benchmarks/data/wnat_onur_boundary.json \
--hmin 0.05 --g 0.10 --niter 120
Status & roadmap
- Shipped (v0.5.0). Pythonic API, fort.14 round-trip, 13-stage faithful port, valence balancing, custom size-field hooks, Numba-JIT SDF/solver kernels. On PyPI and archived on Zenodo.
- In flight. Octree adaptive background grid (
background="octree"); C++ force kernel and native stage rewrite; Gmsh I/O; default size-field-stack consolidation. - Next. Paired-edge IBTYPE 3/4/13/24 promoted to named
BoundaryTypemembers; hosted mkdocs site.
Open epics live as labeled issues — see planning-required.
Citation
Algorithm (cite the original paper):
Conroy, C.J., Kubatko, E.J. & West, D.W. (2012). ADMESH: an advanced, automatic unstructured mesh generator for shallow water models. Ocean Dynamics 62, 1503–1517. https://doi.org/10.1007/s10236-012-0574-0
This software (cite the archived release):
Mattioli, D.O., Conroy, C.J., West, D.W., Kubatko, E.J. (2026). ADMESH: An advanced, automatic unstructured mesh generator for 2D shallow-water models (Python port). Zenodo. https://doi.org/10.5281/zenodo.20264101
A CITATION.cff feeds GitHub's "Cite this repository" button; version-specific DOIs are on the Zenodo record.
Documentation
API reference lives in the docstrings (triangulate, Domain, Mesh, BoundarySegment, read_fort14 / write_fort14, the 13 stage modules). Design notes, the porting log, and domain-format specs are under docs/ and specs/; project invariants in CONSTITUTION.md.
Contributing
Issues and pull requests are welcome on GitHub.
- Theory (algorithm, size-field formulation, ADCIRC integration): Colton Conroy | Ethan Kubatko — kubatko.3@osu.edu
- Python port (this repository): Dominik Mattioli — github.com/domattioli
License
Apache 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file admesh2d-0.5.1.tar.gz.
File metadata
- Download URL: admesh2d-0.5.1.tar.gz
- Upload date:
- Size: 111.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c541334dfebb43668a8146c80258719f31436dbdb7874153f3f40c5b20cebc66
|
|
| MD5 |
a3086304740f05a3ab587809b4684170
|
|
| BLAKE2b-256 |
269c7b69c63665e5c6fabd6bc8747fe4bca2f9312ecad2620509eb462dcdb96f
|
File details
Details for the file admesh2d-0.5.1-cp314-cp314-macosx_26_0_arm64.whl.
File metadata
- Download URL: admesh2d-0.5.1-cp314-cp314-macosx_26_0_arm64.whl
- Upload date:
- Size: 206.5 kB
- Tags: CPython 3.14, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c7fb6de78c39531d99098558f26b0e624498c78caa693fb57c0aee8482b0a28
|
|
| MD5 |
dc3326a60971e3384f45efdba4cdae06
|
|
| BLAKE2b-256 |
f37a105e35ed61a73822f5cdd30df50664aa90e87834070519df1392cdc932cc
|