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_gen_inc (d06aa)

Purpose

nag_mesh_2d_gen_inc (d06aa) generates a triangular mesh of a closed polygonal region in 22, given a mesh of its boundary. It uses a simple incremental method.

Syntax

[nv, nelt, coor, conn, ifail] = d06aa(edge, coor, bspace, smooth, itrace, 'nvb', nvb, 'nvmax', nvmax, 'nedge', nedge, 'coef', coef, 'power', power)
[nv, nelt, coor, conn, ifail] = nag_mesh_2d_gen_inc(edge, coor, bspace, smooth, itrace, 'nvb', nvb, 'nvmax', nvmax, 'nedge', nedge, 'coef', coef, 'power', power)

Description

nag_mesh_2d_gen_inc (d06aa) generates the set of interior vertices using a process based on a simple incremental method. A smoothing of the mesh is optionally available. 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:     edge(33,nedge) – int64int32nag_int array
The specification of the boundary edges. edge(1,j)edge1j and edge(2,j)edge2j contain the vertex numbers of the two end points of the jjth boundary edge. edge(3,j)edge3j is a user-supplied tag for the jjth boundary edge and is not used by nag_mesh_2d_gen_inc (d06aa).
Constraint: 1edge(i,j)nvb1edgeijnvb and edge(1,j)edge(2,j)edge1jedge2j, for i = 1,2i=1,2 and j = 1,2,,nedgej=1,2,,nedge.
2:     coor(22,nvmax) – double array
coor(1,i)coor1i contains the xx coordinate of the iith input boundary mesh vertex; while coor(2,i)coor2i contains the corresponding yy coordinate, for i = 1,2,,nvbi=1,2,,nvb.
3:     bspace(nvb) – double array
nvb, the dimension of the array, must satisfy the constraint 3nvbnvmax3nvbnvmax.
The desired mesh spacing (triangle diameter, which is the length of the longer edge of the triangle) near the boundary vertices.
Constraint: bspace(i) > 0.0bspacei>0.0, for i = 1,2,,nvbi=1,2,,nvb.
4:     smooth – logical scalar
Indicates whether or not mesh smoothing should be performed.
If smooth = truesmooth=true, the smoothing is performed; otherwise no smoothing is performed.
5:     itrace – int64int32nag_int scalar
The level of trace information required from nag_mesh_2d_gen_inc (d06aa).
itrace0itrace0
No output is generated.
itrace1itrace1
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 = 0itrace=0, unless you are experienced with finite element mesh generation.

Optional Input Parameters

1:     nvb – int64int32nag_int scalar
Default: The dimension of the array bspace.
The number of vertices in the input boundary mesh.
Constraint: 3nvbnvmax3nvbnvmax.
2:     nvmax – int64int32nag_int scalar
Default: The dimension of the array coor.
The maximum number of vertices in the mesh to be generated.
3:     nedge – int64int32nag_int scalar
Default: The dimension of the array edge.
The number of boundary edges in the input mesh.
Constraint: nedge1nedge1.
4:     coef – double scalar
The coefficient in the stopping criteria for the generation of interior vertices. This parameter controls the triangle density and the number of triangles generated is in O(coef2)O(coef2). The mesh will be finer if coef is greater than 0.71650.7165 and 0.750.75 is a good value.
Default: 0.750.75.
5:     power – double scalar
Controls the rate of change of the mesh size during the generation of interior vertices. The smaller the value of power, the faster the decrease in element size away from the boundary.
Default: 0.250.25.
Constraint: 0.1power10.00.1power10.0.

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 nvb = nvmaxnvb=nvmax, no interior vertices will be generated and nv = nvbnv=nvb.
2:     nelt – int64int32nag_int scalar
The number of triangular elements in the mesh.
3:     coor(22,nvmax) – double array
coor(1,i)coor1i will contain the xx coordinate of the (invb)(i-nvb)th generated interior mesh vertex; while coor(2,i)coor2i will contain the corresponding yy coordinate, for i = nvb + 1,,nvi=nvb+1,,nv. The remaining elements are unchanged.
4:     conn(33,2 × (nvmax1)2×(nvmax-1)) – int64int32nag_int array
The connectivity of the mesh between triangles and vertices. For each triangle jj, conn(i,j)connij gives the indices of its three vertices (in anticlockwise order), for i = 1,2,3i=1,2,3 and j = 1,2,,neltj=1,2,,nelt.
5:     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,nvb < 3nvb<3 or nvb > nvmaxnvb>nvmax,
ornedge < 1nedge<1,
oredge(i,j) < 1edgeij<1 or edge(i,j) > nvbedgeij>nvb, for some i = 1,2i=1,2 and j = 1,2,,nedgej=1,2,,nedge,
oredge(1,j) = edge(2,j)edge1j=edge2j, for some j = 1,2,,nedgej=1,2,,nedge,
orbspace(i)0.0bspacei0.0, for some i = 1,2,,nvbi=1,2,,nvb,
orpower < 0.1power<0.1 or power > 10.0power>10.0,
orliwork < 16 × nvmax + 2 × nedge + max (4 × nvmax + 2,nedge)14liwork<16×nvmax+2×nedge+max(4×nvmax+2,nedge)-14,
orlrwork < nvmaxlrwork<nvmax.
  ifail = 2ifail=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 > 0itrace>0 may provide more details.

