Coder Social home page Coder Social logo

mdecourse / tetgen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pyvista/tetgen

0.0 0.0 0.0 27.79 MB

A Python interface to the C++ TetGen library to generate tetrahedral meshes of any 3D polyhedral domains

Home Page: http://tetgen.pyvista.org

License: Other

Python 3.10% C++ 96.81% Shell 0.09%

tetgen's Introduction

tetgen

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.

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 .

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)
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.add_mesh(subgrid, 'lightgrey', lighting=True, show_edges=True)
plotter.add_mesh(sphere, 'r', 'wireframe')
plotter.add_legend([[' Input Mesh ', 'r'],
                    [' Tesselated Mesh ', 'black']])
plotter.show()

https://github.com/pyvista/tetgen/raw/master/docs/images/sphere_subgrid.png

Cell quality scalars can be obtained and plotted using pyansys:

import pyansys
cell_qual = subgrid.quality

# plot quality
subgrid.plot(scalars=cell_qual, stitle='Quality', cmap='bwr', clim=[0,1],
             flip_scalars=True, show_edges=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.

tetgen's People

Contributors

akaszynski avatar banesullivan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.