|Convex Hull||Meshing a Box (Advanced)|
|Delaunay Tetrahedralization||Engineering Example|
|Meshing a Box (Basic)||Possible Issues|
Now you can compute the convex hull of the 3D points. TetGenConvexHull will return a list of points and surface triangles.
Each surface triangle is a list of three integers. These integers refer to the coordinates. You can plot them by using GraphicsComplex.
You can compute the Delaunay tetrahedralization of the data with TetGenDelaunay.
The result is a list of points and tetrahedra. The list of tetrahedra is a list of four integers that refer to the coordinate positions. To visualize the tetrahedra as a wireframe, you can use a supporting function.
To set the points in the TetGen instance, use TetGenSetPoints.
The tetrahedralization is done with TetGenTetrahedralize.
The tetrahedralization is then done with the TetGenTetrahedralize command. The tetrahedralization works on the TetGen input instance. A string of parameters (TetGen string codes) may be given to specify requirements on the resulting mesh. The "p" string tetrahedralizes a piecewise linear complex, and the "q" switch requests a quality mesh generation. A minimum radius-edge ratio may be specified (the default is 2.0). The "a" switch followed by a number applies a maximum tetrahedron volume constraint. Once TetGen has completed the mesh generation process, a new TetGen instance is returned. The output instance contains all the data of the mesh.
A visualization of the triangulated surface can be done with a GraphicsComplex.
To extract the tetrahedra you use TetGenGetElements.
A list of all TetGen instances is accessible through TetGenExpressions.
To clean up, you delete the input instance and the output instance of TetGen with the TetGenDelete command.
What follows is a more detailed example of meshing a box. Here you will see how to specify the input to TetGen to create a hole in the box, an opening in the surface with a cavity, different (material) regions, and attribute markers to coordinates, faces, and elements. Also, a refinement of the mesh is shown.
Next, the list of facets is created. If a facet list has more than one entry, like the third facet in this example, the first facet represents the bounding facet and the subsequent facets indicate where the bounding facet should have an opening.
Then set the facet holes in the TetGen input instance with the TetGenSetFacetHoles command.
In the next step you can specify markers. TetGen provides you with the ability to propagate so-called markers. Markers are a convenient way to access grouped parts of the mesh object. This grouping can then be used to specify boundary conditions and regions in the mesh. TetGen allows you to specify markers for points, faces, and elements.
You start by assigning each coordinate point an integer, also called a marker. Once the mesh is created, TetGen will mark each newly created coordinate point according to the markers specified in the input instance of TetGen. In a similar manner, facets and regions are marked.
For each node and facet, you assign an integer according to the following table. This will group different parts of the surface representation together.
1 — bottom part
2 — top part
3 — side walls
4 — cavity/hole
9 — middle part
To visually explore the facets and the attributed markers, you can use a Manipulate. By selecting and deselecting you can visualize facets according to the markers they have been assigned.
TetGen works by meshing the entire object first and then in a second step removing the mesh from holes and cavities. Note that the cavity also needs a point to specify where it is situated. The point that specifies the opening is not sufficient. To specify where TetGen should put holes, you use TetGenSetHoles.
You can specify two different material domains by placing a point in each of them and then assigning a region number to them. Contrary to the point and facet markers, the region attributes are real numbers. With a region constraint you can additionally specify the required coarseness of the mesh in the different regions.
To generate a mesh from the facets, you give the options "p" and "q" as above, and the options "a" and "A" are needed for the maximum element size you specified with the region attribute. The switch "n" directs TetGen to compute the neighbors and the switch "e" directs it to compute the edges. For a complete list of switches, visit http://tetgen.org.
To extract the faces and visualize them, you use TetGenGetFaces.
To extract the face markers, you use TetGenGetFaceMarkers.
You can explore the facets and their markers with a Manipulate.
TetGenGetElements gets the tetrahedra from the output instance.
To efficiently visualize them, you use the following supporting function. This sorts each face of every tetrahedron, and, by finding the union of all sorted faces, the duplicate interior faces are removed. For very large meshes, making use of this technique will result in a shorter rendering time for the graphics.
To extract the attributes of the elements, you use TetGenGetElementAttributes.
Also, the list of neighboring elements can be retrieved. Each entry in the neighbor list is a list of four neighboring tetrahedra. Should a tetrahedron be on a boundary, then the respective entry is set to .
To refine an existing mesh, TetGenTetrahedralize is called once more on a TetGen instance. Now, however, with the "r" switch to request a refinement and the "a" switch with a new maximum tetrahedron volume. The "a" switch will now override the region constraints.
The surface of the meshed object can be displayed through a GraphicsComplex.
You extract the tetrahedron elements with the TetGenGetElements command.
If you have a C compiler, you also might want to give the option CompilationTarget->"C" to gain further speedups.
A potential issue that will result in a failed tetrahedralization can be caused by intersecting facets. To detect if a surface mesh has intersecting facets, TetGenDetectIntersectingFacets can be used. TetGenDetectIntersectingFacets returns a list of points and intersecting facets, should there be any.