0% found this document useful (0 votes)
56 views10 pages

Education: & Training

ok
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views10 pages

Education: & Training

ok
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Education4

& TRAINING
paper a method for economically generating shape
Automatic generation of functions for a wide variety of problems will be
shape functions for finite discussed.
Recently, attention has turned to automatic gen­
element analysis using eration of shape function routines using programs
REDUCE for symbolic manipulation. The idea of algebraic
manipulation of symbols on the computer has been
Christine Barbier,t Philip J . Clark,* around since the early days of computing. Only
Peter Bettess* and Jacqueline A. Bettess† relatively recently, however, have powerful symbolic
*Department of Marine Technology. University manipulation languages become widely available.
of Newcastle-upon-Tyne, Newcastle-upon-Tyne Typical languages now in use are REDUCE 2 ,
NE1 7RU, UK and †Computer Centre, University of MACSYMA 3 , SMP 4 and MuMATH 5 . There is
Durham, Durham DH1 3LE, UK
(Received August 1990) a special interest group in ACM devoted to symbolic
manipulation (SIGSAM 6 ). A few research workers
have realised the enormous potential such languages
ABSTRACT have in the generation of error-free numerical code,
The use of algebraic languages such as REDUCE and in particular finite element software 7-14 . This is
makes possible the automatic generation, from fairly especially true for languages, such as REDUCE,
concise data, of the main families of two and three which can produce Fortran code for the evaluation
dimensional C0 continuous finite element shape of expressions. Most work in the development of
functions, with a high confidence in their correct­ new finite element formulations is concerned with
ness. This paper gives a tutorial introduction to the the algebra of new algorithms. Most of this work can
REDUCE language and describes how it was used be carried out automatically and with practically
to generate shape function routines. complete freedom from error using the symbolic
manipulation languages.
The pioneering work of Wang et al. 1 2 - 1 4 covers
INTRODUCTION
similar ground to the present work. Wang and his
In finite element analysis, it is well known that the co-workers have developed an interactive system
shape functions are used to interpolate field vari­ called FINGER (FINite element code GEneratoR).
ables within elements. Most are based on poly­ This system allows the user to develop Fortran code
nomials. C0 continuous shape functions are those in for isoparametric elements to various levels of
which the field variable is continuous between sophistication. At the lowest level shape functions
adjoining elements but not the derivative of the field are generated which can then be used to construct
variable. The theory for different element shape the finite element strain matrix, the material proper­
functions is available in many standard text books, ties matrix (where this depends on non-linear consti­
for example Zienkiewicz1. Most of the text books do tutive relations), and the integrand of the system
not, however, give the derivatives of the shape matrix. The final objective of integrating this last
functions, and leave it to the user to expand the item to produce the stiffness matrix can be achieved
polynomials, form the derivatives and simplify the in certain hybrid-mixed formulations 13 but in gen­
resulting expressions. Fortran code is available for eral it is not possible because the integrand is
some shape functions, in the NAG library for a rational function of the local element co-ordinates.
example. However, it is not possible to have shape In their early work Wang et al. 12 used a polynomial
function libraries which cover all possibilities. In this approximation of the integrand by assuming that the

0264-1401/90/040349-10$2.00
© 1990 Pineridge Press Ltd. Eng. Comput., 1990, Vol. 7, December 349
Education and Training

Jacobian of the element could be approximated by REDUCE: AN ALGEBRAIC LANGUAGE


