Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

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

None.

## Parameters

### Compulsory Input Parameters

1:     coor1(2$2$,nv1) – double array
coor1(1,i)${\mathbf{coor1}}\left(1,\mathit{i}\right)$ contains the x$x$ coordinate of the i$\mathit{i}$th vertex of the first input mesh, for i = 1,2,,nv1$\mathit{i}=1,2,\dots ,{\mathbf{nv1}}$; while coor1(2,i)${\mathbf{coor1}}\left(2,\mathit{i}\right)$ contains the corresponding y$y$ coordinate.
2:     edge1(3$3$,nedge1) – int64int32nag_int array
The specification of the boundary edges of the first input mesh. edge1(1,j)${\mathbf{edge1}}\left(1,j\right)$ and edge1(2,j)${\mathbf{edge1}}\left(2,j\right)$ contain the vertex numbers of the two end points of the j$j$th boundary edge. edge1(3,j)${\mathbf{edge1}}\left(3,j\right)$ is a user-supplied tag for the j$j$th boundary edge.
Constraint: 1edge1(i,j)nv1$1\le {\mathbf{edge1}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{nv1}}$ and edge1(1,j)edge1(2,j)${\mathbf{edge1}}\left(1,\mathit{j}\right)\ne {\mathbf{edge1}}\left(2,\mathit{j}\right)$, for i = 1,2$\mathit{i}=1,2$ and j = 1,2,,nedge1$\mathit{j}=1,2,\dots ,{\mathbf{nedge1}}$.
3:     conn1(3$3$,nelt1) – int64int32nag_int array
The connectivity between triangles and vertices of the first input mesh. For each triangle j$\mathit{j}$, conn1(i,j)${\mathbf{conn1}}\left(\mathit{i},\mathit{j}\right)$ gives the indices of its three vertices (in anticlockwise order), for i = 1,2,3$\mathit{i}=1,2,3$ and j = 1,2,,nelt1$\mathit{j}=1,2,\dots ,{\mathbf{nelt1}}$.
Constraints:
• 1conn1(i,j)nv1$1\le {\mathbf{conn1}}\left(i,j\right)\le {\mathbf{nv1}}$;
• conn1(1,j)conn1(2,j)${\mathbf{conn1}}\left(1,j\right)\ne {\mathbf{conn1}}\left(2,j\right)$;
• conn1(1,j)conn1(3,j)${\mathbf{conn1}}\left(1,\mathit{j}\right)\ne {\mathbf{conn1}}\left(3,\mathit{j}\right)$ and conn1(2,j)conn1(3,j)${\mathbf{conn1}}\left(2,\mathit{j}\right)\ne {\mathbf{conn1}}\left(3,\mathit{j}\right)$, for i = 1,2,3$\mathit{i}=1,2,3$ and j = 1,2,,nelt1$\mathit{j}=1,2,\dots ,{\mathbf{nelt1}}$.
4:     reft1(nelt1) – int64int32nag_int array
nelt1, the dimension of the array, must satisfy the constraint nelt12 × nv11${\mathbf{nelt1}}\le 2×{\mathbf{nv1}}-1$.
reft1(k)${\mathbf{reft1}}\left(\mathit{k}\right)$ contains the user-supplied tag of the k$\mathit{k}$th triangle from the first input mesh, for k = 1,2,,nelt1$\mathit{k}=1,2,\dots ,{\mathbf{nelt1}}$.
5:     coor2(2$2$,nv2) – double array
coor2(1,i)${\mathbf{coor2}}\left(1,\mathit{i}\right)$ contains the x$x$ coordinate of the i$\mathit{i}$th vertex of the second input mesh, for i = 1,2,,nv2$\mathit{i}=1,2,\dots ,{\mathbf{nv2}}$; while coor2(2,i)${\mathbf{coor2}}\left(2,\mathit{i}\right)$ contains the corresponding y$y$ coordinate.
6:     edge2(3$3$,nedge2) – int64int32nag_int array
The specification of the boundary edges of the second input mesh. edge2(1,j)${\mathbf{edge2}}\left(1,j\right)$ and edge2(2,j)${\mathbf{edge2}}\left(2,j\right)$ contain the vertex numbers of the two end points of the j$j$th boundary edge. edge2(3,j)${\mathbf{edge2}}\left(3,j\right)$ is a user-supplied tag for the j$j$th boundary edge.
Constraint: 1edge2(i,j)nv2$1\le {\mathbf{edge2}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{nv2}}$ and edge2(1,j)edge2(2,j)${\mathbf{edge2}}\left(1,\mathit{j}\right)\ne {\mathbf{edge2}}\left(2,\mathit{j}\right)$, for i = 1,2$\mathit{i}=1,2$ and j = 1,2,,nedge2$\mathit{j}=1,2,\dots ,{\mathbf{nedge2}}$.
7:     conn2(3$3$,nelt2) – int64int32nag_int array
The connectivity between triangles and vertices of the second input mesh. For each triangle j$\mathit{j}$, conn2(i,j)${\mathbf{conn2}}\left(\mathit{i},\mathit{j}\right)$ gives the indices of its three vertices (in anticlockwise order), for i = 1,2,3$\mathit{i}=1,2,3$ and j = 1,2,,nelt2$\mathit{j}=1,2,\dots ,{\mathbf{nelt2}}$.
Constraints:
• 1conn2(i,j)nv2$1\le {\mathbf{conn2}}\left(i,j\right)\le {\mathbf{nv2}}$;
• conn2(1,j)conn2(2,j)${\mathbf{conn2}}\left(1,j\right)\ne {\mathbf{conn2}}\left(2,j\right)$;
• conn2(1,j)conn2(3,j)${\mathbf{conn2}}\left(1,\mathit{j}\right)\ne {\mathbf{conn2}}\left(3,\mathit{j}\right)$ and conn2(2,j)conn2(3,j)${\mathbf{conn2}}\left(2,\mathit{j}\right)\ne {\mathbf{conn2}}\left(3,\mathit{j}\right)$, for i = 1,2,3$\mathit{i}=1,2,3$ and j = 1,2,,nelt2$\mathit{j}=1,2,\dots ,{\mathbf{nelt2}}$.
8:     reft2(nelt2) – int64int32nag_int array
nelt2, the dimension of the array, must satisfy the constraint nelt22 × nv21${\mathbf{nelt2}}\le 2×{\mathbf{nv2}}-1$.
reft2(k)${\mathbf{reft2}}\left(\mathit{k}\right)$ contains the user-supplied tag of the k$\mathit{k}$th triangle from the second input mesh, for k = 1,2,,nelt2$\mathit{k}=1,2,\dots ,{\mathbf{nelt2}}$.
9:     itrace – int64int32nag_int scalar
The level of trace information required from nag_mesh_2d_join (d06db).
itrace0${\mathbf{itrace}}\le 0$
No output is generated.
itrace1${\mathbf{itrace}}\ge 1$
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.001$0.001$.
Constraint: eps > 0.0${\mathbf{eps}}>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: nv13${\mathbf{nv1}}\ge 3$.
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 × nv11${\mathbf{nelt1}}\le 2×{\mathbf{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: nedge11${\mathbf{nedge1}}\ge 1$.
5:     nv2 – int64int32nag_int scalar
Default: The dimension of the array coor2.
The total number of vertices in the second input mesh.
Constraint: nv23${\mathbf{nv2}}\ge 3$.
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 × nv21${\mathbf{nelt2}}\le 2×{\mathbf{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: nedge21${\mathbf{nedge2}}\ge 1$.

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(2$2$, : $:$) – double array
The second dimension of the array will be ${\mathbf{nv1}}+{\mathbf{nv2}}$
coor3(1,i)${\mathbf{coor3}}\left(1,\mathit{i}\right)$ will contain the x$x$ coordinate of the i$\mathit{i}$th vertex of the resulting mesh, for i = 1,2,,nv3$\mathit{i}=1,2,\dots ,{\mathbf{nv3}}$; while coor3(2,i)${\mathbf{coor3}}\left(2,i\right)$ will contain the corresponding y$y$ coordinate.
5:     edge3(3$3$, : $:$) – int64int32nag_int array
The second dimension of the array will be ${\mathbf{nedge1}}+{\mathbf{nedge2}}$. This may be reduced to nedge3${\mathbf{nedge3}}$ once that value is known
The specification of the boundary edges of the resulting mesh. edge3(i,j)${\mathbf{edge3}}\left(i,j\right)$ will contain the vertex number of the i$i$th end point (i = 1,2$i=1,2$) of the j$j$th boundary or interface edge.
If the two meshes overlap, edge3(3,j)${\mathbf{edge3}}\left(3,j\right)$ 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 j$j$th edge is part of the partition interface, then edge3(3,j)${\mathbf{edge3}}\left(3,j\right)$ will contain the value 1000 × k1 + k2$1000×{k}_{1}+{k}_{2}$ where k1${k}_{1}$ and k2${k}_{2}$ are the tags for the same edge of the first and the second mesh respectively; (ii) otherwise, edge3(3,j)${\mathbf{edge3}}\left(3,j\right)$ will contain the same tag as the corresponding edge belonging to the first and/or the second input mesh.
6:     conn3(3$3$, : $:$) – int64int32nag_int array
The second dimension of the array will be ${\mathbf{nelt1}}+{\mathbf{nelt2}}$. This may be reduced to nelt3${\mathbf{nelt3}}$ once that value is known
The connectivity between triangles and vertices of the resulting mesh. conn3(i,j)${\mathbf{conn3}}\left(\mathit{i},\mathit{j}\right)$ will give the indices of its three vertices (in anticlockwise order), for i = 1,2,3$\mathit{i}=1,2,3$ and j = 1,2,,nelt3$\mathit{j}=1,2,\dots ,{\mathbf{nelt3}}$.
7:     reft3( : $:$) – int64int32nag_int array
Note: the dimension of the array reft3 must be at least ${\mathbf{nelt1}}+{\mathbf{nelt2}}$. This may be reduced to nelt3${\mathbf{nelt3}}$ once that value is known.
If the two meshes form a partition, reft3(k)${\mathbf{reft3}}\left(\mathit{k}\right)$ will contain the same tag as the corresponding triangle belonging to the first or the second input mesh, for k = 1,2,,nelt3$\mathit{k}=1,2,\dots ,{\mathbf{nelt3}}$. If the two meshes overlap, then reft3(k)${\mathbf{reft3}}\left(\mathit{k}\right)$ will contain the value 1000 × k1 + k2$1000×{\mathit{k}}_{1}+{\mathit{k}}_{2}$ where k1${\mathit{k}}_{1}$ and k2${\mathit{k}}_{2}$ are the user-supplied tags for the same triangle of the first and the second mesh respectively, for k = 1,2,,nelt3$\mathit{k}=1,2,\dots ,{\mathbf{nelt3}}$.
8:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, eps ≤ 0.0${\mathbf{eps}}\le 0.0$, or nv1 < 3${\mathbf{nv1}}<3$, or nelt1 > 2 × nv1 − 1${\mathbf{nelt1}}>2×{\mathbf{nv1}}-1$, or nedge1 < 1${\mathbf{nedge1}}<1$, or edge1(i,j) < 1${\mathbf{edge1}}\left(i,j\right)<1$ or edge1(i,j) > nv1${\mathbf{edge1}}\left(i,j\right)>{\mathbf{nv1}}$ for some i = 1,2$i=1,2$ and j = 1,2, … ,nedge1$j=1,2,\dots ,{\mathbf{nedge1}}$, or edge1(1,j) = edge1(2,j)${\mathbf{edge1}}\left(1,j\right)={\mathbf{edge1}}\left(2,j\right)$ for some j = 1,2, … ,nedge1$j=1,2,\dots ,{\mathbf{nedge1}}$, or conn1(i,j) < 1${\mathbf{conn1}}\left(i,j\right)<1$ or conn1(i,j) > nv1${\mathbf{conn1}}\left(i,j\right)>{\mathbf{nv1}}$ for some i = 1,2,3$i=1,2,3$ and j = 1,2, … ,nelt1$j=1,2,\dots ,{\mathbf{nelt1}}$, or conn1(1,j) = conn1(2,j)${\mathbf{conn1}}\left(1,j\right)={\mathbf{conn1}}\left(2,j\right)$ or conn1(1,j) = conn1(3,j)${\mathbf{conn1}}\left(1,j\right)={\mathbf{conn1}}\left(3,j\right)$ or conn1(2,j) = conn1(3,j)${\mathbf{conn1}}\left(2,j\right)={\mathbf{conn1}}\left(3,j\right)$ for some j = 1,2, … ,nelt1$j=1,2,\dots ,{\mathbf{nelt1}}$, or nv2 < 3${\mathbf{nv2}}<3$, or nelt2 > 2 × nv2 − 1${\mathbf{nelt2}}>2×{\mathbf{nv2}}-1$, or nedge2 < 1${\mathbf{nedge2}}<1$, or edge2(i,j) < 1${\mathbf{edge2}}\left(i,j\right)<1$ or edge2(i,j) > nv2${\mathbf{edge2}}\left(i,j\right)>{\mathbf{nv2}}$ for some i = 1,2$i=1,2$ and j = 1,2, … ,nedge2$j=1,2,\dots ,{\mathbf{nedge2}}$, or edge2(1,j) = edge2(2,j)${\mathbf{edge2}}\left(1,j\right)={\mathbf{edge2}}\left(2,j\right)$ for some j = 1,2, … ,nedge2$j=1,2,\dots ,{\mathbf{nedge2}}$, or conn2(i,j) < 1${\mathbf{conn2}}\left(i,j\right)<1$ or conn2(i,j) > nv2${\mathbf{conn2}}\left(i,j\right)>{\mathbf{nv2}}$ for some i = 1,2,3$i=1,2,3$ and j = 1,2, … ,nelt2$j=1,2,\dots ,{\mathbf{nelt2}}$, or conn2(1,j) = conn2(2,j)${\mathbf{conn2}}\left(1,j\right)={\mathbf{conn2}}\left(2,j\right)$ or conn2(1,j) = conn2(3,j)${\mathbf{conn2}}\left(1,j\right)={\mathbf{conn2}}\left(3,j\right)$ or conn2(2,j) = conn2(3,j)${\mathbf{conn2}}\left(2,j\right)={\mathbf{conn2}}\left(3,j\right)$ for some j = 1,2, … ,nelt2$j=1,2,\dots ,{\mathbf{nelt2}}$, or liwork < 2 × nv1 + 3 × nv2 + nelt1 + nelt2 + nedge1 + nedge2 + 1024$\mathit{liwork}<2×{\mathbf{nv1}}+3×{\mathbf{nv2}}+{\mathbf{nelt1}}+{\mathbf{nelt2}}+{\mathbf{nedge1}}+{\mathbf{nedge2}}+1024$.
ifail = 2${\mathbf{ifail}}=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 = 3${\mathbf{ifail}}=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 = 4${\mathbf{ifail}}=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 = 5${\mathbf{ifail}}=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.

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.001$0.001$ with itrace1${\mathbf{itrace}}\ge 1$ 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${\left[0,1\right]}^{2}$ meshed uniformly, and then translated by a vector u =
 ( u1 ) u2
$\stackrel{\to }{u}=\left(\begin{array}{c}{u}_{1}\\ {u}_{2}\end{array}\right)$ (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.0${u}_{1}=15.0$, u2 = 17.0${u}_{2}=17.0$), (b) partitioned meshes (u1 = 19.0${u}_{1}=19.0$, u2 = 0.0${u}_{2}=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$-\pi /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

```