# NAG FL Interfaced06ccf (dim2_​renumber)

## 1Purpose

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.

## 2Specification

Fortran Interface
 Subroutine d06ccf ( nv, nelt, nnz, coor, edge, conn, irow, icol,
 Integer, Intent (In) :: nv, nelt, nedge, nnzmax, itrace, liwork, lrwork Integer, Intent (Inout) :: edge(3,nedge), conn(3,nelt), ifail Integer, Intent (Out) :: nnz, irow(nnzmax), icol(nnzmax), iwork(liwork) Real (Kind=nag_wp), Intent (Inout) :: coor(2,nv) Real (Kind=nag_wp), Intent (Out) :: rwork(lrwork)
#include <nag.h>
 void d06ccf_ (const Integer *nv, const Integer *nelt, const Integer *nedge, const Integer *nnzmax, Integer *nnz, double coor[], Integer edge[], Integer conn[], Integer irow[], Integer icol[], const Integer *itrace, Integer iwork[], const Integer *liwork, double rwork[], const Integer *lrwork, Integer *ifail)
The routine may be called by the names d06ccf or nagf_mesh_dim2_renumber.

## 3Description

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).

## 4References

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

## 5Arguments

1: $\mathbf{nv}$Integer Input
On entry: the total number of vertices in the input mesh.
Constraint: ${\mathbf{nv}}\ge 3$.
2: $\mathbf{nelt}$Integer Input
On entry: the number of triangles in the input mesh.
Constraint: ${\mathbf{nelt}}\le 2×{\mathbf{nv}}-1$.
3: $\mathbf{nedge}$Integer Input
On entry: the number of boundary edges in the input mesh.
Constraint: ${\mathbf{nedge}}\ge 1$.
4: $\mathbf{nnzmax}$Integer Input
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: $\mathbf{nnz}$Integer Output
On exit: the number of nonzero entries in the matrix based on the input mesh.
6: $\mathbf{coor}\left(2,{\mathbf{nv}}\right)$Real (Kind=nag_wp) array Input/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: $\mathbf{edge}\left(3,{\mathbf{nedge}}\right)$Integer array Input/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: $\mathbf{conn}\left(3,{\mathbf{nelt}}\right)$Integer array Input/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: $\mathbf{irow}\left({\mathbf{nnzmax}}\right)$Integer array Output
10: $\mathbf{icol}\left({\mathbf{nnzmax}}\right)$Integer array Output
On exit: the first nnz elements contain the row and column indices of the nonzero elements supplied in the finite element matrix $A$.
11: $\mathbf{itrace}$Integer Input
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: $\mathbf{iwork}\left({\mathbf{liwork}}\right)$Integer array Workspace
13: $\mathbf{liwork}$Integer Input
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: $\mathbf{rwork}\left({\mathbf{lrwork}}\right)$Real (Kind=nag_wp) array Workspace
15: $\mathbf{lrwork}$Integer Input
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: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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{conn}}\left(\mathit{I},\mathit{J}\right)=〈\mathit{\text{value}}〉$, $\mathit{I}=〈\mathit{\text{value}}〉$, $\mathit{J}=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{conn}}\left(\mathit{I},\mathit{J}\right)\ge 1$ and ${\mathbf{conn}}\left(\mathit{I},\mathit{J}\right)\le {\mathbf{nv}}$.
On entry, ${\mathbf{edge}}\left(\mathit{I},\mathit{J}\right)=〈\mathit{\text{value}}〉$, $\mathit{I}=〈\mathit{\text{value}}〉$, $\mathit{J}=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{edge}}\left(\mathit{I},\mathit{J}\right)\ge 1$ and ${\mathbf{edge}}\left(\mathit{I},\mathit{J}\right)\le {\mathbf{nv}}$.
On entry, ${\mathbf{liwork}}=〈\mathit{\text{value}}〉$ and $\mathrm{LIWKMN}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{liwork}}\ge \mathrm{LIWKMN}$.
On entry, ${\mathbf{lrwork}}=〈\mathit{\text{value}}〉$ and $\mathrm{LRWKMN}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lrwork}}\ge \mathrm{LRWKMN}$.
On entry, ${\mathbf{nedge}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nedge}}\ge 1$.
On entry, ${\mathbf{nelt}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nelt}}\le 2×{\mathbf{nv}}-1$.
On entry, ${\mathbf{nnzmax}}=〈\mathit{\text{value}}〉$, ${\mathbf{nelt}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nnzmax}}\ge \left(4×{\mathbf{nelt}}+{\mathbf{nv}}\right)$ and ${\mathbf{nnzmax}}\le {{\mathbf{nv}}}^{2}$.
On entry, ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nv}}\ge 3$.
On entry, the end points of the edge $\mathit{J}$ have the same index $\mathit{I}$: $\mathit{J}=〈\mathit{\text{value}}〉$ and $\mathit{I}=〈\mathit{\text{value}}〉$.
On entry, vertices $1$ and $2$ of the triangle $\mathit{K}$ have the same index $\mathit{I}$: $\mathit{K}=〈\mathit{\text{value}}〉$ and $\mathit{I}=〈\mathit{\text{value}}〉$.
On entry, vertices $1$ and $3$ of the triangle $\mathit{K}$ have the same index $\mathit{I}$: $\mathit{K}=〈\mathit{\text{value}}〉$ and $\mathit{I}=〈\mathit{\text{value}}〉$.
On entry, vertices $2$ and $3$ of the triangle $\mathit{K}$ have the same index $\mathit{I}$: $\mathit{K}=〈\mathit{\text{value}}〉$ and $\mathit{I}=〈\mathit{\text{value}}〉$.
On the computation of the compact sparsity of the finite element matrix, an error has occurred. liwork has at least to be greater than $〈\mathit{\text{value}}〉$.
${\mathbf{ifail}}=2$
An error has occurred during the computation of the compact sparsity of the finite element matrix. Check the Triangle/Vertices connectivity.
${\mathbf{ifail}}=3$
A serious error has occurred in an internal call to the renumbering routine. Check the input mesh especially the connectivity. Seek expert help.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

d06ccf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10Example

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 in Section 10.3). 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 and 3 in Section 10.3).

### 10.1Program Text

Program Text (d06ccfe.f90)

None.

### 10.3Program Results

Program Results (d06ccfe.r)