its value at the centre of the element. This approxi­
REDUCE is a system which can accurately perform
mation may be useful for low order elements suffer­
algebraic operations 15 . It can manipulate objects
ing from little deformation, but it is unlikely to
like polynomials, rational functions, user defined
satisfactorily replace the full isoparametric formula­
functions, symbolic matrices, i.e. matrices contain­
tion. Wang's later work does not mention this
ing algebraic expressions (non-numerical matrices).
approximation 14 .
Its capabilities include:
The NUFES finite element system developed at
Newcastle University evaluates the strain and stiff­ ● simplification of expressions such as expansion
ness matrices numerically. However, computer alge­ and factorization of polynomials,
bra has been used to derive the shape functions and ● calculations with symbolic matrices,
their derivatives. Computationally efficient express­ ● substitution and pattern matching in express­
ions have been obtained using GENTRAN, which ions, i.e. substitution of a variable or a sub­
also generates Fortran code. GENTRAN is a tool expression by another within an expression,
developed by Wang and Van Hulzen 14 as part of the ● analytic differentiation and integration of poly­
FINGER system. It can be used with VAXIMA 14 , nomials, rationals and elementary functions,
MACSYMA and REDUCE. ● arbitrary precision integer and real arithmetic,
The use of REDUCE to generate two dimensional ● facilities to extend the system syntax to include
C 0 continuous shape functions was given in an user defined functions.
earlier paper 7 . The aim of this paper is to describe A brief overview of the system is now given, so as
the formation of all the main two and three dimen­ to demonstrate how a computer algebra system
sional C 0 continuous shape function routines, devel­ works. REDUCE is designed to be an interactive
oped from the original REDUCE program but system, although it can be run in batch mode. In
exploiting GENTRAN to generate more efficient interactive mode, once the system is started, the user
Fortran 77 code. is prompted to enter a query. A query can be
While many users have their own tried and tested a declaration statement, an algebraic expression,
shape function routines, it is useful to have access to a whole program.
a comprehensive library of routines. With interest Declarative statements include defining a matrix,
turning to p-type adaptive finite element analysis, an array, a user function, a procedure, an output file,
higher order shape functions may be required and etc. Arrays and matrices are different. A matrix can
they are tedious to code and check. Although not be globally manipulated to obtain, for example, its
discussed explicitly in this paper, the generation of determinant and to perform addition or multiplica­
special elements, such as singular finite elements and tion with another matrix. An array can only be
infinite elements can also be greatly simplified using manipulated element by element. Replacing the
the approach described here. A feature of the array with a matrix allows the user to perform
computer algebra approach is its great flexibility and matrix algebra more efficiently. Single variables do
generality. For example, some users prefer to gener­ not need to be declared. Any variable in REDUCE is
ate the shape functions for triangular elements global in scope. Once variables have been defined
retaining all three area co-ordinates as variables, they can be accessed anywhere in the program,
even though they are not independent. In using including procedures.
REDUCE it is simple to change from the two
Algebraic manipulation is automatically done by
variable form to the three variable form. Again some
REDUCE according to internal rules. The user has
users prefer to explicitly evaluate numerically the
some control over the way REDUCE manipulates
shape functions and their derivatives at quadrature
expressions internally. The following examples show
points and store them as values, in large arrays. It is
how REDUCE expands polynomials, stores the
easy to adapt the REDUCE code to do this also.
result into variables and performs differentiation
As use of computer algebra, or symbolic manipu­ and integration.
lation, is not yet widespread, we have added to this
paper a brief outline of the salient features of Examples:
REDUCE. It is the belief of the authors that these user input P:=(X+Y+Z)**2;
languages will have a considerable influence on the REDUCE response P:=X2+2XY+2XZ+Y2
generation of numerical software. +2YZ+Z2

350 Eng. Comput., 1990, Vol. 7, December


Education and Training

user input D:=DF(P, X); statement or expression as needing some evaluation


