Sie sind auf Seite 1von 13

Isoparametric Elements and Numerical Integration, I

As we consider problems of a more sophisticated nature, it will become apparent that we need to
develop an efficient means of performing integrations over elements. For example, in 1D our text
considered only constant coefficient and equidimensional ODEs because a general procedure of dealing with stiffness and load vector computations for equations with more general coefficients was not
available. (Of course, did we develop a general purpose routine for ODEs with arbitrary coefficients,
but we had to sacrifice accuracy by using linear interpolation in each element in the computation of
stiffness and load matrices.) When we discussed rectangular elements in connection with 2D Laplace
equation problems, we assumed that the element sides were parallel to the coordinate axes. In this
case, integration could easily be performed directly since the limits of integration for both the x
and y variables were constants. In a more general situation, we may have to deal with an element
in the form of an arbitrary quadrilateral having sides that are neither parallel nor parallel to the
coordinate axes. If we have many such elements in a problem, the programming difficulties will be
considerable unless a simplifying procedure is developed.
Perhaps more importantly, we have only considered a limited variety of element types: linear elements in 1D and linear triangular, and bilinear rectangular elements in 2D. There are many more
elements that are useful in various problems. These elements use higher order polynomials to represent the behavior of the trial solution within an element. In general, when we deal with these more
complex elements, we do not use hand computation of element stiffness, load, (and in the case of
transient problems) mass matrix.
We begin by considering the problems in one dimension. In this case, the geometry is elementary,
and we can concentrate on automating the integration, i.e., we consider the problem: Given an
interval [a, b] on the real axis and a continuous function f : [a, b] R find an accurate numerical apRb
proximation to I(a, b, f ) = a f (x) dx. This is the problem of numerical integration (or quadrature),
and there is a vast literature on it. We will have to be satisfied with only a brief introduction
actually, you were probably already exposed to this problem in your mathematical methods course
so our discussion will serve as a review.
Note three things about the quadrature problem: First, the interval [a, b] may always be replaced by

some other interval, say [1, 1] (or [0, 1]). Indeed, define the affine change of variables = (x)
=
2(x a)/(b a) 1 with inverse x = x
() = (b a)( + 1)/2 + a. Then we have
I(a, b, f ) =

Z
a

(b a)
d
x
d =
f (
x())
f (x) dx =
d
2
1
Z

f x
() d,

where f g is the composition of the functions f and g, i.e., f g(x) = f (g(x)) and, of course,
the function x
depends on the end points a and b. This simple observation is quite useful from the
practical viewpoint because we only need to develop formulas for an single interval (often called a
master interval in finite element literature). Second, the integral over any interval may always be
computed as a sum over many small intervals. Define the partition x0 = a < x1 < . . . < xn = b and
use the additivity of the integral to write
I(a, b, f ) =

n
X
e=1

I(xe1 , xe , f ) =

X1
e

(xe xe1 )I(1, 1, f x


e ).

This is essentially the process that we have used to in working with one dimensional finite elements.
(It yields what is known as a composite integration rule.) From an heuristic point of view, it shows
that we only need be concerned about the behavior of the function f over a small interval in order
to approximate the value of I(a, b, f ) for any a and b. Third, if we select the interval [1, 1] as
our master interval, then you will remember that according to the definition of the definite integral:
1

R1
P
I(f ) = 1 f (x) dx k f (xk )(xk+1 xk ), where xk = 1 + 2(k 1)/n, k = 1, . . . , n + 1 is a
partition of the interval. Our basic
P formula for numerical integration will be a simple generalization
of this result. Namely, I(f ) = k f (xk )wk , where xk , k = 1, . . . , n + 1 are points in the interval
[1, 1] (not necessarily evenly spaced) and wk , k = 1, . . . , n + 1 are weights which need to be
specified. Thus, simply put, numerical integration comes down to choosing the points and weights
properly.
In finite element work, we usually approximate functions of interest by polynomials of some degree.
Thus, we will focus on quadrature rules that allow us to integrate polynomials accurately. One
approach to this problem is to preselect nodal positions in the interval of integration (usually evenly
spaced nodes), and then to seek weights that will allow us to integrate exactly all polynomials of a
certain degree. That is we require that the weights wj are adjusted so that
Z
X
IJ =
p(x) dx =
p(xj )wj
J

