tet_mesh_refine, a MATLAB code which refines every tetrahedron in a tet mesh, replacing each tetrahedron by 8 subtetrahedrons.

In particular, TET_MESH_REFINE reads two files, one listing the coordinates of nodes, the other the indices of nodes forming tetrahedrons. From this information, it determines a refinement of the mesh, and writes out new node and tetrahedron files corresponding to this refinement.

The refinement of a single tetrahedron is easy. Every pair of nodes generates a new node whose location is the average of the locations of the original two nodes. The problem is that many tetrahedrons may share the same edge. The new node needs to be generated exactly once, and assigned a unique index, which all the tetrahedrons will share. The tricky part of this calculation is thus figuring out whether it is time to generate a new node, or whether the node has already been generated, in which case the appropriate index must be retrieved.

The current version of the code can only refine a tet mesh of order 4. There's no real reason why it could not also handle meshes of order 10, except that the programming is a bit more complex. For the moment, a mesh of order 10 could be handled by using the sequence of programs:



tet_mesh_refine 'prefix'
where 'prefix' is the common file prefix:

The input and output files use the simple TABLE format; comment lines begin with a "#" character. Otherwise, each line of the file contains one set of information, either the coordinates of a node (for a node file), or the indices of nodes that make up a tetrahedron, (for a tetrahedron file).

The input file nodes.txt contains the coordinate information for the tet mesh. Each data line contains the X and Y coordinates of a single node.

The input file tetras.txt contains the tetrahedron information for the tet mesh. Each data line contains the indices of the nodes that form a tetrahedron.

The output files have the same format.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


tet_mesh_refine is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Programs:

tet_mesh, a MATLAB code which includes a variety of routines for working with tetrahedral meshes.

tet_mesh_boundary, a MATLAB code which returns the nodes and faces of the boundary of a tetrahedral mesh, which themselves form a 3d triangular mesh or "tri_surface".

tet_mesh_display, a MATLAB code which can read in the node and tetra files defining a tet mesh and display a wireframe image.

tet_mesh_l2q, a MATLAB code which takes a 4-node tet mesh and makes a 10-node tet mesh by adding nodes.

tet_mesh_order4, a directory which contains a description and examples of a tet mesh using order 4 elements.

tet_mesh_order10, a directory which contains a description and examples of a tet mesh using order 10 elements.

tet_mesh_q2l, a MATLAB code which takes a 10-node tet mesh and makes a 4-node tet mesh.

tet_mesh_quality, a MATLAB code which takes a 4-node tet mesh and computes the "quality" of the mesh.

tet_mesh_rcm, a MATLAB code which takes a tet mesh and relabels the nodes to reduce the bandwidth of the corresponding adjacency matrix.


tet_mesh_tet_neighbors, a MATLAB code which computes the tetrahedral adjacency information.

tet_mesh_volumes, a MATLAB code which computes the volume of each tetrahedron in a tet mesh;


  1. Herbert Edelsbrunner,
    Geometry and Topology for Mesh Generation,
    Cambridge, 2001,
    ISBN: 0-521-79309-2,
    LC: QA377.E36.
  2. Barry Joe,
    GEOMPACK - a software package for the generation of meshes using geometric algorithms,
    Advances in Engineering Software,
    Volume 13, Number 5, 1991, pages 325-331.
  3. Anwei Liu, Barry Joe,
    Quality Local Refinement of Tetrahedral Meshes Based on 8-Subtetrahedron Subdivision,
    Mathematics of Computation,
    Volume 65, Number 215, July 1996, pages 1183-1200.
  4. Per-Olof Persson, Gilbert Strang,
    A Simple Mesh Generator in MATLAB,
    SIAM Review,
    Volume 46, Number 2, June 2004, pages 329-345.

Source Code:

Last revised on 02 April 2019.