tetgen
tetgen copied to clipboard
Quadratic tet meshing causes python to crash!
Describe the bug, what's wrong, and what you expected.
Tetgen tetrahedralization with quadratic elements causes Python to crash on surface meshes with concave structures (e.g. a hole), although linear meshing works.
Steps to reproduce the bug.
import pyvista
import pyacvd
import pymeshfix
import tetgen
cyl = pyvista.Cylinder()
cylScale = cyl.scale([2,0.5,0.5]).triangulate()
sphere = pyvista.Sphere()
sphereCut = sphere.boolean_difference(cylScale)
clus = pyacvd.Clustering(sphereCut)
clus.subdivide(3)
clus.cluster(sphereCut.n_points)
remesh = clus.create_mesh()
clus2 = pyacvd.Clustering(remesh)
clus2.subdivide(2)
clus2.cluster(1000)
remesh2 = clus2.create_mesh()
fixer = pymeshfix.MeshFix(remesh2)
fixer.repair()
fixMesh = fixer.mesh
tet = tetgen.TetGen(fixMesh)
tet.tetrahedralize(switches='pq1.1/20Ya0.003o2')
grid = tet.grid
### System Information
--------------------------------------------------------------------------------
Date: Tue Jul 12 13:51:39 2022 CEST
OS : Darwin
CPU(s) : 4
Machine : x86_64
Architecture : 64bit
RAM : 8.0 GiB
Environment : Jupyter
File system : apfs
GPU Vendor : Intel Inc.
GPU Renderer : Intel Iris OpenGL Engine
GPU Version : 4.1 INTEL-16.5.9
Python 3.9.12 (main, Apr 5 2022, 01:53:17) [Clang 12.0.0 ]
pyvista : 0.34.1
vtk : 9.1.0
numpy : 1.21.5
imageio : 2.9.0
appdirs : 1.4.4
scooby : 0.5.12
matplotlib : 3.5.1
PyQt5 : 5.9.2
IPython : 8.2.0
colorcet : 1.0.0
scipy : 1.7.3
tqdm : 4.64.0
meshio : 5.3.4
Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904
for Intel(R) 64 architecture applications
--------------------------------------------------------------------------------
Screenshots
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Looks like the default settings work:
tet = tetgen.TetGen(fixMesh)
tet.tetrahedralize()
grid = tet.grid
grid.plot(show_edges=True, background='w')
I'd play around with the parameters until you get something that works.
If you can't get it to work with your desired parameters, you may consider downgrading to tetgen==0.5.5
with:
pip install tetgen==0.5.5
I've run into issues after upgrading support for tetgen 1.6
Hi Alex,
thank you very much for your answer. The default setting has always worked for me as well because it uses linear elements, but if you try to use quadratic elements with order=2 or the switch o2, Python crashes.
However, using the tetgen version 0.5.5 with some adjustments on the switches also seems to work for quadratic elements.
Thanks! Simon
However, using the tetgen version 0.5.5 with some adjustments on the switches also seems to work for quadratic elements.
There's been a request to add support for the older version of tetgen 1.5 and potentially use that as a default. There might be some fundamental issue with 1.6.
Good to know, thanks Alex!
Hi Alex,
I tried everything with tetgen 1.5 (python 0.5.5). Even though quadratic meshing works now (is even the default), using the C++ switches causes python to crash. And the working python inputs are limited. So for example, quality, minratio, and mindihedral work but there is no working volume control (like there would be with the switch -a followed by a number). What causes this issue and are there any intended efforts in solving this problem in the future?
Thanks for your help! Simon