D06 Chapter Contents
D06 Chapter Introduction
NAG Library Manual

NAG Library Routine DocumentD06CCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

1  Purpose

D06CCF renumbers the vertices of a given mesh using a Gibbs method, in order the reduce the bandwidth of Finite Element matrices associated with that mesh.

2  Specification

 SUBROUTINE D06CCF ( NV, NELT, NEDGE, NNZMAX, NNZ, COOR, EDGE, CONN, IROW, ICOL, ITRACE, IWORK, LIWORK, RWORK, LRWORK, IFAIL)
 INTEGER NV, NELT, NEDGE, NNZMAX, NNZ, EDGE(3,NEDGE), CONN(3,NELT), IROW(NNZMAX), ICOL(NNZMAX), ITRACE, IWORK(LIWORK), LIWORK, LRWORK, IFAIL REAL (KIND=nag_wp) COOR(2,NV), RWORK(LRWORK)

3  Description

D06CCF uses a Gibbs method to renumber the vertices of a given mesh in order to reduce the bandwidth of the associated finite element matrix $A$. This matrix has elements ${a}_{ij}$ such that:
 $aij≠0⇒i​ and ​j​ are vertices belonging to the same triangle.$
This routine reduces the bandwidth $m$, which is the smallest integer such that ${a}_{ij}\ne 0$ whenever $\left|i-j\right|>m$ (see Gibbs et al. (1976) for details about that method). D06CCF also returns the sparsity structure of the matrix associated with the renumbered mesh.
This routine is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

4  References

Gibbs N E, Poole W G Jr and Stockmeyer P K (1976) An algorithm for reducing the bandwidth and profile of a sparse matrix SIAM J. Numer. Anal. 13 236–250

5  Parameters

