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.2.3.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.2.3-cp312-abi3-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.12+Windows x86-64

pytetwild-0.2.3-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.2.3-cp312-abi3-macosx_15_0_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12+macOS 15.0+ x86-64

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

Uploaded CPython 3.12+macOS 15.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pytetwild-0.2.3-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.2.3-cp311-cp311-macosx_15_0_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

pytetwild-0.2.3-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.2.3-cp310-cp310-macosx_15_0_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

pytetwild-0.2.3-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.2.3.tar.gz.

File metadata

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

File hashes

Hashes for pytetwild-0.2.3.tar.gz
Algorithm Hash digest
SHA256 406c8dd06d0c2e0860a7715af370fd6832abdd1362d909f2f954d90426f37446
MD5 2ec4c7720dc4cd04acde716886e4723a
BLAKE2b-256 0bb06fd3f4f4df2ce882d12a610913631a7e5bad8e31672dfe2a9836f22c5e4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3.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.2.3-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pytetwild-0.2.3-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.7

File hashes

Hashes for pytetwild-0.2.3-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b6174cb7595e8a06926a2114d7a845990cf9082a505ba91d26b742ecfb4b9b87
MD5 8d5f5a9d60da1e6f9e3ea650074bdc1b
BLAKE2b-256 e106458cee4b67eee745bac68c06898954d1d111fa65ed0899ecfe5fdfd2bd67

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ad6617e4d01f695bee0e246a2d7ef986282f5967afe11e06129ae4e6f00e2022
MD5 ab4aee59333f72a2a8610587c057cf2a
BLAKE2b-256 84ea1db79f6b3379f964ee8c8bcf0651c4b62ac96d5c34a9cba5daffc43dcc6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp312-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp312-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 e692f956f4db511d27521049377a449ccc962224527d0b27c8e3703c3523296b
MD5 ead02f1232d02f826fffc233d249f551
BLAKE2b-256 9ff0edca864530a697c1b96dd4c604f48cd51706c28f114f227acd7291e632ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-cp312-abi3-macosx_15_0_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.2.3-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c3082a789262d358c5f471785e7d70204f2e65132f360e979aa201c8db2cbff5
MD5 f5a30a55218022a5815c8e87f98319cb
BLAKE2b-256 fe981383bb1205fe928093dd9893d55675c46a5ba237b5d01ead5f991e185ee1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pytetwild-0.2.3-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.7

File hashes

Hashes for pytetwild-0.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 042559013e3c2fe9afc41d8dcc4ed43837974ad83e5f37da984cd766e3565904
MD5 ebb59d85a7da9b118f7916303de21314
BLAKE2b-256 3c9621c0f9172fb78acc6db54b18ba81ed172475329f7353df6eed085e4d5443

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 cc29aa2160630f3d4111d2a3b2927787b13c1f922270f747176098c79100e51e
MD5 9182010f208430aded500b62520ad7d9
BLAKE2b-256 9606bbfb06144d41a115e586d5a03759a855d3bb31e5eb7df48b87a88a71b7fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 de02a188d3975be9c9b0ab92f5002f119fa1ab4762fa0137aec4cae486876667
MD5 76415df981aca7429b4c21c422542682
BLAKE2b-256 b2da8ceb9b6efad7df50130ebdfb0bdfd8213c1958a4ab2663905e26a1c1171e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-cp311-cp311-macosx_15_0_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.2.3-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f78b704b8ebe97a5f224837043f14a1121f482b5261bb7dd1e825d10d1c67617
MD5 4853c96c3eb46408247755fe2ea1155d
BLAKE2b-256 d0853df1f0101daaf390d69256c0dda6747f9340d144b2d0683a0a6dc41abe43

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pytetwild-0.2.3-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.7

File hashes

Hashes for pytetwild-0.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4c7a9643596e278010f9019e36d908700e74d8a33759d2cd356d33bdc7be74bb
MD5 104ea1235399f0abfbb5c322ccd28988
BLAKE2b-256 88f506400c0ed63a774b7ddc71886c37253e65c0d63a18a4c68f9d08b9b7d4f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 85392f7d3d5543871f98560e373c5ed2e9c3b61c8f455d9bd897bbfb08f83a91
MD5 e2eaafdaa5b7a0bcf34ef34a9eec8e16
BLAKE2b-256 1dfc0c5b459a171b9129e9271475a1fb4f518d0021cf4579ff1380b479ea4c04

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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.2.3-cp310-cp310-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 c9b2a5169017527b3ba3dbb907b503cb377f7eee8d38da7503910994dd5fda72
MD5 98a5b335f7441e9578ec08a4c44cc402
BLAKE2b-256 06c9bea7f254997c731a543e6464fe4b1f5643db17207ea842e233c157c7d071

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-cp310-cp310-macosx_15_0_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.2.3-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pytetwild-0.2.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 75d7f509d25ab60f250e8488189a7035241266d3d9e986fdc74e95e61b6766f8
MD5 bfd61e9880136d2228950ea02dbd40e4
BLAKE2b-256 0567e206c04704e835c5d0b911c000aa44ec1b7ca9ae48adc723c1280c0c5bc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytetwild-0.2.3-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