File Exchange

## MESHND

version 1.1 (71.9 KB) by Tim Davis

### Tim Davis (view profile)

creation and nested dissection of regular 2D and 3D meshes

Updated 20 Nov 2014

MESHND is an M-file toolbox for creating 2D and 3D meshes and ordering them with nested dissection. It can also create a sparse matrix from a regular mesh using an abitrary stencil.
Examples:

A = meshsparse (meshnd (7,5,2))

creates a 7-by-5-by-2 mesh, and then computes the sparse matrix A that represents the mesh (using a 7-point stencil). You can specify other stencils (5, 7, 9, and 27-point) or create your own to pass to meshsparse.

This example creates the same mesh but also finds the nested dissected ordering of that mesh:

[G p] = meshnd (7,5,2) ;
A = meshsparse (G) ;
subplot (1,2,1) ; spy (A) ;
subplot (1,2,2) ; spy (A (p,p)) ;

Here is a simple view of small mesh.
[G p pinv Gnew] = meshnd (4,5) returns

<pre>
Gnew =
1 2 17 9 10
7 8 18 15 16
3 5 19 11 13
4 6 20 12 14
G =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20

Note that the left 2 columns in Gnew are ordered first (numbers in the range 1 to 8), followed by the right 2 columns (numbered 9 to 16) followed by the node seperator in column 3 of the mesh (numbered 17 to 20). This process repeats recursively, where the cut is taken along the largest dimension of the mesh.

See also the nested.m function in the MATLAB Demo directory, by Cleve Moler, and the numgrid.m function.

The meshnd example optionally uses cspy from the CSparse package. The meshnd_quality test optionally uses the METIS interface in CHOLMOD. These examples work fine without the optional packages. They are available in SuiteSparse on MATLAB Central.

### Cite As

Tim Davis (2020). MESHND (https://www.mathworks.com/matlabcentral/fileexchange/15486-meshnd), MATLAB Central File Exchange. Retrieved .