Skip to main content

Python wrapper of fTetWild

Project description

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytetwild-0.3.0.tar.gz (2.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytetwild-0.3.0-cp312-abi3-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12+Windows x86-64

pytetwild-0.3.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

pytetwild-0.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (2.8 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

pytetwild-0.3.0-cp312-abi3-macosx_15_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12+macOS 15.0+ ARM64

pytetwild-0.3.0-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pytetwild-0.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pytetwild-0.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (2.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pytetwild-0.3.0-cp311-cp311-macosx_15_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pytetwild-0.3.0-cp310-cp310-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pytetwild-0.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pytetwild-0.3.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pytetwild-0.3.0-cp310-cp310-macosx_15_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pytetwild-0.3.0.tar.gz.

File metadata

  • Download URL: pytetwild-0.3.0.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytetwild-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8ea2c460036c757e8f0d27cd2ce3390afa675a1a4d031a6ce209326c592bd6ba
MD5 9ffdeb3b1b11f078672f6e1e29509665
BLAKE2b-256 2bdc55324467c4fe206331fda63d60231e9b6669b92afb2e19d0326913662db3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0.tar.gz:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pytetwild-0.3.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytetwild-0.3.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 11964e295a54cf9e2f6920a920aeeba27668c9b14e369a86f72ec5baa4f46060
MD5 7bf3f24175b1de58b31b7449b06f2cd2
BLAKE2b-256 129137a7ab51c1b779f784cbdfba2f773750ca1eba36b53df774ebe2fc8d6380

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp312-abi3-win_amd64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 387730c725a2dde82be4ae1269f0827a39d57a2a9401bb64d15574d4161960c0
MD5 960e9a28887ed52ed90c8dbdfe4fe31d
BLAKE2b-256 35936cba5f9c7e79ffb311ab5dc1e3019fb1a3d1d52ba1bfeac94b4e2ab573bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f316a039b725ebbffc09c9799df65d396f245b28c0604445e6293c0a5fe81efd
MD5 938f296a840d5be18d3f675f7e956e6f
BLAKE2b-256 e9e46ce7b61c473c9b924a067c3844aa3b116fea511dfdaf6aaef8e531bb73ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e0f7edd8d2e29f1439cf78dde9d2be63b3c0d4091d402b8cb291f5ca75c0312e
MD5 c5e51dff749b488ddb66cc9ee459fa9f
BLAKE2b-256 979b4c68c73658e5a0a5f50b82f76312c26e6fc3455baf244326a84a4f53103a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp312-abi3-macosx_15_0_arm64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pytetwild-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytetwild-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 25a1c670d03abc231a73e4a368d392931a41e5b6726866cda2ecda95b757f766
MD5 5e7ee8960e83dfa48245f3fbfd0f0787
BLAKE2b-256 97d4bdcd30be7d278cf2497f13d198b08b6e6fa6a0d5b10b0372359b153e7a16

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp311-cp311-win_amd64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 692e84313a06f53146a1c6600287815fb310f04cc762150c08ad313d4997c43a
MD5 5bba85b11fb25baa0595824550440370
BLAKE2b-256 db0a30a5764c798626192f67b49cd316bd3d3dace2bc0ef1f5c0d975fadf7bf7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 c11a96fc6c1e1521c6437c749cbdaae50b32f6758b5a1099928fea536b6fdfca
MD5 3ca39f9a6c327b6b70b812caf0d8f8b8
BLAKE2b-256 4666e96ad09771a95bfb27bb9f72fe2ea2cb934f6c8f74a45eda356d59122988

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b01222d31bb5f519583fbc1685b34b40b9c8fa321eb4523ea278f5db403521dd
MD5 415947d6b5953249555752de2503f2c2
BLAKE2b-256 fde35c3ff8cccd72a4fa15af89a28d5032f72ec9f11c660a8c133ac546a85402

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pytetwild-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytetwild-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e5e8d6c4902b852bd6a5b8ecc16155ea341a998f457e31d71f6fe132bdfbf945
MD5 799dd4d703d2503dcfd4b3090a27e88e
BLAKE2b-256 9f475dd26fff16a508308893d9f470293778612bd67adf7f07e2cb5ad6c4745a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp310-cp310-win_amd64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 57d17be76132b038bde09384141bf65b3906595b375b80e34899da2461f3d54d
MD5 441d55fbd209fc125d82c4283df098ca
BLAKE2b-256 e5a29cb714333bb14f51620ea00bc735b793b860e32d53557419efbb88f2deb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 d0a11212d237658ebbfcc4f1573091748117e3c2c76f3c929524fd1391e7b1e7
MD5 d72b3e3152ca2c2e31410077a1176c3c
BLAKE2b-256 b74fd9ad7ef301e76a1ba2cefc7516c8a48cd4507b6e0630bce101705438244f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytetwild-0.3.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pytetwild-0.3.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 7bda6ca512acbb431650cbe702b6c2936188a551805b969e3d7bc786b05390fb
MD5 40380cabbf3a9b6a9216aa82f66bede3
BLAKE2b-256 beadd2bfe83fe4e898295f40fcac17a54fa49a0d3c4fb0f3483aeb0d367d6025

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.3.0-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: build-and-deploy.yml on pyvista/pytetwild

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page