# NAG FL Interfaced06cbf (dim2_​sparsity)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine d06cbf ( nv, nelt, conn, nnz, irow, icol,
 Integer, Intent (In) :: nv, nelt, nnzmax, conn(3,nelt) Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: nnz, irow(nnzmax), icol(nnzmax)
#include <nag.h>
 void d06cbf_ (const Integer *nv, const Integer *nelt, const Integer *nnzmax, const Integer conn[], Integer *nnz, Integer irow[], Integer icol[], Integer *ifail)
The routine may be called by the names d06cbf or nagf_mesh_dim2_sparsity.

## 3Description

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.

## 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{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 d06cbf is called.
Constraint: $4×{\mathbf{nelt}}+{\mathbf{nv}}\le {\mathbf{nnzmax}}\le {{\mathbf{nv}}}^{2}$.
4: $\mathbf{conn}\left(3,{\mathbf{nelt}}\right)$Integer array Input
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: $\mathbf{nnz}$Integer Output
On exit: the number of nonzero entries in the matrix associated with the input mesh.
6: $\mathbf{irow}\left({\mathbf{nnzmax}}\right)$Integer array Output
7: $\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$.
8: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 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{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)$.
On entry, ${\mathbf{nnzmax}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nv}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nnzmax}}\le {{\mathbf{nv}}}^{2}$.
On entry, ${\mathbf{nv}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nv}}\ge 3$.
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}}⟩$.
${\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 argument conn). Array dimensions should also be checked. If the problem persists, contact NAG.
${\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.