Python interface to tetgen
Project description
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.
This python module uses the C++ source from TetGen (version 1.5.1, released on August 18, 2018) hosted at ufz/TetGen.
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 -r requirements_build.txt
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
pv.set_plot_theme('document')
sphere = pv.Sphere()
tet = tetgen.TetGen(sphere)
tet.tetrahedralize(order=1, mindihedral=20, minratio=1.5)
grid = tet.grid
grid.plot(show_edges=True)
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.add_mesh(subgrid, 'lightgrey', lighting=True, show_edges=True)
plotter.add_mesh(sphere, 'r', 'wireframe')
plotter.add_legend([[' Input Mesh ', 'r'],
[' Tessellated Mesh ', 'black']])
plotter.show()
Here is the cell quality as computed according to the scaled jacobian. This example uses the ansys.mapdl.reader library to compute the quality.
Compute cell quality
>>> from ansys.mapdl.reader import quality
>>> cell_qual = quality(subgrid)
Plot quality
>>> subgrid.plot(scalars=cell_qual, stitle='Quality', cmap='bwr', clim=[0, 1],
... flip_scalars=True, show_edges=True)
Acknowledgments
Software was originally created by Hang Si based on work published in TetGen, a Delaunay-Based Quality Tetrahedral Mesh Generator.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for tetgen-0.5.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcbf7fe3ee5e1b39ef3f01e9b64a95c8b2af44bea59fa8dd24b9e98ea3e1f3b9 |
|
MD5 | a0c24a342f645776b7710f5b74f70f82 |
|
BLAKE2b-256 | d4c6fa4072e332d632271f9ce113e5a7e6b68bb2b6fd3287869f4cdc645dc007 |
Hashes for tetgen-0.5.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 857c59abf2e1c7117f89a0dc24ab08b48edfc2ffdd01b76dd6b2ad0d468d92b8 |
|
MD5 | 553f69ea88de0d04fce1bb5990f9c39d |
|
BLAKE2b-256 | fece7adbb4bd17651d183ae8fe120cea1705fc26b055c25dcb102b5455ab63b2 |
Hashes for tetgen-0.5.5-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a6ad98dc6f2f72e3b4612db793501377fd72ffbcd281b5760fd1201c9a353b3 |
|
MD5 | d00ff003f4e2070d06b31ff7cc35f98c |
|
BLAKE2b-256 | b9368df1b99808c838de78836e18f50a062f68a36059b213124854c0290f7ea8 |
Hashes for tetgen-0.5.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38d350c4794b375ce023f4ed993f1b5a6bb720a117d8ef173e5919c4b8851e7c |
|
MD5 | b2cdbd873477e720f93c9788556c1aed |
|
BLAKE2b-256 | 934e8a47844cec5bc8a0a26d1a778b4e195d89aadee82d42340973ce6c31ba26 |
Hashes for tetgen-0.5.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bb5024af781f041ed1d54c6659f9d6316c568f526d95aa9d24b035c20d6d012 |
|
MD5 | 6bcdde4d127db729db35fd6e67507db5 |
|
BLAKE2b-256 | 933dfbc877514519ed51ec06c3b67c1bcd99c4d05463940f4a88a6729b6a8b9a |
Hashes for tetgen-0.5.5-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f2d2f63837ee72f3b2b6408369880990ccd101ec2e853d28f89f4bdb6cad58b |
|
MD5 | 6a5e9935bac85bbee0ee70f850ad15d5 |
|
BLAKE2b-256 | 947cefb84df3449301717e47940502708b0077972d7dac068f556604a88d6b38 |
Hashes for tetgen-0.5.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d957801d72523dc11a78fda4a8b9fbf9cccc1fda5b62eb91e6b4f931c0ed2dea |
|
MD5 | dfbdb9049bfa23f70577ddb2cec2d140 |
|
BLAKE2b-256 | 568133d09bb6c88a43842ec6bae519c9f14b9d046bc6fe587e3b0f06933eb4b8 |
Hashes for tetgen-0.5.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a1e180ab7f7d7a170030fe0e6210e5d856f4a977a304aa183265b03addb2359 |
|
MD5 | 4ab28caa27b77f40c04feafd97f0cc36 |
|
BLAKE2b-256 | 9a58e8a832ae7059560b40421d1b071f8be9848f5bc24b790c96a8a43894425f |
Hashes for tetgen-0.5.5-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c5d1a8b7ae2443dea8665b8143f039c083bedea4b1692338e47eb625688f139 |
|
MD5 | ac6bad8ff6e3cb8855a8c00ec425ff14 |
|
BLAKE2b-256 | 220b01580f788516242bee386838a90dab72cb1f4313136e45a5d565041515ca |
Hashes for tetgen-0.5.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d99ece6a6046fe66983dfb02905687eca155ae7d43f697dd5d059bbdd45aa7c9 |
|
MD5 | 4537746bfb8a6ed5ec34a3c1bcf9fe6b |
|
BLAKE2b-256 | 723cabbdc6a3989ac5f280d08746cd4ef88e469a7258de0273a01c3359a086a1 |
Hashes for tetgen-0.5.5-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8d36a7814b0bec283ff138afa762a9b6d91cd60df3a38caa6ce661d9c7f0afe |
|
MD5 | c34a160777be93cf98669d82eedb285b |
|
BLAKE2b-256 | e6d38b69e03a603c0f999d73a09a0fb4d4d818af8eaa848f8a0e7fe45db01cca |
Hashes for tetgen-0.5.5-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 495830a72bd1c5b98f7bfa9ff7dfa39dc8bb79fb26639ba57db572c89c002c63 |
|
MD5 | 7092049f6bff52f4ffeefefd706332a8 |
|
BLAKE2b-256 | c98808a5217c8e2c525be16a1f5e541ae3100a63de7de7ad35dc414a9ddc6047 |