Skip to main content

pypi MPL

pytetwild is a Python library for mesh tetrahedralization. It is a Python wrapper around the efficient C++ library for tetrahedral meshing provided by fTetWild.

Installation

We have pre-built wheels for Python 3.10 - Python 3.14 for Windows, Linux, and macOS.

The recommended way to install pytetwild is via PyPI:

pip install pytetwild[all]

This installs pyvista by default, which you can use to tetrahedralize sufrace meshes from PyVista. Alternatively you can just install with pip install pytetwild for a lighter install.

You can also clone the repository and install it from source, but since there’s C++ involved, the build is a bit more complicated. See CONTRIBUTING.md for more details.

Usage

To tetrahedralize a surface mesh from PyVista, you’ll need to first install pyvista as it’s not a dependency and then run:

import pyvista as pv
import pytetwild

# Load or create a PyVista PolyData surface mesh
# Here, we'll create a simple sphere mesh as an example
surface_mesh = pv.Icosphere(nsub=2)

# Convert the surface mesh to a tetrahedral mesh. For this example let's
# use a coarse mesh
tetrahedral_mesh = pytetwild.tetrahedralize_pv(surface_mesh, edge_length_fac=1)

# Visualize the tetrahedral mesh in an "exploded" view
tetrahedral_mesh.explode(0.5).plot(
    show_edges=True, zoom=1.6, ssao=True, anti_aliasing="ssaa"
)
https://github.com/pyvista/pytetwild/raw/main/exploded-sphere.png

You can also work with raw arrays. Here’s a simple cube that we turn into tetrahedra.

import numpy as np
import pytetwild

# Define vertices of the cube
vertices = np.array([
    [0, 0, 0],  # Vertex 0
    [1, 0, 0],  # Vertex 1
    [1, 1, 0],  # Vertex 2
    [0, 1, 0],  # Vertex 3
    [0, 0, 1],  # Vertex 4
    [1, 0, 1],  # Vertex 5
    [1, 1, 1],  # Vertex 6
    [0, 1, 1]   # Vertex 7
])

# Define faces using vertex indices
# Each face is a rectangle (also accepts triangles)
faces = np.array([
    [0, 1, 2, 3],  # Front face
    [1, 5, 6, 2],  # Right face
    [5, 4, 7, 6],  # Back face
    [4, 0, 3, 7],  # Left face
    [4, 5, 1, 0],  # Bottom face
    [3, 2, 6, 7]   # Top face
])
v_out, tetra = pytetwild.tetrahedralize(vertices, faces, optimize=False)

Usage - Sizing Field

To vary cell size across the mesh rather than using one edge length everywhere, pass a background tetrahedral mesh carrying the target edge length at each of its points. This is fTetWild’s --bg-mesh.

import numpy as np
import pyvista as pv
import pytetwild

# Background mesh covering the input, refined on one side
background = pv.ImageData(
    dimensions=(5, 5, 5), spacing=(0.3, 0.3, 0.3), origin=(-0.6, -0.6, -0.6)
).to_tetrahedra()
background.point_data["target"] = np.where(
    background.points[:, 0] < 0, 0.04, 0.2
)

mesh = pytetwild.tetrahedralize_pv(
    pv.Sphere(), sizing_field=background, sizing_field_scalars="target"
)

The value at any point is interpolated over the background tetrahedron containing it, and anywhere the background mesh does not cover falls back to the global ideal edge length. Note this is unrelated to disable_filtering, which keeps the internal background mesh fTetWild builds for itself.

Usage - Options

We’ve surfaced a several parameters to each of our interfaces tetrahedralize and tetrahedralize_pv:

Parameters
----------
edge_length_fac : float, default: 0.05
    Tetrahedral edge length as a function of bounding box diagonal. The
    default ideal edge length is ``bb/20`` (bounding box divided by
    20). Ignored when ``edge_length_abs`` is input.
edge_length_abs : float, optional
    Absolute ideal edge length. When input ``edge_length_fac`` is ignored.
