Documentation Center |
Create initial triangular mesh
[p,e,t]=initmesh(g) [p,e,t]=initmesh(g,'PropertyName',PropertyValue,...)
[p,e,t]=initmesh(g) returns a triangular mesh using the geometry specification function g. It uses a Delaunay triangulation algorithm. The mesh size is determined from the shape of the geometry.
g describes the geometry of the PDE problem. g can be a Decomposed Geometry matrix, the name of a Geometry file, or a function handle to a Geometry file. The formats of the Decomposed Geometry matrix and Geometry file are described in the entries on decsg and pdegeom, respectively.
The outputs p, e, and t are the mesh data.
In the Point matrix p, the first and second rows contain x- and y-coordinates of the points in the mesh.
In the Edge matrix e, the first and second rows contain indices of the starting and ending point, the third and fourth rows contain the starting and ending parameter values, the fifth row contains the edge segment number, and the sixth and seventh row contain the left- and right-hand side subdomain numbers.
In the Triangle matrix t, the first three rows contain indices to the corner points, given in counter clockwise order, and the fourth row contains the subdomain number.
The following property name/property value pairs are allowed.
Property | Value | Default | Description |
---|---|---|---|
Hmax | numeric | estimate | Maximum edge size |
Hgrad | numeric, strictly between 1 and 2 | 1.3 | Mesh growth rate |
Box | 'on' | 'off' | 'off' | Preserve bounding box |
Init | 'on' | 'off' | 'off' | Edge triangulation |
Jiggle | 'off' | 'mean' | 'minimum' | 'on' | 'mean' | Call jigglemesh after creating the mesh, with the Opt name-value pair set to the stated value. Exceptions: 'off' means do not call jigglemesh, and 'on' means call jigglemesh with Opt = 'off'. |
JiggleIter | numeric | 10 | Maximum iterations |
MesherVersion | 'R2013a' | 'preR2013a' | 'preR2013a' | Algorithm for generating initial mesh |
The Hmax property controls the size of the triangles on the mesh. initmesh creates a mesh where triangle edge lengths are approximately Hmax or less.
The Hgrad property determines the mesh growth rate away from a small part of the geometry. The default value is 1.3, i.e., a growth rate of 30%. Hgrad cannot be equal to either of its bounds, 1 and 2.
Both the Box and Init property are related to the way the mesh algorithm works. By turning on Box you can get a good idea of how the mesh generation algorithm works within the bounding box. By turning on Init you can see the initial triangulation of the boundaries. By using the command sequence
[p,e,t]=initmesh(dl,'hmax',inf,'init','on'); [uxy,tn,a2,a3]=tri2grid(p,t,zeros(size(p,2)),x,y); n=t(4,tn);
you can determine the subdomain number n of the point xy. If the point is outside the geometry, tn is NaN and the command n=t(4,tn) results in a failure.
The Jiggle property is used to control whether jiggling of the mesh should be attempted (see jigglemesh for details). Jiggling can be done until the minimum or the mean of the quality of the triangles decreases. JiggleIter can be used to set an upper limit on the number of iterations.
The MesherVersion property chooses the algorithm for mesh generation. The 'R2013a' algorithm runs faster, and can triangulate more geometries than the 'preR2013a' algorithm. Both algorithms use Delaunay triangulation.
Make a simple triangular mesh of the L-shaped membrane in the PDE app. Before you do anything in the PDE app, set the Maximum edge size to inf in the Mesh Parameters dialog box. You open the dialog box by selecting the Parameters option from the Mesh menu. Also select the items Show Node Labels and Show Triangle Labels in the Mesh menu. Then create the initial mesh by pressing the button. (This can also be done by selecting the Initialize Mesh option from the Mesh menu.)
The following figure appears.
The corresponding mesh data structures can be exported to the main workspace by selecting the Export Mesh option from the Mesh menu.
p p = -1 1 1 0 0 -1 -1 -1 1 1 0 0 e e = 1 2 3 4 5 6 2 3 4 5 6 1 0 0 0 0 0 0 1 1 1 1 1 1 1 2 3 4 5 6 1 1 1 1 1 1 0 0 0 0 0 0 t t = 1 2 3 1 2 3 4 5 5 5 5 6 1 1 1 1
George, P. L., Automatic Mesh Generation — Application to Finite Element Methods, Wiley, 1991.
decsg | jigglemesh | pdegeom | refinemesh