hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_mesh_2d_join (d06db)

Purpose

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

Syntax

[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = d06db(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace, 'eps', eps, 'nv1', nv1, 'nelt1', nelt1, 'nedge1', nedge1, 'nv2', nv2, 'nelt2', nelt2, 'nedge2', nedge2)
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = nag_mesh_2d_join(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace, 'eps', eps, 'nv1', nv1, 'nelt1', nelt1, 'nedge1', nedge1, 'nv2', nv2, 'nelt2', nelt2, 'nedge2', nedge2)

Description

nag_mesh_2d_join (d06db) 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).

References

None.

Parameters

Compulsory Input Parameters

1:     coor1(22,nv1) – double array
coor1(1,i)coor11i contains the xx coordinate of the iith vertex of the first input mesh, for i = 1,2,,nv1i=1,2,,nv1; while coor1(2,i)coor12i contains the corresponding yy coordinate.
2:     edge1(33,nedge1) – int64int32nag_int array
The specification of the boundary edges of the first input mesh. edge1(1,j)edge11j and edge1(2,j)edge12j contain the vertex numbers of the two end points of the jjth boundary edge. edge1(3,j)edge13j is a user-supplied tag for the jjth boundary edge.
Constraint: 1edge1(i,j)nv11edge1ijnv1 and edge1(1,j)edge1(2,j)edge11jedge12j, for i = 1,2i=1,2 and j = 1,2,,nedge1j=1,2,,nedge1.
3:     conn1(33,nelt1) – int64int32nag_int array
The connectivity between triangles and vertices of the first input mesh. For each triangle jj, conn1(i,j)conn1ij gives the indices of its three vertices (in anticlockwise order), for i = 1,2,3i=1,2,3 and j = 1,2,,nelt1j=1,2,,nelt1.
Constraints:
  • 1conn1(i,j)nv11conn1ijnv1;
  • conn1(1,j)conn1(2,j)conn11jconn12j;
  • conn1(1,j)conn1(3,j)conn11jconn13j and conn1(2,j)conn1(3,j)conn12jconn13j, for i = 1,2,3i=1,2,3 and j = 1,2,,nelt1j=1,2,,nelt1.
4:     reft1(nelt1) – int64int32nag_int array
nelt1, the dimension of the array, must satisfy the constraint nelt12 × nv11nelt12×nv1-1.
reft1(k)reft1k contains the user-supplied tag of the kkth triangle from the first input mesh, for k = 1,2,,nelt1k=1,2,,nelt1.
5:     coor2(22,nv2) – double array
coor2(1,i)coor21i contains the xx coordinate of the iith vertex of the second input mesh, for i = 1,2,,nv2i=1,2,,nv2; while coor2(2,i)coor22i contains the corresponding yy coordinate.
6:     edge2(33,nedge2) – int64int32nag_int array
The specification of the boundary edges of the second input mesh. edge2(1,j)edge21j and edge2(2,j)edge22j contain the vertex numbers of the two end points of the jjth boundary edge. edge2(3,j)edge23j is a user-supplied tag for the jjth boundary edge.
Constraint: 1edge2(i,j)nv21edge2ijnv2 and edge2(1,j)edge2(2,j)edge21jedge22j, for i = 1,2i=1,2 and j = 1,2,,nedge2j=1,2,,nedge2.
7:     conn2(33,nelt2) – int64int32nag_int array
The connectivity between triangles and vertices of the second input mesh. For each triangle jj, conn2(i,j)conn2ij gives the indices of its three vertices (in anticlockwise order), for i = 1,2,3i=1,2,3 and j = 1,2,,nelt2j=1,2,,nelt2.
Constraints:
  • 1conn2(i,j)nv21conn2ijnv2;
  • conn2(1,j)conn2(2,j)conn21jconn22j;
  • conn2(1,j)conn2(3,j)conn21jconn23j and conn2(2,j)conn2(3,j)conn22jconn23j, for i = 1,2,3i=1,2,3 and j = 1,2,,nelt2j=1,2,,nelt2.
8:     reft2(nelt2) – int64int32nag_int array
nelt2, the dimension of the array, must satisfy the constraint nelt22 × nv21nelt22×nv2-1.
reft2(k)reft2k contains the user-supplied tag of the kkth triangle from the second input mesh, for k = 1,2,,nelt2k=1,2,,nelt2.
9:     itrace – int64int32nag_int scalar
The level of trace information required from nag_mesh_2d_join (d06db).
itrace0itrace0
No output is generated.
itrace1itrace1
Details about the common vertices, edges and triangles to both meshes are printed on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).

