nag_mesh2d_bound (d06bac) (PDF version)
d06 Chapter Contents
d06 Chapter Introduction
NAG C Library Manual

NAG Library Function Documentnag_mesh2d_bound (d06bac)

1  Purpose

nag_mesh2d_bound (d06bac) generates a boundary mesh on a closed connected subdomain $\Omega$ of ${ℝ}^{2}$.

2  Specification

 #include #include
void  nag_mesh2d_bound (Integer nlines, const double coorch[], const Integer lined[],
 double (*fbnd)(Integer i, double x, double y, Nag_Comm *comm),
const double crus[], Integer sdcrus, const double rate[], Integer ncomp, const Integer nlcomp[], const Integer lcomp[], Integer nvmax, Integer nedmx, Integer *nvb, double coor[], Integer *nedge, Integer edge[], Integer itrace, const char *outfile, Nag_Comm *comm, NagError *fail)

3  Description

Given a closed connected subdomain $\Omega$ of ${ℝ}^{2}$, whose boundary $\partial \Omega$ is divided by characteristic points into $m$ distinct line segments, nag_mesh2d_bound (d06bac) generates a boundary mesh on $\partial \Omega$. Each line segment may be a straight line, a curve defined by the equation $f\left(x,y\right)=0$, or a polygonal curve defined by a set of given boundary mesh points.
This function is primarily designed for use with either nag_mesh2d_inc (d06aac) (a simple incremental method) or nag_mesh2d_delaunay (d06abc) (Delaunay–Voronoi method) or nag_mesh2d_front (d06acc) (Advancing Front method) to triangulate the interior of the domain $\Omega$. For more details about the boundary and interior mesh generation, consult the d06 Chapter Introduction as well as George and Borouchaki (1998).
This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

4  References

George P L and Borouchaki H (1998) Delaunay Triangulation and Meshing: Application to Finite Elements Editions HERMES, Paris

5  Arguments

1:     nlinesIntegerInput
On entry: $m$, the number of lines that define the boundary of the closed connected subdomain (this equals the number of characteristic points which separate the entire boundary $\partial \Omega$ into lines).
Constraint: ${\mathbf{nlines}}\ge 1$.
2:     coorch[$2×{\mathbf{nlines}}$]const doubleInput
On entry: ${\mathbf{coorch}}\left[\left(\mathit{i}-1\right)×2+0\right]$ contains the $x$ coordinate of the $\mathit{i}$th characteristic point, for $\mathit{i}=1,2,\dots ,{\mathbf{nlines}}$; while ${\mathbf{coorch}}\left[\left(i-1\right)×2+1\right]$ contains the corresponding $y$ coordinate.
3:     lined[$4×{\mathbf{nlines}}$]const IntegerInput
On entry: the description of the lines that define the boundary domain. The line $\mathit{i}$, for $\mathit{i}=1,2,\dots ,m$, is defined as follows:
${\mathbf{lined}}\left[\left(i-1\right)×4+0\right]$
The number of points on the line, including two end points.
${\mathbf{lined}}\left[\left(i-1\right)×4+1\right]$
The first end point of the line. If ${\mathbf{lined}}\left[\left(i-1\right)×4+1\right]=j$, then the coordinates of the first end point are those stored in ${\mathbf{coorch}}\left[\left(j-1\right)×2+0\right],{\mathbf{coorch}}\left[\left(j-1\right)×2+1\right]$.
${\mathbf{lined}}\left[\left(i-1\right)×4+2\right]$
The second end point of the line. If ${\mathbf{lined}}\left[\left(i-1\right)×4+2\right]=k$, then the coordinates of the second end point are those stored in ${\mathbf{coorch}}\left[\left(k-1\right)×2+0\right],{\mathbf{coorch}}\left[\left(k-1\right)×2+1\right]$.
${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]$
This defines the type of line segment connecting the end points. Additional information is conveyed by the numerical value of ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]$ as follows:
 (i) ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]>0$, the line is described in fbnd with ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]$ as the index. In this case, the line must be described in the trigonometric (anticlockwise) direction; (ii) ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]=0$, the line is a straight line; (iii) if ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]<0$, say (i.e., ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]=-p$ for some index $p$), then the line is a polygonal arc joining the end points and interior points specified in crus. In this case the line contains the points whose coordinates are stored in ${\mathbf{coorch}}\left[\left(j-1\right)×2+z\right],\text{}{\mathbf{crus}}\left[\left(p-1\right)×2+z\right],\text{}{\mathbf{crus}}\left[p×2+z\right],\dots ,{\mathbf{crus}}\left[\left(p+r-4\right)×2+z\right],\text{}{\mathbf{coorch}}\left[\left(k-1\right)×2+z\right]$,where $z\in \left\{0,1\right\}$, $r={\mathbf{lined}}\left[\left(i-1\right)×4+0\right]$, $j={\mathbf{lined}}\left[\left(i-1\right)×4+1\right]$ and $k={\mathbf{lined}}\left[\left(i-1\right)×4+2\right]$.
