d06 Chapter Contents
d06 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_mesh2d_sparse (d06cbc)

## 1  Purpose

nag_mesh2d_sparse (d06cbc) generates the sparsity pattern of a finite element matrix associated with a given mesh.

## 2  Specification

 #include #include
 void nag_mesh2d_sparse (Integer nv, Integer nelt, Integer nnzmax, const Integer conn[], Integer *nnz, Integer irow[], Integer icol[], NagError *fail)

## 3  Description

nag_mesh2d_sparse (d06cbc) 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 functions in Chapter f11. More precisely nag_mesh2d_sparse (d06cbc) 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 functions 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  Arguments

1:     nvIntegerInput
On entry: the total number of vertices in the input mesh.
Constraint: ${\mathbf{nv}}\ge 3$.
2:     neltIntegerInput
On entry: the number of triangles in the input mesh.
Constraint: ${\mathbf{nelt}}\le 2×{\mathbf{nv}}-1$.
3:     nnzmaxIntegerInput
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 function from which nag_mesh2d_sparse (d06cbc) is called.
Constraint: $4×{\mathbf{nelt}}+{\mathbf{nv}}\le {\mathbf{nnzmax}}\le {{\mathbf{nv}}}^{2}$.
4:     conn[$3×{\mathbf{nelt}}$]const IntegerInput
On entry: the connectivity of the mesh between triangles and vertices. For each triangle $\mathit{j}$, ${\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+\mathit{i}-1\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}}$. Note that the mesh vertices are numbered from $1$ to nv.
Constraint: $1\le {\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+\mathit{i}-1\right]\le {\mathbf{nv}}$ and ${\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+0\right]\ne {\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+1\right]$ and ${\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+0\right]\ne {\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+2\right]$ and ${\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+1\right]\ne {\mathbf{conn}}\left[\left(\mathit{j}-1\right)×3+2\right]$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$.
5:     nnzInteger *Output
On exit: the number of nonzero entries in the matrix associated with the input mesh.
6:     irow[nnzmax]IntegerOutput
7:     icol[nnzmax]IntegerOutput
On exit: the first nnz elements contain the row and column indices of the nonzero elements supplied in the finite element matrix $A$.
8:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nv}}\ge 3$.
NE_INT_2
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}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nnzmax}}\le {{\mathbf{nv}}}^{2}$.
On entry, vertices $1$ and $2$ of the triangle $k$ have the same index $i$: $k=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
On entry, vertices $1$ and $3$ of the triangle $k$ have the same index $i$: $k=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
On entry, vertices $2$ and $3$ of the triangle $k$ have the same index $i$: $k=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
NE_INT_3
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)$.
NE_INT_4
On entry, ${\mathbf{CONN}}\left(i,j\right)=〈\mathit{\text{value}}〉$, $i=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{CONN}}\left(i,j\right)\ge 1$ and ${\mathbf{CONN}}\left(i,j\right)\le {\mathbf{nv}}$, where ${\mathbf{CONN}}\left(i,j\right)$ denotes ${\mathbf{conn}}\left[\left(j-1\right)×3+i-1\right]$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh especially the connectivity. Seek expert help.

Not applicable.