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_gen_front (d06ac)

## Purpose

nag_mesh_2d_gen_front (d06ac) generates a triangular mesh of a closed polygonal region in 2${ℝ}^{2}$, given a mesh of its boundary. It uses an Advancing Front process, based on an incremental method.

## Syntax

[nv, nelt, coor, conn, ifail] = d06ac(nvb, edge, coor, weight, itrace, 'nvint', nvint, 'nvmax', nvmax, 'nedge', nedge)
[nv, nelt, coor, conn, ifail] = nag_mesh_2d_gen_front(nvb, edge, coor, weight, itrace, 'nvint', nvint, 'nvmax', nvmax, 'nedge', nedge)

## Description

nag_mesh_2d_gen_front (d06ac) generates the set of interior vertices using an Advancing Front process, based on an incremental method. It allows you to specify a number of fixed interior mesh vertices together with weights which allow concentration of the mesh in their neighbourhood. For more details about the triangulation method, consult the D06 Chapter Introduction as well as George and Borouchaki (1998).
This function is derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

## References

George P L and Borouchaki H (1998) Delaunay Triangulation and Meshing: Application to Finite Elements Editions HERMES, Paris

## Parameters

### Compulsory Input Parameters

1:     nvb – int64int32nag_int scalar
The number of vertices in the input boundary mesh.
Constraint: nvb3${\mathbf{nvb}}\ge 3$.
2:     edge(3$3$,nedge) – int64int32nag_int array
The specification of the boundary edges. edge(1,j)${\mathbf{edge}}\left(1,j\right)$ and edge(2,j)${\mathbf{edge}}\left(2,j\right)$ contain the vertex numbers of the two end points of the j$j$th boundary edge. edge(3,j)${\mathbf{edge}}\left(3,j\right)$ is a user-supplied tag for the j$j$th boundary edge and is not used by nag_mesh_2d_gen_front (d06ac).
Constraint: 1edge(i,j)nvb$1\le {\mathbf{edge}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{nvb}}$ and edge(1,j)edge(2,j)${\mathbf{edge}}\left(1,\mathit{j}\right)\ne {\mathbf{edge}}\left(2,\mathit{j}\right)$, for i = 1,2$\mathit{i}=1,2$ and j = 1,2,,nedge$\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$.
3:     coor(2$2$,nvmax) – double array
coor(1,i)${\mathbf{coor}}\left(1,\mathit{i}\right)$ contains the x$x$ coordinate of the i$\mathit{i}$th input boundary mesh vertex, for i = 1,2,,nvb$\mathit{i}=1,2,\dots ,{\mathbf{nvb}}$. coor(1,i)${\mathbf{coor}}\left(1,\mathit{i}\right)$ contains the x$x$ coordinate of the (invb)$\left(\mathit{i}-{\mathbf{nvb}}\right)$th fixed interior vertex, for i = nvb + 1,,nvb + nvint$\mathit{i}={\mathbf{nvb}}+1,\dots ,{\mathbf{nvb}}+{\mathbf{nvint}}$. For boundary and interior vertices, coor(2,i)${\mathbf{coor}}\left(2,\mathit{i}\right)$ contains the corresponding y$y$ coordinate, for i = 1,2,,nvb + nvint$\mathit{i}=1,2,\dots ,{\mathbf{nvb}}+{\mathbf{nvint}}$.
4:     weight( : $:$) – double array
Note: the dimension of the array weight must be at least max (1,nvint)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nvint}}\right)$.
The weight of fixed interior vertices. It is the diameter of triangles (length of the longer edge) created around each of the given interior vertices.
Constraint: if nvint > 0${\mathbf{nvint}}>0$, weight(i) > 0.0${\mathbf{weight}}\left(\mathit{i}\right)>0.0$, for i = 1,2,,nvint$\mathit{i}=1,2,\dots ,{\mathbf{nvint}}$.
5:     itrace – int64int32nag_int scalar
The level of trace information required from nag_mesh_2d_gen_front (d06ac).
itrace0${\mathbf{itrace}}\le 0$
No output is generated.
itrace1${\mathbf{itrace}}\ge 1$
Output from the meshing solver is printed on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)). This output contains details of the vertices and triangles generated by the process.
You are advised to set itrace = 0${\mathbf{itrace}}=0$, unless you are experienced with finite element mesh generation.

### Optional Input Parameters