Constraints:
• $2\le {\mathbf{lined}}\left[\left(i-1\right)×4+0\right]$;
• $1\le {\mathbf{lined}}\left[\left(i-1\right)×4+1\right]\le {\mathbf{nlines}}$;
• $1\le {\mathbf{lined}}\left[\left(i-1\right)×4+2\right]\le {\mathbf{nlines}}$;
• ${\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+1\right]\ne {\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+2\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlines}}$.
For each line described by fbnd (lines with ${\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+3\right]>0$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlines}}$) the two end points (${\mathbf{lined}}\left[\left(i-1\right)×4+1\right]$ and ${\mathbf{lined}}\left[\left(i-1\right)×4+2\right]$) lie on the curve defined by index ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]$ in fbnd, i.e.,
${\mathbf{fbnd}}\left({\mathbf{lined}}\left[\left(i-1\right)×4+3\right],{\mathbf{coorch}}\left[\left({\mathbf{lined}}\left[\left(i-1\right)×4+1\right]-1\right)×2+0\right],\text{}{\mathbf{coorch}}\left[\left({\mathbf{lined}}\left[\left(i-1\right)×4+1\right]-1\right)×2+1\right],{\mathbf{comm}}\right)=0$;
${\mathbf{fbnd}}\left({\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+3\right],{\mathbf{coorch}}\left[\left({\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+2\right]-1\right)×2+0\right],\text{}{\mathbf{coorch}}\left[\left({\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+2\right]-1\right)×2+1\right],{\mathbf{comm}}\right)=0$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlines}}$.
For all lines described as polygonal arcs (lines with ${\mathbf{lined}}\left[\left(\mathit{i}-1\right)×4+3\right]<0$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlines}}$) the sets of intermediate points (i.e.,$\left[-{\mathbf{lined}}\left[\left(i-1\right)×4+3\right]:-{\mathbf{lined}}\left[\left(i-1\right)×4+3\right]+{\mathbf{lined}}\left[\left(i-1\right)×4+0\right]-3\right]$ for all $i$ such that ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]<0$) are not overlapping. This can be expressed as:
 $-lined[i-1×4+3] + lined[i-1×4+0] - 3 = ∑ i,lined[i-1×4+3]<0 lined[i-1×4+0] - 2$
or
 $-lined[i-1×4+3] + lined[i-1×4+0] - 2 = -lined[j-1×4+3] ,$
for a $j$ such that $j=1,2,\dots ,{\mathbf{nlines}}$, $j\ne i$ and ${\mathbf{lined}}\left[\left(j-1\right)×4+3\right]<0$.
4:     fbndfunction, supplied by the userExternal Function
fbnd must be supplied to calculate the value of the function which describes the curve $\left\{\left(x,y\right)\in {ℝ}^{2}\text{; such that ​}f\left(x,y\right)=0\right\}$ on segments of the boundary for which ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]>0$. If there are no boundaries for which ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]>0$ fbnd will never be referenced by nag_mesh2d_bound (d06bac) and fbnd may be NULL.
The specification of fbnd is:
 double fbnd (Integer i, double x, double y, Nag_Comm *comm)
