You are on page 1of 24

Galerkin nite element method

Boundary value problem Lu = f u=g


0

weighted residual formulation partial dierential equation Dirichlet boundary condition Neumann boundary condition Robin boundary condition

in on 0 on 1 on 2

n u = g1 n u + u = g 2

1. Multiply the residual of the PDE by a weighting function w vanishing on the Dirichlet boundary 0 and set the integral over equal to zero 2. Integrate by parts using the Neumann and Robin boundary conditions 3. Represent the approximate solution uh u as a linear combination of polynomial basis functions i dened on a given mesh (triangulation) 4. Substitute the functions uh and i for u and w in the weak formulation 5. Solve the resulting algebraic system for the vector of nodal values ui

Construction of 1D nite elements


1. Linear nite elements Consider the barycentric coordinates 1 (x) = x2 x , x2 x1 2 (x) = x x1 x2 x1

dened on the element e = [x1 , x2 ] i P1 (e), i (xj ) = ij ,


d1 dx

i = 1, 2 i, j = 1, 2 x e

1 (x) + 2 (x) = 1, =
1 x2 x1

2 d dx

constant derivatives 2 |e = 2 x e

Basis functions

1 |e = 1 ,

uh (x) = u1 1 (x) + u2 2 (x),

Construction of 1D nite elements


2. Quadratic nite elements {1 (x), 2 (x)} x1 = {1, 0}, x12 =
x1 +x2 2

barycentric coordinates x2 = {0, 1} endpoints


1 1 = {2 , 2}

midpoint

Basis functions

1 , 2 , 12 P2 (e)

1 (x) = 1 (x)(21 (x) 1) 2 (x) = 2 (x)(22 (x) 1) 12 (x) = 41 (x)2 (x) Shape function uh |e uh (x) = u1 1 (x) + u2 2 (x) + u12 12 (x)

Construction of 1D nite elements


3. Cubic nite elements

{1 (x), 2 (x)} x1 = {1, 0}, x2 = {0, 1}, Basis functions

barycentric coordinates x12 = x21 =


2x1 +x2 3 x1 +2x2 3 2 1 = {3 , 3} 1 2 = {3 , 3}

1 , 2 , 12 , 21 P3 (e)

1 1 (x) = 2 1 (x)(31 (x) 2)(31 (x) 1)

2 (x) = 1 2 2 (x)(32 (x) 2)(32 (x) 1) 12 (x) = 9 2 1 (x)2 (x)(31 (x) 1) 21 (x) = 9 2 1 (x)2 (x)(32 (x) 1) Shape function

uh (x) = u1 1 (x) + u2 2 (x) + u12 12 (x) + u21 21 (x)

Construction of triangular nite elements


Let x = (x, y ) = {1 (x), 2 (x), 3 (x)} Construct 2D barycentric coordinates i P1 (e), i (xj ) = ij , i, j = 1, 2, 3


i1 i2 i3

Polynomial tting: i (x) = ci1 + ci2 x + ci3 y ( x ) = c + c x + c y = i 1 i 1 i 2 1 i 3 1 i 1 c 1 x y i1 1 1 1 x2 y2 ci2 = i (x2 ) = ci1 + ci2 x2 + ci3 y2 = i2 ci3 1 x3 y3 i (x3 ) = ci1 + ci2 x3 + ci3 y3 = i3
A

We have 3 systems of 3 equations for 9 unknowns. They can be solved for the unknown coecients cij by resorting to Cramers rule. det A = x2 y3 + x1 y2 + x3 y1 x2 y1 x3 y2 x1 y3 Area of the triangle |e| = 1 2 | det A| (also needed for quadrature rules)

Construction of triangular nite elements


Connect the point x to the vertices to construct the barycentric splitting Areas of the triangles 1 x y A1 = 1 x2 y2 , 1 x3 y3 xi , e=
i=1

i = 1, 2, 3
3

ei

|ei (x)| = 1 x1 y1 A2 = 1 x y , 1 x3 y3 i (x) =

1 2 | det Ai (x)|