for p a polynomial of given degree.


As a simple example of the above approach, suppose we want to integrate linear functions, p(x) =
a + bx exactly. Since any such polynomial is a linear combination of 1 and x, we require that these
two functions be integrated exactly, i.e., I(1) = 2, I(x) = 0. Since we have two equations to satisfy
we choose two equally space points x1 = 1/3, x2 = 1/3, and select the corresponding weights to
satisfy the equations. This gives w1 + w2 = 2 and w1 /3 + w2 /3 = 0. This yields w1 = w2 = 1.
Computations for higher order polynomials are similar, but of course, more complex.
For the next example, we do not specify the nodes, but instead look for weights wk and node points
xk , k = 1, 2 such that if p is a polynomial (of degree to be determined momentarily)
Z
p dx = p(x1 )w1 + p(x2 )w2 = p1 w1 + p2 w2 .
J

Since we are going to choose both the nodes and the weights we have 4 parameters to determine. As
above we need to consider polynomials with 4 coefficients, i.e., we should require the above formula
to hold for all polynomials of order three p = c0 + c1 x + c2 x2 + c3 x3 . Substituting into the above
formula we then obtain four equations for the weights and nodes. In fact, we find
2c0 +

2c2
= c0 (w1 + w2 ) + c1 (w1 x1 + w2 x2 ) + c2 (w1 x21 + w2 x22 ) + c3 (w1 x31 + w2 x32 )
3

or the system of equations:


w1 + w2
w1 x1 + w2 x2
w1 x21 + w2 x22
w1 x31 + w2 x32

=2
=0
= 23
=0

The solution of this system is


w1 = w2 = 1,

x2 = x1 = 1/ 3

Thus, we have (recalling our earlier discussion)


Z
a

f (x) dx

(b a)
(f (
x(1/ 3)) + f (
x(1/ 3)))
2

where x
() = 0.5(b a)( + 1) 1. This formula is exact for polynomials of order three, and is an
approximation for smooth functions. Of course, this could be developed into a composite rule as
2

indicated above, but in finite element method the interval [a, b] is usually an element, and for this
reason accuracy is controlled by keeping the element size small enough. The approach just described
of choosing both points and weights gives a series of quadrature formulas know as Gauss-Legendre
rules. In general, a Gauss-Legendre formula with n points and weights can be used to integrate a
polynomial of degree 2n 1.
Lets discuss how this fits into 1D FEM problems. Here we will generally be integrating over a single
element to find the element stiffness matrix or the element load vector. Since the elements are small
we will be using a single interval quadrature rule (not a composite one). Usually, we will be using
Gaussian quadrature since this requires fewer points, and therefore less computation for a given
accuracy. The most efficient procedure is to do all the integrations on the same interval [-1,1] since
then we can always have the weights and quadrature points supplied by the same program. Thus,
it seems most efficient to define all element shape functions on [-1,1] and map the actual element
interval to this interval (usually called the master interval) in some simple way. As a first example,
consider linear elements. On the master element 1 s 1, we have
H1 (s) = (1 s)/2,
H2 (s) = (1 + s)/2.
The mapping we have been using to go back and forth from this element to the interval [x1 , x2 ] is
just x = x
(s) = x1 H1 (s) + x2 H2 (s), i.e., it is constructed from the shape functions themselves. This
is called an isoparametric mapping. Using this mapping to compute an element load vector (and
k ) would involve the integral
denoting the element shape functions by H
Z

x2

x1

k (x) dx = (x2 x1 )
f (x)H
2