1:     iIntegerInput
On entry: ${\mathbf{lined}}\left[3\right]\left[i-1\right]$, the reference index of the line (portion of the contour) $i$ described.
2:     xdoubleInput
3:     ydoubleInput
On entry: the values of $x$ and $y$ at which $f\left(x,y\right)$ is to be evaluated.
4:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to fbnd.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_mesh2d_bound (d06bac) you may allocate memory and initialize these pointers with various quantities for use by fbnd when called from nag_mesh2d_bound (d06bac) (see Section 3.2.1 in the Essential Introduction).
5:     crus[$2×{\mathbf{sdcrus}}$]const doubleInput
On entry: the coordinates of the intermediate points for polygonal arc lines. For a line $i$ defined as a polygonal arc (i.e., ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]<0$), if $p=-{\mathbf{lined}}\left[\left(i-1\right)×4+3\right]$, then ${\mathbf{crus}}\left[\left(\mathit{k}-1\right)×2+0\right]$, for $\mathit{k}=p,\dots ,p+{\mathbf{lined}}\left[\left(i-1\right)×4+0\right]-3$, must contain the $x$ coordinate of the consecutive intermediate points for this line. Similarly ${\mathbf{crus}}\left[\left(\mathit{k}-1\right)×2+1\right]$, for $\mathit{k}=p,\dots ,p+{\mathbf{lined}}\left[\left(i-1\right)×4+0\right]-3$, must contain the corresponding $y$ coordinate.
6:     sdcrusIntegerInput
On entry: the half dimension of the array crus as declared in the function from which nag_mesh2d_bound (d06bac) is called.
Constraint: ${\mathbf{sdcrus}}\ge \sum _{\left\{i,{\mathbf{lined}}\left[\left(i-1\right)×4+3\right]<0\right\}}\phantom{\rule{0.25em}{0ex}}\left\{{\mathbf{lined}}\left[\left(i-1\right)×4+0\right]-2\right\}$.
7:     rate[nlines]const doubleInput
On entry: ${\mathbf{rate}}\left[\mathit{i}-1\right]$ is the geometric progression ratio between the points to be generated on the line $\mathit{i}$, for $\mathit{i}=1,2,\dots ,m$ and ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]\ge 0$.
If ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]<0$, ${\mathbf{rate}}\left[i-1\right]$ is not referenced.
Constraint: if ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]\ge 0$, ${\mathbf{rate}}\left[\mathit{i}-1\right]>0.0$, for $\mathit{i}=1,2,\dots ,{\mathbf{nlines}}$.
8:     ncompIntegerInput
On entry: $n$, the number of separately connected components of the boundary.
Constraint: ${\mathbf{ncomp}}\ge 1$.
9:     nlcomp[ncomp]const IntegerInput
On entry: $\left|{\mathbf{nlcomp}}\left[k-1\right]\right|$ is the number of line segments in component $k$ of the contour. The line $i$ of component $k$ runs in the direction ${\mathbf{lined}}\left[\left(i-1\right)×4+1\right]$ to ${\mathbf{lined}}\left[\left(i-1\right)×4+2\right]$ if ${\mathbf{nlcomp}}\left[k-1\right]>0$, and in the opposite direction otherwise; for $k=1,2,\dots ,n$.
Constraints:
• $1\le \left|{\mathbf{nlcomp}}\left[\mathit{k}-1\right]\right|\le {\mathbf{nlines}}$, for $\mathit{k}=1,2,\dots ,{\mathbf{ncomp}}$;
• $\sum _{k=1}^{n}\left|{\mathbf{nlcomp}}\left[k-1\right]\right|={\mathbf{nlines}}$.
10:   lcomp[nlines]const IntegerInput
On entry: ${\mathbf{LCOMP}}\left(l1:l2\right)$, where $l2=\sum _{i=1}^{k}\left|{\mathbf{nlcomp}}\left[i-1\right]\right|$ and $l1=l2+1-\left|{\mathbf{nlcomp}}\left[\mathit{k}-1\right]\right|$ is the list of line numbers for the $\mathit{k}$th components of the boundary, for $\mathit{k}=1,2,\dots ,{\mathbf{ncomp}}$.
Constraint: ${\mathbf{lcomp}}$ must hold a valid permutation of the integers $\left[1,{\mathbf{nlines}}\right]$.
11:   nvmaxIntegerInput
On entry: the maximum number of the boundary mesh vertices to be generated.
Constraint: ${\mathbf{nvmax}}\ge {\mathbf{nlines}}$.
12:   nedmxIntegerInput
On entry: the maximum number of boundary edges in the boundary mesh to be generated.
Constraint: ${\mathbf{nedmx}}\ge 1$.
13:   nvbInteger *Output
On exit: the total number of boundary mesh vertices generated.
14:   coor[$2×{\mathbf{nvmax}}$]doubleOutput
On exit: ${\mathbf{coor}}\left[\left(\mathit{i}-1\right)×2+0\right]$ will contain the $x$ coordinate of the $\mathit{i}$th boundary mesh vertex generated, for $\mathit{i}=1,2,\dots ,{\mathbf{nvb}}$; while ${\mathbf{coor}}\left[\left(i-1\right)×2+1\right]$ will contain the corresponding $y$ coordinate.
15:   nedgeInteger *Output
On exit: the total number of boundary edges in the boundary mesh.
16:   edge[$3×{\mathbf{nedmx}}$]IntegerOutput
On exit: the specification of the boundary edges. ${\mathbf{edge}}\left[\left(j-1\right)×3+0\right]$ and ${\mathbf{edge}}\left[\left(j-1\right)×3+1\right]$ will contain the vertex numbers of the two end points of the $j$th boundary edge. ${\mathbf{edge}}\left[\left(j-1\right)×3+2\right]$ is a reference number for the $j$th boundary edge and
• ${\mathbf{edge}}\left[\left(j-1\right)×3+2\right]={\mathbf{lined}}\left[\left(i-1\right)×4+3\right]$, where $i$ and $j$ are such that the $j$th edges is part of the $i$th line of the boundary and ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]\ge 0$;
• ${\mathbf{edge}}\left[\left(j-1\right)×3+2\right]=100+\left|{\mathbf{lined}}\left[\left(i-1\right)×4+3\right]\right|$, where $i$ and $j$ are such that the $j$th edges is part of the $i$th line of the boundary and ${\mathbf{lined}}\left[\left(i-1\right)×4+3\right]<0$.
Note that the edge vertices are numbered from $1$ to nvb.
17:   itraceIntegerInput
On entry: the level of trace information required from nag_mesh2d_bound (d06bac).
${\mathbf{itrace}}=0$ or ${\mathbf{itrace}}<-1$
No output is generated.
${\mathbf{itrace}}=1$
Output from the boundary mesh generator is printed. This output contains the input information of each line and each connected component of the boundary.
${\mathbf{itrace}}=-1$
An analysis of the output boundary mesh is printed on the current advisory message unit. This analysis includes the orientation (clockwise or anticlockwise) of each connected component of the boundary. This information could be of interest to you, especially if an interior meshing is carried out using the output of this function, calling either nag_mesh2d_inc (d06aac), nag_mesh2d_delaunay (d06abc) or nag_mesh2d_front (d06acc).
${\mathbf{itrace}}>1$
The output is similar to that produced when ${\mathbf{itrace}}=1$, but the coordinates of the generated vertices on the boundary are also output.
You are advised to set ${\mathbf{itrace}}=0$, unless you are experienced with finite element mesh generation.
18:   outfileconst char *Input
On entry: the name of a file to which diagnostic output will be directed. If outfile is NULL the diagnostic output will be directed to standard output.
19:   commNag_Comm *Communication Structure
The NAG communication argument (see Section 3.2.1.1 in the Essential Introduction).
20:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ncomp the number of connected components of the boundary is less than $1$: ${\mathbf{ncomp}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{nedmx}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nedmx}}\ge 1$.
On entry, nedmx the maximum number of boundary edge lines is less than $1$: ${\mathbf{nedmx}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nlines}}\ge 1$.
On entry, nlines the number of lines is less than $1$: ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
NE_INT_2
On entry, ${\mathbf{nvmax}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nvmax}}\ge {\mathbf{nlines}}$.
On entry, nvmax the maximum number of boundary vertices is less than nlines: ${\mathbf{nvmax}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{sdcrus}}=〈\mathit{\text{value}}〉$ and $\mathit{nusmin}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{sdcrus}}\ge \mathit{nusmin}$.
On entry, the line list for the separate connected component of the boundary is badly set: ${\mathbf{lcomp}}\left[l-1\right]=〈\mathit{\text{value}}〉$ and $l=〈\mathit{\text{value}}〉$. It should be less than or equal to nlines and greater than or equal to $1$.
On entry, the number of points on line $〈\mathit{\text{value}}〉$ is $〈\mathit{\text{value}}〉$. It should be greater than or equal to $2$.
On entry, there is a correlation problem between the user-supplied coordinates and the specification of the polygonal arc representing line $i=〈\mathit{\text{value}}〉$ with the index in ${\mathbf{crus}}=〈\mathit{\text{value}}〉$.
On entry, the sum of absolute values of all numbers of line segments is different from nlines. The sum of all the elements of ${\mathbf{nlcomp}}=〈\mathit{\text{value}}〉$. ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
NE_INT_3
On entry, the absolute number of line segments in the $k$th component of the contour should be less than or equal to nlines and greater than $0$. $k=〈\mathit{\text{value}}〉$, ${\mathbf{nlcomp}}\left[k-1\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
On entry, the index of the first end point of line $〈\mathit{\text{value}}〉$ is $〈\mathit{\text{value}}〉$. It should be greater than or equal to $1$ and less than or equal to ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
On entry, the index of the second end point of line $〈\mathit{\text{value}}〉$ is $〈\mathit{\text{value}}〉$. It should be greater than or equal to $1$ and less than or equal to ${\mathbf{nlines}}=〈\mathit{\text{value}}〉$.
On entry, the indices of the extremities of line $〈\mathit{\text{value}}〉$ are both equal to $〈\mathit{\text{value}}〉$.
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.
NE_MESH_ERROR
An error has occurred during the generation of the boundary mesh. It appears that nedmx is not large enough: ${\mathbf{nedmx}}=〈\mathit{\text{value}}〉$.
An error has occurred during the generation of the boundary mesh. It appears that nvmax is not large enough: ${\mathbf{nvmax}}=〈\mathit{\text{value}}〉$.
On entry, end point $1$, with index $k$, does not lie on the curve representing line $i$ with index $j$: $k=〈\mathit{\text{value}}〉$, $i=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$, $f\left(x,y\right)=〈\mathit{\text{value}}〉$.
On entry, end point $2$, with index $k$, does not lie on the curve representing line $i$ with index $j$: $k=〈\mathit{\text{value}}〉$, $i=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$, $f\left(x,y\right)=〈\mathit{\text{value}}〉$.
On entry, the geometric progression ratio between the points to be generated on line $〈\mathit{\text{value}}〉$ is $〈\mathit{\text{value}}〉$. It should be greater than $0$ unless the line segment is defined by user-supplied points.
On entry, there is a problem with either the coordinates of characteristic points, or with the definition of the mesh lines.
NE_NOT_CLOSE_FILE
Cannot close file $〈\mathit{\text{value}}〉$.
NE_NOT_WRITE_FILE
Cannot open file $〈\mathit{\text{value}}〉$ for writing.

Not applicable.

8  Further Comments

The boundary mesh generation technique in this function has a ‘tree’ structure. The boundary should be partitioned into geometrically simple segments (straight lines or curves) delimited by characteristic points. Then, the lines should be assembled into connected components of the boundary domain.
Using this strategy, the inputs to that function can be built up, following the requirements stated in Section 5:
The example below details the use of this strategy.

9  Example

The NAG logo is taken as an example of a geometry with holes. The boundary has been partitioned in $40$ lines characteristic points; including $4$ for the exterior boundary and $36$ for the logo itself. All line geometry specifications have been considered, see the description of lined, including $4$ lines defined as polygonal arc, $4$ defined by fbnd and all the others are straight lines.

9.1  Program Text

Program Text (d06bace.c)

9.2  Program Data

Program Data (d06bace.d)

9.3  Program Results

Program Results (d06bace.r)

nag_mesh2d_bound (d06bac) (PDF version)
d06 Chapter Contents
d06 Chapter Introduction
NAG C Library Manual