Sie sind auf Seite 1von 7

Chandan Singh et al.

/ International Journal of Engineering Science and Technology (IJEST)

A SIMPLE AND FAST CONTOUR


PLOTTING ALGORITHM
FOR LINEAR 2D AND 3D ELEMENTS
CHANDAN SINGH
Department of Computer Science, Punjabi University,
Patiala, 147 002, India.

JASWINDER SINGH SAINI


Department of Mechanical Engineering, Thapar University,
Patiala, 147004, India.

Abstract:
We present a fast contour plotting algorithm using three-node triangular and four-node tetrahedral
elements which are mostly used in FEA as they fit better in an irregular domain. To make the overall task
simple the analysis is performed with higher order elements whereas the graphical display of results in
the form of contour lines or surfaces is carried out with linear elements. A three-node triangular and
four-node tetrahedral element which interpolates the function linearly over the element is used mainly for
its simplicity for fast contouring. A fast algorithm using the shape functions is demonstrated for the
plotting of contours. Numerical results are presented using these elements.

Keywords: FEA; Contour Plotting; three-Node triangle; four-Node tetrahedral; Linear Interpolation.
1. Introduction
Graphical representation of results is essential to understand numerical model behavior. This representation
substitutes analysis of a large amount of data by a simple visual inspection. Contour plotting of data is one step
towards such representation. A contour plot is a curve along which the physical parameter has a constant value
in a given domain.
The Finite Element Analysis, which is increasingly, becoming an integral tool for computer aided
design, produces large amount of results which can be interpreted easily if presented graphically. It is a common
practice in FEA to use higher order elements for better accuracy and stability of the results of the analysis
[Zienkiewicz(2002)]. However, generation of contour lines or contour surfaces using higher order elements is a
complex task. A three-node triangular element and four-node tetrahedral element which interpolates the function
linearly over the element is used mainly for its simplicity for fast contouring as speed is an important issue for
quick visualization of data, especially in animated situation. Higher order 2D and 3D elements are generally
degenerated into triangular and tetrahedral elements respectively in order to avoid complexity. Researchers have
used the preprocessor and postprocessor data of FEA for plotting of contours. Their algorithms do not need
additional information but the coordinate values and the calculated function values at discrete (nodal) points.
Many researchers have worked on different interpolation schemes. A method is based on a distance- weighted
least- squares approximation technique with the weights varying with the distance of the data points [Mclain
(1972)]. The scheme is given which is based on linear interpolation on any isoparametric element surface in 2D
domains [Meek and Beer (1976)]. A solution is given to the problem of approximating the surface spanning a
given set of 3D points as a polyhedron of triangular faces [Ganapathy and Dennehy (1982)]. The algorithm is
developed which is useful for any general-purpose 2D mesh where a linear interpolation is used over triangular
elements, which are refined in the domain [Yeo (1984)]. A few interpolation formulae such as Newton’s divided
difference, Lagrangian interpolation or least square fitting, are used to plot the contour curves [Rajasekaran
(1984)]. A method for computing contour lines directly from the polynomial coefficients found for each triangle
by solving a nonlinear equation for every point of a line [Preusser (1984)]. A general triangulation procedure
which provides a solution to the problems of conventional triangulation algorithms and also plots contours
linearly over an element [Ekoule et al. (1991)]. A direct method is given for tracing contour surfaces in 3D by
( ) ( ) ( )
converting the contour equation φ r , s, t = C into r = ψ s, t (where φ r , s, t is the interpolation function
in local coordinates r , s and t ), and then varying s and t in the interval [− 1, 1] and restricting r
between -
1 and +1 [Stelzer and Welzel (1987)]. The contour surface is represented as a set of contour points in local

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2796


Chandan Singh et al. / International Journal of Engineering Science and Technology (IJEST)

