Skip to content

TetGen volumetric meshing fails on manifold STLs due to Delaunay criterion (Fixed with PyACVD uniform remeshing) #68

Description

@mmegally

Description

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\svv\domain\domain.py", line 442, in build
self.get_interior()
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\svv\domain\domain.py", line 734, in get_interior
_mesh, nodes, vertices = tetrahedralize(self.boundary, order=1, nobisect=True, verbose=verbose, **kwargs)
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\svv\domain\routines\tetrahedralize.py", line 209, in tetrahedralize
raise RuntimeError(
RuntimeError: TetGen worker failed with code 1
STDOUT:

STDERR:
Traceback (most recent call last):
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\tetgen\pytetgen.py", line 608, in tetrahedralize
self.node, self.elem = _tetgen.Tetrahedralize(
File "tetgen\cython\tetgen\_tetgen.pyx", line 469, in tetgen._tetgen.Tetrahedralize
RuntimeError: Unknown exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\svv\domain\routines\tetgen_worker.py", line 45, in
main(sys.argv[1], sys.argv[2], sys.argv[3])
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\svv\domain\routines\tetgen_worker.py", line 22, in main
result = tgen.tetrahedralize(*args, **kwargs)
File "C:\Users\micha\miniconda3\envs\svv\lib\site-packages\tetgen\pytetgen.py", line 699, in tetrahedralize
raise RuntimeError(
RuntimeError: Failed to tetrahedralize.
May need to repair surface by making it manifold:
Unknown exception

Reproduction

mesh = pv.read('baffle_sample.stl').triangulate()
baffle = Domain(mesh)
baffle.create()
baffle.solve()
baffle.build()

Note: was also able to reproduce this issue with the GUI.

Expected behavior

For my use case, we verified the mesh is manifold, watertight, etc. It seems like TetGen fails to generate the volumetric mesh in my case because some surface traingles do not satisfy the Delauney criterion. By using Voronoi clustering to force uniform, isotropic triangles, baffle.build() passes with no issues and TetGen successfully generates the volumetric mesh. When I ran the below code the baffle.build() line ran with no issues:

import pyacvd

mesh = pv.read('baffle_sample.stl').triangulate()
base_mesh = mesh.clean(tolerance=1e-5).triangulate()
clus = pyacvd.Clustering(base_mesh)
clus.subdivide(3)
clus.cluster(20000)
uniform_mesh = clus.create_mesh()
baffle = Domain(uniform_mesh)

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions