D06BAF (PDF version)
D06 Chapter Contents
D06 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

D06BAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

D06BAF generates a boundary mesh on a closed connected subdomain Ω of 2.

2  Specification

INTEGER  NLINES, LINED(4,NLINES), SDCRUS, NCOMP, NLCOMP(NCOMP), LCOMP(NLINES), NVMAX, NEDMX, NVB, NEDGE, EDGE(3,NEDMX), ITRACE, IUSER(*), LRWORK, IWORK(LIWORK), LIWORK, IFAIL
REAL (KIND=nag_wp)  COORCH(2,NLINES), FBND, CRUS(2,SDCRUS), RATE(NLINES), COOR(2,NVMAX), RUSER(*), RWORK(LRWORK)
EXTERNAL  FBND

3  Description

Given a closed connected subdomain Ω of 2, whose boundary Ω is divided by characteristic points into m distinct line segments, D06BAF 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 routine is primarily designed for use with either D06AAF (a simple incremental method) or D06ABF (Delaunay–Voronoi method) or D06ACF (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 routine 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:     COORCH2NLINES – REAL (KIND=nag_wp) arrayInput
On entry: COORCH1i contains the x coordinate of the ith characteristic point, for i=1,2,,NLINES; while COORCH2i contains the corresponding y coordinate.
3:     LINED4NLINES – INTEGER arrayInput
On entry: the description of the lines that define the boundary domain. The line i, for i=1,2,,m, is defined as follows:
LINED1i
The number of points on the line, including two end points.
LINED2i
The first end point of the line. If LINED2i=j, then the coordinates of the first end point are those stored in COORCH:j.
LINED3i
The second end point of the line. If LINED3i=k, then the coordinates of the second end point are those stored in COORCH:k.
LINED4i
This defines the type of line segment connecting the end points. Additional information is conveyed by the numerical value of LINED4i as follows:
(i) LINED4i>0, the line is described in FBND with LINED4i as the index. In this case, the line must be described in the trigonometric (anticlockwise) direction;
(ii) LINED4i=0, the line is a straight line;
(iii) if LINED4i<0, say (-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 , CRUS:p , CRUS:p+1 ,, CRUS:p+r-3 , COORCH:k  , where z1,2, r=LINED1i, j=LINED2i and k=LINED3i.
Constraints:
  • 2LINED1i;
  • 1LINED2iNLINES;
  • 1LINED3iNLINES;
  • LINED2iLINED3i, for i=1,2,,NLINES.
For each line described by FBND (lines with LINED4i > 0 , for i=1,2,,NLINES) the two end points ( LINED2i  and LINED3i ) lie on the curve defined by index LINED4i in FBND, i.e.,
FBND LINED4i,COORCH1LINED2i,COORCH2LINED2i,RUSER,IUSER = 0 ;
FBND LINED4i,COORCH1LINED3i,COORCH2LINED3i,RUSER,IUSER = 0 , for i=1,2,,NLINES.
For all lines described as polygonal arcs (lines with LINED4i < 0 , for i=1,2,,NLINES) the sets of intermediate points (i.e., -LINED4i : -LINED4i + LINED1i - 3  for all i such that LINED4i<0) are not overlapping. This can be expressed as:
-LINED4i + LINED1i - 3 = i,LINED4i<0 LINED1i - 2  
or
-LINED4i + LINED1i - 2 = -LINED4j ,  
for a j such that j=1,2,,NLINES, ji and LINED4j<0.
4:     FBND – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
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 LINED4i>0. If there are no boundaries for which LINED4i>0 FBND will never be referenced by D06BAF and FBND may be the dummy function D06BAD. (D06BAD is included in the NAG Library.)
The specification of FBND is:
FUNCTION FBND ( I, X, Y, RUSER, IUSER)
REAL (KIND=nag_wp) FBND
INTEGER  I, IUSER(*)
REAL (KIND=nag_wp)  X, Y, RUSER(*)
1:     I – INTEGERInput
On entry: LINED4i, the reference index of the line (portion of the contour) i described.
2:     X – REAL (KIND=nag_wp)Input
3:     Y – REAL (KIND=nag_wp)Input
On entry: the values of x and y at which fx,y is to be evaluated.
4:     RUSER* – REAL (KIND=nag_wp) arrayUser Workspace
5:     IUSER* – INTEGER arrayUser Workspace
FBND is called with the arguments RUSER and IUSER as supplied to D06BAF. You should use the arrays RUSER and IUSER to supply information to FBND.
FBND must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D06BAF is called. Arguments denoted as Input must not be changed by this procedure.
5:     CRUS2SDCRUS – REAL (KIND=nag_wp) arrayInput
On entry: the coordinates of the intermediate points for polygonal arc lines. For a line i defined as a polygonal arc (i.e., LINED4i<0), if p=-LINED4i, then CRUS1k, for k=p,,p+LINED1i-3, must contain the x coordinate of the consecutive intermediate points for this line. Similarly CRUS2k, for k=p,,p+LINED1i-3, must contain the corresponding y coordinate.
6:     SDCRUS – INTEGERInput
On entry: the second dimension of the array CRUS as declared in the (sub)program from which D06BAF is called.
Constraint: SDCRUSi,LINED4i<0LINED1i-2.
7:     RATENLINES – REAL (KIND=nag_wp) arrayInput
On entry: RATEi is the geometric progression ratio between the points to be generated on the line i, for i=1,2,,m and LINED4i0.
If LINED4i<0, RATEi is not referenced.
Constraint: if LINED4i0, RATEi>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:     NLCOMPNCOMP – INTEGER arrayInput
On entry: NLCOMPk is the number of line segments in component k of the contour. The line i of component k runs in the direction LINED2i to LINED3i if NLCOMPk>0, and in the opposite direction otherwise; for k=1,2,,n.
Constraints:
  • 1NLCOMPkNLINES, for k=1,2,,NCOMP;
  • k =1 n NLCOMPk =NLINES .
10:   LCOMPNLINES – INTEGER arrayInput
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 NLCOMPi  and l1=l2+1-NLCOMPk.
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 – INTEGEROutput
On exit: the total number of boundary mesh vertices generated.
14:   COOR2NVMAX – REAL (KIND=nag_wp) arrayOutput
On exit: COOR1i will contain the x coordinate of the ith boundary mesh vertex generated, for i=1,2,,NVB; while COOR2i will contain the corresponding y coordinate.
15:   NEDGE – INTEGEROutput
On exit: the total number of boundary edges in the boundary mesh.
16:   EDGE3NEDMX – INTEGER arrayOutput
On exit: the specification of the boundary edges. EDGE1j and EDGE2j will contain the vertex numbers of the two end points of the jth boundary edge. EDGE3j is a reference number for the jth boundary edge and
  • EDGE3j=LINED4i, where i and j are such that the jth edges is part of the ith line of the boundary and LINED4i0;
  • EDGE3j=100+LINED4i, where i and j are such that the jth edges is part of the ith line of the boundary and LINED4i<0.
17:   ITRACE – INTEGERInput
On entry: the level of trace information required from D06BAF.
ITRACE=0 or ITRACE<-1
No output is generated.
ITRACE=1
Output from the boundary mesh generator is printed on the current advisory message unit (see X04ABF). 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 routine, calling either D06AAF, D06ABF or D06ACF.
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:   RUSER* – REAL (KIND=nag_wp) arrayUser Workspace
19:   IUSER* – INTEGER arrayUser Workspace
RUSER and IUSER are not used by D06BAF, but are passed directly to FBND and should be used to pass information to this routine.
20:   RWORKLRWORK – REAL (KIND=nag_wp) arrayWorkspace
21:   LRWORK – INTEGERInput
On entry: the dimension of the array RWORK as declared in the (sub)program from which D06BAF is called.
Constraint: LRWORK2×NLINES+SDCRUS+2×maxi=1,2,,mLINED1i×NLINES.
22:   IWORKLIWORK – INTEGER arrayWorkspace
23:   LIWORK – INTEGERInput
On entry: the dimension of the array IWORK as declared in the (sub)program from which D06BAF is called.
Constraint: LIWORKi,LINED4i<0 LINED1i-2+8×NLINES+NVMAX+3×NEDMX+2×SDCRUS.
24:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry 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:
IFAIL=1
On entry,NLINES<1;
orNVMAX<NLINES;
orNEDMX<1;
orNCOMP<1;
orLRWORK<2×NLINES+SDCRUS+2×maxi=1,2,,mLINED1i×NLINES;
or LIWORK < i, LINED4 i < 0 LINED1 i -2 +8 × NLINES +NVMAX +3 × NEDMX +2 × SDCRUS ;
or SDCRUS < i, LINED4 i < 0 LINED1 i -2 ;
orRATEi<0.0 for some i=1,2,,NLINES with LINED4i0;
orLINED1i<2 for some i=1,2,,NLINES;
orLINED2i<1 or LINED2i>NLINES for some i=1,2,,NLINES;
orLINED3i<1 or LINED3i>NLINES for some i=1,2,,NLINES;
orLINED2i=LINED3i for some i=1,2,,NLINES;
orNLCOMPk=0, or NLCOMPk>NLINES for a k=1,2,,NCOMP;
or k =1 n NLCOMP k NLINES ;
orLCOMP does not represent a valid permutation of the integers in 1,NLINES;
orone of the end points for a line i described by the user-supplied function (lines with LINED4i>0, for i=1,2,,NLINES) does not belong to the corresponding curve in FBND;
orthe intermediate points for the lines described as polygonal arcs (lines with LINED4i<0, for i=1,2,,NLINES) are overlapping.
IFAIL=2
An error has occurred during the generation of the boundary mesh. It appears that NEDMX is not large enough, so you are advised to increase the value of NEDMX.
IFAIL=3
An error has occurred during the generation of the boundary mesh. It appears that NVMAX is not large enough, so you are advised to increase the value of NVMAX.
IFAIL=4
An error has occurred during the generation of the boundary mesh. Check the definition of each line (the argument LINED) and each connected component of the boundary (the arguments NLCOMP, and LCOMP, as well as the coordinates of the characteristic points. Setting ITRACE>0 may provide more details.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

D06BAF is not threaded in any implementation.

9  Further Comments

The boundary mesh generation technique in this routine 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 routine 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 (d06bafe.f90)

10.2  Program Data

Program Data (d06bafe.d)

10.3  Program Results

Program Results (d06bafe.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

D06BAF (PDF version)
D06 Chapter Contents
D06 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016