REDUCE response D:=2(X+Y+ Z) before translation. This is done by handing to
user input INT(D, Y); REDUCE the pieces of code to evaluate and then
REDUCE response Y(2X+Y+2Z) translating the resulting expressions. The following
examples illustrate how GENTRAN translates
As can be seen above, DF(P, X) performs the a loop statement and how the generation of code is
differentiation of the function P with respect to X, achieved using the GENTRAN statement EVAL
INT(D, Y) performs the integration of the function (the value of P is as defined previously).
D with respect to Y.
In REDUCE variables represent themselves.
They are as defined in mathematics. Arrays and Example:
matrices do not represent themselves. They are user input GENTRAN « FOR I:= 1:N DO
initialized by default to zero when declared. They V(I):=0»;
can contain algebraic expressions. The following REDUCE
examples illustrate how variables stand for them­ response DO 25001 I = 1,N
selves and how substitution and pattern matching V(I) = 0.0
work (the value of P is as defined in the previous 25001 CONTINUE
example): user input GENTRAN « RES := EVAL(P)»;
user input X:=3; Y:=U; P; REDUCE
REDUCE response X = 3 response RES = U**2 + 2.000000E0*U*Z +
Y=U 6.000000E0*U + Z**2 +
P=U 2 + 2UZ + 6U + Z2 + 6.000000E0*Z +9.000000E0;
6Z + 9 user input GENTRAN « RES: = P »
REDUCE
REDUCE provides all the usual control state­ response RES = P
ments:
Tools are provided by GENTRAN to insert
● assignment (:=) type declarations (statement DECLARE) and com­
● group statement (BEGIN ... END or « . . . » ) ments (statement LITERAL). The type declarations
● loop(FOR NB: = 1:N DO) are automatically inserted before any executable
● condition (IF ... THEN ... ELSE) statement when the option GENDECS (ON
● jump (GO TO) GENDECS) is used. GENTRAN is an external
package of REDUCE which needs to be loaded
before being used (LOAD GENTRAN). CR!* rep­
REDUCE performs exact arithmetic calculations.
resents a carriage return and TAB!* a Fortran
For example 2/7 remains as a rational and is not
tabulation (seven colums).
transformed into a real. A program in REDUCE is
built in the same way as in other languages. Tasks user input LOAD GENTRAN;
can be divided into sub-tasks performed by pro­ ON GENDECS;
cedures which are called in turn. A program can be GENTRAN
entered interactively or from a file (batch mode). «
An important feature of REDUCE not discussed LITERAL "C test program",CR!*;
yet is its ability to produce Fortran code. This can be FOR I:=1:N DO V(I):=0;
done using the FORT option in the language itself, RES:=EVAL(P);
but more comprehensive facilities are available DECLARE«V(!*):DIMENSION;
through an additional package called GEN- X,Y,Z,V,RES:REAL»;
TRAN 16 . GENTRAN can produce Fortran, C and LITERAL TAB!*,"STOP",CR!*,
RATFOR (RATional FORtran) code. GENTRAN TAB!*,"END"
is used within REDUCE (same syntax) to translate »;
and generate numerical code. The translator of code END;
takes a REDUCE expression, statement or pro­ REDUCE
cedure and translates it into code in the target response REAL X,Y,Z,V(*),RES
language. This mainly involves a change in the C test program
syntax. The code generator recognizes part of the DO 25001 I = 1,N

Eng. Comput., 1990, Vol. 7, December 351


Education and Training

V(I) = 0.0 Lagrangian element


25001 CONTINUE The shape functions for the Lagrangian element
RES = U**2+2.000000E0*U* are obtained as follows:
Z+6.000000E0*U+Z**2+
● 2 dimensions:
6.000000E0*Z+ 9.000000E0
STOP
END
● 3 dimensions:

where ξ, η, ζ are the local co-ordinates,


ALGORITHMS IMPLEMENTED
i, j , k denote the position of the node in the
Working with shape functions is well known to standard cube (see below),
anybody involved in finite element analysis using node (i, j , k) is the node number of the node
isoparametric elements. Designing a program to whose position in the standard cube is (i, j,k)
calculate shape functions involves first hand ma­ i,j,k are defined as follows:
nipulations then coding into a numerical language.
When using a computer algebra system the same
steps are followed but all the actual calculation and
coding are done by the machine. We will now briefly
explain how the shape functions are developed.
Several types of elements have been considered.
They are Lagrangian and serendipity quadrilaterals
and cubes, triangles and tetrahedra, Lagrangian and
serendipity triangular prisms.
The REDUCE program carries out the calcula­
The general form of the shape functions for these
tions as described by (1), (3) and (4). First, the one
elements can be found for example in Zienkiewicz1.
dimensional normalized co-ordinates ξ0, ξ1, . . . ξn
All the shape functions are built up from the one
are calculated and stored.
dimensional Lagrange polynomials for interpola­
ting through the points in one dimension.
Lagrange polynomials, of degree n are defined as:

