nag_mesh2d_smooth (d06cac) (PDF version)
d06 Chapter Contents
d06 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_mesh2d_smooth (d06cac)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_mesh2d_smooth (d06cac) uses a barycentering technique to smooth a given mesh.

2  Specification

#include <nag.h>
#include <nagd06.h>
void  nag_mesh2d_smooth (Integer nv, Integer nelt, Integer nedge, double coor[], const Integer edge[], const Integer conn[], Integer nvfix, const Integer numfix[], Integer itrace, const char *outfile, Integer nqint, NagError *fail)

3  Description

nag_mesh2d_smooth (d06cac) uses a barycentering approach to improve the smoothness of a given mesh. The measure of quality used for a triangle K is
QK=αhKρK;  
where hK is the diameter (length of the longest edge) of K, ρK is the radius of its inscribed circle and α= 36  is a normalization factor chosen to give QK=1 for an equilateral triangle. QK ranges from 1, for an equilateral triangle, to , for a totally flat triangle.
nag_mesh2d_smooth (d06cac) makes small perturbation to vertices (using a barycenter formula) in order to give a reasonably good value of QK for all neighbouring triangles. Some vertices may optionally be excluded from this process.
For more details about the smoothing method, especially with regard to differing quality, 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).

4  References

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

5  Arguments

1:     nv IntegerInput
On entry: the total number of vertices in the input mesh.
Constraint: nv3.
2:     nelt IntegerInput
On entry: the number of triangles in the input mesh.
Constraint: nelt2×nv-1.
3:     nedge IntegerInput
On entry: the number of the boundary and interface edges in the input mesh.
Constraint: nedge1.
4:     coor[2×nv] doubleInput/Output
Note: the i,jth element of the matrix is stored in coor[j-1×2+i-1].
On entry: coor[i-1×2] contains the x coordinate of the ith input mesh vertex, for i=1,2,,nv; while coor[i-1×2+1] contains the corresponding y coordinate.
On exit: coor[i-1×2] will contain the x coordinate of the ith smoothed mesh vertex, for i=1,2,,nv; while coor[i-1×2+1] will contain the corresponding y coordinate. Note that the coordinates of boundary and interface edge vertices, as well as those specified by you (see the description of numfix), are unchanged by the process.
5:     edge[3×nedge] const IntegerInput
Note: the i,jth element of the matrix is stored in edge[j-1×3+i-1].
On entry: the specification of the boundary or interface edges. edge[j-1×3] and edge[j-1×3+1] contain the vertex numbers of the two end points of the jth boundary edge. edge[j-1×3+2] is a user-supplied tag for the jth boundary or interface edge: edge[j-1×3+2]=0 for an interior edge and has a nonzero tag otherwise. Note that the edge vertices are numbered from 1 to nv.
Constraint: 1edge[j-1×3+i-1]nv and edge[j-1×3]edge[j-1×3+1], for i=1,2 and j=1,2,,nedge.
6:     conn[3×nelt] const IntegerInput
Note: the i,jth element of the matrix is stored in conn[j-1×3+i-1].
On entry: the connectivity of the mesh between triangles and vertices. For each triangle j, conn[j-1×3+i-1] gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,nelt. Note that the mesh vertices are numbered from 1 to nv.
Constraint: 1conn[j-1×3+i-1]nv and conn[j-1×3]conn[j-1×3+1] and conn[j-1×3]conn[j-1×3+2] and conn[j-1×3+1]conn[j-1×3+2], for i=1,2,3 and j=1,2,,nelt.
7:     nvfix IntegerInput
On entry: the number of fixed vertices in the input mesh.
Constraint: 0nvfixnv.
8:     numfix[dim] const IntegerInput
Note: the dimension, dim, of the array numfix must be at least max1,nvfix.
On entry: the indices in coor of fixed interior vertices of the input mesh.
Constraint: if nvfix>0, 1numfix[i-1]nv, for i=1,2,,nvfix.
9:     itrace IntegerInput
On entry: the level of trace information required from nag_mesh2d_smooth (d06cac).
itrace0
No output is generated.
itrace=1
A histogram of the triangular element qualities is printed before and after smoothing. This histogram gives the lowest and the highest triangle quality as well as the number of elements lying in each of the nqint equal intervals between the extremes.
itrace>1
The output is similar to that produced when itrace=1 but the connectivity between vertices and triangles (for each vertex, the list of triangles in which it appears) is given.
You are advised to set itrace=0, unless you are experienced with finite element meshes.
10:   outfile const char *Input
On entry: the name of a file to which diagnostic output will be directed. If outfile is NULL the diagnostic output will be directed to standard output.
11:   nqint IntegerInput
On entry: the number of intervals between the extreme quality values for the input and the smoothed mesh.
If itrace=0, nqint is not referenced.
12:   fail NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, nedge=value.
Constraint: nedge1.
On entry, nv=value.
Constraint: nv3.
NE_INT_2
On entry, nelt=value and nv=value.
Constraint: nelt2×nv-1.
On entry, nv=value and nvfix=value.
Constraint: 0nvfixnv.
On entry, the end points of the edge J have the same index I: J=value and I=value.
On entry, vertices 1 and 2 of the triangle K have the same index I: K=value and I=value.
On entry, vertices 1 and 3 of the triangle K have the same index I: K=value and I=value.
On entry, vertices 2 and 3 of the triangle K have the same index I: K=value and I=value.
NE_INT_3
On entry, numfix[I-1]=value, I=value and nv=value.
Constraint: numfix[I-1]1 and numfix[I-1]nv.
NE_INT_4
On entry, CONNI,J=value, I=value, J=value and nv=value.
Constraint: CONNI,J1 and CONNI,Jnv, where CONNI,J denotes conn[J-1×3+I-1].
On entry, EDGEI,J=value, I=value, J=value and nv=value.
Constraint: EDGEI,J1 and EDGEI,Jnv, where EDGEI,J denotes edge[J-1×3+I-1].
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh especially the connectivity. Seek expert help.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_NOT_CLOSE_FILE
Cannot close file value.
NE_NOT_WRITE_FILE
Cannot open file value for writing.

7  Accuracy

Not applicable.

8  Parallelism and Performance

nag_mesh2d_smooth (d06cac) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

None.

10  Example

In this example, a uniform mesh on the unit square is randomly distorted using functions from Chapter g05. nag_mesh2d_smooth (d06cac) is then used to smooth the distorted mesh and recover a uniform mesh.

10.1  Program Text

Program Text (d06cace.c)

10.2  Program Data

Program Data (d06cace.d)

10.3  Program Results

Program Results (d06cace.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Example Program Randomly distorted uniform mesh gnuplot_plot_1
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 Distorted mesh smoothed and a uniform mesh recovered gnuplot_plot_1

nag_mesh2d_smooth (d06cac) (PDF version)
d06 Chapter Contents
d06 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016