f x
(s)Hk (s) ds

where we use the fact that d


x/ds = (x2 x1 )/2.
As a second example, lets look at quadratic elements. Note that a quadratic is defined by three
coefficients in 1D. Thus, a quadratic element will have three nodes the two end points of the
interval and an interior point which is normally taken as the midpoint of the interval. Shifting to
the master element which we take to be the interval [1, 1], we require the three nodes to be 1, 0, 1.
In this case, the master element shape functions are
H1 (s) = s(1 s)/2,
H2 (s) = (1 s)(1 + s)
H3 (s) = s(1 + s)/2
P
We can again use an isoparametric mapping x = x
(s) =
k xk Hk (s) to transform an arbitrary
element [x1 , x3 ] to the master element. In this case, if the point x2 is the midpoint of the interval,
x2 = (x1 + x3 )/2, the mapping reduces to the linear one used above.
We could move on and consider still higher order elements which have more interior points within the
element for example, a cubic element will have two interior points in addition to the two interval
end points, e.g. 1, 1/3, 1/3, 1 for the master element. These nodes lead to shape functions such
as H1 (s) = (9/16)(1/3 s)(1/3 + s)(1 s), etc.. Generally these elements are used less frequently
then the lower order ones.
Isoparametric Elements and Numerical Integration, II
Now we are ready to tackle problems in higher dimensions (well only be concerned with 2D problems,
but 3D can be treated in the same way). This turns out to be easier then might be expected,
particularly in regard to the geometry. We assume that a finite element mesh consisting of triangles
or quadrilaterals has been created on the physical domain of interest. Since these physical elements
may be oriented in arbitrary ways, we proceed using the following steps: 1.) Define a fixed triangle
3

or rectangle called a master element. 2.) Develop shape functions of various sorts on these master
element. 3.) Define a mapping or transformation of the master element onto the physical triangles
or rectangles composing our mesh. 4.) Use this transformation to produce the shape functions we
need on this physical mesh. We first consider triangles then move to quadrilaterals. Although well
only discuss a few possible shape functions in each case, you should realize that a large number are
available.
First consider linear triangles. The master element in this case is the triangle T = {(s, t) : 0 s
1, 0 t (1 s)}. The nodes of T are denoted as follows: 1: (0,0), 2: (1,0), 3: (0,1). The linear
master element shape functions are
H1 (s, t) = 1 s t
H2 (s, t) = s
H3 (s, t) = t
Next, lets look at quadratic triangles, again using the triangle T as the master element. A quadratic
function of two variables has, in general, six coefficients so we need to select six nodes Nj , j = 1, . . . , 6
in T and to define six quadratic polynomials Hj (s, t) on T such that Hj (Nk ) = jk . The standard
approach is to select the vertices of T plus the midpoints of the sides of T as the six nodes, i.e.,
{Nj } = {(0, 0), (1, 0), (0, 1), (0.5, 0), (0.5, 0.5), (0, 0.5)}. You can easily check that the required shape
functions are:
H1 = (1 s t)(1 2s 2t),
H2 = s(2s 1),
H3 = t(2t 1),
H4 = 4s(1 s t).
H5 = 4st,
H6 = 4t(1 s t),
You will notice that each of these functions is the product of the equations for two lines such that
the two lines that define Hj pass through all nodes Nk , k 6= j. Once these lines are found, only the
normalization of the shape function has to be adjusted (so that Hj (Nj ) = 1).
Lets now construct the required mappings from the master triangle to the actual element triangle.
For linear triangles, we use the isoparametric map (now for 2D). Let an arbitrary triangle T be
defined by points (xk , yk ), k = 1, 2, 3, and construct the mappings x
, y : T T by
X
X
x=x
(s, t) =
xk Hk (s, t),
y = y(s, t) =
yk Hk (s, t).
k

Note that if H = [H1 , H2 , H3 ]T is the vector of element shape functions, these transformations can
be written in matrix form as

 
  
