NAG CL Interface
d06dbc (dim2_​join)

Settings help

CL Name Style:


1 Purpose

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

2 Specification

#include <nag.h>
void  d06dbc (double eps, Integer nv1, Integer nelt1, Integer nedge1, const double coor1[], const Integer edge1[], const Integer conn1[], const Integer reft1[], Integer nv2, Integer nelt2, Integer nedge2, const double coor2[], const Integer edge2[], const Integer conn2[], const Integer reft2[], Integer *nv3, Integer *nelt3, Integer *nedge3, double coor3[], Integer edge3[], Integer conn3[], Integer reft3[], Integer itrace, const char *outfile, NagError *fail)
The function may be called by the names: d06dbc, nag_mesh_dim2_join or nag_mesh2d_join.

3 Description

d06dbc 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 function is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

4 References

None.

5 Arguments

1: eps double 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 Integer Input
On entry: the total number of vertices in the first input mesh.
Constraint: nv13.
3: nelt1 Integer Input
On entry: the number of triangular elements in the first input mesh.
Constraint: nelt12×nv1-1.
4: nedge1 Integer Input
On entry: the number of boundary edges in the first input mesh.
Constraint: nedge11.
5: coor1[2×nv1] const double Input
Note: the (i,j)th element of the matrix is stored in coor1[(j-1)×2+i-1].
On entry: coor1[(i-1)×2] contains the x coordinate of the ith vertex of the first input mesh, for i=1,2,,nv1; while coor1[(i-1)×2+1] contains the corresponding y coordinate.
6: edge1[3×nedge1] const Integer Input
Note: the (i,j)th element of the matrix is stored in edge1[(j-1)×3+i-1].
On entry: the specification of the boundary edges of the first input mesh. edge1[(j-1)×3] and edge1[(j-1)×3+1] contain the vertex numbers of the two end points of the jth boundary edge. edge1[(j-1)×3+2] is a user-supplied tag for the jth boundary edge.
Constraint: 1edge1[(j-1)×3+i-1]nv1 and
edge1[(j-1)×3]edge1[(j-1)×3+1], for i=1,2 and j=1,2,,nedge1.
7: conn1[3×nelt1] const Integer Input
Note: the (i,j)th element of the matrix is stored in conn1[(j-1)×3+i-1].
On entry: the connectivity between triangles and vertices of the first input mesh. For each triangle j, conn1[(j-1)×3+i-1] gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,nelt1.
Constraints:
  • 1conn1[(j-1)×3+i-1]nv1;
  • conn1[(j-1)×3]conn1[(j-1)×3+1];
  • conn1[(j-1)×3]conn1[(j-1)×3+2] and
    conn1[(j-1)×3+1]conn1[(j-1)×3+2], for i=1,2,3 and j=1,2,,nelt1.
8: reft1[nelt1] const Integer Input
On entry: reft1[k-1] contains the user-supplied tag of the kth triangle from the first input mesh, for k=1,2,,nelt1.
9: nv2 Integer Input
On entry: the total number of vertices in the second input mesh.
Constraint: nv23.
10: nelt2 Integer Input
On entry: the number of triangular elements in the second input mesh.
Constraint: nelt22×nv2-1.
11: nedge2 Integer Input
On entry: the number of boundary edges in the second input mesh.
Constraint: nedge21.
12: coor2[2×nv2] const double Input
Note: the (i,j)th element of the matrix is stored in coor2[(j-1)×2+i-1].
On entry: coor2[(i-1)×2] contains the x coordinate of the ith vertex of the second input mesh, for i=1,2,,nv2; while coor2[(i-1)×2+1] contains the corresponding y coordinate.
13: edge2[3×nedge2] const Integer Input
Note: the (i,j)th element of the matrix is stored in edge2[(j-1)×3+i-1].
On entry: the specification of the boundary edges of the second input mesh. edge2[(j-1)×3] and edge2[(j-1)×3+1] contain the vertex numbers of the two end points of the jth boundary edge. edge2[(j-1)×3+2] is a user-supplied tag for the jth boundary edge.
Constraint: 1edge2[(j-1)×3+i-1]nv2 and
edge2[(j-1)×3]edge2[(j-1)×3+1], for i=1,2 and j=1,2,,nedge2.
14: conn2[3×nelt2] const Integer Input
Note: the (i,j)th element of the matrix is stored in conn2[(j-1)×3+i-1].
On entry: the connectivity between triangles and vertices of the second input mesh. For each triangle j, conn2[(j-1)×3+i-1] gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,nelt2.
Constraints:
  • 1conn2[(j-1)×3+i-1]nv2;
  • conn2[(j-1)×3]conn2[(j-1)×3+1];
  • conn2[(j-1)×3]conn2[(j-1)×3+2] and
    conn2[(j-1)×3+1]conn2[(j-1)×3+2], for i=1,2,3 and j=1,2,,nelt2.
15: reft2[nelt2] const Integer Input
On entry: reft2[k-1] contains the user-supplied tag of the kth triangle from the second input mesh, for k=1,2,,nelt2.
16: nv3 Integer * Output
On exit: the total number of vertices in the resulting mesh.
17: nelt3 Integer * Output
On exit: the number of triangular elements in the resulting mesh.
18: nedge3 Integer * Output
On exit: the number of boundary edges in the resulting mesh.
19: coor3[dim] double Output
Note: the dimension, dim, of the array coor3 must be at least 2×(nv1+nv2).
The (i,j)th element of the matrix is stored in coor3[(j-1)×2+i-1].
On exit: coor3[(i-1)×2] will contain the x coordinate of the ith vertex of the resulting mesh, for i=1,2,,nv3; while coor3[(i-1)×2+1] will contain the corresponding y coordinate.
20: edge3[dim] Integer Output
Note: the dimension, dim, of the array edge3 must be at least 3×(nedge1+nedge2). This may be reduced to nedge3 once that value is known.
The (i,j)th element of the matrix is stored in edge3[(j-1)×3+i-1].
On exit: the specification of the boundary edges of the resulting mesh. edge3[(j-1)×3+i-1] 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, edge3[(j-1)×3+2] 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,
  1. (i)if the jth edge is part of the partition interface, edge3[(j-1)×3+2] 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;
  2. (ii)otherwise, edge3[(j-1)×3+2] will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.
