Skip to main content

rapidmesh

Conforming tetrahedral and surface meshes for finite element and finite volume solvers. The mesher is written in Rust; this package is a thin layer over its API, so everything here is also available to Rust programs.

  • Primitives, CAD files and exact CSG: boxes, cylinders, spheres, cones, tori, prisms, sweeps, helices, lofts, fillets and chamfers, sheets, STEP files and STL/OBJ imports, united and cut by an exact arrangement. Material interfaces stay exactly conforming.
  • Bottom-up meshing: edges, then each face on its analytic surface, then each region on its own, with hierarchical sizing per region, geometric face and geometric edge. Thin layers take flat tets instead of being refined to their thickness.
  • Solver output: topology with orientation signs, the geometric entity of every face and edge, named sets, periodic point pairs, gmsh MSH 4.1, VTU, OpenFOAM polyMesh with tets or polyhedral cells (mesh.write_foam(case, polyhedral=True)), CalculiX/Abaqus (mesh.write_inp(path, order=2)), second-order tets on the true geometry (mesh.second_order()), finite volume quality (mesh.fvm_quality()).

Install

pip install rapidmesh

Usage

import rapidmesh as rm

g = rm.Geometry(maxh=0.5)
air = g.box(10, 10, 13.6)
sub = g.box(10, 10, 1.6, maxh=0.8)
g.label(air, "air")
g.label(sub, "substrate")
g.xy_plate(6, 6, position=(2, 2, 1.6), tag=1)   # a PEC patch
g.label(1, "patch")

# a periodic unit cell, and a named port face
g.periodic(g.surf(normal=(-1, 0, 0)), g.surf(normal=(1, 0, 0)))
g.periodic(g.surf(normal=(0, -1, 0)), g.surf(normal=(0, 1, 0)))
g.surf(near=(5, 5, 13.6)).name = "port"

mesh = g.mesh()
print(mesh)                 # Mesh(... tets, ... points, min dihedral ... deg, ... ms)

mesh.points                 # (n_points, 3) float64
mesh.tets                   # (n_tets, 4)   uint64
mesh.tet_regions            # region tag per tet
mesh.topology               # edges, faces, incidence with signs, classification
mesh.sets()                 # {"cells": ..., "faces": ..., "edges": ...} by name
mesh.periodic_points        # (n, 2) point on a master face and its image
mesh.write_msh("cell.msh")  # physical groups from the labels and names

CAD files

g = rm.Geometry(maxh=2.0)
bodies = g.import_step("assembly.step")   # one solid per body of the file
mesh = g.mesh()                           # faces meshed on their true surfaces

STEP files (AP203 and AP214) bring planes, cylinders, cones, spheres, tori and B-spline surfaces; coordinates stay in the file's unit. Each solid takes the name the file gives its part, so an assembly's mesh has its parts as named sets and physical groups.

Sizing

g.maxh = 0.5                               # global target size
g.region(2).maxh = 0.2                     # one region
g.surf(normal=(0, 0, 1)).maxh = 0.1        # the faces facing +z
g.edge(near=(0, 0, 1)).maxh = 0.05         # the edge nearest a point
g.tol = 1e-3                               # chord tolerance of curved entities
g.refine_near_points([(1, 1, 1)], 0.02)    # point size sources
mesh = g.mesh(target_elements=50_000)      # an element budget
mesh = g.mesh(min_angle=15)                # refined where tets stay below 15 degrees

maxh is the size the mesh needs for what lives on it; curved geometry takes either a chord tolerance (g.tol, about ten segments round a circle by default) or a geometric error:

mesh = g.mesh(geom_error=1e-2, order=2)    # volumes and sheet areas within 1 %
                                           # on quadratic elements

geom_error bounds the error of the volume of every region and the area of every sheet, measured on flat elements (order=1) or on the quadratic elements of the second-order mesh (order=2). Quadratic elements follow a curve with far fewer of them: on CAD parts read from STEP, one percent at order=2 takes about as many tets as the default tolerance or fewer, with a measured error of a few hundredths of a percent.

Second order

so = mesh.second_order()       # tet10: points, tets (n, 10), faces (m, 6), volumes
so["curved_tets"]              # per tet: a mid-edge node off its chord
mesh.write_msh("part.msh", order=2)
mesh.write_inp("part.inp", order=2)
mesh.show(second_order=True)   # curved faces drawn curved