1:     nvint – int64int32nag_int scalar
Default: The dimension of the array weight.
The number of fixed interior mesh vertices to which a weight will be applied.
Constraint: nvint0${\mathbf{nvint}}\ge 0$.
2:     nvmax – int64int32nag_int scalar
Default: The dimension of the array coor.
The maximum number of vertices in the mesh to be generated.
Constraint: ${\mathbf{nvmax}}\ge {\mathbf{nvb}}+{\mathbf{nvint}}$.
3:     nedge – int64int32nag_int scalar
Default: The dimension of the array edge.
The number of boundary edges in the input mesh.
Constraint: nedge1${\mathbf{nedge}}\ge 1$.

### Input Parameters Omitted from the MATLAB Interface

rwork lrwork iwork liwork

### Output Parameters

1:     nv – int64int32nag_int scalar
The total number of vertices in the output mesh (including both boundary and interior vertices). If ${\mathbf{nvb}}+{\mathbf{nvint}}={\mathbf{nvmax}}$, no interior vertices will be generated and ${\mathbf{nv}}={\mathbf{nvmax}}$.
2:     nelt – int64int32nag_int scalar
The number of triangular elements in the mesh.
3:     coor(2$2$,nvmax) – double array
coor(1,i)${\mathbf{coor}}\left(1,\mathit{i}\right)$ will contain the x$x$ coordinate of the (invbnvint)$\left(\mathit{i}-{\mathbf{nvb}}-{\mathbf{nvint}}\right)$th generated interior mesh vertex, for i = nvb + nvint + 1,,nv$\mathit{i}={\mathbf{nvb}}+{\mathbf{nvint}}+1,\dots ,{\mathbf{nv}}$; while coor(2,i)${\mathbf{coor}}\left(2,i\right)$ will contain the corresponding y$y$ coordinate. The remaining elements are unchanged.
4:     conn(3$3$,2 × nvmax + 5$2×{\mathbf{nvmax}}+5$) – int64int32nag_int array
The connectivity of the mesh between triangles and vertices. For each triangle j$\mathit{j}$, conn(i,j)${\mathbf{conn}}\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,,nelt$\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$.
5:     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, nvb < 3${\mathbf{nvb}}<3$, or nvint < 0${\mathbf{nvint}}<0$, or ${\mathbf{nvb}}+{\mathbf{nvint}}>{\mathbf{nvmax}}$, or nedge < 1${\mathbf{nedge}}<1$, or edge(i,j) < 1${\mathbf{edge}}\left(i,j\right)<1$ or edge(i,j) > nvb${\mathbf{edge}}\left(i,j\right)>{\mathbf{nvb}}$, for some i = 1,2$i=1,2$ and j = 1,2, … ,nedge$j=1,2,\dots ,{\mathbf{nedge}}$, or edge(1,j) = edge(2,j)${\mathbf{edge}}\left(1,j\right)={\mathbf{edge}}\left(2,j\right)$, for some j = 1,2, … ,nedge$j=1,2,\dots ,{\mathbf{nedge}}$, or if nvint > 0${\mathbf{nvint}}>0$, weight(i) ≤ 0.0${\mathbf{weight}}\left(i\right)\le 0.0$, for some i = 1,2, … ,nvint$i=1,2,\dots ,{\mathbf{nvint}}$; or lrwork < 12 × nvmax + 30015$\mathit{lrwork}<12×{\mathbf{nvmax}}+30015$, or liwork < 8 × nedge + 53 × nvmax + 2 × nvb + 10078$\mathit{liwork}<8×{\mathbf{nedge}}+53×{\mathbf{nvmax}}+2×{\mathbf{nvb}}+10078$.
ifail = 2${\mathbf{ifail}}=2$
An error has occurred during the generation of the interior mesh. Check the definition of the boundary (arguments coor and edge) as well as the orientation of the boundary (especially in the case of a multiple connected component boundary). Setting itrace > 0${\mathbf{itrace}}>0$ may provide more details.

Not applicable.

## Further Comments

The position of the internal vertices is a function position of the vertices on the given boundary. A fine mesh on the boundary results in a fine mesh in the interior. During the process vertices are generated on edges of the mesh Ti${\mathcal{T}}_{i}$ to obtain the mesh Ti + 1${\mathcal{T}}_{i+1}$ in the general incremental method (consult the D06 Chapter Introduction or George and Borouchaki (1998)).
You are advised to take care to set the boundary inputs properly, especially for a boundary with multiply connected components. The orientation of the interior boundaries should be in clockwise order and opposite to that of the exterior boundary. If the boundary has only one connected component, its orientation should be anticlockwise.

