TETGENLINK TUTORIAL

Introduction

TetGen is a quality tetrahedral mesh generator and a three-dimensional Delaunay triangulator. It is used by the Wolfram Language for various operations, such as interpolation in three-dimensional convex domains.

TetGenLink is a Wolfram System application that makes the functions of TetGen available to the Wolfram Language. This is done with Wolfram LibraryLink, which allows TetGen to be used in a high-speed and low-memory fashion. TetGenLink is used automatically by other Wolfram Language functions. However, it can also be used directly, which gives a flexible and innovative way to use the functionality of TetGen.

To use the application it must first be loaded.

In[1]:=
Click for copyable input

Now you can create an instance of a TetGen object.

In[1]:=
Click for copyable input
Out[1]=

This sets up points and facets to use.

In[2]:=
Click for copyable input

In the following, the points and facets are plotted as a three-dimensional outline.

In[4]:=
Click for copyable input
Out[4]=

Here, the points and facets are set in the instance.

In[5]:=
Click for copyable input

The following creates a new TetGen instance that contains the result of meshing the first.

In[7]:=
Click for copyable input
Out[7]=

This gets the points and faces for the generated mesh.

In[8]:=
Click for copyable input

The generated mesh can be plotted, as shown below.

In[10]:=
Click for copyable input
Out[10]=

If you plot just the wire frame, you can see that this just includes the exterior of the mesh.

In[11]:=
Click for copyable input
Out[11]=

If you want to get all the triangularization of the interior, you can do this with TetGenGetElements.

In[12]:=
Click for copyable input

The wire frame plot is more complicated since it contains the interior.

In[14]:=
Click for copyable input
Out[14]=

When you have finished with the meshes, you can release them as shown in the following.

In[15]:=
Click for copyable input

Loading a Dataset

TetGen can read and write several formats of mesh data. This is useful since it lets you work with meshes created in other applications and also save meshes created by TetGen to use elsewhere.

TetGenLink contains a number of sample data files that are useful for demonstrations.

To use the application it must first be loaded.

In[17]:=
Click for copyable input

This sets up the location of some data files in the TetGenLink installation.

In[18]:=
Click for copyable input

This creates a TetGen instance and then loads point and facet information from the data into it.

In[19]:=
Click for copyable input

Next, you create a tetrahedron mesh.

In[22]:=
Click for copyable input
Out[22]=

Here, the points and faces are extracted from the TetGen instance.

In[23]:=
Click for copyable input

Finally, a plot is made of the points and faces.

In[25]:=
Click for copyable input
Out[25]=

You can then work with the TetGen mesh to carry out refinement or some other computation. Here, the instances are removed to free the resources.

In[26]:=
Click for copyable input

TetGen Details

TetGen is created by Hang Si, Research Group: "Numerical Mathematics and Scientific Computing", Weierstrass Institute for Applied Analysis and Stochastics (WIAS), Berlin. More information can be found at http://tetgen.org.