NAG Library Function Document

nag_mesh2d_bound (d06bac)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

nag_mesh2d_bound (d06bac) generates a boundary mesh on a closed connected subdomain Ω of 2.

2
Specification

#include <nag.h>
#include <nagd06.h>
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 Ω of 2, whose boundary Ω is divided by characteristic points into m distinct line segments, nag_mesh2d_bound (d06bac) generates a boundary mesh on Ω. Each line segment may be a straight line, a curve defined by the equation fx,y=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 Ω. 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:     nlines IntegerInput
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 Ω into lines).
Constraint: nlines1.
2:     coorch[2×nlines] const doubleInput
Note: the i,jth element of the matrix is stored in coorch[j-1×2+i-1].
On entry: coorch[i-1×2] contains the x coordinate of the ith characteristic point, for i=1,2,,nlines; while coorch[i-1×2+1] contains the corresponding y coordinate.
3:     lined[4×nlines] const IntegerInput
Note: the i,jth element of the matrix is stored in lined[j-1×4+i-1].
On entry: the description of the lines that define the boundary domain. The line i, for i=1,2,,m, is defined as follows:
lined[i-1×4]
The number of points on the line, including two end points.
lined[i-1×4+1]
The first end point of the line. If lined[i-1×4+1]=j, the coordinates of the first end point are those stored in coorch[j-1×2],coorch[j-1×2+1].
lined[i-1×4+2]
The second end point of the line. If lined[i-1×4+2]=k, the coordinates of the second end point are those stored in coorch[k-1×2],coorch[k-1×2+1].
lined[i-1×4+3]
This defines the type of line segment connecting the end points. Additional information is conveyed by the numerical value of lined[i-1×4+3] as follows:
(i) lined[i-1×4+3]>0, the line is described in fbnd with lined[i-1×4+3] as the index. In this case, the line must be described in the trigonometric (anticlockwise) direction;
(ii) lined[i-1×4+3]=0, the line is a straight line;
(iii) if lined[i-1×4+3]<0, say (i.e., lined[i-1×4+3]=-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 coorch[j-1×2+z] , crus[p-1×2+z] , crus[p×2+z] ,, crus[p+r-4×2+z] , coorch[k-1×2+z] , where z0,1, r=lined[i-1×4], j=lined[i-1×4+1] and k=lined[i-1×4+2].
Constraints:
  • 2lined[i-1×4];
  • 1lined[i-1×4+1]nlines;
  • 1lined[i-1×4+2]nlines;
  • lined[i-1×4+1]lined[i-1×4+2], for i=1,2,,nlines.
For each line described by fbnd (lines with lined[i-1×4+3] > 0 , for i=1,2,,nlines) the two end points ( lined[i-1×4+1]  and lined[i-1×4+2] ) lie on the curve defined by index lined[i-1×4+3] in fbnd, i.e.,
fbnd lined[i-1×4+3],coorch[lined[i-1×4+1]-1×2],coorch[lined[i-1×4+1]-1×2+1],comm = 0 ;
fbnd lined[i-1×4+3],coorch[lined[i-1×4+2]-1×2],coorch[lined[i-1×4+2]-1×2+1],comm = 0 , for i=1,2,,nlines.
For all lines described as polygonal arcs (lines with lined[i-1×4+3] < 0 , for i=1,2,,nlines) the sets of intermediate points (i.e., -lined[i-1×4+3] : -lined[i-1×4+3] + lined[i-1×4] - 3  for all i such that lined[i-1×4+3]<0) are not overlapping. This can be expressed as:
-lined[i-1×4+3] + lined[i-1×4] - 3 = i,lined[i-1×4+3]<0 lined[i-1×4] - 2  
or
-lined[i-1×4+3] + lined[i-1×4] - 2 = -lined[j-1×4+3] ,  
for a j such that j=1,2,,nlines, ji and lined[j-1×4+3]<0.
4:     fbnd function, supplied by the userExternal Function
fbnd must be supplied to calculate the value of the function which describes the curve x,y 2; such that ​f x,y=0  on segments of the boundary for which lined[i-1×4+3]>0. If there are no boundaries for which lined[i-1×4+3]>0 fbnd will never be referenced by nag_mesh2d_bound (d06bac), in which case fbnd may be NULLFN.
The specification of fbnd is:
double  fbnd (Integer i, double x, double y, Nag_Comm *comm)
1:     i IntegerInput
On entry: lined[i-1×4+3], the reference index of the line (portion of the contour) i described.
2:     x doubleInput
3:     y doubleInput
On entry: the values of x and y at which fx,y is to be evaluated.
4:     comm Nag_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.3.1.1 in How to Use the NAG Library and its Documentation).
Note: fbnd should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by nag_mesh2d_bound (d06bac). If your code inadvertently does return any NaNs or infinities, nag_mesh2d_bound (d06bac) is likely to produce unexpected results.
5:     crus[2×sdcrus] const doubleInput
Note: the i,jth element of the matrix is stored in crus[j-1×2+i-1].
On entry: the coordinates of the intermediate points for polygonal arc lines. For a line i defined as a polygonal arc (i.e., lined[i-1×4+3]<0), if p=-lined[i-1×4+3], crus[k-1×2], for k=p,,p+lined[i-1×4]-3, must contain the x coordinate of the consecutive intermediate points for this line. Similarly crus[k-1×2+1], for k=p,,p+lined[i-1×4]-3, must contain the corresponding y coordinate.
6:     sdcrus IntegerInput
On entry: the half dimension of the array crus as declared in the function from which nag_mesh2d_bound (d06bac) is called.
Constraint: sdcrusi,lined[i-1×4+3]<0lined[i-1×4]-2.
7:     rate[nlines] const doubleInput
On entry: rate[i-1] is the geometric progression ratio between the points to be generated on the line i, for i=1,2,,m and lined[i-1×4+3]0.
If lined[i-1×4+3]<0, rate[i-1] is not referenced.
Constraint: if lined[i-1×4+3]0, rate[i-1]>0.0, for i=1,2,,nlines.
8:     ncomp IntegerInput
On entry: n, the number of separately connected components of the boundary.
Constraint: ncomp1.
9:     nlcomp[ncomp] const IntegerInput
On entry: nlcomp[k-1] is the number of line segments in component k of the contour. The line i of component k runs in the direction lined[i-1×4+1] to lined[i-1×4+2] if nlcomp[k-1]>0, and in the opposite direction otherwise; for k=1,2,,n.
Constraints:
  • 1nlcomp[k-1]nlines, for k=1,2,,ncomp;
  • k =1 n nlcomp[k-1] =nlines .