21: conn3[dim] Integer Output
Note: the dimension, dim, of the array conn3 must be at least 3×(nelt1+nelt2). This may be reduced to nelt3 once that value is known.
The (i,j)th element of the matrix is stored in conn3[(j-1)×3+i-1].
On exit: the connectivity between triangles and vertices of the resulting mesh. conn3[(j-1)×3+i-1] will give the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,nelt3.
22: reft3[dim] Integer Output
Note: the dimension, dim, 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, reft3[k-1] 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, reft3[k-1] 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 Integer Input
On entry: the level of trace information required from d06dbc.
itrace0
No output is generated.
itrace1
Details about the common vertices, edges and triangles to both meshes are printed.
24: 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.
25: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, nedge1=value.
Constraint: nedge11.
On entry, nedge2=value.
Constraint: nedge21.
On entry, nv1=value.
Constraint: nv13.
On entry, nv2=value.
Constraint: nv23.
NE_INT_2
On entry, nelt1=value and nv1=value.
Constraint: nelt12×nv1-1.
On entry, nelt2=value and nv2=value.
Constraint: nelt22×nv2-1.
On entry, the end points of edge J in the first mesh have the same index I: J=value and I=value.
On entry, the end points of edge J in the second mesh have the same index I: J=value and I=value.
On entry, vertices 1 and 2 of triangle K in the first mesh have the same index I: K=value and I=value.
On entry, vertices 1 and 2 of triangle K in the second mesh have the same index I: K=value and I=value.
On entry, vertices 1 and 3 of triangle K in the first mesh have the same index I: K=value and I=value.
On entry, vertices 1 and 3 of triangle K in the second mesh have the same index I: K=value and I=value.
On entry, vertices 2 and 3 of triangle K in the first mesh have the same index I: K=value and I=value.
On entry, vertices 2 and 3 of triangle K in the second mesh have the same index I: K=value and I=value.
NE_INT_4
On entry, conn1(I,J)=value, I=value, J=value and nv1=value.
Constraint: conn1(I,J)1 and conn1(I,J)nv1, where conn1(I,J) denotes conn1[(J-1)×3+I-1].
On entry, conn2(I,J)=value, I=value, J=value and nv2=value.
Constraint: conn2(I,J)1 and conn2(I,J)nv2, where conn2(I,J) denotes conn2[(J-1)×3+I-1].
On entry, edge1(I,J)=value, I=value, J=value and nv1=value.
Constraint: edge1(I,J)1 and edge1(I,J)nv1, where edge1(I,J) denotes edge1[(J-1)×3+I-1].
On entry, edge2(I,J)=value, I=value, J=value and nv2=value.
Constraint: edge2(I,J)1 and edge2(I,J)nv2, where edge2(I,J) denotes edge2[(J-1)×3+I-1].
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 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_MESH_ERROR
A serious error has occurred in an internal call to the restitching routine. Check the input of the two meshes, especially the edges/vertices and/or the triangles/vertices connectivities. Seek expert help.
The function has detected a different number of coincident edges from the two meshes on the partition interface value value. Check the input of the two meshes, especially the edges/vertices connectivity.
The function has detected a different number of coincident triangles from the two meshes in the overlapping zone value value. Check the input of the two meshes, especially the triangles/vertices connectivity.
The function has detected only value coincident vertices with a precision eps=value. Either eps should be changed or the two meshes are not restitchable.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_CLOSE_FILE
Cannot close file value.
NE_NOT_WRITE_FILE
Cannot open file value for writing.
NE_REAL
On entry, eps=value.
Constraint: eps>0.0.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
d06dbc is not threaded in any implementation.

9 Further Comments

d06dbc finds all the common vertices between the two input meshes using the relative precision of the restitching argument 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 function two examples are presented. There is a single example program for d06dbc, 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,1]2 meshed uniformly, and then translated by a vector u= ( u1 u2 ) (using d06dac). This translated mesh is then restitched with the original mesh. Two cases are considered:
  1. (a)overlapping meshes (u1=15.0, u2=17.0),
  2. (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 function d06dbc twice. The result is a mesh with three partitions. The first geometry is meshed by the Delaunay–Voronoi process (using d06abc), the second one meshed by an Advancing Front algorithm (using d06acc), while the third one is the result of a rotation (by -π/2) of the second one (using d06dac). 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 (d06dbce.c)

10.2 Program Data

Program Data (d06dbce.d)

10.3 Program Results

Program Results (d06dbce.r)
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 '-' Example Program Figure 1: Boundary and Interior Interface of Partitioned Squares
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 "d06dbfe.r" ind 2 Figure 2: Interior Mesh of Partitioned Squares
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 '-' Figure 3: Boundary and Interior Interface of Overlapping Squares
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 "d06dbfe.r" ind 1 Figure 4: Interior Mesh of Overlapping Squares
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 '-' Figure 5: Boundary and Interior Interfaces for Key Shape
GnuplotProduced by GNUPLOT 5.4 patchlevel 6 "d06dbfe.r" ind 3 Figure 6: Interior Mesh of KeyShape