x
(s, t)
x1 x2 x3
x
H XH
=
=
y1 y2 y3
y(s, t)
y
The Jacobian matrix1 of this mapping is
J=

x
/s
y/s

x
/t
y/t

1
H H
,
]=X 1
= X[
s t
0

1 Please

1
0 .
1

be aware that the Jacobian matrix as defined in these notes is the transpose of the matrix which our text
calls the Jacobian matrix. I have used the standard definition which you will find in most mathematical work (e.g., see
Michael Spivak, Calculus on Manifolds, p.17). It is easy to translate from one notation to the other. If J is the Jacobian
as defined in the text, then J = J T , and the relation J = X[H/s, H/t] becomes J = [H/s, H/t]T X T .

Thus,
det(J) = (
x, y)/(s, t) = det

(x2 x1 )
(y2 y1 )

(x3 x1 )
(y3 y1 )

= 2AT ,

where AT is the area of the triangle. Recall that a nonzero Jacobian determinant means the mapping
is invertible. Of course, since the map is linear, lines are sent into lines, and it is easy to verify directly
that the boundary of the master element is mapped onto the boundary of T.
In the case of quadratic triangular elements, the physical triangles have six notes: the three vertices,
(xk , yk ), k = 1, 2, 3, as in the linear case, and the three midpoints (xk , yk ), k = 4, 5, 6 of the
sides (with node 4 on side 1,2, etc). As in the 1D case, we consider two possibilities: First, the
P6
isoparametric map (s, t) (
x(s, t), y(s, t)) (where, for example, x = x
(s, t) = k=1 xk Hk (s, t)).
This may be again expressed in matrix form as

  
 
x
x
(s, t)
x1 x6
H XH,
=
=
y1 y6
y
y(s, t)
where H = [H1 (s, t), , H6 (s, t)]T .
These are quadratic maps from the six noded master triangle to the corresponding 6 noded physical
triangle. You can verify that the boundary of the master triangle is again mapped onto the boundary
of the physical one. A second possibility is the subparametric map using the linear shape functions
as above. This map places the six nodes of the master triangle in such a way that the midpoints
of the master element sides are transformed to the midpoints of the physical triangle sides (e.g.
(s, t) = (0.5, 0) 0.5(x1 + x2 , y1 + y2 ) = (x4 , y4 )).
The shape functions on the physical triangles are defined as follows: Let (x, y) = (
x(s, t), y(s, t))
denote the map from the master triangle to the physical one. with inverse (s, t) = (
s(x, y), t(x, y)).
k (x, y) = Hk (
Then the shape functions on the physical triangle T are defined by H
s(x, y), t(x, y)).
k (
Actually, the more useful relation is the inverse of this one, H
x, y) = Hk (s, t).
The final consideration for triangles is that of integration. Well consider the integration problem
in detail shortly, in particular the relation between integration over master elements and physical
elements. At this point we simply note that we can map any triangle to the master triangle, so
ultimately we need only find formulas for integration over this triangle. Ignoring for the moment the
problem of what happens to the integral under the mapping process we consider only the evaluation
of integrals over the master element. As a simple example, consider the Gaussian quadrature formula
for integration of a linear function p(s, t) = a + bs + ct over the master element. Since there are three
parameters, we can look for a formula involving one point (s1 , t1 ) and one weight w1 . We have
Z
p(s, t) dsdt = a/2 + b/6 + c/6 = p(s1 , t1 )w1 = (a + bs1 + ct1 )w1 .
T

This leads to w1 = 1/2, s1 = t1 = 1/3. For quadrature formulas involving polynomials of higher
order see the text. Note however, that the weights listed in the table on page 173 are all twice what
they should be. (They should sum to the area of the master triangle (=1/2) not to 1.) Using these
points and weights we have the approximations
Z
X
f (s, t) ds dt
f (sj , tj )wj
T

which can be used to evaluate integrals over physical triangular elements.


After triangles, quadrilateral elements for which the master element is usually selected as the square
S = {(s, t) : 1 s, t 1} are probably the most widely used. The shape functions associated
with these elements are covered fairly thoroughly in the text, so I refer you to the presentation given
there.
5

Isoparametric Elements and Numerical Integration III


Lets consider the relation between the integral over the master element and its image physical
element. To keep things simple well only look at integration over an arbitrary quadrilateral, Q,
defined by corner points (xk , yk ), k = 1, . . . , 4. Other elements can be dealt with in a similar
manner. Using the isoparametric mappings we have just been discussing, Q can be mapped onto
the master element S = {(s, t) : 1 s, t 1} in a 1 to 1 way. Well denote the mapping functions
by (x, y) = (
x(s, t), y(s, t)) as above. Ill review briefly the relation between the integral over the
master element S and its image the physical element Q. Recall that if f : Q IR, then the integral
of f over Q is by definition
Z
Z
X
X
f (x, y) dxdy
f (xi , yj ) Aij
f (
x(si , tj ), y(si , tj )) Aij
f(s, t) det(J) dsdt,
Q

i,j

ij

where (xi , yi ) = (
x(si , ti ), y(si , ti )) and the relation between the area elements will be considered
next. The area element Aij in the transformed integral over the master rectangle is not simply
dsdt as it would be if the integration was originally over S, but must be adjusted appropriately if
the equality of the two sums above is to hold. In order to find the proper magnification, we need
to compare the areas of the small rectangular elements in S and Q. Let (s0 , t0 ) be a point of S
(corresponding to some fixed value of i, j in the expressions above) and consider the small rectangle
formed by the vectors
1 = (s0 + ds, t0 ) (s0 , t0 ),
2 = (s0 , t0 + dt) (s0 , t0 ).
The sides of this rectangle are mapped to
1 = (

x(s0 + ds, t0 ), y(s0 + ds, t0 )) (


x(s0 , t0 ), y(s0 , t0 )),
2 = (

x(s0 , t0 + dt), y(s0 , t0 + dt)) (


x(s0 , t0 ), y(s0 , t0 ))
Approximating the above differences using Taylors theorem gives
1 ( x

(s0 , t0 )/s, y(s0 , t0 )/s)ds


2 ( x

(s0 , t0 )/t, y(s0 , t0 )/t)dt,


The area of the master element rectangle is clearly dsdt = |1 2 |, and the area of the image
1
2 |. Substituting from
rectangle my be computed as the magnitude of the cross product |
above, we have
1
2 | = |det (
|
x, y)/(s, t) | ds dt,
where (
x, y)/(s, t) is the determinant of the Jacobian matrix2 evaluated at the point (s0 , t0 )


x
/s(s0 , t0 ) x
/t(s0 , t0 )
det (
x, y)/(s, t) = det
.
y/s(s0 , t0 ) y/t(s0 , t0 )
Thus, the ratio of the area elements is determined by the mapping, and we can write (setting
f(s, t) = f (
x(s, t), y(s, t)))
Z
Z
f (x, y) dx dy =
f(s, t)|(
x, y)/(s, t)| ds dt
Q

This formula reduces the integral over the quadrilateral to an integral over the master square, S.
Finally, the integral of any function F over S is approximated using the product quadrature rule
Z
ns X
nt
X
F (s, t) ds dt =
F (si , tj )wi wj
S

i=1 j=1

2 Since the determinant of a matrix has the same value as the determinant of its transpose, the same result holds
with our texts definition of the Jacobian.

where the points si (tj ) and weights wi (wj ) are the 1D Gauss Legendre quadrature points and
weights. Now we are ready to develop an m-file for quadrature over a quadrilateral Q.
function val=num_int(pts,fnc, nqp)
%---------------------------------------------------------------------------%
Gauss-Legendre quadrature of a function in 2-dimensions
%
% Problem description
%
Integrate f(x,y) (given by an m-file) over a quadrilateral, Q
%
% Inputs:
% pts = 4 by 2 matrix with (pts(i,1),pts(i,2)) the coordinates of the i-th
%
corner of Q
% fnc = name of m-file defining function to be integrated (must be in single quotes)
% nqp = two component vector (nqp1,nqp2) = number of quadrature points in each
%
each coordinate direction
%
%----------------------------------------------------------------------------%

[point2,weight2]=feglqd2(nqp(1),nqp(2));

% integration points and weights

value=0.0; jacob2=zeros(2,2); gg=zeros(1,2);


% call coordinates on master element (r,s)
for intr=1:nqp(1) % loop over points along r-axis
r=point2(intr,1);
wtr=weight2(intr,1);
for ints=1:nqp(2) % loop over points along s-axis
s=point2(ints,2);
wts=weight2(ints,2);
[shapeq4, dhdrq4, dhdsq4] = feisoq4(r,s); % compute shape functions at (r,s)
gg = shapeq4*pts; %image of (r,s) in Q (using bilinear shape functions)
func=feval(fnc, gg); % evaluate function at image of (r,s)
jacob2=fejacob2(4, dhdrq4, dhdsq4, pts(:,1), pts(:,2)); % Jacobian
value=value+func*abs(det(jacob2))*wtr*wts; % compute sum approximating integral
end
end

val=value;
%-----------------------------------------------------------------

function [jacob2]=fejacob2(nnel,dhdr,dhds,xcoord,ycoord)
%-----------------------------------------------------------------------% Purpose:
%
determine the Jacobian for two-dimensional mapping
%
7

% Synopsis:
%
[jacob2]=fejacob2(nnel,dhdr,dhds,xcoord,ycoord)
%
% Variable Description:
%
jacob2 - Jacobian for one-dimension
%
nnel - number of nodes per element
%
dhdr - derivative of shape functions w.r.t. natural coordinate r
%
dhds - derivative of shape functions w.r.t. natural coordinate s
%
xcoord - x axis coordinate values of nodes
%
ycoord - y axis coordinate values of nodes
%-----------------------------------------------------------------------jacob2=zeros(2,2);
for i=1:nnel
jacob2(1,1)=jacob2(1,1)+dhdr(i)*xcoord(i);
jacob2(1,2)=jacob2(1,2)+dhdr(i)*ycoord(i);
jacob2(2,1)=jacob2(2,1)+dhds(i)*xcoord(i);
jacob2(2,2)=jacob2(2,2)+dhds(i)*ycoord(i);
end

function [shapeq4,dhdrq4,dhdsq4]=feisoq4(rvalue,svalue)
%-----------------------------------------------------------------------% Purpose:
%
compute isoparametric four-node quadilateral shape functions
%
and their derivatves at the selected (integration) point
%
in terms of the natural coordinate
%
% Synopsis:
%
[shapeq4,dhdrq4,dhdsq4]=feisoq4(rvalue,svalue)
%
% Variable Description:
%
shapeq4 - shape functions for four-node element
%
dhdrq4 - derivatives of the shape functions w.r.t. r
%
dhdsq4 - derivatives of the shape functions w.r.t. s
%
rvalue - r coordinate value of the selected point
%
svalue - s coordinate value of the selected point
%
% Notes:
%
1st node at (-1,-1), 2nd node at (1,-1)
%
3rd node at (1,1), 4th node at (-1,1)
%-----------------------------------------------------------------------% shape functions
shapeq4(1)=0.25*(1-rvalue)*(1-svalue);
shapeq4(2)=0.25*(1+rvalue)*(1-svalue);
shapeq4(3)=0.25*(1+rvalue)*(1+svalue);
shapeq4(4)=0.25*(1-rvalue)*(1+svalue);

% derivatives
dhdrq4(1)=-0.25*(1-svalue);
dhdrq4(2)=0.25*(1-svalue);
dhdrq4(3)=0.25*(1+svalue);
dhdrq4(4)=-0.25*(1+svalue);
dhdsq4(1)=-0.25*(1-rvalue);
dhdsq4(2)=-0.25*(1+rvalue);
dhdsq4(3)=0.25*(1+rvalue);
dhdsq4(4)=0.25*(1-rvalue);

function [point1,weight1]=feglqd1(ngl)
%------------------------------------------------------------------% Purpose:
%
determine the integration points and weighting coefficients
%
of Gauss-Legendre quadrature for one-dimensional integration
%
% Synopsis:
%
[point1,weight1]=feglqd1(ngl)
%
% Variable Description:
%
ngl - number of integration points
%
point1 - vector containing integration points
%
weight1 - vector containing weighting coefficients
%------------------------------------------------------------------%

initialization
point1=zeros(ngl,1);
weight1=zeros(ngl,1);

find corresponding integration points and weights


if ngl==1
point1(1)=0.0;
weight1(1)=2.0;

% 1-point quadrature rule

elseif ngl==2
% 2-point quadrature rule
point1(1)=-0.577350269189626;
point1(2)=-point1(1);
weight1(1)=1.0;
weight1(2)=weight1(1);
elseif ngl==3
% 3-point quadrature rule
point1(1)=-0.774596669241483;
point1(2)=0.0;
point1(3)=-point1(1);

weight1(1)=0.555555555555556;
weight1(2)=0.888888888888889;
weight1(3)=weight1(1);
elseif ngl==4
% 4-point quadrature rule
point1(1)=-0.861136311594053;
point1(2)=-0.339981043584856;
point1(3)=-point1(2);
point1(4)=-point1(1);
weight1(1)=0.347854845137454;
weight1(2)=0.652145154862546;
weight1(3)=weight1(2);
weight1(4)=weight1(1);
else

% 5-point quadrature rule


point1(1)=-0.906179845938664;
point1(2)=-0.538469310105683;
point1(3)=0.0;
point1(4)=-point1(2);
point1(5)=-point1(1);
weight1(1)=0.236926885056189;
weight1(2)=0.478628670499366;
weight1(3)=0.568888888888889;
weight1(4)=weight1(2);
weight1(5)=weight1(1);

end

function [point2,weight2]=feglqd2(nglx,ngly)
%------------------------------------------------------------------% Purpose:
%
determine the integration points and weighting coefficients
%
of Gauss-Legendre quadrature for two-dimensional integration
%
% Synopsis:
%
[point2,weight2]=feglqd2(nglx,ngly)
%
% Variable Description:
%
nglx - number of integration points in the x-axis
%
ngly - number of integration points in the y-axis
%
point2 - vector containing integration points
%
weight2 - vector containing weighting coefficients
%------------------------------------------------------------------%

determine the largest one between nglx and ngly


if nglx > ngly
ngl=nglx;
else

10

ngl=ngly;
end
%

initialization
point2=zeros(ngl,2);
weight2=zeros(ngl,2);

find corresponding integration points and weights


[pointx,weightx]=feglqd1(nglx);
[pointy,weighty]=feglqd1(ngly);

% quadrature rule for x-axis


% quadrature rule for y-axis

quadrature for two-dimension


for intx=1:nglx
point2(intx,1)=pointx(intx);
weight2(intx,1)=weightx(intx);
end

% quadrature in x-axis

for inty=1:ngly
point2(inty,2)=pointy(inty);
weight2(inty,2)=weighty(inty);
end

% quadrature in y-axis

Note that this function calls several of the m-files supplied with the text: fejacob2.m, feisoq4.m,
R1R1
feglqd2.m and feglqd1.m. As a check on this routine, lets compute the integral 0 0 exp(x2
y 2 ) dxdy = erf(1)2 /4. Using 4 points in the unit square we obtain the Matlab output
>> val=num_int([0,0;0,1;1,1;1,0],tst_fnc,[4,4])
val =
0.5577
>> (pi/4)*erf(1)^2
ans =
0.5577
When we are computing element stiffness and load vectors, we need to compute integrals involving
shape functions. Of course, this can be done using the m-file just created, but the shape functions
have special transformation properties when we use an isoparametric mapping between S and Q.
Thus, it is worth developing special formulas for this case. In the case of element load vectors we
have the simple result
Z
Z
k (x, y) dx dy =
f (x, y)H
f(s, t)Hk (s, t)|(
x, y)/(s, t)| ds dt,
Q

k (
where we use the definition of the element shape functions, H
x, y) = Hk (s, t).
The stiffness function integrals involve the derivatives of the shape functions. We have already
considered the relation between the derivatives with respect to the physical coordinates and the
x, y) = H(s, t)
master element coordinates. As a reminder, we start from the basic relation H(

(where H and H are column vectors formed from the shape functions) and use the chain rule to
derive the relation

H
H H
H
,
]J = [
,
]
[
x y
s t
11

for example

x, y)
x
y
H