Optional Input Parameters

1:     eps – double scalar
The relative precision of the restitching of the two input meshes (see Section [Further Comments]).
Default: 0.0010.001.
Constraint: eps > 0.0eps>0.0.
2:     nv1 – int64int32nag_int scalar
Default: The dimension of the array coor1.
The total number of vertices in the first input mesh.
Constraint: nv13nv13.
3:     nelt1 – int64int32nag_int scalar
Default: The dimension of the arrays conn1, reft1. (An error is raised if these dimensions are not equal.)
The number of triangular elements in the first input mesh.
Constraint: nelt12 × nv11nelt12×nv1-1.
4:     nedge1 – int64int32nag_int scalar
Default: The dimension of the array edge1.
The number of boundary edges in the first input mesh.
Constraint: nedge11nedge11.
5:     nv2 – int64int32nag_int scalar
Default: The dimension of the array coor2.
The total number of vertices in the second input mesh.
Constraint: nv23nv23.
6:     nelt2 – int64int32nag_int scalar
Default: The dimension of the arrays conn2, reft2. (An error is raised if these dimensions are not equal.)
The number of triangular elements in the second input mesh.
Constraint: nelt22 × nv21nelt22×nv2-1.
7:     nedge2 – int64int32nag_int scalar
Default: The dimension of the array edge2.
The number of boundary edges in the second input mesh.
Constraint: nedge21nedge21.

Input Parameters Omitted from the MATLAB Interface

iwork liwork

Output Parameters

1:     nv3 – int64int32nag_int scalar
The total number of vertices in the resulting mesh.
2:     nelt3 – int64int32nag_int scalar
The number of triangular elements in the resulting mesh.
3:     nedge3 – int64int32nag_int scalar
The number of boundary edges in the resulting mesh.
4:     coor3(22, : :) – double array
The second dimension of the array will be nv1 + nv2nv1+nv2
coor3(1,i)coor31i will contain the xx coordinate of the iith vertex of the resulting mesh, for i = 1,2,,nv3i=1,2,,nv3; while coor3(2,i)coor32i will contain the corresponding yy coordinate.
5:     edge3(33, : :) – int64int32nag_int array
The second dimension of the array will be nedge1 + nedge2nedge1+nedge2. This may be reduced to nedge3nedge3 once that value is known
The specification of the boundary edges of the resulting mesh. edge3(i,j)edge3ij will contain the vertex number of the iith end point (i = 1,2i=1,2) of the jjth boundary or interface edge.
If the two meshes overlap, edge3(3,j)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 jjth edge is part of the partition interface, then edge3(3,j)edge33j will contain the value 1000 × k1 + k21000×k1+k2 where k1k1 and k2k2 are the tags for the same edge of the first and the second mesh respectively;
(ii) otherwise, edge3(3,j)edge33j will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.
6:     conn3(33, : :) – int64int32nag_int array
The second dimension of the array will be nelt1 + nelt2nelt1+nelt2. This may be reduced to nelt3nelt3 once that value is known
The connectivity between triangles and vertices of the resulting mesh. conn3(i,j)conn3ij will give the indices of its three vertices (in anticlockwise order), for i = 1,2,3i=1,2,3 and j = 1,2,,nelt3j=1,2,,nelt3.
7:     reft3( : :) – int64int32nag_int array
Note: the dimension of the array reft3 must be at least nelt1 + nelt2nelt1+nelt2. This may be reduced to nelt3nelt3 once that value is known.
If the two meshes form a partition, reft3(k)reft3k will contain the same tag as the corresponding triangle belonging to the first or the second input mesh, for k = 1,2,,nelt3k=1,2,,nelt3. If the two meshes overlap, then reft3(k)reft3k will contain the value 1000 × k1 + k21000×k1+k2 where k1k1 and k2k2 are the user-supplied tags for the same triangle of the first and the second mesh respectively, for k = 1,2,,nelt3k=1,2,,nelt3.
8:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,eps0.0eps0.0,
ornv1 < 3nv1<3,
ornelt1 > 2 × nv11nelt1>2×nv1-1,
ornedge1 < 1nedge1<1,
oredge1(i,j) < 1edge1ij<1 or edge1(i,j) > nv1edge1ij>nv1 for some i = 1,2i=1,2 and j = 1,2,,nedge1j=1,2,,nedge1,
oredge1(1,j) = edge1(2,j)edge11j=edge12j for some j = 1,2,,nedge1j=1,2,,nedge1,
orconn1(i,j) < 1conn1ij<1 or conn1(i,j) > nv1conn1ij>nv1 for some i = 1,2,3i=1,2,3 and j = 1,2,,nelt1j=1,2,,nelt1,
orconn1(1,j) = conn1(2,j)conn11j=conn12j or conn1(1,j) = conn1(3,j)conn11j=conn13j or
conn1(2,j) = conn1(3,j)conn12j=conn13j for some j = 1,2,,nelt1j=1,2,,nelt1,
ornv2 < 3nv2<3,
ornelt2 > 2 × nv21nelt2>2×nv2-1,
ornedge2 < 1nedge2<1,
oredge2(i,j) < 1edge2ij<1 or edge2(i,j) > nv2edge2ij>nv2 for some i = 1,2i=1,2 and j = 1,2,,nedge2j=1,2,,nedge2,
oredge2(1,j) = edge2(2,j)edge21j=edge22j for some j = 1,2,,nedge2j=1,2,,nedge2,
orconn2(i,j) < 1conn2ij<1 or conn2(i,j) > nv2conn2ij>nv2 for some i = 1,2,3i=1,2,3 and j = 1,2,,nelt2j=1,2,,nelt2,
orconn2(1,j) = conn2(2,j)conn21j=conn22j or conn2(1,j) = conn2(3,j)conn21j=conn23j or
conn2(2,j) = conn2(3,j)conn22j=conn23j for some j = 1,2,,nelt2j=1,2,,nelt2,
orliwork < 2 × nv1 + 3 × nv2 + nelt1 + nelt2 + nedge1 + nedge2 + 1024liwork<2×nv1+3×nv2+nelt1+nelt2+nedge1+nedge2+1024.
  ifail = 2ifail=2