optimize : bool, default: True
    Improve the minimum scaled Jacobean for each cell. This leads to higher
    cell quality at the expense of computation time. Optimization level is
    dependent on ``stop_energy`` and ``num_opt_iter``.
simplify : bool, default: True
    Simplfiy the input mesh surface before tetrahedralization.
epsilon : float, default 1e-3
    Envelop size, specifying the maximum distance of the output surface
    from the input surface, relative to the bounding box size.
stop_energy : float, default: 10.0
    The mesh optimization stops when the conformal AMIPS energy reaches
    ``stop_energy``.
coarsen : bool, default: False
    Coarsen the output as much as possible, while maintaining the mesh
    quality.
num_threads : int, default: 0
    Set number of threads used. 0 (default) uses all available cores.
num_opt_iter : int, default: 80
    Maximum number of optimization iterations if ``optimize=True``.
loglevel : int, default: 6
    Set log level (0 = most verbose, 6 = minimal output).
quiet : bool, default: False
    Disable all output. Overrides ``loglevel``.
sizing_field : pv.UnstructuredGrid, optional
    ``tetrahedralize_pv`` only. All-tetrahedral mesh supplying a
    spatially varying target edge length. Requires ``optimize=True``.
sizing_field_scalars : str, optional
    ``tetrahedralize_pv`` only. Name of the point array on
    ``sizing_field`` holding the target edge length. Defaults to its
    active point scalars.
bg_vertices, bg_tets, bg_values : np.ndarray, optional
    ``tetrahedralize`` only. The same sizing field as raw arrays:
    points ``(n, 3)``, tetrahedra ``(m, 4)``, and the target edge
    length at each point ``(n,)``.

License and Acknowledgments

This project relies on fTetWild and credit goes to the original authors for their efficient C++ library for tetrahedral meshing. That work is licensed under the Mozilla Public License v2.0.

The work in this repository is also licensed under the Mozilla Public License v2.0.

Support

If you are having issues, please feel free to raise an Issue.

Metadata

Release files for pytetwild 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytetwild 0.4.2
File Size Uploaded
pytetwild-0.4.2.tar.gz 2.6 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pytetwild 0.4.2
File
pytetwild-0.4.2-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
pytetwild-0.4.2-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details
pytetwild-0.4.2-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details
pytetwild-0.4.2-cp312-abi3-macosx_15_0_arm64.whl CPython 3.12 abi3 macOS 15.0+ ARM64 Details
pytetwild-0.4.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pytetwild-0.4.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
pytetwild-0.4.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
pytetwild-0.4.2-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
pytetwild-0.4.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pytetwild-0.4.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
pytetwild-0.4.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
pytetwild-0.4.2-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details

Total release size: 34.2 MB

Release files / pytetwild-0.4.2.tar.gz

Download URL pytetwild-0.4.2.tar.gz
Size 2.6 MB
Tags Source
SHA-256 checksum
How to use checksums
60b88a5c9d0fd3cba24b3ab677b6a8344161de958622ce301bd3913fc1f4b917
BLAKE2b-256 checksum
How to use checksums
3d66925933fde3a76a38792f89eb4546ca96f861b4922fbacb4b9c3ee7b994e1
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp312-abi3-win_amd64.whl

Download URL pytetwild-0.4.2-cp312-abi3-win_amd64.whl
Size 2.2 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2d04cbe669c2795decd8e7cfb9e3dfe3f603cce89507bd528b0ae0400c4d3912
BLAKE2b-256 checksum
How to use checksums
03949cab38f8904985bdd4f2a34e1c1aee3149827d5d87bded7c0dc4e8e3ca0f
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pytetwild-0.4.2-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e387d6c2803edaeeee7b970ebf157c281a7ee8b257e6c522e26557314ae0e765
BLAKE2b-256 checksum
How to use checksums
d8ea10e1219ff042b3e01cdfc8a1734b4e4fde8d865d69ad591ad8eb91022839
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pytetwild-0.4.2-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.8 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2a1749d4d79fc6c38e901d678b030f48b9bd7bce9387fab35e18f286e28d3d2e
BLAKE2b-256 checksum
How to use checksums
34062c4a9e0ad48f11e246df75b224c8558367a58212cbc8fb8e86b493926193
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp312-abi3-macosx_15_0_arm64.whl