## Example

In this example, a geometry with two holes (two wings inside an exterior circle) is meshed using a Delaunay–Voronoi method. The exterior circle is centred at the point (1.5,0.0)$\left(1.5,0.0\right)$ with a radius 4.5$4.5$, the first wing begins at the origin and it is normalized, finally the last wing is also normalized and begins at the point (0.8,0.3)$\left(0.8,-0.3\right)$. To be able to carry out some realistic computation on that geometry, some interior points have been introduced to have a finer mesh in the wake of those airfoils.
The boundary mesh has 120$120$ vertices and 120$120$ edges. Note that the particular mesh generated could be sensitive to the machine precision and therefore may differ from one implementation to another.
```function nag_mesh_2d_gen_front_example
% The characteristic points of the boundary mesh
coorch = [0, 1, -3, 6,  0.8,  1.8, 1.5,  1.5;
0, 0,  0, 0, -0.3, -0.3, 4.5, -4.5];
coorus = zeros(2,100);
% The lines of the boundary mesh
blines = [int64(21), 21, 11, 11, 21, 21,  11, 11;
2,  1,  3,  4,  6, 5,  7,  8;
1,  2,  8,  7,  5,  6,  3,  4;
1,  2, 3,  3,  4,  5,  3,  3];
rate = ones(8,1);

% The number of connected components to the boundary
ncomp = int64(3);
% Number and direction of lines per contour
nlcomp = [int64(-2), 4, -2];
% List of line numbers
lcomp = [int64(1), 2, 3, 8, 4, 7, 5, 6];

user = struct('x0', 1.5, 'y0', 0, 'radius', 4.5, 'x1', 0.8, 'y1', -0.3);

nvmax = int64(2000);
nedmx = int64(200);
itrace = int64(0);

[nvb, coor, nedge, edge, user, ifail] = ...
nag_mesh_2d_gen_boundary(coorch, blines, @fbnd, coorus, rate, nlcomp, lcomp, nvmax, ...
nedmx, itrace, 'user', user);
fprintf('\nBoundary mesh characteristics:\n');
fprintf('  nvb   = %d\n', nvb);
fprintf('  nedge = %d\n', nedge);

% Generation of interior vertices for the wake of the first naca
nvint  = 40;
nvint2 = 20;
dnvint = 5/(nvint2+1);
weight = 0.05*ones(nvint,1);
for i=1:nvint2
coor(1, double(nvb)+i) = 1+i*dnvint;
end
% ... for the wake of the second naca
for i = nvint2+1:nvint
coor(1, double(nvb)+i) = 1.8 + (i-nvint2)*dnvint;
coor(2, double(nvb)+i) = -0.3;
end

% Call the 2D advancing front mesh generator.  Note only pass relevant
% portion of edge
[nv, nelt, coor, conn, ifail] = nag_mesh_2d_gen_front(nvb, edge(:,1:double(nedge)), ...
coor, weight, itrace);

fprintf('\nComplete mesh characteristics:\n');
fprintf('  nv    = %d\n', nv);
fprintf('  nelt  = %d\n', nelt);

% Plot mesh
fig = figure('Number', 'off');
triplot(transpose(conn(:,1:double(nelt))), coor(1,:), coor(2,:));

function [result, user] = fbnd(i, x, y, user)

result = 0;
if (i==1)
% upper naca0012 wing beginning at the origin
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*x)-0.126*c*x-0.3516 ...
*(c*x)^2+0.2843*(c*x)^3-0.1015*(c*x)^4) - c*y;
elseif (i==2)
% lower naca0012 wing beginning at the origin
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*x)-0.126*c*x-0.3516 ...
*(c*x)^2+0.2843*(c*x)^3-0.1015*(c*x)^4) + c*y;
elseif (i==3)
result = (x-user.x0)^2 + (y-user.y0)^2 - user.radius^2;
elseif (i==4)
% upper naca0012 wing beginning at (user.x1;user.y1)
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*(x-user.x1))-0.126*c*(x-user.x1)-...
0.3516*(c*(x-user.x1))^2+0.2843*(c*(x-user.x1))^3-...
0.1015*(c*(x-user.x1))^4) - c*(y-user.y1);
elseif (i==5)
% lower naca0012 wing beginning at (user.x1;user.y1)
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*(x-user.x1))-0.126*c*(x-user.x1)-...
0.3516*(c*(x-user.x1))^2+0.2843*(c*(x-user.x1))^3-...
0.1015*(c*(x-user.x1))^4) + c*(y-user.y1);
end
```
```

Boundary mesh characteristics:
nvb   = 120
nedge = 120

Complete mesh characteristics:
nv    = 1894
nelt  = 3664

```
```function d06ac_example
% The characteristic points of the boundary mesh
coorch = [0, 1, -3, 6,  0.8,  1.8, 1.5,  1.5;
0, 0,  0, 0, -0.3, -0.3, 4.5, -4.5];
coorus = zeros(2,100);
% The lines of the boundary mesh
blines = [int64(21), 21, 11, 11, 21, 21,  11, 11;
2,  1,  3,  4,  6, 5,  7,  8;
1,  2,  8,  7,  5,  6,  3,  4;
1,  2, 3,  3,  4,  5,  3,  3];
rate = ones(8,1);

% The number of connected components to the boundary
ncomp = int64(3);
% Number and direction of lines per contour
nlcomp = [int64(-2), 4, -2];
% List of line numbers
lcomp = [int64(1), 2, 3, 8, 4, 7, 5, 6];

user = struct('x0', 1.5, 'y0', 0, 'radius', 4.5, 'x1', 0.8, 'y1', -0.3);

nvmax = int64(2000);
nedmx = int64(200);
itrace = int64(0);

[nvb, coor, nedge, edge, user, ifail] = ...
d06ba(coorch, blines, @fbnd, coorus, rate, nlcomp, lcomp, nvmax, ...
nedmx, itrace, 'user', user);
fprintf('\nBoundary mesh characteristics:\n');
fprintf('  nvb   = %d\n', nvb);
fprintf('  nedge = %d\n', nedge);

% Generation of interior vertices for the wake of the first naca
nvint  = 40;
nvint2 = 20;
dnvint = 5/(nvint2+1);
weight = 0.05*ones(nvint,1);
for i=1:nvint2
coor(1, double(nvb)+i) = 1+i*dnvint;
end
% ... for the wake of the second naca
for i = nvint2+1:nvint
coor(1, double(nvb)+i) = 1.8 + (i-nvint2)*dnvint;
coor(2, double(nvb)+i) = -0.3;
end

% Call the 2D advancing front mesh generator.  Note only pass relevant
% portion of edge
[nv, nelt, coor, conn, ifail] = d06ac(nvb, edge(:,1:double(nedge)), ...
coor, weight, itrace);

fprintf('\nComplete mesh characteristics:\n');
fprintf('  nv    = %d\n', nv);
fprintf('  nelt  = %d\n', nelt);

% Plot mesh
fig = figure('Number', 'off');
triplot(transpose(conn(:,1:double(nelt))), coor(1,:), coor(2,:));

function [result, user] = fbnd(i, x, y, user)

result = 0;
if (i==1)
% upper naca0012 wing beginning at the origin
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*x)-0.126*c*x-0.3516 ...
*(c*x)^2+0.2843*(c*x)^3-0.1015*(c*x)^4) - c*y;
elseif (i==2)
% lower naca0012 wing beginning at the origin
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*x)-0.126*c*x-0.3516 ...
*(c*x)^2+0.2843*(c*x)^3-0.1015*(c*x)^4) + c*y;
elseif (i==3)
result = (x-user.x0)^2 + (y-user.y0)^2 - user.radius^2;
elseif (i==4)
% upper naca0012 wing beginning at (user.x1;user.y1)
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*(x-user.x1))-0.126*c*(x-user.x1)-...
0.3516*(c*(x-user.x1))^2+0.2843*(c*(x-user.x1))^3-...
0.1015*(c*(x-user.x1))^4) - c*(y-user.y1);
elseif (i==5)
% lower naca0012 wing beginning at (user.x1;user.y1)
c = 1.008930411365;
result = 0.6*(0.2969*sqrt(c*(x-user.x1))-0.126*c*(x-user.x1)-...
0.3516*(c*(x-user.x1))^2+0.2843*(c*(x-user.x1))^3-...
0.1015*(c*(x-user.x1))^4) + c*(y-user.y1);
end
```
```

Boundary mesh characteristics:
nvb   = 120
nedge = 120

Complete mesh characteristics:
nv    = 1894
nelt  = 3664

```

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