where i = 0,...n,ξ is the normalized co-ordinate in Then the one dimensional Lagrange polynomials
the range [— 1, + 1] and the element has n + 1 nodes. are calculated in terms of a generic coordinate VAR1
The shape functions depend upon the cardinal­ and stored. The REDUCE code corresponding to
ity condition of the Lagrange polynomials, (1) is given by:
FOR I: = 0:N DO
« L(I): = 1;
The formation of the shape functions using
REDUCE is next described for each element con­
sidered. The cartesian co-ordinates over the stan­
dard square (cube) are ξ, η (and ζ). The barycentric
co-ordinates over the standard triangle (tetrahed­
ron) are L1, L2, L3 (and L 4 ). They are called local
co-ordinates (see Figure 1). The shape functions can
be used to map the local co-ordinates to the global
co-ordinates, i.e. the actual co-ordinates of the nodes
in the mesh.

352 Eng. Comput., 1990, Vol. 7, December


Education and Training

FOR J: = 0:ND O tion of the node in the quadrilateral:


« IF I NEQ J THEN
« L(I): = L(I)*(VAR1-XI(J))/(XI(I)-XI(J))»
»
» ;
The one dimensional quadratic Lagrangian poly­
nomials are:

where

The REDUCE code corresponding to (6) is:


user input N : = 2 ; L(0); L(1); L(2);
REDUCE response N = 2
L(0) = (VAR1 − 1)*VA0R1/2
L(1) = −(VAR1 + 1)*(VAR1−1) and
L(2) = (VAR1 + 1)*VAR1/2
The two dimensional shape functions are ob­
tained by multiplying two one-dimensional Lag­
range polynomials in the ξ and η directions. RE­
DUCE uses the one dimensional Lagrange poly­
nomials already calulated and substitutes VAR1 (ξc, ηc) are the local co-ordinates of the corner node,
(operator SUB) by the actual co-ordinate. The code n + 1 is the number of nodes along one edge of the
corresponding to (3) is (using XI for ξ and ET for η): element, and edges are as shown on Figure 2.
EH corresponds to the nodes on the horizontal
FOR I: = 0:N DO edges, except the corner nodes. It is composed of
« FOR J: = 0:N DO a (n + 1 )th order Lagrange polynomial in ξ direction
« SF(NODE(I, J)): = SUB(VAR1 = XI,L(I))* and a linear Lagrange polynomial in η direction as
SUB(VAR1 = ET, L(J))» there are n + 1 nodes in the ξ direction and only
» ; two nodes in the η direction. Similarly, EV
Similarly for three dimensions. corresponds to the nodes on the vertical edges,
The one dimensional Lagrange polynomials can except the corner nodes. C is the shape function of
be used as many times as wanted because the all four corner nodes. It is formed from a bilinear
operator SUB does not affect the values of L in function in ξ and η, from which two polynomials
memory. The REDUCE programming language are subtracted. The two polynomials are weighted
uses dynamic array storage. Therefore REDUCE is sums of EH and EV along the ξ and η directions.
able to generate Lagrange polynomials to any high They ensure that C is equal to one at the corner
order, e.g. n = 50, which far exceeds any practical and zero at all other points of the element. The first
limit as far as finite element analysis is concerned.

Serendipity element
A geometrical interpolation of serendipity ele­
ments is given by Zienkiewicz1. For example, the
two dimensional quadratic and cubic quadrilateral
shape functions are defined below. SFnode(i,j)(ξ, η)
takes three different values depending on the posi­

Eng. Comput., 1990, Vol. 7, December 353


Education and Training