Download URL pytetwild-0.4.2-cp312-abi3-macosx_15_0_arm64.whl
Size 2.4 MB
Tags CPython 3.12 abi3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
e70693fcbe493341778ccbe9ce5bea2e449d998e12e57753d2ffc7cf788174a4
BLAKE2b-256 checksum
How to use checksums
d20825d686ee70e6abcff53420829afed5a270ef9c8ac25876148cc0fbea9d22
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp311-cp311-win_amd64.whl

Download URL pytetwild-0.4.2-cp311-cp311-win_amd64.whl
Size 2.2 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
b71487fd79408da6bcc85191566a3d03e7184dab0eae5917d2247a484efdcda6
BLAKE2b-256 checksum
How to use checksums
986edae3491b3fd00411bd91c2758537055089e484b9eb981f7d0e658b20569e
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pytetwild-0.4.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
4b5a369785bd3b9cdc18612af0d1d0257e6dbec4605b963d32a4cc5cdc098cb5
BLAKE2b-256 checksum
How to use checksums
ca939f3fc1be788043c90eac91974cb7db064cc318007d5d274f707204b14a35
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pytetwild-0.4.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.8 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
6df71b77e84c7a5b8e02332ce89918d54023fd35ac0775ddaf336e4070b884b6
BLAKE2b-256 checksum
How to use checksums
4e1cdc7979cd32ee78392930f11c84c90ad63ee6d7922270f53c625431bdea6a
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp311-cp311-macosx_15_0_arm64.whl

Download URL pytetwild-0.4.2-cp311-cp311-macosx_15_0_arm64.whl
Size 2.4 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
e090cac6f9306f83edeecf12d8cc3847e526df13443e8d5ed68d26eef7da2091
BLAKE2b-256 checksum
How to use checksums
2feb97351e6dffe285ca5e235ed7403ec33cf6796fdc25333cc72a7bc052a529
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp310-cp310-win_amd64.whl

Download URL pytetwild-0.4.2-cp310-cp310-win_amd64.whl
Size 2.2 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
c598c9f3f383d6abb89cee1cadc254d3e74fa0f31a3514f2aed661b82ea057b2
BLAKE2b-256 checksum
How to use checksums
72381c508c8defb174335f9df9176f4ad376c2347017757a29f556dbb356ca70
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pytetwild-0.4.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1237a31c66d8944dc6e7c656457a31c97699e581653ea78de212cd7b9d063065
BLAKE2b-256 checksum
How to use checksums
e380abb7e70eda2060174c14d1b74d625fe9264badf79d9339301f85d0cf8745
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pytetwild-0.4.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
e96f9aae1682083608c12414610f49041d87d9249bf8bffa62dcd82323450f08
BLAKE2b-256 checksum
How to use checksums
bab90a53324995420079a71dd8940165152c8c08a2393584f82e2c624cf250cb
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 17, 2026.

Transparency log

Release files / pytetwild-0.4.2-cp310-cp310-macosx_15_0_arm64.whl

Download URL pytetwild-0.4.2-cp310-cp310-macosx_15_0_arm64.whl
Size 2.4 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
de4a05cee32888cd918044c51646af7949ea2832bfa6a28656279c1cba265549
BLAKE2b-256 checksum
How to use checksums
9011177315bf81bf801ab42c6a2ee518fbc782edaecbde90e5730a0d68c4c7dd
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 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.2 This release

13 release files

0.4.1

13 release files

0.4.0

9 release files

0.3.0

13 release files

0.1.1

17 release files

0.1.0

13 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