10:   lcomp[nlines] const IntegerInput
On entry: lcomp must contain the list of line numbers for the each component of the boundary. Specifically, the line numbers for the kth component of the boundary, for k=1,2,,ncomp, must be in elements l1-1 to l2-1 of lcomp, where l2 = i=1 k nlcomp[i-1]  and l1=l2+1-nlcomp[k-1].
Constraint: lcomp must hold a valid permutation of the integers 1,nlines.
11:   nvmax IntegerInput
On entry: the maximum number of the boundary mesh vertices to be generated.
Constraint: nvmaxnlines.
12:   nedmx IntegerInput
On entry: the maximum number of boundary edges in the boundary mesh to be generated.
Constraint: nedmx1.
13:   nvb Integer *Output
On exit: the total number of boundary mesh vertices generated.
14:   coor[2×nvmax] doubleOutput
Note: the i,jth element of the matrix is stored in coor[j-1×2+i-1].
On exit: coor[i-1×2] will contain the x coordinate of the ith boundary mesh vertex generated, for i=1,2,,nvb; while coor[i-1×2+1] will contain the corresponding y coordinate.
15:   nedge Integer *Output
On exit: the total number of boundary edges in the boundary mesh.
16:   edge[3×nedmx] IntegerOutput
Note: the i,jth element of the matrix is stored in edge[j-1×3+i-1].
On exit: the specification of the boundary edges. edge[j-1×3] and edge[j-1×3+1] will contain the vertex numbers of the two end points of the jth boundary edge. edge[j-1×3+2] is a reference number for the jth boundary edge and
  • edge[j-1×3+2]=lined[i-1×4+3], where i and j are such that the jth edges is part of the ith line of the boundary and lined[i-1×4+3]0;
  • edge[j-1×3+2]=100+lined[i-1×4+3], where i and j are such that the jth edges is part of the ith line of the boundary and lined[i-1×4+3]<0.