part of C (bilinear function) gives one at the corner, to one. The formula for the shape function is:
zero at the other corners and some non-zero values
at the mid-side nodes along the edges. P and Q
modify C so that its value at the mid-side nodes is where
zero.
The calculation in three dimensions is similar. The
mid-side nodes are calculated by multiplying two
linear Lagrange polynomials by a (η + l)th order
Lagrange polynomial. The corner nodes are cal­
culated by assigning a trilinear polynomial and then Li(j) denotes the Li barycentric co-ordinate of the
subtracting the sums of weighted parts of the values node at position j in the Li direction. Similarly for
of the shape functions at the mid-side nodes.
REDUCE handles the calculations as described As there can be several nodes in position j in the Li
above. The mid-side node shape functions EH and direction the actual nodes used in (9) are undeter­
EV are constructed with suitable order Lagrange mined. However, as all nodes in position j have the
polynomials in ξ and η (and ζ in 3D) directions, same Li co-ordinate the choice of the node is not
using the operator SUB (see Lagrangian element). important as the result will be the same in all cases.
The corners are initially assigned with the bilinear For example, a triangle (123) with 4 nodes along one
(or trilinear in 3D) function using the one dimen­ edge has the following shape functions (see Figure 3):
sional Lagrange polynomials. The two polynomials ● Node 1 (i, j, k) = (3, 0, 0)
P and Q are calculated and the subtraction is made.
The program is such that, P and Q being initialized SF1 (L1, L2, L3)
to zero, as soon as one shape function for a mid-side = 4th order in L1 * 1st order in L2 * 1st order in L 3
node is calculated its weighted value is added to P
and Q.
Extension to quartic and higher order serendipity
polynomials requires the introduction of mid-face
nodes. Although straight forward in principle it has
not been done here, as such elements are not widely
used.

Triangular and tetrahedral elements • Node 2 (i, j , k) = (2, 1, 0)


The method given by Zienkiewicz1 for the con­
struction of shape functions for triangular and SF2 (L 1 ,L 2 ,L 3 )
tetrahedral elements is followed here. = 3rd order in L1 * 2nd order in L 2 * 1st order in L 3
A point in a triangular element is defined by its
barycentric co-ordinates L 1 , L 2 , L 3 . A node can be
denoted by three integers i, j , k which correspond to
the transformed barycentric co-ordinates in the
range [0, η], when n + 1 is the number of nodes along
one edge of the element.
i =nL10≤L1≤1→0≤i≤n
j = nL2 0 ≤ L2 ≤ 1→ 0 ≤ j ≤ n
k = nL3 0 ≤ L3 ≤ 1→ 0 ≤ k ≤ n
i +j + k = n
The shape functions can then be constructed by
the multiplication of an (i + 1)th order polynomial in
the L1 direction, by a (j + 1)th order polynomial in
the L 2 direction, and by a (k + 1)th order polynomial
in the L 3 direction. The first order polynomial is set

354 Eng. Comput., 1990, Vol. 7, December


Education and Training

● Node 6 (i, j , k) = (1, 1, 1) dimensional polynomials:


SF 6 (L 1 , L2, L3)
= 2nd order in L1 * 2nd order in L2 * 2nd order in L 3
where n +1 is the number of nodes along one edge of
the element, i, j and k are the transformed barycen­
tric co-ordinates in the range [ 0 , n], l denotes the
position of the node in the ζ direction, l = 0 on
The method can easily be extended to the 3 dimen­ bottom triangular plan, l = n on top triangular plan.
sional case. The 3 dimensional barycentric co­ REDUCE handles these expressions in a similar
ordinate system L1, L2, L3, L4 is used. i, j , k, l are manner to those described in the sections on Lagran­
defined as follows: gian and triangular elements.
Serendipity prism. The shape functions are ob­
i = nL1 0 ≤ L1, ≤ 1 → 0 ≤ i ≤ n tained by combining the methods for the serendipity
j = nL2 0 ≤ L2, ≤ 1 → 0 ≤ j ≤ n and triangular elements. The quadratic and cubic
shape functions SFnode(i, j, k, l)(L1, L 2 , L 3 ,ζ)are ob­
k = nL3 0 ≤ L3, ≤ 1 → 0 ≤ k ≤ n tained as follows:
l = nL4 0 ≤ L4, ≤ 1 → 0 ≤ l ≤ n
i +j + k + l = n
The shape functions for tetrahedral elements are
developed extending the formulation of the triangle
element.

