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

Purpose

nag_mesh_2d_gen_front (d06ac) generates a triangular mesh of a closed polygonal region in 22, 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: nvb3nvb3.
2:     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_front (d06ac).
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.
3:     coor(22,nvmax) – double array
coor(1,i)coor1i contains the xx coordinate of the iith input boundary mesh vertex, for i = 1,2,,nvbi=1,2,,nvb. coor(1,i)coor1i contains the xx coordinate of the (invb)(i-nvb)th fixed interior vertex, for i = nvb + 1,,nvb + nvinti=nvb+1,,nvb+nvint. For boundary and interior vertices, coor(2,i)coor2i contains the corresponding yy coordinate, for i = 1,2,,nvb + nvinti=1,2,,nvb+nvint.
4:     weight( : :) – double array
Note: the dimension of the array weight must be at least max (1,nvint)max(1,nvint).
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 > 0nvint>0, weight(i) > 0.0weighti>0.0, for i = 1,2,,nvinti=1,2,,nvint.
5:     itrace – int64int32nag_int scalar
The level of trace information required from nag_mesh_2d_gen_front (d06ac).
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:     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: nvint0nvint0.
2:     nvmax – int64int32nag_int scalar
Default: The dimension of the array coor.
The maximum number of vertices in the mesh to be generated.
Constraint: nvmaxnvb + nvintnvmaxnvb+nvint.
3:     nedge – int64int32nag_int scalar
Default: The dimension of the array edge.
The number of boundary edges in the input mesh.
Constraint: nedge1nedge1.

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 + nvint = nvmaxnvb+nvint=nvmax, no interior vertices will be generated and nv = nvmaxnv=nvmax.
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 (invbnvint)(i-nvb-nvint)th generated interior mesh vertex, for i = nvb + nvint + 1,,nvi=nvb+nvint+1,,nv; while coor(2,i)coor2i will contain the corresponding yy coordinate. The remaining elements are unchanged.
4:     conn(33,2 × nvmax + 52×nvmax+5) – 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,
ornvint < 0nvint<0,
ornvb + nvint > nvmaxnvb+nvint>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,
orif nvint > 0nvint>0, weight(i)0.0weighti0.0, for some i = 1,2,,nvinti=1,2,,nvint;
orlrwork < 12 × nvmax + 30015lrwork<12×nvmax+30015,
orliwork < 8 × nedge + 53 × nvmax + 2 × nvb + 10078liwork<8×nedge+53×nvmax+2×nvb+10078.
  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 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 TiTi to obtain the mesh Ti + 1Ti+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)(1.5,0.0) with a radius 4.54.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)(0.8,-0.3). 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 120120 vertices and 120120 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