Skip to main content

Python interface to pytetgen

Project description

This python module is a python interface to Hang Si’s tetgen C++ software. This module combines speed of C++ with the portability and ease of installation of Python along integration with the visualization toolkit VTK . See the tetgen GitHub page for more details on the 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 --user

From source at GitHub

git clone https://github.com/akaszynski/tetgen
cd tetgen
pip install . --user

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.

from vtkInterface import examples
import vtkInterface as vtki
import tetgen
import numpy as np

sphere = vtki.PolyData(examples.spherefile)
tet = tetgen.TetGen(sphere)
tet.Tetrahedralize(order=1, mindihedral=20, minratio=1.5)
grid = tet.grid
grid.Plot()
https://github.com/akaszynski/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.ExtractSelectionCells(cell_ind)

# advanced plotting
plotter = vtki.PlotClass()
plotter.SetBackground('w')
plotter.AddMesh(subgrid, 'lightgrey', lighting=True)
plotter.AddMesh(sphere, 'r', 'wireframe')
plotter.AddLegend([[' Input Mesh ', 'r'],
                   [' Tesselated Mesh ', 'black']])
plotter.Plot()
https://github.com/akaszynski/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', colormap='bwr', flipscalars=True)
https://github.com/akaszynski/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.1.0.tar.gz (275.1 kB view details)

Uploaded Source

Built Distributions

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

tetgen-0.1.0-cp36-cp36m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6m

tetgen-0.1.0-cp35-cp35m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.5m

tetgen-0.1.0-cp27-cp27mu-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 2.7mu

tetgen-0.1.0-cp27-cp27m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 2.7m

File details

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

File metadata

  • Download URL: tetgen-0.1.0.tar.gz
  • Upload date:
  • Size: 275.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tetgen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3f92578832336231fb1a0398886dd448509142aa27b6c6facd8bd9531701d72
MD5 ad53e1c099abfa2bc9c718cb994421c8
BLAKE2b-256 7e8b5686d17bbf6f69b65e301a40b05ed9856b5822df395fdb381637274effaa

See more details on using hashes here.

File details

Details for the file tetgen-0.1.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for tetgen-0.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 deec92bd97135985d4752f018c66e76a7c6fb13317214a558881648029b5ed2c
MD5 5d758b384e20751e761645b246605160
BLAKE2b-256 b4ef11b905e85740423a26a404e1281e1efbc27b2c2065f7bfd56534cf052a1b

See more details on using hashes here.

File details

Details for the file tetgen-0.1.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for tetgen-0.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 47a5a91647082b12e455cb494863d7f6c2459c304d78faf15b0a6a1c05c0bf88
MD5 bc5552f5d5267bc36eaf3ae8289677a5
BLAKE2b-256 0b47fffd9cc7e81686d8796ab364c67747245468c3a8d56a6f811b1ad36af945

See more details on using hashes here.

File details

Details for the file tetgen-0.1.0-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for tetgen-0.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3a606b7c3bdc2c67a464b77b3c6ea1141374667549e5b5e110644929cf0bb6fc
MD5 c8ea5b939dea0b35acd34b8c92e6af99
BLAKE2b-256 7b3d3b485a722964132455767db433fccaa8dc3db57e959ca4da89fb6e48d04c

See more details on using hashes here.

File details

Details for the file tetgen-0.1.0-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for tetgen-0.1.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e8fde3b9b0e1378fb29649fc04674feb4ef7b79e386eef430327c0462f52a6b2
MD5 c81a7c15071cc573708750192787bd3c
BLAKE2b-256 2e505c9b034e106d060d76cd2a3270f89c300b1d1b49838b3a338516eedd63ea

See more details on using hashes here.

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