Accuracy

Not applicable.

Further Comments

The position of the internal vertices is a function of the positions of the vertices on the given boundary. A fine mesh on the boundary results in a fine mesh in the interior. The algorithm allows you to obtain a denser interior mesh by varying nvmax, bspace, coef and power. But you are advised to manipulate the last two parameters with care.
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 interior circles inside an exterior one) is meshed using the simple incremental method (see the D06 Chapter Introduction). The exterior circle is centred at the origin with a radius 1.01.0, the first interior circle is centred at the point (0.5,0.0)(-0.5,0.0) with a radius 0.490.49, and the second one is centred at the point (0.5,0.65)(-0.5,0.65) with a radius 0.150.15. Note that the points (1.0,0.0)(-1.0,0.0) and (0.5,0.5)(-0.5,0.5)) are points of ‘near tangency’ between the exterior circle and the first and second circles.
The boundary mesh has 100100 vertices and 100100 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_inc_example
edge = zeros(3, 100, 'int64');
coor = zeros(2, 250);

% Define boundaries
ncirc     = 3; % 3 circles
nvertices = [40, 30, 30];
radii     = [1, 0.49, 0.15];
centres   = [0, 0; -0.5, 0; -0.5, 0.65];

% First circle is outer circle
csign = 1;
i1 = 0;
nvb = 0;
for icirc = 1:ncirc
   for i = 0:nvertices(icirc)-1
      i1 = i1+1;
      theta = 2*pi*i/nvertices(icirc);
      coor(1,i1) = radii(icirc)*cos(theta) + centres(icirc, 1);
      coor(2,i1) = csign*radii(icirc)*sin(theta) +  centres(icirc, 2);
      edge(1,i1) = i1;
      edge(2,i1) = i1 + 1;
      edge(3,i1) = 1;
   end
   edge(2,i1) = nvb + 1;
   nvb = nvb + nvertices(icirc);
   % Subsequent circles are inner circles
   csign = -1;
end
nedge = nvb;

% Initialise mesh control parameters
bspace = zeros(1, 100);
bspace(1:nvb) = 0.05;
smooth = true;
itrace = int64(0);

[nv, nelt, coor, conn, ifail] = nag_mesh_2d_gen_inc(edge, coor, bspace, smooth, itrace);
if (ifail == 0)
  fprintf('\nnv   = %d\n', nv);
  fprintf('nelt = %d\n', nelt);
  % Plot mesh
  fig = figure('Number', 'off');
  triplot(transpose(conn(:,1:double(nelt))), coor(1,:), coor(2,:));
  axis equal; % To ensure that circles look like circles
end
 

nv   = 250
nelt = 402

function d06aa_example
edge = zeros(3, 100, 'int64');
coor = zeros(2, 250);

% Define boundaries
ncirc     = 3; % 3 circles
nvertices = [40, 30, 30];
radii     = [1, 0.49, 0.15];
centres   = [0, 0; -0.5, 0; -0.5, 0.65];

% First circle is outer circle
csign = 1;
i1 = 0;
nvb = 0;
for icirc = 1:ncirc
   for i = 0:nvertices(icirc)-1
      i1 = i1+1;
      theta = 2*pi*i/nvertices(icirc);
      coor(1,i1) = radii(icirc)*cos(theta) + centres(icirc, 1);
      coor(2,i1) = csign*radii(icirc)*sin(theta) +  centres(icirc, 2);
      edge(1,i1) = i1;
      edge(2,i1) = i1 + 1;
      edge(3,i1) = 1;
   end
   edge(2,i1) = nvb + 1;
   nvb = nvb + nvertices(icirc);
   % Subsequent circles are inner circles
   csign = -1;
end
nedge = nvb;

% Initialise mesh control parameters
bspace = zeros(1, 100);
bspace(1:nvb) = 0.05;
smooth = true;
itrace = int64(0);

[nv, nelt, coor, conn, ifail] = d06aa(edge, coor, bspace, smooth, itrace);
if (ifail == 0)
  fprintf('\nnv   = %d\n', nv);
  fprintf('nelt = %d\n', nelt);
  % Plot mesh
  fig = figure('Number', 'off');
  triplot(transpose(conn(:,1:double(nelt))), coor(1,:), coor(2,:));
  axis equal; % To ensure that circles look like circles
end
 

nv   = 250
nelt = 402


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