Skip to main content

Python interface to tetgen

Project description

https://travis-ci.org/pyvista/tetgen.svg?branch=master https://img.shields.io/pypi/v/tetgen.svg?logo=python&logoColor=white

This Python module is an interface to Hang Si’s TetGen C++ software. This module combines speed of C++ with the portability and ease of installation of Python along with integration to PyVista for 3D visualization and analysis. See the TetGen GitHub page for more details on the original creator.

The last update to the original C++ software was on 19 January 2011, but the software remains relevant today. Brief description from Weierstrass Institute Software:

TetGen is a program to generate tetrahedral meshes of any 3D polyhedral domains. TetGen generates exact constrained Delaunay tetrahedralization, boundary conforming Delaunay meshes, and Voronoi partitions.

TetGen provides various features to generate good quality and adaptive tetrahedral meshes suitable for numerical methods, such as finite element or finite volume methods. For more information of TetGen, please take a look at a list of features.

Installation

From PyPI

pip install tetgen

From source at GitHub

git clone https://github.com/pyvista/tetgen
cd tetgen
pip install .

Basic Example

The features of the C++ TetGen software implemented in this module are primarily focused on the tetrahedralization a manifold triangular surface. This basic example demonstrates how to tetrahedralize a manifold surface and plot part of the mesh.

import pyvista as pv
import tetgen
import numpy as np

sphere = pv.Sphere()
tet = tetgen.TetGen(sphere)
tet.tetrahedralize(order=1, mindihedral=20, minratio=1.5)
grid = tet.grid
grid.plot()
https://github.com/pyvista/tetgen/raw/master/docs/images/sphere.png

Tetrahedralized Sphere

Extract a portion of the sphere’s tetrahedral mesh below the xy plane and plot the mesh quality.

# get cell centroids
cells = grid.cells.reshape(-1, 5)[:, 1:]
cell_center = grid.points[cells].mean(1)

# extract cells below the 0 xy plane
mask = cell_center[:, 2] < 0
cell_ind = mask.nonzero()[0]
subgrid = grid.extract_cells(cell_ind)

# advanced plotting
plotter = pv.Plotter()
plotter.set_background('w')
plotter.add_mesh(subgrid, 'lightgrey', lighting=True)
plotter.add_mesh(sphere, 'r', 'wireframe')
plotter.add_legend([[' Input Mesh ', 'r'],
                    [' Tesselated Mesh ', 'black']])
plotter.plot()
https://github.com/pyvista/tetgen/raw/master/docs/images/sphere_subgrid.png

Cell quality scalars can be obtained and plotted with:

cell_qual = subgrid.quality

# plot quality
subgrid.plot(scalars=cell_qual, stitle='quality', cmap='bwr', flip_scalars=True)
https://github.com/pyvista/tetgen/raw/master/docs/images/sphere_qual.png

Acknowledgments

Software was originally created by Hang Si based on work published in TetGen, a Delaunay-Based Quality Tetrahedral Mesh Generator.

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

tetgen-0.4.0.tar.gz (328.0 kB view details)

Uploaded Source

Built Distributions

tetgen-0.4.0-cp37-cp37m-win_amd64.whl (295.6 kB view details)

Uploaded CPython 3.7mWindows x86-64

tetgen-0.4.0-cp37-cp37m-macosx_10_6_intel.whl (763.9 kB view details)

Uploaded CPython 3.7mmacOS 10.6+ Intel (x86-64, i386)

tetgen-0.4.0-cp36-cp36m-win_amd64.whl (295.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

tetgen-0.4.0-cp36-cp36m-macosx_10_6_intel.whl (763.5 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

tetgen-0.4.0-cp35-cp35m-win_amd64.whl (293.5 kB view details)

Uploaded CPython 3.5mWindows x86-64

tetgen-0.4.0-cp35-cp35m-macosx_10_6_intel.whl (759.3 kB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

tetgen-0.4.0-cp27-cp27m-macosx_10_6_intel.whl (769.4 kB view details)

Uploaded CPython 2.7mmacOS 10.6+ Intel (x86-64, i386)

File details

Details for the file tetgen-0.4.0.tar.gz.

File metadata

  • Download URL: tetgen-0.4.0.tar.gz
  • Upload date:
  • Size: 328.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

File hashes

Hashes for tetgen-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ec2200f3aede2d9089e0089751420dbb62c2b89ba131a7baae15499893b592b8
MD5 7bf91263b94e2053c2e675e50a738ab4
BLAKE2b-256 5a20b422b1b568253392500b735586a0d1adb3e36aac9a186c6e6fdbcce8e407

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 295.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.4

File hashes

Hashes for tetgen-0.4.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3df262e8ed4a120912dbe0c784708ab5760c5e63a22fbe3934aa3b7b2ab4f61f
MD5 f2c6710fa927edba26a1346b19b4ed04
BLAKE2b-256 d0920a11bad1b0208748d9b3a4b8318b0f0d83742abe36de9719cd0579855e5e

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 763.9 kB
  • Tags: CPython 3.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

File hashes

Hashes for tetgen-0.4.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 3bbbd5f023c341128c9c4c4c63a3b122317bf08c57e37191eb98a0767bc76efd
MD5 40b81f577207ff771cef94447767b5b3
BLAKE2b-256 88f9152bb87bdfc6f96b7c603d7c4efde037e84988604f21a787a3afb7c08d87

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 295.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.4

File hashes

Hashes for tetgen-0.4.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e96549aa2e25998ca6a3aeed2c37be7f139091a6bb47f3bb50530db45f3d2a25
MD5 19afc505de6c266f1a82243db13b2b7f
BLAKE2b-256 323a75077f11282b33c8a55c6ce1d2c8d82d73ad6e4a0bde48b400eaa23587a4

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 763.5 kB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

File hashes

Hashes for tetgen-0.4.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 7d03059a677941fd150fcb8bdc9b3021e0e8315ef1c4b3719ae22c47bf0468ef
MD5 a11ee33015a7d1c9faf47feefe27a91a
BLAKE2b-256 734fe0edfd70b5aec72b7c9ef84506c5028d894676dccd9782701d30b0e85845

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 293.5 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.4

File hashes

Hashes for tetgen-0.4.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 6556e344dcea65d1b0e108fc8688d83a0f5842a2226e229b5052d1dbf41db3f9
MD5 e92237aee3bd1139cd8d9c4f76edcacf
BLAKE2b-256 48e72732d5f42e6020ea3cdf2d17a291ec8052b3f8e0e6b4e16ee7c9fa73eb01

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 759.3 kB
  • Tags: CPython 3.5m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

File hashes

Hashes for tetgen-0.4.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 c5950d34e5a91914fe8d942ffe19d2f7f5de4cfcbdf5195f10bc860a21ed260d
MD5 fa04fd769281dbffbaf060eea9f39b8d
BLAKE2b-256 df8bcf5141c4518756c92f1bbcc9494df560d113fe5a83ff3efeb88fb23dcfc7

See more details on using hashes here.

File details

Details for the file tetgen-0.4.0-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

  • Download URL: tetgen-0.4.0-cp27-cp27m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 769.4 kB
  • Tags: CPython 2.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

File hashes

Hashes for tetgen-0.4.0-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 d771c390fa33b8cb954614922374fd09ec590c40089e1f70615da38e9d7b8ab4
MD5 cfcc9f2c935b025a4827bce49132797d
BLAKE2b-256 414d94c95acd74992e450c6b916960b3deb28772e90e58648fbc2b14a7f5100e

See more details on using hashes here.

Supported by

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