Every edge takes a node in its middle, on the true geometry where the edge lies on a curved surface or a curve. Tets with no such node keep their mid-edge nodes in the middle of their edges (an affine map, curved_tets false).

Surface meshes

g.surface_mesh() meshes only the surfaces (interfaces, outer boundary, sheets) and gives its edge topology and the same sets and file output. rm.polygon_union merges overlapping layout polygons into outlines for sheets and prisms.

What happened, how long, and where the quality is worst

print(mesh.report())     # stage timings, quality with location, warnings
mesh.timings             # seconds per stage
mesh.metrics             # predicate counts, point and tet counts
mesh.quality             # min_dihedral_deg, worst_location, worst_region, regions
mesh.diagnostics         # histogram, watertightness, fidelity, located defects
mesh.log                 # [{level, stage, message, at}, ...]

Set RAPIDMESH_LOG=1 to stream the log to stderr while meshing.

A geometry the mesher cannot mesh raises rm.MeshError (a ValueError) whose message says where and what to repair: features far below the mesh size, gaps between solids, degenerate faces.

License

Dual licensed: GNU Affero General Public License v3.0, or a commercial license for use in proprietary products and services without the AGPL obligations (contact milanrother.com/consulting). Versions up to 0.6.0 were published under the MIT license.

Metadata

Release files for rapidmesh 2.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 rapidmesh 2.2.0
File Size Uploaded Provenance Actions
rapidmesh-2.2.0.tar.gz 1.6 MB With provenance Details for rapidmesh-2.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rapidmesh 2.2.0
File Actions
rapidmesh-2.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for rapidmesh-2.2.0-cp310-abi3-win_amd64.whl
rapidmesh-2.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for rapidmesh-2.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rapidmesh-2.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for rapidmesh-2.2.0-cp310-abi3-macosx_11_0_arm64.whl
rapidmesh-2.2.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for rapidmesh-2.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 14.0 MB

Release files / rapidmesh-2.2.0.tar.gz

Download URL rapidmesh-2.2.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
e2a18741e13c34575ec2e2fa3307661f18e627a5635e87bd3cf2556c20b6b778
BLAKE2b-256 checksum
How to use checksums
84642e56c87af32bac38ee4aac44327393f1486ca6731ccab69a2887d569be8f
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 Oct 3, 2026.

Transparency log

Release files / rapidmesh-2.2.0-cp310-abi3-win_amd64.whl

Download URL rapidmesh-2.2.0-cp310-abi3-win_amd64.whl
Size 3.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0e55d912412fd7512caa94f43785095a539322a963a044898a0db594a2c62803
BLAKE2b-256 checksum
How to use checksums
896ac13d6489c4d4aefce5c07fd0505fa9489a18112b80f5927eec365b929685
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 Oct 3, 2026.

Transparency log

Release files / rapidmesh-2.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rapidmesh-2.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0027607033419d1d6eaefa18180fa07686bd320be487bea006c153866eaa04bb
BLAKE2b-256 checksum
How to use checksums
39c9c73837752bd673ea3f2211c98a6f046b104e317bc1424e9c36a625561b99
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 Oct 3, 2026.

Transparency log

Release files / rapidmesh-2.2.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL rapidmesh-2.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 2.9 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b1cc5aa363d19f55a3eb23cc2b6ed35a6e0518e7e0117bdf5911422f5bd0052f
BLAKE2b-256 checksum
How to use checksums
fceac79e8007bf72108fdf1073fa2f3db365706c5ecfc5dc5db9d809a77e2433
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 Oct 3, 2026.

Transparency log

Release files / rapidmesh-2.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL rapidmesh-2.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
826bb8f0e471eb73fc01975b1fffa5870a07cbc9d29c02489cc162e1ce61b4a3
BLAKE2b-256 checksum
How to use checksums
a1ed10db8823acdafdbc137acfb22ee0c3055d344392fcbb5b53faf83258b568
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 Oct 3, 2026.

Transparency log

Security for rapidmesh 2.2.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

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for rapidmesh-2.2.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 Oct 3, 2026.

Transparency log

A 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.

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