D06 Chapter Contents
D06 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD06CBF

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

D06CBF generates the sparsity pattern of a finite element matrix associated with a given mesh.

## 2  Specification

 SUBROUTINE D06CBF ( NV, NELT, NNZMAX, CONN, NNZ, IROW, ICOL, IFAIL)
 INTEGER NV, NELT, NNZMAX, CONN(3,NELT), NNZ, IROW(NNZMAX), ICOL(NNZMAX), IFAIL

## 3  Description

D06CBF generates the sparsity pattern of a finite element matrix associated with a given mesh. The sparsity pattern is returned in a coordinate storage format consistent with the sparse linear algebra routines in Chapter F11. More precisely D06CBF returns the number of nonzero elements in the associated sparse matrix, and their row and column indices. This is designed to assist you in applying finite element discretization to meshes from the D06 Chapter Introduction and in solving the resulting sparse linear system using routines from Chapter F11.
The output sparsity pattern is based on the fact that finite element matrix $A$ has elements ${a}_{ij}$ satisfying:
 $aij≠0 ⇒i​ and ​j ​ are vertices belonging to the same triangle.$

None.

## 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:     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 D06CBF is called.
Constraint: $4×{\mathbf{NELT}}+{\mathbf{NV}}\le {\mathbf{NNZMAX}}\le {{\mathbf{NV}}}^{2}$.
4:     CONN($3$,NELT) – INTEGER arrayInput
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}}$.
5:     NNZ – INTEGEROutput
On exit: the number of nonzero entries in the matrix associated with the input mesh.
6:     IROW(NNZMAX) – INTEGER arrayOutput
7:     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$.
8:     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{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,3$ and $j$, $1\le j\le {\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}}$.
${\mathbf{IFAIL}}=2$
A serious error has occurred in an internal call to an auxiliary routine. Check the input mesh, especially the connectivity between triangles and vertices (the parameter CONN). Array dimensions should be checked as well. If the problem persists, contact NAG.

Not applicable.