where

The REDUCE program calculates the shape


functions in a similar way to the Lagrangian element
except that contrary to the case of the quadrilateral
and cubic elements, where the polynomials are of the
same order, here all lower order polynomials are
used. First, the normalized co-ordinates, varying
between zero and one, are calculated and stored. Then
the one dimensional Lagrange polynomials for the
triangle, given (9), are calculated in terms of a gen­
and
eric co-ordinate VAR2 and stored. The calculation
of the shape functions, in (8) and (10), is done by
multiplying together the Lagrange polynomials for
the triangle in L1, L2 and L 3 (and L 4 in 3D) using the
operator SUB to substitute VAR2 by the actual
barycentric co-ordinates. n +1 is the number of nodes along one edge of the
element, i, j and k are the transformed barycentric
co-ordinates in the range [0, n] and l denotes the
position of the node on the vertical edges.
Triangular prisms The geometrical interpretation and the handling
The triangular prism is defined by a local co­ of the calculations by REDUCE of these formulas
ordinate system which is made up of barycentric and are similar to the serendipity and triangular ele­
cartesian co-ordinates, L1, L2, L3 on the triangular ments.
faces and ζ in the perpendicular direction. The
elements can be of Lagrangian or of serendipity type.
PROGRAM STRUCTURE
Lagrangian prism. The shape functions are de­
rived as a product of triangular and Lagrangian one The program is divided in four tasks:

Eng. Comput., 1990, Vol. 7, December 355


Education and Training

GENTRAN are not always optimized for numerical


calculations. Here is an example:
SF(l) = (XI−1.0)*(ET−1.0)/4.0
SF(2) = − (XI+1.0)*(ET−1.0)/4.0
SF(3) = − (XI−1.0)*(ET+1.0)/4.0
SF(4) = (XI+1.0)*(ET+1.0)/4.0
This is not very good Fortran code because
several expressions are calculated several times,
which is time consuming. A better way of writing the
same set of expressions would be:
T1 = XI−1.0
T2 = XI+1.0
T3 = ET−1.0
T4 = ET+1.0
SF(l) = T1*T3/4.0
SF(2) = −T2*T3/4.0
SF(3) = −Tl*T4/4.0
1. Input from the user. SF(4) = T2*T4/4.0
2. Labelling of the element nodes.
3. Calculation of the shape functions. This uses a bit more memory but could save a lot
4. Generation of Fortran code. of time in cases where one of the Ti is used many
times. REDUCE and GENTRAN provide tools to
The numbering convention is shown in Figure 4. automatically extract common sub-expressions out
The Lagrangian element has its nodes numbered of a series of expressions and generate the intermedi­
first along ξ, second along Η and third along ζ. The ate variables Ti. The developers of GENTRAN plan
serendipity element is numbered anticlockwise that an optimization process will be included in the
around the edges in 2 dimensions and up one layer future so that any Fortran output generated by
after the other in 3 dimensions. The triangular and GENTRAN will be optimized. This is worthwhile
tetrahedral elements have their nodes numbered in for higher order elements where the size of the
the same way as the Lagrangian element. The prism generated code has been dramatically reduced.
elements use the previous conventions.
Modules to perform the four tasks are organised
within a main program unit. The user has several TESTS AND PERFORMANCE
choices: To check the validity of the Fortran code produced
1. Generating all shape functions from one given by GENTRAN, several tests were carried out on the
order up to another one. shape functions and their derivatives. First, the
2. Generating all shape functions of one family REDUCE code has directly been checked by print­
from one given order up to another one. ing the REDUCE expressions for the shape func­
tions and comparing the results with hand calcula­
3. Generating shape functions for a given family,
tions from other sources. Second, Fortran test
dimension and order.
programs have been written to automatically check
This allows flexibility in the generation of wanted the Fortran code generated by GENTRAN from the
shape functions and minimizes the intervention of REDUCE expressions. It has been necessary to
the user. The program has been used to generate carry out two sets of tests to make sure that no errors
Lagrangian and serendipity elements up to cubic, were introduced during the translation. Both RE­
triangular and tetrahedral elements up to quartic, DUCE and GENTRAN are continually evolving
Lagrangian and serendipity triangular prism ele­ and improving. When this program was first written
ments up to cubic. some problems were encountered with REDUCE
An effort has been made to produce efficient and GENTRAN which have since been fixed.
Fortran code from the REDUCE algebraic express­ The first test checks that the cardinality property
ions for the shape functions. Indeed, the Fortran of the shape functions is respected. For each element
expressions for the shape functions produced by the sum of the shape functions at each node should

