21_oktober_2010

Embed Size (px)

Citation preview

  • 8/10/2019 21_oktober_2010

    1/23

  • 8/10/2019 21_oktober_2010

    2/23

    The Finite Element Method

    Contents:

    - Introduction. History. Simple1D Example.

    - Weak Derivatives. Sobolev spaces. Weak formulation.

    - Finite Element method. Mesh. Stiffness Matrix.

    - Example: Simple boundary value problem in2D.

    - Summary. Course Contents MAI0088.

    Typeset by FoilTEX 2

  • 8/10/2019 21_oktober_2010

    3/23

    The Finite Element Method (FEM)

    - A general purpose technique for solving boundary value problems for elliptic

    PDEs in complicated domains.

    - Mostly developed by engineers 19551965 (Ray W. Clough, John Argyris,. . . )but building on earlier work by Courant, Rayleigh, Ritz, and Galerkin.

    - Rigurous mathematical analysis in Strang and Fix, An Analysis of The FiniteElement Method, 1973.

    Typeset by FoilTEX 3

  • 8/10/2019 21_oktober_2010

    4/23

    The Finite Element Method

    Example:Find usuch that

    u + 2u= 1, x(0, 1),u(0) = 1, and, u(1) = 1. (1)

    Solution:Multiply by a test functionand integrate,

    10

    (u + 2u)vdx = 1

    01 vdx.

    Integrate by parts

    10

    (uv +2uv)dx=u(1)v(1)u(0)v(0)+ 1

    0(uv+2uv)dx=

    10

    vdx.

    Restrict test functions to V ={vC1(0, 1) such that v(0) = 0}.

    Typeset by FoilTEX 4

  • 8/10/2019 21_oktober_2010

    5/23

    We obtain a new problem: Find usuch that

    10

    (uv + 2uv)dx=

    10

    vdx + 1 v(1) for allvV. (2)

    Remarks:

    - The problems are equivalent in the sense that any solution u C2(0, 1) of

    (2) also satisfies (1) except possibly the boundary value u(0) = 1. Also (2) iscalled the weak formof (1).

    - We have a(u, v) =< , v > for all vV, where a(, )is a bilinear operatorand< , >is a linear functional.

    - The condition u(0) = 1is called anessentialboundary condition and u(1) = 1is a naturalboundary condition.

    Typeset by FoilTEX 5

  • 8/10/2019 21_oktober_2010

    6/23

    Introduce a grid Sh={xi}Ni=0and a space Vh={v(x) piecewise linear on Sh}.

    The discetizedproblem is: Find uhVh such that

    a(uh, v) =< , v > for all vVh such thatv(0) = 0,uh(0) = 1.

    Remarks:

    - The solution uhVh is called the finite element solution.

    - Theessentialboundary conditionu(0) = 1appear explicitly in the formulationof the problem.

    - The naturalboundary condition u(1) = 1 is included in the definition of thefunctional< , >.

    Typeset by FoilTEX 6

  • 8/10/2019 21_oktober_2010

    7/23

    A basisforVh is

    x0 x1 x2 xN

    1 xN

    0 1 2 N1N

    i(x) =

    1, x=xi,0, x=xj, j =i.

    The finite element solution can be written as a linear combination

    uh(x) =

    Ni=0

    cii(x).

    Remark:The boundary value uh(0)= c00(0)=1gives us an equation for c0.

    Typeset by FoilTEX 7

  • 8/10/2019 21_oktober_2010

    8/23

    The relation a(uh, v) =< , v >, for v = j, gives us a system of linearequations,

    N

    i=0

    cia(i, j) =< , j >, j = 1, 2 . . . , N .

    or

    1 0 . . . 0a(0, 1) . . . a(N, 1)

    ... ...a(0, N) . . . a(N, N)

    c0c1

    ...cN

    =

    1< , 1>

    ...< , N >

    RemarkThis is a system Kc=f where K is the stiffness matrixandf is the

    load vector.

    Typeset by FoilTEX 8

  • 8/10/2019 21_oktober_2010

    9/23

    Elements are easy to compute

    a(i, i+1) =

    10

    (i

    i+1+2ii+1)dx=

    h0

    {1

    h

    1

    h+2(1

    x

    h)

    x

    h}dx=

    1

    h+

    h

    6.

    xi xi+1

    i i+1

    h

    Remark:Ki,j = 0unlessxi andxj are neighbours since othervise ij 0.

    So typically the matrix K is sparse.

    Exercise: Compute Ki,i = a(i, i) and fi =< , i >. Since i are simplepolynomials its easy to do this numerically.

    Typeset by FoilTEX 9

  • 8/10/2019 21_oktober_2010

    10/23

    Matlab and Comsol example

    Find usuch that

    u + 2u= 1, x(0, 1),u(0) = 1, and, u(1) = 1.

    (3)

    Use Comsol Multiphysics to: (module add comsol and comsol matlab onLinux).

    Create the computational grid{xi}.

    Speficy the equation and boundary conditions.

    Assemble the stiffness matrix and load vector.

    Solve the problem and visualize the result.

    Typeset by FoilTEX 10

  • 8/10/2019 21_oktober_2010

    11/23

  • 8/10/2019 21_oktober_2010

    12/23

    Weak Derivatives and Sobolev Spaces

    Definition:LetuL2()and suppose u L2()satisfies

    (v, ) =(u, x), for allC

    0 ().

    Thenv is theweak derivativeofu.

    Example: = (1, 1)andu= 1 |x|.

    (u, x) =

    Z 11

    uxdx=

    Z 01

    uxdx+

    Z 10

    uxdx=

    [u]01Z 01uxdx+[u]10

    Z 10uxdx=

    Z 01

    (+1)dx

    Z 10

    (1)dx= (v, )

    u(x)

    +1

    1

    v(x)

    Typeset by FoilTEX 12

  • 8/10/2019 21_oktober_2010

    13/23

    Definition:The Sobolev spaceH1() is the set of functions uL2() thathave weak derivatives in L2().

    Remarks:

    - The set H1()consists of piecewise differentiable and continous functions.

    - The space H1() is a Hilbert spacewith scalar product (u, v)1 and norm

    u1= (u, u)1/21 .

    - Higher order Sobolev spacesHm()can be defined similarily.

    Example:Suppose R2 then

    (u, v)1=

    uvd +

    uxvxd +

    uyvyd.

    Typeset by FoilTEX 13

  • 8/10/2019 21_oktober_2010

    14/23

    Weak formulationExample:Find uC2()such that

    u=f, in,u=g, onD,u

    n =h, onN, D

    N

    Introduce V = {v H1() andv = 0 onD}. Take a test function v V

    and write

    vf d =

    vud =

    v ud +

    N

    u

    nvd +

    D

    u

    nvd =

    v ud +

    N

    hvd.

    Typeset by FoilTEX 14

  • 8/10/2019 21_oktober_2010

    15/23

    The weak formulation is: Find u H1()such that

    v ud =

    f vd +

    N

    hvd, for allvV

    u=g, onD.

    (4)

    Remarks

    - Can introduce a bilinear operatora(u, v)and a linear functional < , v >.

    - The next step is to pick a finite dimensional subspace Sh H1() and

    discretize the problem (4).

    Typeset by FoilTEX 15

  • 8/10/2019 21_oktober_2010

    16/23

  • 8/10/2019 21_oktober_2010

    17/23

    Example:

    N1

    N2 N3 N4

    N5

    N6N7

    N8

    N9T1

    T2

    T3

    T4

    T5

    T6T7

    T8T9

    Data structures needed:

    - A2NmatrixNodes, a3MmatrixTriangles, and a2KmatrixEdges.

    Here we have Triangles(:,3)= (7 ,8 ,9)T

    .

    - Is a node Nk subject to a Dirichlet boundary condition? Is an edge Eksubjectto a Neumann boundary condition?

    Typeset by FoilTEX 17

  • 8/10/2019 21_oktober_2010

    18/23

    Linear basis functions

    Introduce a spaceVhH1()of piecewise linear functions on a given mesh Th.

    For each node Nk we obtain a basis function k. The functions k are uniqelydetermined by k(xk, yk) = 1, k(xj, yj) = 0 for k = j, and k is linear oneach triangle Ti.

    Example:

    N1

    N2 N3 N4

    N5

    N6N7

    N8

    N9T1

    T2

    T3

    T4

    T5

    T6T7

    T8T9

    The basis function 8 is non-zero on the triangles T3, T4, T5, T6, and T7.

    Typeset by FoilTEX 18

  • 8/10/2019 21_oktober_2010

    19/23

    Assembly of Stiffness matrix and load vector

    The discretized problem is: Find uhVh such that

    a(uh, j) =Ni=1

    cia(i, j) =< , j >, for allj such that j = 0 onD,

    and,

    uh(xj, yj) =g(xj, yj), for nodes Nj = (xj, yj)T onD.

    Remarks:

    - Most elements Ki,j are integrals a(j, i). How to compute them?

    - The linear system Kc=fis (very) sparse.

    Typeset by FoilTEX 19

  • 8/10/2019 21_oktober_2010

    20/23

    Note that

    a(i, j) =

    i jd =Tk

    Tk

    i jd.

    and only3basis functions are non-zero on each triangle Tk.

    K=sparse(N,N), f=zeros(N,1)

    fork= 1 :M

    [N1,N2,N3]=Triangles(:,k);Compute9local contributions ( KN1,N1=a

    (Tk)(N1, N1),. . . )

    Compute3local contributions to < , j >(that isTk

    f N1d,. . . ).

    end

    This is an Element orientedalgorithm. Have to fix rows corresponding to nodessubject to Dirichlet conditions and need a loop over all the Edges subject to aNeumann conditions to get final Kc=f.

    Typeset by FoilTEX 20

  • 8/10/2019 21_oktober_2010

    21/23

    Comsol Multiphysics 2D Example

    u= 0

    n u= 0

    n

    u= 0

    u= 0

    u= 10

    Typeset by FoilTEX 21

  • 8/10/2019 21_oktober_2010

    22/23

    SummaryThe Finite Element Method compared to Finite Differences

    - A general purpose technique for solving (elliptic) PDEs in complex domains.

    - Relatively easy to make good software that can handle many different types ofequations and domains.

    - The linear system Kc= fis sparse but usually not very structured. Have touse standard sparse linear equation solvers. Less efficient preconditioners.

    - Assuming the mesh is of good quality error estimates are similar for Finite

    Elements and Finite Differences.

    - Can use different types of basis functions, e.g.j C1(), without changing

    the codes very much.

    Typeset by FoilTEX 22

  • 8/10/2019 21_oktober_2010

    23/23

    MAI0088 Applied Functional Analysis and FEM

    Course contents:

    mathematical concepts: weak derivative, weak form of a boundary value

    problem, and Sobolev spaces.

    Use tools from functional analysis to analyze the finite element method:Existance and Uniqueness. Various error estimates.

    Implement the core of a realistic finite element solver. Try a commercialsoftware package.

    Computational Techniques: Sparse linear equation solvers. Preconditioning.Multigrid solvers.

    Course literature:Braess, Finite elements, Cambridge University press.

    Typeset by FoilTEX 23