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
mesh.without_regions([2])   # region 2 left out, its walls kept as boundary

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. rm.read_step(path) reads a file once and gives its unit (metres_per_unit) and body names; g.add_body(step, i) then adds the bodies one by one, in any order, some left out.

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(order=2)   # 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. Sheets in one plane take exact booleans, g.sheet_boolean("difference", ground, slot, disc) (or "union", "intersection"): points stay as given, and a round rim that is left stays a circle, so a plate with a round hole extrudes into a block with an exact bore. g.polygon_plate(points, position, axes=(u, v)) puts a polygon in any plane.

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 4.0.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 4.0.0
File Size Uploaded Provenance Actions
rapidmesh-4.0.0.tar.gz 1.7 MB With provenance Details for rapidmesh-4.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rapidmesh 4.0.0
File Actions
rapidmesh-4.0.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for rapidmesh-4.0.0-cp310-abi3-win_amd64.whl
rapidmesh-4.0.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-4.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rapidmesh-4.0.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for rapidmesh-4.0.0-cp310-abi3-macosx_11_0_arm64.whl
rapidmesh-4.0.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for rapidmesh-4.0.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 14.7 MB

Release files / rapidmesh-4.0.0.tar.gz

Download URL rapidmesh-4.0.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
ad9cc16de0a3f6dc7b009d1a48ddcc8468279b84440db8696026290f69e9b3a3
BLAKE2b-256 checksum
How to use checksums
7bc91be671aa29b6f5d7ec49ac0c4f5b063a29eafc4444fcf7ac5cbdb688a813
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 9, 2026.

Transparency log

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

Download URL rapidmesh-4.0.0-cp310-abi3-win_amd64.whl
Size 3.2 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e82b21938f4221900386d0969d7bb93946b8d16f95024ffb9867cd6dda5c316f
BLAKE2b-256 checksum
How to use checksums
0b7a0438eca335bd34c566f9f35d2d93454155281deecc018770e06146168108
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 9, 2026.

Transparency log

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

Download URL rapidmesh-4.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
bf42b148250da2a9e6d3497f94fe064d6e2fc47e715c34b5874234c7fb6e8fd5
BLAKE2b-256 checksum
How to use checksums
f1882cc94b5915eb6a3d50502d2781c5fe966fb91a0787ff375c1aa36d52ac3b
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 9, 2026.

Transparency log

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

Download URL rapidmesh-4.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 3.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d41f776504f272d5cfc0188bcc6761ab2c3b5d762a65d084a43624cf886220e7
BLAKE2b-256 checksum
How to use checksums
9d6ba7d9feb60280e7014a6e1a6af50097ec622aa4dfb5abe298a63d57aec661
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 9, 2026.

Transparency log

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

Download URL rapidmesh-4.0.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
c5890f839af7ef2901b7e24141c757e31b4e7519cf5d675c224c4b0042611349
BLAKE2b-256 checksum
How to use checksums
8d1e254708e07f2b92364b9a162ca775e63b731e508ddd091438438f6692ec8d
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 9, 2026.

Transparency log

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

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

Select from 5 files

Attestation for rapidmesh-4.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 Oct 9, 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