356 Eng. Comput., 1990, Vol. 7, December


Education and Training

be equal to 1. Equation (13) gives the form of the test Table 1 Performance of REDUCE translated code and direct
FORTRAN code
for a quadrilateral Lagrangian element:
2 dimensions 3 dimensions

Quadratic elements FD NG RT FD NG RT

Lagrangian 80 / 29 262 / 136


Serendipity 147 37 24 455 199 96
where n +1 is the number of nodes along one edge of Triangle 90 103 14 197 120 26
the element.
At each node the sum of the shape function 2 dimensions 3 dimensions
derivatives with respect to the kth co-ordinate Cubic elements FD NG RT FD NG RT
should be equal to zero. Equation (14) gives the
Lagrangian 107 / 91 547 / 547
expression of the test for a quadrilateral Lagrangian Serendipity 218 83 56 773 409 177
element: Triangle 116 129 47 334 230 101

All times are in μs. RT: Reduce translated. NG: NAG library routines.
FD: Fortran directly written by hand

operations so it is likely to run faster than the code


written directly which contains calls to procedures,
where SFDk represents the shape function derivative
loops, etc. in addition to assignments and arithmetic
with respect to the kth co-ordinate (ξ, η).
operations. The best speed up has been obtained for
A question which exercised the authors was
the serendipity and triangular elements where the
whether it was better to create the shape functions as
REDUCE translated code runs on average 75%
products of one dimensional shape functions or to
faster than the direct Fortran. The Lagrangian
expand them completely. To determine which is
elements give an average speed up for quadratic
better, Fortran software for all shape functions has
element but quite a poor one for cubic element.
been written directly by hand. This software uses the
Indeed, the expanded expressions for the Lagran­
one dimensional Lagrange polynomials, the one
gian elements are complicated because the poly­
dimensional Lagrange polynomials for the triangle
nomials used are of higher order than for the
and their derivatives produced by REDUCE and
serendipity and triangular elements.
translated by GENTRAN. The Fortran code writ­
ten by hand reflects the REDUCE code in the way it The REDUCE translated code for serendipity
works. The two and three dimensional shape func­ elements compares well with the NAG library
tions and their derivatives have been calculated by routines. The times for the NAG routines for
forming products of the one dimensional Lagrange the triangle are to be considered with caution as
polynomials and their derivatives. The numerical the calculations are carried out differently. The
results obtained with the above software have been REDUCE translated code and the direct Fortran
checked to be identical to those obtained with the code use the barycentric co-ordinates in the calcula­
REDUCE translated code. tions and as arguments in the subroutine statement.
The NAG library uses the cartesian co-ordinates in
The performance of the REDUCE translated code the subroutine statement and the barycentric co­
have been evaluated in absolute value, in compari­ ordinates in the calculations which implies extra
son with the software directly coded by hand in calculation to transform the cartesian co-ordinates
Fortran and the NAG library routines. The results into barycentric co-ordinates. Lagrangian shape
for the quadratic and cubic elements are given in functions are not available in the NAG library.
Table 1. The times have been obtained on a main­
frame Amdahl 5860 running under MTS (Michigan
CONCLUSIONS
Terminal System) operating system. The IBM FOR-
TRANVS V.2.2.0 Fortran compiler has been used. An alternative method for generating numerical
Timings have been obtained without optimization. code for shape functions has been presented which
The results in Table 1 show that in most cases the uses computer algebra. It is comprehensive and
REDUCE translated code is faster than the Fortran accurate because most algebraic manipulations are
direct code and the NAG library. The REDUCE carried out by the machine and Fortran code is
translated code contains only assignment statements generated automatically from the resulting express­
and the time is largely spent doing arithmetic ions. The shape function derivatives are also pro-