1 x1 y1 A3 = 1 x2 y2 1 x y =
det Ai (x) det A

Solution of the linear systems:

|ei (x)| |e |

i = 1, 2, 3

It is obvious that the barycentric coordinates satisfy |e1 (x)| + |e2 (x)| + |e3 (x)| = |e|, x e

i (xj ) = ij 1 (x) + 2 (x) + 3 (x) 1


A similar interpretation is possible in one dimension:

Construction of triangular nite elements


Nodal barycentric coordinates x1 = {1, 0, 0},
1 , x12 = { 1 2 2 , 0}, 1 1 x123 = { 1 3, 3, 3}

x2 = {0, 1, 0},

x3 = {0, 0, 1}
1 1 x23 = {0, 2 , 2}

1 x13 = { 1 , 0 , 2 2 },

1. Linear elements vertex-oriented midpoint-oriented 2. Quadratic elements

uh (x) = c1 + c2 x + c3 y P1 (e) 1 = 1 , 2 = 2 , 3 = 3 (standard) 23 = 1 21 12 = 1 23 , 13 = 1 22 ,

uh (x) = c1 + c2 x + c3 y + c4 x2 + c5 xy + c6 y 2 P2 (e)
+ basis (7 nodes) Extended P2

Standard P2 basis (6 nodes) 1 = 1 (21 1), 12 = 41 2 13 = 41 3 23 = 42 3

3 = 3 (23 1),

2 = 2 (22 1),

123 = 271 2 3 ,

ij = 4i j 121 2 3

i = i (2i 1) + 31 2 3 i, j = 1, 2, 3

Construction of tetrahedral nite elements


Let x = (x, y, z ) = {1 (x), 2 (x), 3 (x), 4 (x)} Construct i P1 (e) : i (xj ) = ij , i, j = 1, . . . , 4

Polynomial tting: 1 1 1 1 x1 x2 x3 x4 y1 y2 y3 y4

i (x) = ci1 + ci2 x + ci3 y + ci4 z

i1 ci1 z1 z2 ci2 = i2 z3 ci3 i3 i4 ci4 z4

Barycentric splitting i (x) = |ei (x)| , |e|

e=
i=1

ei

i = 1, . . . , 4

1. Linear elements vertex-oriented face-oriented

uh (x) = c1 + c2 x + c3 y + c4 z P1 (e) 1 = 1 , 2 = 2 , 3 = 3 , 4 = 4 (standard)


xi +xj +xk 3

134 = 1 32 ,

123 = 1 34 ,

234 = 1 31

124 = 1 33

xijk =

2. Higher-order approximations are possible but rather expensive in 3D

Coordinate and element transformations


Idea: dene the basis functions on a geometrically simple reference element

Linear mapping in Rn

Fe : e e

Coordinate and element transformations


Mapping of the reference element e onto an element e with vertices xi
n+1

Fe :

e = Fe ( e)

x = Fe ( x) =
i=1

xi i ( x),

x e

where i are the barycentric coordinates. This mapping is of the form + be , Fe ( x) = Be x Be Rnn , be Rn

It is applicable to arbitrary simplex elements with straight sides n=1 n=2 Be = x2 x1 , Be = be = x1 , be = x1 y1 x1 be = y1 z1

x2 x1 x3 x1 y2 y1 y3 y1

n=3

x2 x1 x3 x1 x4 x1 Be = y2 y1 y3 y1 y4 y1 , z2 z1 z3 z1 z4 z1

Coordinate and element transformations


Properties of the linear mapping vertices are mapped onto vertices xij =
xi +xj 2

+ be Fe ( x) = Be x xi = Fe ( xi )

midpoints of sides are mapped onto midpoints of sides = Fe


i + x xj 2

= Fe ( xij )

barycenters are mapped onto barycenters xijk =


xi +xj +xk 3

= Fe

i + x xj + xk 3

= Fe ( xijk )

The values of i on the physical element e are dened by the formula


