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

NAG Library Routine Document

D06DBF

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

D06DBF joins together (restitches) two adjacent, or overlapping, meshes.

2  Specification

INTEGER  NV1, NELT1, NEDGE1, EDGE1(3,NEDGE1), CONN1(3,NELT1), REFT1(NELT1), NV2, NELT2, NEDGE2, EDGE2(3,NEDGE2), CONN2(3,NELT2), REFT2(NELT2), NV3, NELT3, NEDGE3, EDGE3(3,*), CONN3(3,*), REFT3(*), ITRACE, IWORK(LIWORK), LIWORK, IFAIL
REAL (KIND=nag_wp)  EPS, COOR1(2,NV1), COOR2(2,NV2), COOR3(2,*)

3  Description

D06DBF joins together two adjacent, or overlapping, meshes. If the two meshes are adjacent then vertices belonging to the part of the boundary forming the common interface should coincide. If the two meshes overlap then vertices and triangles in the overlapping zone should coincide too.
This routine is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

4  References

None.

5  Parameters

1:     EPS – REAL (KIND=nag_wp)Input
On entry: the relative precision of the restitching of the two input meshes (see Section 9).
Suggested value: 0.001.
Constraint: EPS>0.0.
2:     NV1 – INTEGERInput
On entry: the total number of vertices in the first input mesh.
Constraint: NV13.
3:     NELT1 – INTEGERInput
On entry: the number of triangular elements in the first input mesh.
Constraint: NELT12×NV1-1.
4:     NEDGE1 – INTEGERInput
On entry: the number of boundary edges in the first input mesh.
Constraint: NEDGE11.
5:     COOR12NV1 – REAL (KIND=nag_wp) arrayInput
On entry: COOR11i contains the x coordinate of the ith vertex of the first input mesh, for i=1,2,,NV1; while COOR12i contains the corresponding y coordinate.
6:     EDGE13NEDGE1 – INTEGER arrayInput
On entry: the specification of the boundary edges of the first input mesh. EDGE11j and EDGE12j contain the vertex numbers of the two end points of the jth boundary edge. EDGE13j is a user-supplied tag for the jth boundary edge.
Constraint: 1EDGE1ijNV1 and EDGE11jEDGE12j, for i=1,2 and j=1,2,,NEDGE1.
7:     CONN13NELT1 – INTEGER arrayInput
On entry: the connectivity between triangles and vertices of the first input mesh. For each triangle j, CONN1ij gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,NELT1.
Constraints:
  • 1CONN1ijNV1;
  • CONN11jCONN12j;
  • CONN11jCONN13j and CONN12jCONN13j, for i=1,2,3 and j=1,2,,NELT1.
8:     REFT1NELT1 – INTEGER arrayInput
On entry: REFT1k contains the user-supplied tag of the kth triangle from the first input mesh, for k=1,2,,NELT1.
9:     NV2 – INTEGERInput
On entry: the total number of vertices in the second input mesh.
Constraint: NV23.
10:   NELT2 – INTEGERInput
On entry: the number of triangular elements in the second input mesh.
Constraint: NELT22×NV2-1.
11:   NEDGE2 – INTEGERInput
On entry: the number of boundary edges in the second input mesh.
Constraint: NEDGE21.
12:   COOR22NV2 – REAL (KIND=nag_wp) arrayInput
On entry: COOR21i contains the x coordinate of the ith vertex of the second input mesh, for i=1,2,,NV2; while COOR22i contains the corresponding y coordinate.
13:   EDGE23NEDGE2 – INTEGER arrayInput
On entry: the specification of the boundary edges of the second input mesh. EDGE21j and EDGE22j contain the vertex numbers of the two end points of the jth boundary edge. EDGE23j is a user-supplied tag for the jth boundary edge.
Constraint: 1EDGE2ijNV2 and EDGE21jEDGE22j, for i=1,2 and j=1,2,,NEDGE2.
14:   CONN23NELT2 – INTEGER arrayInput
On entry: the connectivity between triangles and vertices of the second input mesh. For each triangle j, CONN2ij gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,NELT2.
Constraints:
  • 1CONN2ijNV2;
  • CONN21jCONN22j;
  • CONN21jCONN23j and CONN22jCONN23j, for i=1,2,3 and j=1,2,,NELT2.