Using the input precision eps, the function 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 = 3ifail=3
A serious error has occurred in an internal call to the restitching function. 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 = 4ifail=4
The function 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 = 5ifail=5
The function 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.

Accuracy

Not applicable.

Further Comments

nag_mesh_2d_join (d06db) 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.0010.001 with itrace1itrace1 to get the optimal value for the meshes under consideration.

Example

For this function two examples are presented. There is a single example program for nag_mesh_2d_join (d06db), 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[0,1]2 meshed uniformly, and then translated by a vector u =
(u1)
u2
u= u1 u2  (using nag_mesh_2d_transform_affine (d06da)). This translated mesh is then restitched with the original mesh. Two cases are considered:
(a) overlapping meshes (u1 = 15.0u1=15.0, u2 = 17.0u2=17.0),
(b) partitioned meshes (u1 = 19.0u1=19.0, u2 = 0.0u2=0.0).
Example 2 (EX2)
This example restitches three geometries by calling the function nag_mesh_2d_join (d06db) twice. The result is a mesh with three partitions. The first geometry is meshed by the Delaunay–Voronoi process (using nag_mesh_2d_gen_delaunay (d06ab)), the second one meshed by an Advancing Front algorithm (using nag_mesh_2d_gen_front (d06ac)), while the third one is the result of a rotation (by π / 2-π/2) of the second one (using nag_mesh_2d_transform_affine (d06da)).
function nag_mesh_2d_join_example
coor1 = zeros(2,400);
for j = 1:20
  for i = 1:20
    coor1(1,(j-1)*20+i) = (i-1)/19;
    coor1(2,(j-1)*20+i) = (j-1)/19;
  end
end
edge1 = ones(3, 76, 'int64');
edge1(1, 1:76) = [int64(1),2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, ...
    20,40,60,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380, ...
    400,399,398,397,396,395,394,393,392,391,390,389,388,387,386,385,384,383, ...
    382,381,361,341,321,301,281,261,241,221,201,181,161,141,121,101,81,61,41,21];
edge1(2, 1:76) = [ int64(2),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, ...
    20,40,60,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380, ...
    400,399,398,397,396,395,394,393,392,391,390,389,388,387,386,385,384,383, ...
    382,381,361,341,321,301,281,261,241,221,201,181,161,141,121,101,81,61,41,21,1];