coordinates which are mapped to global coordinates and finally converted into screen coordinates for display
purpose. This is a direct approach and works well but it is computation intensive. Moreover, contour surfaces
are not generated in explicit form but, only the contour points are located. A smooth contour surfaces is
generated within the volume of an element using marching cubes method and bi-cubic polynomials [Gallagher
and Nagtegaal (1989)]. Marching cubes algorithm is also used for tetrahedral, prism and hexahedral elements to
create contour surfaces [Breitkopf (1998)]. The more complex forms and higher-order elements were treated by
subdivision into these simple forms. Linear interpolation is used within the element providing exact tracing of
contours for linear shape functions. A contour surfaces is generated using quadratic tetrahedrals by finding the
intersection of a contour surface with each face of a tetrahedron and then connecting the face intersection curves
end-to-end to form group of curves that bound various portions of the contour surface [Wiley et al. (2003)].
After determining the bounding curves, the contour surface is developed using Bernstein’s polynomials. The
method generates very smooth contour surfaces but due to approximation involved the points on contour surface
deviate from their true locations.
From the above discussion it is seen that contouring in 2D and 3D is targeted towards generating
accurate and smooth contour surfaces. These two objectives are conflicting in nature. Often, for simplicity the
higher order elements are decomposed to lower order elements at the cost of accuracy. A simplest way to plot
contours on 2D and 3D domains is to use linear interpolation over triangular and tetrahedral elements. As stated
earlier, a three-node triangular and four-node tetrahedral element which interpolates the function linearly over
the element is used mainly for its simplicity for fast contouring. In the present work an attempt is made to
develop a very fast algorithm for plotting linear contours over three-node triangular and four-node tetrahedral
elements.

2. Mathematical Formulations
A contour in 2D is a continuous curve characterized by the equation
f ( x, y ) = C (1)
where x,y are spatial coordinates and C is a constant.
A three node triangular element normally used for analysis is given in Fig. 1.

Fig. 1. A three node triangular element

The coordinates of the three vertices of the triangle are available prior to analysis and the physical quantity,
f(x,y), is known after analysis, i.e. after solving a mathematical model. The linear interpolation of coordinates
and functions over the element is performed as
3
x = ∑ N i xi (2)
i =1
3
y = ∑ N i yi (3)
i =1
3
f ( x, y ) = ∑ N i f i (4)
i =1
1
where, ܰ௜ = ‫ܮ‬௜ and Li = (a i + bi x + ci y ) (5)
2∆
The coefficients ai ,bi and ci are cofactors of the matrix, M, where
1 x1 y1 
M = 1 x 2 y 2  (6)
1 x3 y 3 

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2797


Chandan Singh et al. / International Journal of Engineering Science and Technology (IJEST)

and, ∆ = det(M ) . The functions Li = Li ( x, y ), i = 1, 2,3 are called shape functions.


The Eq. (4) is simplified to
l 0 + l1 x + l 2 y = C (7)
where
1
l0 = (a1 f 1 + a 2 f 2 + a 3 f 3 )
2∆
1
l1 = (b1 f 1 + b2 f 2 + b3 f 3 )
2∆
1
l2 = (c1 f 1 + c 2 f 2 + c3 f 3 )
2∆

Eq. (7) can be compared with the following general equation which represents a line
( )
F x, y, z = ax + by + c (8)
The problem now reduces to accurately trace the contour represented by a line over a triangle. The high speed
line algorithm like mid-point algorithm [Hearn and Baker (2003)] is used to trace the line.
Now, for a four-node tetrahedral element, the contour Eq. (1) in 3D assumes the following form
f ( x, y , z ) = C (9)
where x, y, z are spatial coordinates and C is a constant.
A four node tetrahedral element normally used for analysis is given in Fig. 2.

Fig. 2. A four-node tetrahedral element

The coordinates of the four vertices of the tetrahedral are available prior to analysis and the physical quantity,
f(x,y,z), is known after analysis, i.e. after solving a mathematical model. The linear interpolation of coordinates
and functions over the element is performed as
4
x = ∑ N i xi (10)
i =1
4
y = ∑ N i yi (11)
i =1
4
z = ∑ N i zi (12)
i =1
4
f ( x, y , z ) = ∑ N i f i (13)
i =1
1
where, where, ܰ௜ = ‫ܮ‬௜ and Li = (ai + bi x + ci y + d i z ) (14)
6∆
The coefficients ai ,bi, ci and di are cofactors of the matrix, M, where

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2798


Chandan Singh et al. / International Journal of Engineering Science and Technology (IJEST)

1 xi y i z i 
1 x y j z j 
M =  j
(15)
1 x m y m z m 
 
1 x p y p z p 
and, 6∆ = det(M ) . The functions Li = Li ( x, y , z ), i = 1,2,3,4 are called shape functions.
The Eq. (13) is simplified to
l 0 + l1 x + l 2 y + l 3 z = C
(16)
where
1
l0 = (a1 f 1 + a 2 f 2 + a 3 f 3 + a 4 f 4 )
6∆
1
l1 = (b1 f1 + b2 f 2 + b3 f 3 + b4 f 4 )
6∆
1
l2 = (c1 f 1 + c 2 f 2 + c 3 f 3 + c 4 f 4 )
6∆
1
l3 = (d 1 f 1 + d 2 f 2 + d 3 f 3 + d 4 f 4 )
6∆