15:   REFT2NELT2 – INTEGER arrayInput
On entry: REFT2k contains the user-supplied tag of the kth triangle from the second input mesh, for k=1,2,,NELT2.
16:   NV3 – INTEGEROutput
On exit: the total number of vertices in the resulting mesh.
17:   NELT3 – INTEGEROutput
On exit: the number of triangular elements in the resulting mesh.
18:   NEDGE3 – INTEGEROutput
On exit: the number of boundary edges in the resulting mesh.
19:   COOR32* – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array COOR3 must be at least NV1+NV2.
On exit: COOR31i will contain the x coordinate of the ith vertex of the resulting mesh, for i=1,2,,NV3; while COOR32i will contain the corresponding y coordinate.
20:   EDGE33* – INTEGER arrayOutput
Note: the second dimension of the array EDGE3 must be at least NEDGE1+NEDGE2. This may be reduced to NEDGE3 once that value is known.
On exit: the specification of the boundary edges of the resulting mesh. EDGE3ij will contain the vertex number of the ith end point (i=1,2) of the jth boundary or interface edge.
If the two meshes overlap, EDGE33j will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.
If the two meshes are adjacent,
(i) if the jth edge is part of the partition interface, then EDGE33j will contain the value 1000×k1+k2 where k1 and k2 are the tags for the same edge of the first and the second mesh respectively;
(ii) otherwise, EDGE33j will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.
21:   CONN33* – INTEGER arrayOutput
Note: the second dimension of the array CONN3 must be at least NELT1+NELT2. This may be reduced to NELT3 once that value is known.
On exit: the connectivity between triangles and vertices of the resulting mesh. CONN3ij will give the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,NELT3.
22:   REFT3* – INTEGER arrayOutput
Note: the dimension of the array REFT3 must be at least NELT1+NELT2. This may be reduced to NELT3 once that value is known.
On exit: if the two meshes form a partition, REFT3k will contain the same tag as the corresponding triangle belonging to the first or the second input mesh, for k=1,2,,NELT3. If the two meshes overlap, then REFT3k will contain the value 1000×k1+k2 where k1 and k2 are the user-supplied tags for the same triangle of the first and the second mesh respectively, for k=1,2,,NELT3.
23:   ITRACE – INTEGERInput
On entry: the level of trace information required from D06DBF.
ITRACE0
No output is generated.
ITRACE1
Details about the common vertices, edges and triangles to both meshes are printed on the current advisory message unit (see X04ABF).
24:   IWORKLIWORK – INTEGER arrayWorkspace
25:   LIWORK – INTEGERInput
On entry: the dimension of the array IWORK as declared in the (sub)program from which D06DBF is called.
Constraint: LIWORK2×NV1+3×NV2+NELT1+NELT2+NEDGE1+NEDGE2+1024.
26:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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,EPS0.0,
orNV1<3,
orNELT1>2×NV1-1,
orNEDGE1<1,
orEDGE1ij<1 or EDGE1ij>NV1 for some i=1,2 and j=1,2,,NEDGE1,
orEDGE11j=EDGE12j for some j=1,2,,NEDGE1,
orCONN1ij<1 or CONN1ij>NV1 for some i=1,2,3 and j=1,2,,NELT1,
orCONN11j=CONN12j or CONN11j=CONN13j or
CONN12j=CONN13j for some j=1,2,,NELT1,
orNV2<3,
orNELT2>2×NV2-1,
orNEDGE2<1,
orEDGE2ij<1 or EDGE2ij>NV2 for some i=1,2 and j=1,2,,NEDGE2,
orEDGE21j=EDGE22j for some j=1,2,,NEDGE2,
orCONN2ij<1 or CONN2ij>NV2 for some i=1,2,3 and j=1,2,,NELT2,
orCONN21j=CONN22j or CONN21j=CONN23j or
CONN22j=CONN23j for some j=1,2,,NELT2,
orLIWORK<2×NV1+3×NV2+NELT1+NELT2+NEDGE1+NEDGE2+1024.
IFAIL=2
Using the input precision EPS, the routine has detected fewer than two coincident vertices between the two input meshes. You are advised to try another value of EPS; if this error still occurs the two meshes are probably not stitchable.
IFAIL=3
A serious error has occurred in an internal call to the restitching routine. You should check the input of the two meshes, especially the edge/vertex and/or the triangle/vertex connectivities. If the problem persists, contact NAG.
IFAIL=4
The routine has detected a different number of coincident triangles from the two input meshes in the overlapping zone. You should check the input of the two meshes, especially the triangle/vertex connectivities.
IFAIL=5
The routine has detected a different number of coincident edges from the two meshes on the partition interface. You should check the input of the two meshes, especially the edge/vertex connectivities.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

Not applicable.

9  Further Comments

D06DBF finds all the common vertices between the two input meshes using the relative precision of the restitching parameter EPS. You are advised to vary the value of EPS in the neighbourhood of 0.001 with ITRACE1 to get the optimal value for the meshes under consideration.

10  Example

For this routine two examples are presented. There is a single example program for D06DBF, with a main program and the code to solve the two example problems given in Example 1 (EX1) and Example 2 (EX2).
Example 1 (EX1)
This example involves the unit square 0,12 meshed uniformly, and then translated by a vector u= u1 u2  (using D06DAF). This translated mesh is then restitched with the original mesh. Two cases are considered:
(a) overlapping meshes (u1=15.0, u2=17.0),
(b) partitioned meshes (u1=19.0, u2=0.0).
The mesh on the unit square has 400 vertices, 722 triangles and its boundary has 76 edges. In the partitioned case the resulting geometry is shown in Figure 1 in Section 10.3 while the restitched mesh is shown in Figure 2 in Section 10.3. In the overlapping case the geometry and mesh are shown in Figure 3 and Figure 4 in Section 10.3.
Example 2 (EX2)
This example restitches three geometries by calling the routine D06DBF twice. The result is a mesh with three partitions. The first geometry is meshed by the Delaunay–Voronoi process (using D06ABF), the second one meshed by an Advancing Front algorithm (using D06ACF), while the third one is the result of a rotation (by -π/2) of the second one (using D06DAF). The resulting geometry is shown in Figure 5 in Section 10.3 and restitched mesh in Figure 6 in Section 10.3.

10.1  Program Text

Program Text (d06dbfe.f90)

10.2  Program Data

Program Data (d06dbfe.d)

10.3  Program Results

Program Results (d06dbfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Example Program Figure 1: Boundary and Interior Interface of Partitioned Squares gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Figure 2: Interior Mesh of Partitioned Squares gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Figure 3: Boundary and Interior Interface of Overlapping Squares gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Figure 4: Interior Mesh of Overlapping Squares gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Figure 5: Boundary and Interior Interfaces for Key Shape gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Figure 6: Interior Mesh of KeyShape gnuplot_plot_1

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

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