## DistMesh – is a simple MATLAB code for generation of unstructured triangular and tetrahedral meshes.

### News (Mar 16, 2005)

• A new function « fixmesh » removes duplicated and unused nodes from a mesh generated by DistMesh. It also makes the element orientations equal. This might be necessary when the mesh is used in, for example, a finite element code. Please download updated zip/tar files from below.
• Note that the current version of DistMesh requires true signed distance functions for the geometries. For example, an ellipse can not be modeled by scaling the x- and y-coordinates in the circle distance function. Instead, compute real distances (for the ellipse, see « dellipse »), or use the approximate projections that I proposed in Section 3.2 of my thesis (a very simple modification to DistMesh).

### Description

DistMesh is a simple MATLAB code for generation of unstructured triangular and tetrahedral meshes. It was developed by Per-Olof Persson and Gilbert Strang in the Department of Mathematics at MIT. A detailed description of the program is provided in our SIAM Review paper, see documentation below.

One reason that the code is short and simple is that the geometries are specified by Signed Distance Functions. These give the shortest distance from any point in space to the boundary of the domain. The sign is negative inside the region and positive outside. A simple example is the unit circle in 2-D, which has the distance function d=r-1, where r is the distance from the origin. For more complicated geometries the distance function can be computed by interpolation between values on a grid, a common representation for level set methods.

For the actual mesh generation, DistMesh uses the Delaunay triangulation routine in MATLAB and tries to optimize the node locations by a force-based smoothing procedure. The topology is regularly updated by Delaunay. The boundary points are only allowed to move tangentially to the boundary by projections using the distance function. This iterative procedure typically results in very well-shaped meshes.

Our aim with this code is simplicity, so that everyone can understand the code and modify it according to their needs. The code is not entirely robust (that is, it might not terminate and return a well-shaped mesh), and it is relatively slow. However, our current research shows that these issues can be resolved in an optimized C++ code, and we believe our simple MATLAB code is important for demonstration of the underlying principles.

To use the code, simply download it from below and run it from MATLAB. For a quick demonstration, type « meshdemo2d » or « meshdemond ». For more details see the documentation.

Download one of the following archives and unpack it to a directory. Add this directory to your MATLAB path, or make it the current directory. The code contains one C++ file (for polygon distance functions). Binaries for PC Windows and Linux compiled on MATLAB 6.5 are provided, as well as the source code.

If you are using MATLAB 6.1, download the following patch as well.

# DISTMESH_3D A Simple Mesh Generator in MATLAB

DISTMESH_3D is a set of MATLAB routines for the generation and manipulation of unstructured meshes in 3D. The code is relatively simple, and the user is able to define a variety of geometric shapes, and desired mesh densities.

DISTMESH_3D is, pretty much, simply the subset of Persson and Strang’s DISTMESH package that works on 3D problems.

### Related Programs:

CVT_TET_MESH is an executable FORTRAN90 program which uses CVT methods to compute a tet mesh in a region.

DISTMESH is a library of MATLAB routines for creating meshes, for 2D or 3D data.

GEOMPACK is a MATLAB library of routines which can compute the tet mesh for a set of 3D points, as well as the adjacency information.

MATLAB has a command delaunay3 that can compute the tet mesh for a set of 3D points.

TABLE is a data directory which contains a description and examples of TABLE files.

TABLE_IO is a library of MATLAB routines for reading and writing TABLE files.

TABLE_TET_MESH is an executable FORTRAN90 program which can compute the tet mesh for a given set of points.

TEST_TET_MESH is a library of FORTRAN90 routines defining test problems for 3D tetrahedral meshing.

TET_MESH is a library of MATLAB routines useful for tet mesh calculations.

TET_MESH_DISPLAY_MATLAB is an executable MATLAB program which can read in the node and tetra files defining a tet mesh and display a wireframe image.

TET_MESH_DISPLAY_OPEN_GL is an executable C++ program which can read in the node and tetra files defining a tet mesh and display a wireframe image using OPEN_GL.

TET_MESH_L2Q is an executable MATLAB program which converts a linear to quadratic tet mesh.

TET_MESH_ORDER4 is a directory which contains a description and examples of a tet mesh using order 4 elements.

TET_MESH_ORDER10 is a directory which contains a description and examples of a tet mesh using order 10 elements.

TET_MESH_Q2L is an executable MATLAB program which converts a quadratic to linear tet mesh.

TET_MESH_QUALITY is a MATLAB program which computes the quality of a tet mesh.

TET_MESH_RCM is an executable MATLAB program which takes a tet mesh and relabels the nodes to reduce the bandwidth of the corresponding adjacency matrix.

TET_MESH_REFINE is an executable MATLAB program which can refine a tet mesh.

TET_MESH_TET_NEIGHBORS is an executable MATLAB program which computes the tetrahedral adjacency information.

### Reference:

A Simple Mesh Generator in MATLAB,
SIAM Review,
Volume 46, Number 2, June 2004, pages 329-345,

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.

If you use DISTMESH in any program or publication, please acknowledge its authors by citing the reference.

### Source Code:

• ddiff.m returns the signed distance of one or more points to a region defined as the set difference of two regions.
• dintersect.m returns the signed distance to a region that is the intersection of two regions.
• distmesh_3d.m computes a mesh of a given 3D region.
• dsphere.m returns the signed distance of one or more points to a sphere.
• meshdemo_3d.m demonstrates the use of the program for 3D problems.
• post_3d.m performs postprocessing for output from DISTMESH_3D.
• simp_plot_3d.m displays a plot of the tetrahedrons that form a mesh in 3D.
• simp_qual_3d.m computes the simplex quality of the mesh.
• simpvol.m returns the volume of a simplex.
• surftri.m finds the surface triangles in a tetrahedral mesh.
• timestamp.m prints the current YMDHMS time as a timestamp.
• timestring.m returns the current YMDHMS time as a string.

Routines to write data to files (borrowed from TABLE_IO) include:

### Examples and Tests:

Problem #1 is the 3x1x1 channel:

Problem #2 is the vertical cylinder:

Problem #3 is the unit cube:

Problem #4 is the unit sphere:

Problem #5 is the cylinder with a spherical hole:

Department of Mathematics, MIT
« lastname »@math.mit.edu      #### 0 Responses to “matlab . m code for generation of unstructured triangular and tetrahedral meshes”

1. Laisser un commentaire

I MOVED THIS BLOG FROM WORDPRESS TO BLOGGER. Ce blog est à  • 223 070 hits