Eq. (16) can be compared with the following general equation which represents a plane
F (x, y, z ) = ax + by + cz + d (17)
The problem now reduces to accurately trace the contour represented by a plane over a tetrahedral.

3. Contouring Algorithm
The overall algorithm for contouring is described as follows.
(i) Consider an element.
(ii) Find the minimum and the maximum, fmin and fmax, of f(x, y, z) over the element.
(iii) If f min ≤ C ≤ f max then go to step (iv), else go to step (vi).
(iv) Trace the contour over the element.
(v) Save the contour.
(vi) If not all the elements are processed, then consider the next element and go to step (ii), else go to step
(vii).
(vii) Join the contours of the same level.
(viii) Plot the contours.
Except for step iv) all steps are easy to understand. Detailed explanation is given for this step as follows.

3.1 Tracing contour line over a triangle element


The contour line is traced over the triangle element by finding the possible intersection of the line with the edge
of the triangle.

3 3 3

1 2 1 2 1 2

Fig. 3. Possible cases of intersection of a side with nodes 1 and 2 with the line a) The line intersects at one point of the side;
b) Intersection point is outside the side; c) The line touches the corner point

The intersection of a line with one of the sides of the triangle has three possible cases as shown in Fig. 3(a)
through Fig. 3(c). In the second case the contour line lies outside the element. The last case, if detected, is
discarded for contour plotting as it yields a single point which is of no interest.

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2799


Chandan Singh et al. / International Journal of Engineering Science and Technology (IJEST)

In general, we find intersection of a line with an edge of a triangle using parametric equations and record the
point of intersection, if any. Let the parametric equation in vector form of an edge represented by P1 P2 end
points be
(
P = P1 + u P2 − P1 ) (18)
And the general equation of the contour line be
l1 x + l 2 y + l 3 = 0 (19)
On substituting x and y from Eq. (18) into Eq. (19) and rearranging, we get

u=
(l1 x1 + l 2 y1 + l3 ) (20)
(l1 (x1 − x2 ) + l 2 ( y1 − y 2 ))
The intersection point lies between P1 and P2 if the value of u lies between 0 to 1.
Similarly, the intersection points on all the edges are calculated and joined with the help of a line to form a
contour line over an element.

3.2 Tracing contour surface over a tetrahedral element


As is discussed in 2D, we find intersection of an edge of a tetrahedral with the contour plane using parametric
equations and record the point of intersection, if any. Let the parametric equation in vector form of an edge
represented by P1 P2 end points be
P = P1 + u (P2 − P1 ) (21)
And the general equation of the contour plane be
l1 x + l 2 y + l 3 z + l 4 = 0 (22)
On substituting x, y and z from Eq. (18) into Eq. (19) and rearranging, we get

u=
(l1 x1 + l 2 y1 + l3 z + l 4 ) (23)
(l1 (x1 − x2 ) + l 2 ( y1 − y 2 ) + l3 (z1 − z 2 ))
The intersection point lies between P1 and P2 if the value of u lies between 0 to 1.
Similarly, the intersection points on all the edges are calculated and joined with the help of a line to form a
contour plane over an element. The shading of the plane is done using OpenGL.

4. Implementation of the Algorithm and Experimental Results


The contour plot algorithm is implemented in Turbo C++ and runs on an IBM compatible PC under Windows
operating system. The algorithm takes 0.054945 sec for the tracing and plotting of contours for 276, four-node
tetrahedral elements on a PC with 3.0 GHz CPU and 256 RAM. The OpenGL graphics libraries are used to
display the geometry and contour surfaces.
The first problem is a deflection of a 2D beam with length 400 mm, height 200 mm, and upper cut of
40 mm radius. The beam is fixed at one end and an axial load is applied at the other end, shown in Fig. 4.

Fig. 4. Beam fixed at one end and axially loaded at other end

5
For a load of 100 N, Young’s Modulus 2.1 × 10 N/mm2, Poisson’s ratio 0.3, the values of deflections are
derived using FEA taking 132, three-node triangle elements, considering the problem as 2D plane problem with
negligible thickness of beam 0.5 mm.
Since the beam is axially loaded, the general expression for direct horizontal deflection [Subramanian
(2005)] is given by

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2800