Eng. Comput., 1990, Vol. 7, December 357


Education and Training

vided. The Fortran code obtained is optimized and 3 Macsyma-Symbolics Ltd, St. John's Court, Easton St, High
Wycombe, Bucks, HP11 1JX, UK
its performance compares well with other methods 4 SMP-Inference Corporation, 5300 West Central Building, Los
and existing libraries. Work is now going on to Angeles, CA 90045, USA
5 MuMath-Soft Warehouse Inc, 3615, Harding Avenue, Suite 505,
develop similar infinite element mapping functions. Honolulu, Hawaii 96186, USA & C. D. Woofand D. E. Hodinson,
MuMath A Microcomputer Algebra System, Academic Press,
New York (1987)
CODE AVAILABILITY 6 SIGSAM-ACM Special Interest Group on Symbolic and Alge­
braic Manipulation, 11 West 42nd St, NY 10036, USA
All the software described above is available from 7 Bettess, P. and Bettess, J. A. Automatic generation of shape
function routines, in Numerical Techniques for Engineering and
Mrs J. A. Bettess (Computer Centre, University of Design (NUMETA '87, Swansea) paper S20, Vol. II, Martinus
Durham, South Road, Durham, DH1 3LE, tel: 091 Nijhoff, Dordrecht (1987)
8 Kidger, D. J. The 14 node brick element, Proc. 2nd A. Robert J.
374 2895) for a modest charge. The complete set of Melosh Medal Paper Competition, Duke University, NC (1990); to
materials consists of: be published in a special issue of Finite Elements in Analysis and
Design
9 Park, K. C. and Flagg, D. L. An operational procedure for the
1. REDUCE source codes. symbolic analysis of the finite element method, Comp. Meth. Appl.
2. Automatically produced FORTRAN 77 Mech. Eng., 42, 37-46 (1984)
10 Nedergaard, H. and Pedersen, P. T. Analysis procedure for space
source codes for all the shape functions de­ frames with material and geometrical nonlinearities, in Finite
scribed above. Element Method for Nonlinear Problems (Eds P. G. Bergan, K. J.
Bathe and W. Wunderlich) Springer-Verlag, Berlin (1985)
3. User instruction file. 11 Dasgupta, G. A computational scheme to analyze nonlinear
stochastic dynamic system by finite elements, Res Rep. 1UTAM
Symp. Igls, Austria (1987)
ACKNOWLEDGEMENTS 12 Wang, Paul S , Chang, T. Y. P. and Van Hulzen, J. A. Code
generation and optimization for finite element analysis, Proc.
The authors are pleased to acknowledge the support EUROSAM '84, London, pp. 237-247 (July 1984)
13 Wang, Paul S., Tan, H., Saleeb, A. and Chang, T. Y. Code
of the Science and Engineering Research Council, generation for hybrid mixed mode formulation in finite element
through awards GR/E/2099.8 and GR/F/06173. analysis, ACMSYMSAC '86 Conf. Univ. Waterloo, Canada (July
1986)
14 Wang. Paul S. FINGER: a symbolic system for automatic
generation of numerical programs in finite element analysis, J.
REFERENCES Symb. Comput. 2, 305-316 (1986)
15 Hearn, Anthony C. REDUCE User's Manual, RAND Publication
1 Zienkiewicz, O. C. The Finite Element Method, 3rd Edn, McGraw- CP7S (Rev. 7/87) (July 1987)
Hill, London (1977) 16 Gates, Barbara L GENTRAN user's Manual, REDUCE version,
2 REDUCE is available from The RAND Corporation, 1700 Main Information Sciences Department, The RAND Corporation, P.O.
Street, Santa Monica, CA, 90406-2138, USA Box 2138, 1700 Main Street, Santa Monica, CA 90406-2138, USA

358 Eng. Comput., 1990, Vol. 7, December

You might also like