pyvista / tetgen

A Python interface to the C++ TetGen library to generate tetrahedral meshes of any 3D polyhedral domains
http://tetgen.pyvista.org
Other
219 stars 32 forks source link

tetrahedralize input arguments `opt_scheme` and `steinerleft` are simply ignored #55

Open MbBrainz opened 1 year ago

MbBrainz commented 1 year ago

Im trying to generate a tetrahedral mesh that has to have exactly the same vertices as those that are given in the input. I've had trouble with understanding why my mesh was still wrong, but apparently the parameters are just ignored?

In the case that the variables that i set cause tetgen to fail to tetrahedralise, it should break, instead of ignore the parameter.

According to the tetgen documentation the opt_scheme=0 should prevent the algo from optimizing:

The integer for choosing operations is ranged from 0 to 7. Here 0 means no operation is chosen (hence no mesh optimization will be done). Each operation is enabled/disabled by setting the corresponding bit in this integer.

The 1st bit (the least significant bit) enables/disables edge/face flips. The 2nd bit enables/disables vertex smoothing. The 3rd bit enables/disables vertex insertion/deletion.

And according to the pytetgen docs steinerleft=0 should result in no steinerpoints being added:

steinerleft (int, optional) –

Steiner points are points added to the original surface mesh to create a valid tetrahedral mesh. Settings this to -1 will allow tetgen to create an unlimited number of steiner points, but the program will likely hang if this is used in combination with narrow quality requirements. Default 100000.

The first type of Steiner points are used in creating an initial tetrahedralization of PLC. These Steiner points are mandatory in order to create a valid tetrahedralization

The second type of Steiner points are used in creating quality tetra- hedral meshes of PLCs. These Steiner points are optional, while they may be necessary in order to improve the mesh quality or to conform the size of mesh elements.

Reproduce:

import pyvista as pv
import tetgen

meshes = [pv.Sphere(radius=i).triangulate() for i in range(10)]
merged = pv.PolyData()
for mesh in meshes:
    merged += mesh

tet = tetgen.TetGen(merged)
tet.tetrahedralize(order=1, opt_scheme=0, steinerleft=0, minratio=10, verbose=True)

shows the following logs in the console:

  ...
  Removed 6260 edges/faces.
  Smoothed 55 vertices.
  Added 56 Steiner points.
  ...
MbBrainz commented 1 year ago

I just found out that when using the switches so for optimisation lvl 0 `tetrahedralize(switches="O/0") does generate the correct output.