me471s03_lec10

Upload: hasen-bebba

Post on 01-Jun-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 me471s03_lec10

    1/13

    Isoparametric Elements and Numerical Integration, I

    As we consider problems of a more sophisticated nature, it will become apparent that we need todevelop an efficient means of performing integrations over elements. For example, in 1D our textconsidered only constant coefficient and equidimensional ODEs because a general procedure of deal-ing 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 Laplaceequation problems, we assumed that the element sides were parallel to the coordinate axes. In thiscase, integration could easily be performed directly since the limits of integration for both the   xand  y  variables were constants. In a more general situation, we may have to deal with an elementin the form of an arbitrary quadrilateral having sides that are neither parallel nor parallel to thecoordinate axes. If we have many such elements in a problem, the programming difficulties will beconsiderable unless a simplifying procedure is developed.

    Perhaps more importantly, we have only considered a limited variety of element types: linear ele-ments in 1D and linear triangular, and bilinear rectangular elements in 2D. There are many moreelements that are useful in various problems. These elements use higher order polynomials to repre-

    sent the behavior of the trial solution within an element. In general, when we deal with these morecomplex 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 aninterval [a, b] on the real axis and a continuous function f   : [a, b] → R find an accurate numerical ap-proximation to I (a,b,f ) =

     ba

     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 courseso 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 ) =

       ba

    f (x) dx =

       1−1

    f (x̂(ξ ))dx̂

    dξ  dξ  =

     (b − a)2

       1−1

    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 thepractical viewpoint because we only need to develop formulas for an single interval (often called amaster interval in finite element literature). Second, the integral over any interval may always becomputed as a sum over many small intervals. Define the partition x0 = a < x1 < .. . < xn = b  anduse the additivity of the integral to write

    I (a,b,f ) =

    n

    e=1

    I (xe−1, xe, f ) = e

    1

    2(xe

    −xe−1)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 showsthat we only need be concerned about the behavior of the function  f  over a small interval in orderto approximate the value of   I (a,b,f ) for any   a   and   b. Third, if we select the interval [−1, 1] asour master interval, then you will remember that according to the definition of the definite integral:

    1

  • 8/9/2019 me471s03_lec10

    2/13

  • 8/9/2019 me471s03_lec10

    3/13

    indicated above, but in finite element method the interval [a, b] is usually an element, and for thisreason accuracy is controlled by keeping the element size small enough. The approach just describedof choosing both points and weights gives a series of quadrature formulas know as Gauss-Legendrerules. In general, a Gauss-Legendre formula with  n  points and weights can be used to integrate apolynomial of degree 2n − 1.Let’s 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 smallwe will be using a single interval quadrature rule (not a composite one). Usually, we will be usingGaussian quadrature since this requires fewer points, and therefore less computation for a givenaccuracy. The most efficient procedure is to do all the integrations on the same interval [-1,1] sincethen 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 elementinterval 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

    H 1(s) = (1 − s)/2,H 2(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) =  x1H 1(s) + x2H 2(s), i.e., it is constructed from the shape functions themselves. Thisis called an isoparametric mapping. Using this mapping to compute an element load vector (anddenoting the element shape functions by  H̄ k) would involve the integral   x2

    x1

    f (x) H̄ k(x) dx = (x2 − x1)

    2

       1−1

    f  ◦ x̂(s)H k(s) ds

    where we use the fact that  dx̂/ds = (x2 − x1)/2.As a second example, let’s look at quadratic elements. Note that a quadratic is defined by threecoefficients in 1D. Thus, a quadratic element will have three nodes – the two end points of theinterval and an interior point which is normally taken as the midpoint of the interval. Shifting tothe 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

    H 1(s) = −s(1− s)/2,H 2(s) = (1 − s)(1 + s)H 3(s) = s(1 + s)/2

    We can again use an isoparametric mapping   x   = x̃(s) = 

    k xkH k(s) to transform an arbitraryelement [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 theelement – for example, a cubic element will have two interior points in addition to the two intervalend points, e.g. −1,−1/3, 1/3, 1 for the master element. These nodes lead to shape functions suchas H 1(s) = (−9/16)(1/3− s)(1/3 + s)(1− s), etc.. Generally these elements are used less frequentlythen the lower order ones.

    Isoparametric Elements and Numerical Integration, II

    Now we are ready to tackle problems in higher dimensions (we’ll 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 trianglesor quadrilaterals has been created on the physical domain of interest. Since these physical elementsmay be oriented in arbitrary ways, we proceed using the following steps: 1.) Define a fixed triangle

    3

  • 8/9/2019 me471s03_lec10

    4/13

    or rectangle called a master element. 2.) Develop shape functions of various sorts on these masterelement. 3.) Define a mapping or transformation of the master element onto the physical trianglesor rectangles composing our mesh. 4.) Use this transformation to produce the shape functions weneed on this physical mesh. We first consider triangles then move to quadrilaterals. Although we’llonly discuss a few possible shape functions in each case, you should realize that a large number areavailable.

    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 linearmaster element shape functions are

    H 1(s, t) = 1 − s − tH 2(s, t) = sH 3(s, t) = t

    Next, let’s look at quadratic triangles, again using the triangle T  as the master element. A quadraticfunction of two variables has, in general, six coefficients so we need to select six nodes  N j , j  = 1, . . . , 6in T  and to define six quadratic polynomials  H j(s, t) on  T   such that  H j(N k) = δ jk . The standardapproach is to select the vertices of   T   plus the midpoints of the sides of  T  as the six nodes, i.e.,

    {N j}

    =

    {(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:H 1   = (1 − s − t)(1− 2s − 2t),H 2   = s(2s − 1),H 3   = t(2t − 1),H 4   = 4s(1 − s − t).H 5   = 4st,H 6   = 4t(1 − s − t),

    You will notice that each of these functions is the product of the equations for two lines such thatthe two lines that define  H j  pass through all nodes  N k, k = j.  Once these lines are found, only thenormalization of the shape function has to be adjusted (so that  H j(N j) = 1).

    Let’s 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̂,   ŷ :  T  →  T̄   byx = x̂(s, t) =

    k

    xkH k(s, t), y = ŷ(s, t) =k

    ykH k(s, t).

    Note that if  H  = [H 1, H 2, H 3]T  is the vector of element shape functions, these transformations canbe written in matrix form as

    xy

    =

    x̂(s, t)ŷ(s, t)

    =

    x1   x2   x3y1   y2   y3

    H  ≡ XH 

    The Jacobian matrix1 of this mapping is

    J  =

    ∂ ̂x/∂ s ∂  ̂x/∂t∂ ̂y/∂ s ∂  ̂y/∂t

    = X [ ∂H ∂s  ,  ∂H ∂t   ] =  X −

    1

      −1

    1 00 1

    .

    1Please be aware that the Jacobian matrix as defined in these notes is the   transpose  of the matrix which our textcalls the Jacobian matrix. I have used the standard definition which you will find in most mathematical work (e.g., seeMichael Spivak, Calculus on Manifolds , p.17). It is easy to translate from one notation to the other. If  J̃  is the Jacobianas 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 .

    4

  • 8/9/2019 me471s03_lec10

    5/13

    Thus,

    det(J ) =  ∂ (x̂, ŷ)/∂ (s, t) = det

    (x2 − x1) (x3 − x1)(y2 − y1) (y3 − y1)

    = 2AT̄ ,

    where AT̄  is the area of the triangle. Recall that a nonzero Jacobian determinant means the mappingis invertible. Of course, since the map is linear, lines are sent into lines, and it is easy to verify directlythat 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 thesides (with node 4 on side 1,2, etc). As in the 1D case, we consider two possibilities: First, the

    isoparametric map (s, t) →   (x̂(s, t), ŷ(s, t)) (where, for example,   x   = x̂(s, t) = 6k=1 xkH k(s, t)).This may be again expressed in matrix form as

    xy

    =

    x̂(s, t)ŷ(s, t)

    =

    x1   · · ·   x6y1   · · ·   y6

    H  ≡ XH,

    where H  = [H 1(s, t), · · · , H 6(s, t)]T .These are quadratic maps from the six noded master triangle to the corresponding 6 noded physicaltriangle. 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 functionsas above. This map places the six nodes of the master triangle in such a way that the midpointsof 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), ŷ(s, t))denote the map from the master triangle to the physical one. with inverse (s, t) = (ŝ(x, y), t̂(x, y)).Then the shape functions on the physical triangle  T̄  are defined by  H̄ k(x, y) =  H k(ŝ(x, y), t̂(x, y)).Actually, the more useful relation is the inverse of this one,  H̄ k(x̂, ŷ) =  H k(s, t).

    The final consideration for triangles is that of integration. We’ll consider the integration problemin detail shortly, in particular the relation between integration over master elements and physicalelements. At this point we simply note that we can map any triangle to the master triangle, soultimately we need only find formulas for integration over this triangle. Ignoring for the moment theproblem of what happens to the integral under the mapping process we consider only the evaluationof integrals over the master element. As a simple example, consider the Gaussian quadrature formulafor integration of a linear function p(s, t) =  a + bs+ ct over the master element. Since there are threeparameters, we can look for a formula involving one point (s1, t1) and one weight w1. We have 

     p(s, t) dsdt =  a/2 + b/6 + c/6 =  p(s1, t1)w1  = (a + bs1 + ct1)w1.

    This leads to  w1   = 1/2,  s1   =   t1   = 1/3. For quadrature formulas involving polynomials of higherorder see the text. Note however, that the weights listed in the table on page 173 are all twice whatthey should be. (They should sum to the area of the master triangle (=1/2) not to 1.) Using thesepoints and weights we have the approximations

     T 

    f (s, t) dsdt

    ≈jf (sj , tj)wj

    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 squareS   = {(s, t) : −1 ≤  s, t ≤  1}   are probably the most widely used. The shape functions associatedwith these elements are covered fairly thoroughly in the text, so I refer you to the presentation giventhere.

    5

  • 8/9/2019 me471s03_lec10

    6/13

    Isoparametric Elements and Numerical Integration III

    Let’s consider the relation between the integral over the master element and its image physicalelement. To keep things simple we’ll 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 similarmanner. Using the isoparametric mappings we have just been discussing,   Q   can be mapped ontothe master element  S  =

    {(s, t) :

    −1

    ≤s, t

    ≤1

    }  in a 1 to 1 way. We’ll denote the mapping functions

    by (x, y) = (x̂(s, t), ŷ(s, t)) as above. I’ll review briefly the relation between the integral over themaster element S  and its image the physical element  Q. Recall that if  f   : Q → IR, then the integralof  f   over Q  is by definition 

    Q

    f (x, y) dxdy ≈i,j

    f (xi, yj) ∆Aij ≈ij

    f (x̂(si, tj), ŷ(si, tj)) ∆ Âij ≈ S 

    f̂ (s, t) det(J ) dsdt,

    where (xi, yi) = (x̂(si, ti), ŷ(si, ti)) and the relation between the area elements will be considerednext. The area element ∆ Âij  in the transformed integral over the master rectangle is not simplydsdt  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 needto 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), ŷ(s0 + ds, t0)) − (x̂(s0, t0), ŷ(s0, t0)),∆̂2  = (x̂(s0, t0 + dt), ŷ(s0, t0 + dt)) − (x̂(s0, t0), ŷ(s0, t0))

    Approximating the above differences using Taylor’s 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 imagerectangle my be computed as the magnitude of the cross product

     |∆̂1 ×

     ∆̂2|. Substituting from

    above, we have|∆̂1 ×  ∆̂2| = |det ∂ (x̂, ŷ)/∂ (s, t) | ds dt,

    where ∂ (x̂, ŷ)/∂ (s, t) is the determinant of the Jacobian matrix2 evaluated at the point (s0, t0)

    det ∂ (x̂, ŷ)/∂ (s, t) = det

    ∂ ̂x/∂s(s0, t0)   ∂ ̂x/∂t(s0, t0)∂ ̂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), ŷ(s, t))) Q

    f (x, y) dxdy =

     S 

    f̂ (s, t)|∂ (x̂, ŷ)/∂ (s, t)| dsdt

    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 

    F (s, t) dsdt =

    nsi=1

    ntj=1

    F (si, tj)wiwj

    2Since the determinant of a matrix has the same value as the determinant of its transpose, the same result holdswith our text’s definition of the Jacobian.

    6

  • 8/9/2019 me471s03_lec10

    7/13

    where the points   si   (tj) and weights   wi   (wj) are the 1D Gauss Legendre quadrature points andweights. 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

  • 8/9/2019 me471s03_lec10

    8/13

    % 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);

    8

  • 8/9/2019 me471s03_lec10

    9/13

    % 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 % 1-point quadrature rule

    point1(1)=0.0;

    weight1(1)=2.0;

    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);

    9

  • 8/9/2019 me471s03_lec10

    10/13

    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

  • 8/9/2019 me471s03_lec10

    11/13

    ngl=ngly;

    end

    % initialization

    point2=zeros(ngl,2);

    weight2=zeros(ngl,2);

    % find corresponding integration points and weights

    [pointx,weightx]=feglqd1(nglx); % quadrature rule for x-axis

    [pointy,weighty]=feglqd1(ngly); % quadrature rule for y-axis

    % quadrature for two-dimension

    for intx=1:nglx % quadrature in x-axis

    point2(intx,1)=pointx(intx);

    weight2(intx,1)=weightx(intx);

    end

    for inty=1:ngly % quadrature in y-axis

    point2(inty,2)=pointy(inty);

    weight2(inty,2)=weighty(inty);

    end

    Note that this function calls several of the m-files supplied with the text:   fejacob2.m, feisoq4.m,

    feglqd2.m and  feglqd1.m. As a check on this routine, let’s compute the integral 10

     10

     exp(−x2 −y2) 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)̂ 2ans =

    0.5577

    When we are computing element stiffness and load vectors, we need to compute integrals involvingshape functions. Of course, this can be done using the m-file just created, but the shape functionshave 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 wehave the simple result 

    Q

    f (x, y) H̄ k(x, y) dxdy =

     S 

    f̂ (s, t)H k(s, t)|∂ (x̂, ŷ)/∂ (s, t)| dsdt,

    where we use the definition of the element shape functions,  H̄ k(x̂, ŷ) =  H k(s, t).

    The stiffness function integrals involve the derivatives of the shape functions. We have alreadyconsidered the relation between the derivatives with respect to the physical coordinates and themaster element coordinates. As a reminder, we start from the basic relation  H̄ (x̂, ŷ) =   H (s, t)(where  H̄   and  H   are column vectors formed from the shape functions) and use the chain rule toderive the relation

    [∂  H̄ 

    ∂x ,

     ∂  H̄ 

    ∂y ]J  = [

    ∂H 

    ∂s ,

     ∂H 

    ∂t  ]

    11

  • 8/9/2019 me471s03_lec10

    12/13

    for example∂H 

    ∂s  =

     ∂  H̄ (x̂, ŷ)

    ∂s  =

     ∂  H̄ 

    ∂x

    ∂ ̂x

    ∂s +

     ∂  H̄ 

    ∂y

    ∂ ̂y

    ∂s  = [

    ∂  H̄ 

    ∂x ,

     ∂  H̄ 

    ∂y ]J ∗,1

    where  J ∗,1   is the first column of  J.  This matrix relation can be solved for the derivatives  ∂  H̄ k/∂xand ∂  H̄ k/∂y  giving

    [∂  H̄ 

    ∂x  , ∂  H̄ 

    ∂y  ] = [∂H 

    ∂s  , ∂H 

    ∂t   ]J −1

    A typical stiffness integral involving the partial derivatives   ∂  H̄ ∂x

      and   ∂  H̄ ∂y

     can therefore be computedas follows: Calculate the derivatives of the master element shape functions with respect to   s, t.Compute the Jacobian matrix and then its inverse. Use the above equation to compute   ∂ 

     H̄ ∂x

      and∂  H̄ ∂y

     as functions of  s, t. Finally, substitute the results into the transformed integral over the masterelement.

    Let’s write an m-file which can compute the integrals of the type just discussed, i.e.,

    I ij  =

     Q

    ∂  H̄ i∂x∂  H̄ i∂y

    ∂  H̄ j∂x∂  H̄ j∂y

    T f (x, y) dxdy,

    where

    A ⊗ B = a11B   · · ·   a1nB... ...

    am1B   · · ·   amnB

    is called the Kronecker product of the matricies  A  and  B. We’ll use the bilinear shape functionsas in our previous effort. In fact, we need only make a few modifications of our previous file to getwhat 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 ss=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

  • 8/9/2019 me471s03_lec10

    13/13

    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