conn1 = zeros(3, 722, 'int64');
ind = -1;
for i=1:379
  if (rem(i, 20) ~= 0)
    ind = ind+2;
    conn1(1, ind)   = int64(i);
    conn1(1, ind+1) = int64(i);
    conn1(2, ind)   = int64(i+1);
    conn1(2, ind+1) = int64(i+21);
    conn1(3, ind)   = int64(i+21);
    conn1(3, ind+1) = int64(i+20);
  end
end
reft1 = ones(722, 1, 'int64');
reft2 = reft1;
reft2(:) = int64(2);
itype = [int64(1)];
itrace = int64(0);

% Transform the first domain to obtain an overlapping second domain
trans = [15/19; 17/19; 0; 0; 0; 0];
[coor1, edge1, conn1, coor2, edge2, conn2, ifail] = ...
    nag_mesh_2d_transform_affine(itype, trans, coor1, edge1, conn1, itrace);

% Restitch the meshes
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = ...
     nag_mesh_2d_join(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace);

% Plot the result
fig1 = figure('Number', 'off');
triplot(transpose(conn3(:,1:double(nelt3))), coor3(1,:), coor3(2,:));
title ('Interior mesh of the two overlapping squares geometry', 'FontSize', 14);

% Now consider a partitioned second domain
trans = [1; 0; 0; 0; 0; 0];
[coor1, edge1, conn1, coor2, edge2, conn2, ifail] = ...
    nag_mesh_2d_transform_affine(itype, trans, coor1, edge1, conn1, itrace);

% Restitch the meshes
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = ...
     nag_mesh_2d_join(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace);
 ifail

% Plot the result
fig2 = figure('Number', 'off');
triplot(transpose(conn3(:,1:double(nelt3))), coor3(1,:), coor3(2,:));
title ('Interior mesh of the two partitioned squares geometry', 'FontSize', 14);
 

ifail =

                    0


function d06db_example
coor1 = zeros(2,400);
for j = 1:20
  for i = 1:20
    coor1(1,(j-1)*20+i) = (i-1)/19;
    coor1(2,(j-1)*20+i) = (j-1)/19;
  end
end
edge1 = ones(3, 76, 'int64');
edge1(1, 1:76) = [int64(1),2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, ...
    20,40,60,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380, ...
    400,399,398,397,396,395,394,393,392,391,390,389,388,387,386,385,384,383, ...
    382,381,361,341,321,301,281,261,241,221,201,181,161,141,121,101,81,61,41,21];
edge1(2, 1:76) = [ int64(2),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, ...
    20,40,60,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380, ...
    400,399,398,397,396,395,394,393,392,391,390,389,388,387,386,385,384,383, ...
    382,381,361,341,321,301,281,261,241,221,201,181,161,141,121,101,81,61,41,21,1];
conn1 = zeros(3, 722, 'int64');
ind = -1;
for i=1:379
  if (rem(i, 20) ~= 0)
    ind = ind+2;
    conn1(1, ind)   = int64(i);
    conn1(1, ind+1) = int64(i);
    conn1(2, ind)   = int64(i+1);
    conn1(2, ind+1) = int64(i+21);
    conn1(3, ind)   = int64(i+21);
    conn1(3, ind+1) = int64(i+20);
  end
end
reft1 = ones(722, 1, 'int64');
reft2 = reft1;
reft2(:) = int64(2);
itype = [int64(1)];
itrace = int64(0);

% Transform the first domain to obtain an overlapping second domain
trans = [15/19; 17/19; 0; 0; 0; 0];
[coor1, edge1, conn1, coor2, edge2, conn2, ifail] = ...
    d06da(itype, trans, coor1, edge1, conn1, itrace);

% Restitch the meshes
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = ...
     d06db(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace);

% Plot the result
fig1 = figure('Number', 'off');
triplot(transpose(conn3(:,1:double(nelt3))), coor3(1,:), coor3(2,:));
title ('Interior mesh of the two overlapping squares geometry', 'FontSize', 14);

% Now consider a partitioned second domain
trans = [1; 0; 0; 0; 0; 0];
[coor1, edge1, conn1, coor2, edge2, conn2, ifail] = ...
    d06da(itype, trans, coor1, edge1, conn1, itrace);

% Restitch the meshes
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = ...
     d06db(coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace);
 ifail

% Plot the result
fig2 = figure('Number', 'off');
triplot(transpose(conn3(:,1:double(nelt3))), coor3(1,:), coor3(2,:));
title ('Interior mesh of the two partitioned squares geometry', 'FontSize', 14);
 

ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013