Super ToroidΒΆ

Tetrahedralize a super toroid surface

# sphinx_gallery_thumbnail_number = 2
import pyvista as pv
import tetgen
import numpy as np
toroid = pv.ParametricSuperToroid()
tet = tetgen.TetGen(toroid)
tet.tetrahedralize(order=1, mindihedral=20, minratio=1.5)
grid = tet.grid
super toroid
# 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, color='lightgrey', lighting=True, show_edges=True)
plotter.add_mesh(toroid, color='r', style='wireframe')
plotter.add_legend([[' Input Mesh ', 'r'],
                    [' Tessellated Mesh ', 'black']])
super toroid

Cell quality using pyansys

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)
super toroid


/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pyvista/plotting/ PyvistaDeprecationWarning:
"stitle" is a depreciated keyword and will be removed in a future

Use ``scalar_bar_args`` instead.  For example:

scalar_bar_args={'title': 'Scalar Bar Title'}

  warnings.warn(USE_SCALAR_BAR_ARGS, PyvistaDeprecationWarning)

Total running time of the script: ( 0 minutes 3.764 seconds)

Gallery generated by Sphinx-Gallery