Partial Differential Equation Toolbox |

initmesh

Create initial triangular mesh

Syntax

-     [p,e,t]=initmesh(g)
      [p,e,t]=initmesh(g,'PropertyName',PropertyValue,...)

Description

`[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 either be a Decomposed Geometry matrix or the name of a Geometry M-file. The formats of the Decomposed Geometry matrix and Geometry M-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 | `1.3` | `Mesh growth rate`
`Box` | `on|off` | ``off`` | `Preserve bounding box`
`Init` | `on|off` | ``off`` | `Edge triangulation`
`Jiggle` | `off|mean|min` | `mean` | `Call `jigglemesh``
`JiggleIter` | numeric | 10 | Maximum iterations

The `Hmax` property controls the size of the triangles on the mesh. `initmesh` creates a mesh where no triangle side exceeds `Hmax`.

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` must be between 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.

Algorithm

`initmesh` implements a Delaunay triangulation algorithm:

1. Place node points on the edges.
2. Enclose geometry in bounding box.
3. Triangulate edges.
4. Check that the triangulation respects boundaries.
5. Insert node points into centers of circumscribed circles of large triangles.
6. Repeat from step 4 if `Hmax` not yet achieved.
7. Remove bounding box.

Examples

Make a simple triangular mesh of the L-shaped membrane in `pdetool`.
Before you do anything in `pdetool`, 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 figure below 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

See Also

`decsg`, `pdegeom`, `jigglemesh`, `refinemesh`

Reference

George, P. L., Automatic Mesh Generation -- Application to Finite Element Methods, Wiley, 1991.

| hyperbolic |  | jigglemesh |