Chandan Singh et al. / International Journal of Engineering Science and Technology (IJEST)

WL
δx =
Ax E
where W is the load applied, L is the length of beam, Ax is the area of cross section and E is the Young’s
Modulus.
The resultant horizontal deflections are considered for contouring in the numerical experimentation for
the proposed algorithm. Fig. 5 depicts the contour plots of horizontal deflections using three-node triangles for
different levels of deflections.

Fig. 5. Contour plot of horizontal deflection using three-node triangles for axially loaded beam (All units in mm )

The second problem is a deflection of a 3D beam with length 10 mm, height 10 mm, thickness 1 mm
and central through hole of 5 mm diameter. The beam is fixed at one end and an axial load is applied at the other
end, shown in Fig. 6. For a load of 48 N, Young’s Modulus 200 GPa , Poisson’s ratio 0.3, the values of
horizontal deflections are derived using FEA taking 274, four-node tetrahedral elements.

Fig. 6. Beam fixed at one end and axially loaded at other end

Fig. 7 shows the contour surfaces for horizontal deflections using four-node tetrahedrals for different levels of
deflections.

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2801


Chandan Singh et al. / International Journal of Engineering Science and Technology (IJEST)

Fig. 7. Contour surfaces of horizontal deflection using four-node tetrahedrals for the different deflection levels (All units in mm)

5. Conclusions
A number of 2D and 3D problems in engineering applications are analyzed using triangular and tetrahedral
elements respectively because they fit better in an irregular shape as compared to other elements. Algorithms for
fast contour plotting using three-node triangular elements and four-node tetrahedral elements are discussed in
this paper. The interpolation functions representing contours in 2D and 3D elements are degenerated into lines
and planes respectively. It is observed that the contouring algorithm is very fast and takes 0.054945 sec for the
problem involving 276, four-node tetrahedral elements. The technique developed in this paper can be used to
plot contours for applications where high speed is required. Although the discussed algorithm simplifies contour
plotting, inaccuracies due to lower order interpolation are introduced.

References
[1] Breitkopf, P. (1998): An algorithm for construction of iso-valued surfaces for finite elements. Engineering with Computers, 14, pp.
146-149.
[2] Ekoule, A. B.; Peyrin, F. C.; Odet, C. L. (1991): A triangulation algorithm from arbitrary shaped multiple planar contours. ACM
Transactions on Graphics, 10, pp. 182-199.
[3] Gallagher, R. S.; Nagtegaal, J. C. (1989): An efficient 3-D visualization technique for finite element models and other coarse volumes.
Computer Graphics, 23, pp. 185-194.
[4] Ganapathy, S.; Dennehy, T.G. (1982): A new general triangulation method for plannar contours. ACM Transactions on Computer
Graphics, 16, pp. 69-75.
[5] Hearn, D.; Baker, M. P. (2002). Computer Graphics, Prentice Hall, India.
[6] Mclain, D. H. (1972): Drawing contours from arbitrary data points. Computer Journal, 17, pp. 318-324.
[7] Meek, J.L.; Beer, G. (1976): Contour plotting of data using isoparametric element representation. Int. J. Num. Methods Eng., 10, pp.
954-957.
[8] Preusser, A. (1984): Computing contours by successive solution of quintic polynomial equation. ACM Transactions on Mathematical
Software, 10, pp. 463-472.
[9] Rajasekaran, S. (1984): A note on plotting curves. Computers and Structures, 19, pp. 497-500.
[10] Stelzer, J. F.; Welzel, R. (1987): Plotting of contours in a natural way. Int. J. Numer. Methods Eng., 24, pp. 1757-1769.
[11] Subramanian, R. (2005). Strength of Materials, Oxford University Press, India.
[12] Wiley, D. F.; Childs, H. R. ; Gregorski, B. F.; Hamann, B.; Joy, K. I. (2003): Contouring curved quadratic elements. Proceedings of
Joint Eurographics-IEEE TCVG Symposium on Visualization, pp. 167-175.
[13] Yeo, M. E. (1984): An iteractive contour plotting program. Eng. Comput., 1, pp. 273-279.
[14] Zienkiewicz, O. C. (2002). The Finite Element Method, Tata McGraw-Hill, India.

ISSN : 0975-5462 Vol. 3 No. 4 Apr 2011 2802

Das könnte Ihnen auch gefallen