1 (x)), i (x) = i (Fe

x e

i (x) = i ( x),

x = Fe ( x)

Note that i (xj ) = i ( xj ) = ij and the degree of basis functions (linear, quadratic, cubic etc.) is preserved since x depends linearly on x

Coordinate and element transformations


Derivative transformations Chain rule i = J i i (x) = i ( x), x e, e x

where J is the Jacobian of the (inverse)

mapping as introduced before in the context of the nite dierence method


i x i y

= =

1 det J 1 det J

i y x y i x y x

i y y x i x x y

J =

x x x y

y x y y

must be nonsingular for Fe to be invertible

Isoparametric mappings: it is possible to dene curved elements e using a mapping Fe of the same degree as the basis functions on the reference element e
+ Example. Extended quadratic element P2

e = Fe ( e) x = Fe ( x) =

i xi , x
i=1 3 P

ij xij , x P
ij

123 x123 x

xi i ( x) +

xij ij ( x) + x123 123 ( x)

Construction of quadrilateral nite elements


Idea: construct 2D basis functions as a tensor product of 1D ones dened on e 1. Bilinear nite elements Let 1 (t) = 1 t, 2 (t) = t, t [0, 1]

1 ( x) = 1 ( x)1 ( y ), 2 ( x) = 2 ( x)1 ( y ),

3 ( x) = 2 ( x)2 ( y) 4 ( x) = 1 ( x)2 ( y)

The space Q1 ( e) spanned by i consists of functions which are P1 for each variable In general
kn 1 k2 Qk ( e) = span{xk 1 x2 . . . xn }, 4

0 ki k,

i = 1, . . . , n

Isoparametric mapping

x = Fe ( x) =
i=1

xi i ( x),

1 (x)) i (x) = i (Fe

The physical element e = Fe ( e) is a quadrilateral with straight sides which must be convex for Fe to be invertible. It is easy to verify that Fe ( xi ) = xi , i = 1, . . . , 4

Construction of quadrilateral nite elements


2. Nonconforming rotated bilinear elements Let 1 ( Q e) = span{1, x , y , x 2 y 2 }
2 2 4

(Rannacher and Turek, 1992)


y 1 4 x 0 e 1 x 1 2 x x Fe x4 e x1 0 x 3 x y x3 x2

uh (x) = c1 + c2 x + c3 y + c4 ( x y ) x = Fe ( x) =
i=1

i xi

bilinear mapping
1 |Si | Si

Degrees of freedom: ui =

uh (x(s)) ds uh (xi )
4

edge mean values


4

Edge-oriented basis functions: u = [u1 , u2 , u3 , u4 ]T , c = [c1 , c2 , c3 , c4 ]T , Coecients: Ac = u

uh (x) =
j =1

uj j ( x) =
j =1

j ( cj x), x e
j

= [ 1 , 2 , 3 , 4 ]T , = [1, x , y , x 2 y 2 ]T , T c = T A1 u = T u

ui = aij =

aij cj
Si

1 |Si |

j ( x)ds

T A1 T =

Construction of quadrilateral nite elements


Midpoint rule: a Q 1 j ( aij xi ), ui uh (xi ) b Q 1 exact for linear functions

{edge mean values} 1 1 1 2 0 3 2 1 1 1 2 3 A= 1 1 1 2 2 3 1 1 0 1 3 2


3 4 3 +2 x 5 3 x2 y 2 ) 2y 2 (

{edge midpoint values} 1 1 1 2 0 4 3 1 1 1 2 4 A= 1 1 1 3 2 4 1 1 0 1 4 2


3 4

1 ( x) =

1 ( x) =

3 1 +3 1 2 ( x2 y 2 ) 3 ( x) = 4 2x 2y

3 1 2 ( x) = 4 1 + 3 + 2 ( x2 y 2 ) 2x 2y 3 4 5 2 x + 3 + 3 x2 y 2 ) 2y 2 (

1 2 ( x) = 4 +y + ( x2 y 2 )

+x 2 y ( x2 y 2 )

4 ( x) =

4 ( x) =

1 +x ( x2 y 2 ) 3 ( x) = 4 3 4

2 x+y + ( x2 y 2 )

Nonparametric version: construct the basis functions directly using a local coordinate system rather than the transformation to a reference element

Construction of quadrilateral nite elements


3. Biquadratic nite elements 1 (t) = (1 t)(1 2t), 1 ( x) = 1 ( x)1 ( y ), 2 ( x) = 2 ( x)1 ( y ), 3 ( x) = 2 ( x)2 ( y ), 2 (t) = t(1 2t), 3 (t) = 4t(1 t), t [0, 1]

Products of 1D quadratic basis functions spanning the space Q2 ( e) 4 ( x) = 1 ( x)2 ( y ), 5 ( x) = 3 ( x)1 ( y ), 6 ( x) = 2 ( x)3 ( y ), 7 ( x) = 3 ( x)2 ( y) 8 ( x) = 1 ( x)3 ( y) 9 ( x) = 3 ( x)3 ( y) x e

Basis functions on the physical element

1 (x)), i (x) = i (Fe

Mapping: subparametric (bilinear) or isoparametric

x = Fe ( x) =
i=1

xi i ( x)

e = Fe ( e) is curved

Construction of hexahedral nite elements


1. Trilinear nite elements 1 (t) = 1 t, 2 (t) = t, t [0, 1]

Products of 1D linear basis functions spanning the space Q1 ( e) 1 ( x) = 1 ( x)1 ( y )1 ( z ), 2 ( x) = 2 ( x)1 ( y )1 ( z ), 3 ( x) = 2 ( x)2 ( y )1 ( z ), 4 ( x) = 1 ( x)2 ( y )1 ( z ), Basis functions on the physical element

5 ( x) = 1 ( x)1 ( y )2 ( z) 6 ( x) = 2 ( x)1 ( y )2 ( z) 7 ( x) = 2 ( x)2 ( y )2 ( z) 8 ( x) = 1 ( x)2 ( y )2 ( z)


1 (x)), i (x) = i (Fe

x e

Isoparametric mapping
8

x = Fe ( x) =
i=1

xi i ( x)

2. Rotated trilinear elements (6 nodes, face-oriented degrees of freedom)

Finite element matrix assembly


Example: 1D Poisson equation d2 u = f in (0, 1) dx2 u(0) = 0, du (1) = 0
dx

Galerkin discretization: u0 = 0,

uh =
j =1 1

u j j

(linear nite elements)


1

uj
j =1 0

di dj dx = dx dx

f i dx,
0

i = 1, . . . , N ek = [xk1 , xk ]

Decomposition of integrals into element contributions


ak ij N N
k Fi

Au = F,
j =1

uj
k=1 ek

di dj dx = dx dx
aij

f i dx,
k=1 ek Fi

i = 1, . . . , N

Example: 1D Poisson equation / linear elements


Idea: evaluate element contributions and insert them into the global matrix
N

aij =
k=1 N

ak ij =

1 di dj 0 dx dx 1 0

dx

ak ij = 0 only for i, j {k 1, k } Fik = 0 only for i {k 1, k }

Fi =
k=1

Fik =

f i dx

Element stiness matrix and load vector ek = [xk1 , xk ] dk1 dk1 dk1 dk dx dx dx dx dx dx ek ek k a = , fk = dk dk dk dk1 dx dx dx ek dx dx ek dx Coecients of the global system Au = F ak1 k1 ak1 k A= ak k1 ak k

ek

f k1 dx f k dx

ek

which are to be augmented Fk 1 , F = Fk

Example: 1D Poisson equation / linear elements


Special case: k1 (x) = k (x) = 3 elements,
xk x xk xk1 1 x = 3 , dk1 dx dk dx

f 1
1 = x

kxx x ,

xxk1 xk xk1

x(k1)x , x

1 x 1 x

x ek = [xk1 , xk ]

Hence,

ak =

1 1 1 1

fk =

x 2

1 1

Assembly of the global stiness matrix and load vector 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 A= + + x x x 0 0 1 1 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 2 1 0 x 1 x 2 x 1 x 0 1 1 , F = = + + A= x 2 2 2 2 2 0 1 2 1 0 1 1 0 0 1 1 1 0 0 1

Example: 1D Poisson equation / linear elements


Recall that u0 = 0 so the rst equation drops out and the system shrinks to 5 1 2 1 0 u 1 u1 = 2 (x)2 , u2 = 4(x)2 1 1 2 1 u2 = 1 2 1 2 (x) 1 u3 = 9 x = 3 0 1 1 u3 2 (x) ,
2

Implementation of Dirichlet boundary conditions 1. Row/column elimination: u0 = g0 whereas the second one turns into the rst equation is superuous a11 u1 + a12 u2 + a13 u3 = F1 a10 g0 F0 := g0

2. Row modication (replacement by a row of the identity matrix) a00 := 1, a0j := 0, j = 1, 2, 3,

3. Penalty method / addition of a large number to the diagonal a00 := a00 + , F0 := F0 + g0 symmetry is preserved

Implementation of Neumann boundary conditions


du dx (1)

= g1

FN =

eN

f N dx + g1

a surface integral is added

Example: 1D Poisson equation / quadratic elements


N N

Galerkin FEM:
j =1/2

uj
k=1

ek

di dj dx dx

dx =
k=1

ek

f i dx,

i = 1, . . . , N

ek = [xk1 , xk ],

x = {1 (x), 2 (x)}
dk1 41 1 = dx x dk1/2 2 1 = 4 dx x dk 1 2 dx = 4 x

k = 2 (22 1), k1/2 = 41 2 ,

k1 = 1 (21 1),

Element stiness matrix and load vector


dk1 dk1 dx dx dx ek 6 R dk1/2 dk1 6 dx dx dx 4 ek R dk dk1 dx dx ek dx

ak =

2 R

dk1 dk1/2 dx dx dx ek R dk1/2 dk1/2 dx dx dx ek R dk dk1/2 dx dx ek dx

3 dk1 dk dx dx dx ek 7 R dk1/2 dk dx 7 dx dx 5 ek R dk dk dx ek dx dx R

1 3x

3 7 8 1 4 8 16 8 5 1 8 7

f dx k 1 ek k f = ek f k1/2 dx = f k dx ek

x 6

1 4 1

Global system: Au = F, where u = [u1/2 u1 u3/2 . . . uN 1/2 uN ]T

Numerical integration for nite elements


Change of variables theorem
e 1 i (x) = i (Fe (x)),

f (x) dx =
e

( f x)| det J | dx i i = J 1

x e

i = J i

For instance, the entries of the element stiness matrix are given by aij =
e

i j d x =

j )| det J | dx i ) (J 1 (J 1
n

Numerical integration
e

g ( x) dx

w i g ( xi ),
i=0

( g ( x) = f x)| det J |

Newton-Cotes formulae can be used but Gaussian quadrature is preferable: g ( x) dx e


g ( x1 )+ g ( x2 ) , 2

x 1 =

1 2

1 6

3,

x 2 =

1 2

1 6

3,

e = [0, 1]

exact for g P3 ( e) as compared to P1 ( e) for the trapezoidal rule

Storage of sparse matrices


Banded matrices: store the nonzero diagonals as 1D arrays Arbitrary matrices: store the nonzero elements as a 1D array 1. Coordinate storage
A(NNZ) IROW(NNZ) ICOL(NNZ)

(inconvenient access)

nonzero elements in arbitrary order auxiliary array of row numbers auxiliary array of column numbers

2. Compact storage
A(NNZ) ILD(N+1) ICOL(NNZ)

(convenient access)

nonzero elements stored row-by-row pointers to the beginning of each row auxiliary array of column numbers

Example

1 2 A= 0 7

2 4 3 0

0 3 6 5

7 0 5 8

A = (1, 2, 7, 4, 2, 3, 6, 3, 5, 8, 7, 5) ICOL = (1, 2, 4, 2, 1, 3, 3, 2, 4, 4, 1, 3) IROW = (1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4) NNZ = 12, ILD = (1, 4, 7, 10, 13)

You might also like