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

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

Built distributions (wheels)

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

Total release size: 14.3 MB

Release files / rapidmesh-3.0.0.tar.gz

Download URL rapidmesh-3.0.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
0fbb35917ae5cf0c8e171fb306afd7a08988cd0c0827c85b0eca3d5242c9ca31
BLAKE2b-256 checksum
How to use checksums
0f8840edbf0e189de7aee634972a0fff8e4f5fd67a441e48b73fbb6f2ef5b28f
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 5, 2026.

Transparency log

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

Download URL rapidmesh-3.0.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
200eb2d9f9163ed4c3f342faf2220abdcdef943146ec353711ef1e0af4a5e3f7
BLAKE2b-256 checksum
How to use checksums
f094440d67912cf38bf9f70460e1efc743ae21f58808ca0eb291e7908d04ab23
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 5, 2026.

Transparency log

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

Download URL rapidmesh-3.0.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
e3b17e502fa86908ada60970a35743b37186055b4c306b2c154546b8d72a35e7
BLAKE2b-256 checksum
How to use checksums
5b51d5ba8d4a48dc5e1a00803c2a5fb74486b02f809db00e1ca1994b47b18f0b
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 5, 2026.

Transparency log

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

Download URL rapidmesh-3.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
951958e0f40ae5dfbd26e393766f84cf941a40cb054a6d3adc831fcde3d40edf
BLAKE2b-256 checksum
How to use checksums
98cc9ba9a845eb8686ffb427b9aafadf2e902a10d8be7aa6942c41584610adc4
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 5, 2026.

Transparency log

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

Download URL rapidmesh-3.0.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.2 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6c54fd1bab2a5e4d9e7c53865dc05f2ac4fbf36dcad47f548c5af6364727bbff
BLAKE2b-256 checksum
How to use checksums
0d3bab3b4b0424eb5d9d99f43835a8f49d84f6a89681186847aa27c37ceb7a19
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 5, 2026.

Transparency log

Security for rapidmesh 3.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-3.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 5, 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