Automatic 2D Mesh Generation for Several Faces

**MESH2D**
is a MATLAB program which generates
unstructured meshes in 2D for a regeion which has been subdivided
into several faces,
by Darren Engwirda.

The program is based on MESH2D, and can be regarded as an extension of the program to handle the additional constraint that the internal boundaries shared by pairs of faces are required to be covered by edges of the mesh triangles.

[where:p, t, fnum, stats] =meshfaces(node, edge, hdata, options);

- s
*node*, an N by 2 list of (X,Y) coordinates of node, used to dilineate the faces. -
*edge*, an E by 2 list of pairs of indices that constitute edges of the faces. -
*faces*, a cell array of F entries. F{i} is a vector containing a list of the edges, in counterclockwise order, that form the boundary of the i-th face. -
*hdata*, optional input, a structure containing element size information. -
*options*, optional input that allows the user to modify the default behavior of the solver. -
*p*, a NP by 2 list of the points used to define the mesh. -
*t*, an NT by 3 list of point indices, forming counterclockwise triangles. -
*fnum*, an NT vector which indicates the face to which each triangle belongs. -
*stats*, the computational time, average and minimum triangle quality, number of points and number of triangles.

Copyright (c) 2009, Darren Engwirda All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

**MESHFACES** is available in
a MATLAB version.

DISTMESH, a MATLAB library which carries out triangular or tetrahedral mesh generation, by Per-Olof Persson and Gilbert Strang.

MESH2D, a MATLAB library which can automatically create a triangular mesh for a given polygonal region, by Darren Engwirda.

MESH2D_HAND, a MATLAB program which reads in a set of 59 points which outline a human hand, and calls MESH2D, which is able to create a fine triangular mesh of the region outlined by the points.

MESH2D_WRITE, a MATLAB program which demonstrates how node and element data from MESH2D can be written to files.

TEST_TRIANGULATION, a MATLAB library which defines some test regions for triangulation.

TRIANGLE, a C program which computes a triangulation of a geometric region, by Jonathan Shewchuk.

TRIANGULATION, a MATLAB library which performs various operations on order 3 ("linear") or order 6 ("quadratic") triangulations.

TSEARCH, a MATLAB library which compares several replacements for MATLAB's obsolete tsearch() function, which searched a Delaunay triangulation to find the triangle that encloses a given point.

Darren Engwirda

- checkgeometry.m checks a geometry input for MESH2D.
- circumcircle.m computes the center and radius of the circumcircle of a triangle.
- dist2poly.m finds the distance between a point and a polygon.
- findedge.m locates the edges that contain a sequence of points.
- fixmesh.m checks a triangular mesh for consistency.
- inpoly.m determines whether a point is inside a polygon.
- meshfaces.m generates a triangular mesh for a polygonal region which has been subdivided.
- meshpoly.m used to mesh a region.
- mydelaunayn.m computes the Delaunay triangulation of a set of points.
- quadtree.m decomposes a polygonal region using a quadtree.
- quality.m determines the "quality" of a triangle.
- timestamp.m prints the YMDHMS date as a timestamp.
- tinterp.m carries out linear interpolation at points within a triangle, given function values at the vertices.
- triarea.m computes the area of one or more triangles, assuming their vertices are given in counterclockwise order.

- meshfaces_test.m calls the tests.
- meshfaces_test_output.txt the output file.
- meshfaces_test01.m calls meshfaces() for a square that has been subdivided into three regions.
- test01.png an image of the mesh.
- meshfaces_test02.m calls meshfaces() for two rectangles separated by a very thin rectangle.
- test02.png an image of the mesh.
- meshfaces_test03.m calls meshfaces() for a circle inside a square.
- test03.png an image of the mesh.
- meshfaces_test04.m calls meshfaces() for a battery design with 7 regions.
- test04.png an image of the mesh.
- test04_nodes.txt the nodes of the mesh.
- test04_elements.txt the elements of the mesh.
- meshfaces_test05.m calls meshfaces() for a square inside a square.
- test05.png an image of the mesh.
- test05_nodes.txt the nodes of the mesh.
- test05_elements.txt the elements of the mesh.

You can go up one level to the MATLAB source codes.