d03maf begins with a uniform triangular grid as shown in
Figure 1 and assumes that the region to be triangulated lies within the rectangle given by the inequalities
This rectangle is drawn in bold in
Figure 1. The region is specified by the
isin which must determine whether any given point
$\left(x,y\right)$ lies in the region. The uniform grid is processed columnwise, with
$\left({x}_{1},{y}_{1}\right)$ preceding
$\left({x}_{2},{y}_{2}\right)$ if
${x}_{1}<{x}_{2}$ or
${x}_{1}={x}_{2}$,
${y}_{1}<{y}_{2}$. Points near the boundary are moved onto it and points well outside the boundary are omitted. The direction of movement is chosen to avoid pathologically thin triangles. The points accepted are numbered in exactly the same order as the corresponding points of the uniform grid were scanned. The output consists of the
$x,y$ coordinates of all grid points and integers indicating whether they are internal and to which other points they are joined by triangle sides.
Further details of the algorithm are given in the references.
Reid J K (1970) Fortran subroutines for the solutions of Laplace's equation over a general routine in two dimensions Harwell Report TP422
Reid J K (1972) On the construction and convergence of a finiteelement solution of Laplace's equation J. Instr. Math. Appl. 9 1–13

1:
$\mathbf{h}$ – Real (Kind=nag_wp)
Input

On entry: $h$, the required length for the sides of the triangles of the uniform mesh.

2:
$\mathbf{m}$ – Integer
Input

3:
$\mathbf{n}$ – Integer
Input

On entry: values
$m$ and
$n$ such that all points
$\left(x,y\right)$ inside the region satisfy the inequalities
Constraint:
${\mathbf{m}}={\mathbf{n}}>2$.

4:
$\mathbf{nb}$ – Integer
Input

On entry: the number of times a triangle side is bisected to find a point on the boundary. A value of
$10$ is adequate for most purposes (see
Section 7).
Constraint:
${\mathbf{nb}}\ge 1$.

5:
$\mathbf{npts}$ – Integer
Output

On exit: the number of points in the triangulation.

6:
$\mathbf{places}\left(2,{\mathbf{sdindx}}\right)$ – Real (Kind=nag_wp) array
Output

On exit: the $x$ and $y$ coordinates respectively of the $i$th point of the triangulation.

7:
$\mathbf{indx}\left(4,{\mathbf{sdindx}}\right)$ – Integer array
Output

On exit: ${\mathbf{indx}}\left(1,i\right)$ contains $i$ if point $i$ is inside the region and $i$ if it is on the boundary. For each triangle side between points $i$ and $j$ with $j>i$, ${\mathbf{indx}}\left(k,i\right)$, $k>1$, contains $j$ or $j$ according to whether point $j$ is internal or on the boundary. There can never be more than three such points. If there are less, some values ${\mathbf{indx}}\left(k,i\right)$, $k>1$, are zero.

8:
$\mathbf{sdindx}$ – Integer
Input

On entry: the second dimension of the arrays
places and
indx as declared in the (sub)program from which
d03maf is called.
Constraint:
${\mathbf{sdindx}}\ge {\mathbf{npts}}$.

9:
$\mathbf{isin}$ – Integer Function, supplied by the user.
External Procedure

isin must return the value
$1$ if the given point
$\left({\mathbf{x}},{\mathbf{y}}\right)$ lies inside the region, and
$0$ if it lies outside.
The specification of
isin is:
Fortran Interface
Integer 
:: 
isin 
Real (Kind=nag_wp), Intent (In) 
:: 
x, y 

C Header Interface
Integer 
isin_ (const double *x, const double *y) 

C++ Header Interface
#include <nag.h> extern "C" {
Integer 
isin_ (const double &x, const double &y) 
}


1:
$\mathbf{x}$ – Real (Kind=nag_wp)
Input

2:
$\mathbf{y}$ – Real (Kind=nag_wp)
Input

On entry: the coordinates of the given point.
isin must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
d03maf is called. Arguments denoted as
Input must
not be changed by this procedure.

10:
$\mathbf{dist}\left(4,{\mathbf{sddist}}\right)$ – Real (Kind=nag_wp) array
Workspace

11:
$\mathbf{sddist}$ – Integer
Input

On entry: the second dimension of the array
dist as declared in the (sub)program from which
d03maf is called.
Constraint:
${\mathbf{sddist}}\ge 4{\mathbf{n}}$.

12:
$\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).
If on entry
${\mathbf{ifail}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Points are moved onto the boundary by bisecting a triangle side
nb times. The accuracy is therefore
$h\times {2}^{{\mathbf{nb}}}$.