1:     NV – INTEGERInput
On entry: the total number of vertices in the input mesh.
Constraint: ${\mathbf{NV}}\ge 3$.
2:     NELT – INTEGERInput
On entry: the number of triangles in the input mesh.
Constraint: ${\mathbf{NELT}}\le 2×{\mathbf{NV}}-1$.
3:     NEDGE – INTEGERInput
On entry: the number of boundary edges in the input mesh.
Constraint: ${\mathbf{NEDGE}}\ge 1$.
4:     NNZMAX – INTEGERInput
On entry: the maximum number of nonzero entries in the matrix based on the input mesh. It is the dimension of the arrays IROW and ICOL as declared in the subroutine from which D06CCF is called.
Constraint: $4×{\mathbf{NELT}}+{\mathbf{NV}}\le {\mathbf{NNZMAX}}\le {{\mathbf{NV}}}^{2}$.
5:     NNZ – INTEGEROutput
On exit: the number of nonzero entries in the matrix based on the input mesh.
6:     COOR($2$,NV) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{COOR}}\left(1,\mathit{i}\right)$ contains the $x$ coordinate of the $\mathit{i}$th input mesh vertex, for $\mathit{i}=1,2,\dots ,{\mathbf{NV}}$; while ${\mathbf{COOR}}\left(2,\mathit{i}\right)$ contains the corresponding $y$ coordinate.
On exit: ${\mathbf{COOR}}\left(1,\mathit{i}\right)$ will contain the $x$ coordinate of the $\mathit{i}$th renumbered mesh vertex, for $\mathit{i}=1,2,\dots ,{\mathbf{NV}}$; while ${\mathbf{COOR}}\left(2,\mathit{i}\right)$ will contain the corresponding $y$ coordinate.
7:     EDGE($3$,NEDGE) – INTEGER arrayInput/Output
On entry: the specification of the boundary or interface edges. ${\mathbf{EDGE}}\left(1,j\right)$ and ${\mathbf{EDGE}}\left(2,j\right)$ contain the vertex numbers of the two end points of the $j$th boundary edge. ${\mathbf{EDGE}}\left(3,j\right)$ is a user-supplied tag for the $j$th boundary or interface edge: ${\mathbf{EDGE}}\left(3,j\right)=0$ for an interior edge and has a nonzero tag otherwise.
Constraint: $1\le {\mathbf{EDGE}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{NV}}$ and ${\mathbf{EDGE}}\left(1,\mathit{j}\right)\ne {\mathbf{EDGE}}\left(2,\mathit{j}\right)$, for $\mathit{i}=1,2$ and $\mathit{j}=1,2,\dots ,{\mathbf{NEDGE}}$.
On exit: the renumbered specification of the boundary or interface edges.
8:     CONN($3$,NELT) – INTEGER arrayInput/Output
On entry: the connectivity of the mesh between triangles and vertices. For each triangle $\mathit{j}$, ${\mathbf{CONN}}\left(\mathit{i},\mathit{j}\right)$ gives the indices of its three vertices (in anticlockwise order), for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NELT}}$.
Constraint: $1\le {\mathbf{CONN}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{NV}}$ and ${\mathbf{CONN}}\left(1,\mathit{j}\right)\ne {\mathbf{CONN}}\left(2,\mathit{j}\right)$ and ${\mathbf{CONN}}\left(1,\mathit{j}\right)\ne {\mathbf{CONN}}\left(3,\mathit{j}\right)$ and ${\mathbf{CONN}}\left(2,\mathit{j}\right)\ne {\mathbf{CONN}}\left(3,\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NELT}}$.
On exit: the renumbered connectivity of the mesh between triangles and vertices.
9:     IROW(NNZMAX) – INTEGER arrayOutput
10:   ICOL(NNZMAX) – INTEGER arrayOutput
On exit: the first NNZ elements contain the row and column indices of the nonzero elements supplied in the finite element matrix $A$.
11:   ITRACE – INTEGERInput
On entry: the level of trace information required from D06CCF.
${\mathbf{ITRACE}}\le 0$
No output is generated.
${\mathbf{ITRACE}}=1$
Information about the effect of the renumbering on the finite element matrix are output. This information includes the half bandwidth and the sparsity structure of this matrix before and after renumbering.
${\mathbf{ITRACE}}>1$
The output is similar to that produced when ${\mathbf{ITRACE}}=1$ but the sparsities (for each row of the matrix, indices of nonzero entries) of the matrix before and after renumbering are also output.
12:   IWORK(LIWORK) – INTEGER arrayWorkspace
13:   LIWORK – INTEGERInput
On entry: the dimension of the array IWORK as declared in the (sub)program from which D06CCF is called.
Constraint: ${\mathbf{LIWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NNZMAX}},20×{\mathbf{NV}}\right)$.
14:   RWORK(LRWORK) – REAL (KIND=nag_wp) arrayWorkspace
15:   LRWORK – INTEGERInput
On entry: the dimension of the array RWORK as declared in the (sub)program from which D06CCF is called.
Constraint: ${\mathbf{LRWORK}}\ge {\mathbf{NV}}$.
16:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{NV}}<3$, or ${\mathbf{NELT}}>2×{\mathbf{NV}}-1$, or ${\mathbf{NEDGE}}<1$, or ${\mathbf{NNZMAX}}<4×{\mathbf{NELT}}+{\mathbf{NV}}$ or ${\mathbf{NNZMAX}}>{{\mathbf{NV}}}^{2}$ or ${\mathbf{CONN}}\left(i,j\right)<1$ or ${\mathbf{CONN}}\left(i,j\right)>{\mathbf{NV}}$ for some $i=1,2,3$ and $j=1,2,\dots ,{\mathbf{NELT}}$, or ${\mathbf{CONN}}\left(1,j\right)={\mathbf{CONN}}\left(2,j\right)$ or ${\mathbf{CONN}}\left(1,j\right)={\mathbf{CONN}}\left(3,j\right)$ or ${\mathbf{CONN}}\left(2,j\right)={\mathbf{CONN}}\left(3,j\right)$ for some $j=1,2,\dots ,{\mathbf{NELT}}$, or ${\mathbf{EDGE}}\left(i,j\right)<1$ or ${\mathbf{EDGE}}\left(i,j\right)>{\mathbf{NV}}$ for some $i=1,2$ and $j=1,2,\dots ,{\mathbf{NEDGE}}$, or ${\mathbf{EDGE}}\left(1,j\right)={\mathbf{EDGE}}\left(2,j\right)$ for some $j=1,2,\dots ,{\mathbf{NEDGE}}$, or ${\mathbf{LIWORK}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NNZMAX}},20×{\mathbf{NV}}\right)$, or ${\mathbf{LRWORK}}<{\mathbf{NV}}$.
${\mathbf{IFAIL}}=2$
A serious error has occurred during the computation of the compact sparsity of the finite element matrix or in an internal call to the renumbering routine. Check the input mesh, especially the connectivity between triangles and vertices (the parameter CONN). If the problem persists, contact NAG.

Not applicable.

None.

9  Example

In this example, a geometry with two holes (two interior circles inside an exterior one) is considered. The geometry has been meshed using the simple incremental method (D06AAF) and it has $250$ vertices and $402$ triangles (see Figure 1). The routine D06BAF is used to renumber the vertices, and one can see the benefit in terms of the sparsity of the finite element matrix based on the renumbered mesh (see Figure 2).

9.1  Program Text

Program Text (d06ccfe.f90)

9.2  Program Data

Program Data (d06ccfe.d)

9.3  Program Results

Program Results (d06ccfe.r)

Figure 1: Mesh of the geometry
Figure 2: Sparsity of the matrix before (top) and after (bottom) the renumbering