Note that the edge vertices are numbered from 1 to nvb.
17:   itrace IntegerInput
On entry: the level of trace information required from nag_mesh2d_bound (d06bac).
itrace=0 or itrace<-1
No output is generated.
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.
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).
itrace>1
The output is similar to that produced when itrace=1, but the coordinates of the generated vertices on the boundary are also output.
You are advised to set itrace=0, unless you are experienced with finite element mesh generation.
18:   outfile const 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:   comm Nag_Comm *
The NAG communication argument (see Section 3.3.1.1 in How to Use the NAG Library and its Documentation).
20:   fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, ncomp the number of connected components of the boundary is less than 1: ncomp=value.
On entry, nedmx=value.
Constraint: nedmx1.
On entry, nedmx the maximum number of boundary edge lines is less than 1: nedmx=value.
On entry, nlines=value.
Constraint: nlines1.
On entry, nlines the number of lines is less than 1: nlines=value.
NE_INT_2
On entry, nvmax=value and nlines=value.
Constraint: nvmaxnlines.
On entry, nvmax the maximum number of boundary vertices is less than nlines: nvmax=value and nlines=value.
On entry, sdcrus=value and nusmin=value.
Constraint: sdcrusnusmin.
On entry, the line list for the separate connected component of the boundary is badly set: lcomp[l-1]=value and l=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 value is 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=value with the index in crus=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 nlcomp=value. nlines=value.
NE_INT_3
On entry, the absolute number of line segments in the kth component of the contour should be less than or equal to nlines and greater than 0. k=value, nlcomp[k-1]=value and nlines=value.
On entry, the index of the first end point of line value is value. It should be greater than or equal to 1 and less than or equal to nlines=value.
On entry, the index of the second end point of line value is value. It should be greater than or equal to 1 and less than or equal to nlines=value.
On entry, the indices of the extremities of line value are both equal to 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.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_MESH_ERROR
An error has occurred during the generation of the boundary mesh. It appears that nedmx is not large enough: nedmx=value.
An error has occurred during the generation of the boundary mesh. It appears that nvmax is not large enough: nvmax=value.
On entry, end point 1, with index K, does not lie on the curve representing line I with index J: K=value, I=value, J=value, fx,y=value.
On entry, end point 2, with index K, does not lie on the curve representing line I with index J: K=value, I=value, J=value, fx,y=value.
On entry, the geometric progression ratio between the points to be generated on line value is 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_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_NOT_CLOSE_FILE
Cannot close file value.
NE_NOT_WRITE_FILE
Cannot open file value for writing.

7
Accuracy

Not applicable.

8
Parallelism and Performance

nag_mesh2d_bound (d06bac) is not threaded in any implementation.

9
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.

10
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.

10.1
Program Text

Program Text (d06bace.c)

10.2
Program Data

Program Data (d06bace.d)

10.3
Program Results

Program Results (d06bace.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Example Program Boundary Mesh of the NAG Logo with 259 Nodes and 259 Edges gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Final Mesh Built Using the Delaunay-Voronoi Method gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Final Mesh Built Using the Advancing Front Method gnuplot_plot_1
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017