H
H(
H
H
H
=
=
+
=[
,
]J,1
s
s
x s
y s
x y

k /x
where J,1 is the first column of J. This matrix relation can be solved for the derivatives H

and Hk /y giving
H

H
H H 1
[
,
]=[
,
]J
x y
s t

H
H
and y
can therefore be computed
A typical stiffness integral involving the partial derivatives x
as follows: Calculate the derivatives of the master element shape functions with respect to s, t.

H
and
Compute the Jacobian matrix and then its inverse. Use the above equation to compute x

H
y as functions of s, t. Finally, substitute the results into the transformed integral over the master
element.

Lets write an m-file which can compute the integrals of the type just discussed, i.e.,
Iij =

Z
Q

where

i
H
x
i
H
y

j
H
x
j
H
y

a11 B
.
A B = ..
am1 B

!T

f (x, y) dxdy,

a1n B
..
.

amn B

is called the Kronecker product of the matricies A and B. Well use the bilinear shape functions
as in our previous effort. In fact, we need only make a few modifications of our previous file to get
what we want.

function [value]=stiff_int(i, j, fnc, pts, nqp)


%
% Purpose: Compute integral int_Q func kron(DH_i, DH_j) dxdy
% where: Q is a quadralateral defined by pts(k,l)
%
DH_k=[dH_k/dx; dH_k/dy];
%
kron(DH_i,DH_j) = [dh_i/dx dh_j/dx, dh_i/dx dh_j/dy;
%
dh_i/dy dh_j/dx, dh_i/dy dh_j/dy]
%
nqp(1), nqp(2) are the number of quadrature points in the coordinate directions
%
[point2,weight2]=feglqd2(nqp(1),nqp(2)); % integration points and weights
value=zeros(2,2); jacob2=zeros(2,2); gg=zeros(1,2);
Dhi=zeros(2,1); Dhj=zeros(2,1);
% call coordinates on master element (r,s)
for intr=1:nqp(1) % loop over r
r=point2(intr,1);
wtr=weight2(intr,1);
for ints=1:nqp(2) % loop over s
s=point2(ints,2);
wts=weight2(ints,2);
[shapeq4, dhdrq4, dhdsq4] = feisoq4(r,s); % compute shape functions at (r,s)
gg = shapeq4*pts; %image of (r,s) in Q (using bilinear shape functions)
func=feval(fnc, gg); % evaluate function at image of (r,s)
jacob2=fejacob2(4, dhdrq4, dhdsq4, pts(:,1), pts(:,2)); % Jacobian of transformation
12

invjacob2=inv(jacob2);
Dhi=invjacob2*[dhdrq4(i);dhdsq4(i)]; Dhj=invjacob2*[dhdrq4(j);dhdsq4(j)];
value=value+(func*abs(det(jacob2))*wtr*wts).*kron(Dhi,Dhj);
end
end

13

Das könnte Ihnen auch gefallen