• No results found

u + u = x 0 < x < 1 u(0) = 0 u(1) = 0

N/A
N/A
Protected

Academic year: 2022

Share "u + u = x 0 < x < 1 u(0) = 0 u(1) = 0"

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

ENERGY 281

Spring Quarter 2007-08

Le ture 11 Notes

Thesenoteswereoriginally written byTara LaFor e.

1 Derivation of the Finite Element Method

Inordertoderivethefundamental on eptsofniteelementmethods(FEM)

we will start by looking at an extremely simple ODE and approximate it

usingFEM.

1.1 The Model Problem

Themodel problemis:

−u ′′ + u = x 0 < x < 1

u (0) = 0 u (1) = 0

(1)

andthis problem an be solved analyti ally:

u (x) = x − sinh x/ sinh 1

. The

purpose of starting with this problem is to demonstrate the fundamental

on epts and pitfalls in FEM in a situation where we know the orre t an-

swer, sothatwe willknowwhere our approximationis goodand where itis

poor. In asesof pra ti alinterestwe willlookat ODEs andPDEsthatare

too omplex to be solved analyti ally.

FEMdoesn'ta tuallyapproximatetheoriginalequation,butrathertheweak

form of the original equation. The purpose of the weak form is to satisfy

the equation in the "average sense," so that we an approximate solutions

thatare dis ontinuous or otherwise poorly behaved. Ifa fun tion

u(x)

is a

solutiontotheoriginalformoftheODE, thenitalsosatisesthe weakform

ofthe ODE. The weakform ofEq. 1is

Z 1

0 −u ′′ + u vdx = Z 1

0

xvdx

(2)

Thefun tion

v(x)

is alled theweight fun tionor testfun tion.

v(x)

an be

any fun tion of

x

that issu iently well behaved for the integrals to exist.

(2)

Theset of all fun tions

v

that also have

v(0) = 0

,

v(1) = 0

are denoted by

H

. (We willput many more onstraintson

v

shortly.)

Thenew problemisto nd

u

sothat

R 1

0 (−u ′′ + u − x) vdx = 0

for all

v ∈ H

u (0) = 0 u (1) = 0

(3)

On etheproblemiswritteninthiswaywe ansaythatthesolution

u

belongs

to the lass of trial fun tions whi h are denoted

H ˜

. When the problem is

written in this way the lasses of test fun tions

H

and trial fun tions

H ˜

arenot the same. For example,

u

must be twi edierentiable and have the propertythat

R 1

0 u ′′ vdx < ∞

, while

v

doesn't even have to be ontinuousas

longastheintegralinEq. 3existsandisnite. Itispossibletoapproximate

u

in this way, but having to work with two dierent lasses of fun tions

unne essarily ompli ates the problem. In order to make sure that

H

and

H ˜

arethe same we an observe thatif

v

issu iently smooth then

Z 1

0 −u ′′ vdx = Z 1

0

u v dx − u v| 1 0

(4)

Thisformulationmustbevalidsin e

u

mustbetwi edierentiableand

v

was

arbitrary. This puts another onstraint on

v

that it must be dierentiable and thatthose derivatives mustbe well-enough behaved to ensure thatthe

integral

R 1

0 u v dx

exists. Moreover, sin e we de ided from the outset that

v(0) = 0

and

v(1) = 0

, the se ond term in Eq. 4 is zero regardless of the

behaviorof

u

atthese points. The newproblem is

Z 1

0

u v + uv − xv  dx = 0.

(5)

Noti ethatbyperformingthe integrationbyparts werestri tedthe lassof

testfun tions

H

byintrodu ing

v

intotheequation. Wehavesimultaneously expandedthe lassoftrialfun tions

H ˜

,sin e

u

isnolongerrequiredto have

ase ondderivativeinEq. 5. TheweakformulationdenedinEq. 5is alled

avariational boundary-valueproblem.

InEq. 5

u

and

v

have exa tlythe same onstraints onthem:

1.

u

and

v

mustbesquare integrable, thatis:

R 1

0 uvdx ≈ R 1

0 u 2 dx < ∞

(3)

2. The rst derivatives of

u

and

v

must be square integrable, that is:

R 1

0 u v dx ≈ R 1

0 (u ) 2 dx < ∞

(this a tually guarantees the rst prop-

erty)

3. Wehadalreadyassumedthat

v(0) = 0

and

v(1) = 0

andweknowfrom

the originalstatement of theproblem that

u(0) = 0

and

u(1) = 0

.

Now we have that

H = H = H ˜ 0 1

. Any fun tion

w

is a member of

H 0 1

if

R 1

0 (u ) 2 dx < ∞

and

w(0) = w(1) = 0

.

H 0 1

is the spa e of admissible

fun tionsforthe variational boundary-value problem(ie. all admissibletest

and trialfun tionsarein

H 0 1

)

Wewill onsiderthevariationalformEq. 5tobetheequationthatwewould

like to approximate, rather than the original statement in Eq. 1. On e we

have found asolution toEq. 5in this waywe an askthe question whether

thisformulation isalsoa solutiontoEq. 1: That is,whetherthissolution is

afun tionsatisfyingEq. 1atevery

x

in

0 < x < 1

,orwhetherwehavefound

asolutionthatsatisesonlythe weakformoftheequation. Inthe asethat

we anonly nd asolution to the weakform, no " lassi al" solutionexists.

1.2 Galerkin Approximations

We now have the problemre-stated so thatwe arelooking for

u ∈ H 0 1

su h

that

Z 1 0

u v + uv dx = Z 1

0

xvdx

(6)

for all

v ∈ H 0 1

. In order to narrow down the number of fun tions we will

onsider in our approximate solutions we will make two more assumptions

about

H 0 1

. First,wewill assumethat

H 0 1

isalinearspa eof fun tions(that

isif

v 1 , v 2 ∈ H 0 1

and

a, b

are onstants then

av 1 + bv 2 ∈ H 0 1

.)

These ondassumption isthat

H 0 1

isinnite dimensional. For exampleifwe have the sine series

ψ n (x) = √

2 sin(nπx)

for

n = 1, 2, 3, ...

and

v ∈ H 0 1

then

v

an be represented by

v (x) = P

n=1 a n ψ n (x)

. The s alar oe ients

a n

aregiven by

a n = R 1

0 v (x) ψ n (x) dx

, justlike usual. Hen einnititely many oe ients

a n

must be found to dene

v

exa tly. As in Fourier analysis,

many of these oe ients will be zero. We will also trun ate the series in

orderto have managablelength series,justlike in dis rete Fourier analysis.

(4)

and osines,mu hlesssmoothfun tions anbeused. Infa tour setofbasis

fun tionsdo not even have to be smooth and an ontain dis ontinuities in

the derivatives,but they mustbe ontinuous. We will assumethatthe in-

niteseries onvergessothatwe an onsideronlytherst

N

basisfun tions

andgeta good approximation

v N

ofthe original test (ortrial) fun tion:

v ∼ = v N = X N

i=1 β i φ i (x)

(7)

where

φ i

areas-yetunspe iedbasisfun tions. Thissubspa eoffun tionsis

denoted

H 0 (N )

andisasubspa e of

H 0 1

. Galerkin'smethod onsistsofnding

an approximate solution to Eq. 6 in a nite-dimensional subspa e

H 0 (N )

of

H 0 (1

ofadmissible fun tionsrather thanin the whole spa e

H 0 1

. Nowwe are

looking for

u N = P N

i=1 α i φ i (x)

. The new approximate problem we have is to nd

u N ∈ H 0 (N )

su h that

Z 1

0

u N v N + u N v N  dx = Z 1

0

xv N dx

(8)

for all

v N ∈ H 0 (N )

. Sin e the

φ i

are known (in prin iple)

u N

will be om-

pletely determined on e the oe ients

α i

havebeen found.

Inorderto ndthat

α n

weput

P N

i=1 α i φ i (x)

and

P N

i=1 β i φ i (x)

into Eq. 8.

Z 1 0

 

 

d dx

h P N

i=1 β i φ i (x) i

d dx

h P N

j=1 α j φ i (x) i + h P N

i=1 β i φ i (x) i h P N

j=1 α j φ i (x) i

− x P N

i=1 β i φ i (x)

 

 

dx = 0

(9)

forall

N

independent sets of

β i

.

This an be expanded andfa tored to give

X N i=1 β i

 X N

j=1

Z 1

0

j (x) φ i (x) + φ j (x) φ i (x) dx

 α j −

Z 1

0

xφ i (x) dx



= 0

(10)

forall

N

independent setsof

β i

. Thestru ture ofEq. 10iseasierto seeifit

isre-written as

(5)

X N i=1 β i

 X N

j=1 K ij α j − F i



= 0

(11)

forall

β i

. Where

K ij = R 1 0

h φ j (x) φ i (x) + φ j (x) φ i (x) i

dx F = Z 1

0

i (x) dx

(12)

and where

i

,

j = 1, ..., N

. The

N × N

matrix of

K ij

is alled the stiness

matrixand the ve tor

F

isthe loadve tor. Sin ethe

β i

areknown

K ij

and

F

an be al ulated dire tly. But the

β i

were arbitrary so we an hoose

ea h element

β i

for ea h equation. For the rst equation hoose

β 1 = 1

and

β n = 0

for

n 6= 1

. Now

P N

j=1 K 1j α j = F 1

. Similarly for the se ond

equation hoose

β 2 = 1

and

β n = 0

for

n 6= 2

so that

P N

j=1 K 2j α j = F 2

.

In this way we have hosen

N

independent equations that an be used to

ndthe

N

unknowns

α i

. Moreover the

N

oe ients

α i

an be found from

α j = P N

j=1 K 1 

ji F i

where

K 1 

ji

arethe elementsof the inverse of

K

.

The stiness matrix

K

is symmetri for this simple problem, whi h makes

the omputation of the matrix faster sin e we don't have to ompute all of

the elements, symmetri matri ies arealsomu h faster to invert.

1.3 Finite Elements Basis Fun tions

Now we have done a great deal of work, but it may not seem like we are

mu h loser to nding a solution to the original ODE sin e we still know

nothing about

φ i

. The purpose of using su h a general formulation is that any set of linearly independent fun tionswill work to solve the ODE. Now

wearenallygoingto talkaboutwhatkindoffun tionswewillwant touse

as basis fun tions. The nite element method is a general and systemati

te hnique for onstru ting basis fun tions for Galerkin approximations. In

FEMthebasisfun tions

φ i

aredened pie ewiseover subregions. Overany subdomain the

φ i

will be hosen to be polynomials of low degree, though otherpossibilitiesdoexist.

niteelements arethe subregionsofthe domainover whi hea hbasis

fun tion is dened. Hen e ea h basis fun tion has ompa t support

over an element. Ea h element has length

h

. The lengths of the ele-

mentsdoNOTneed tobethesame(butgenerallywewillassumethat

theyare.)

(6)

nodes ornodalpointsaredened withinea helement. InFigure1the

venodesarethe endpoints ofea h element (numbered 0to 4).

the nite element mesh is the olle tion ofelementsand nodalpoints

that make up the domain and is shown in Figure 1. An element

i

is

denotedby

i

.

Now weneed to onstru tthe a tual basisfun tionsusing the three riteria

denedbefore: 1)Thebasisfun tionsaresimple fun tionsdenedpie ewise

overtheniteelementmesh,2)thebasisfun tionsmustbeinthe lassoftest

fun tions

H 0 1

, and3) The basisfun tionsare hosen sothatthe parameters

α i

arethe valuesof

u N (x)

at the nodalpoints.

The simplest set of basis fun tionsare the hat fun tions on elements

i = 1, 2, 3

.

φ i (x) =

 

 

x−x i −1

h i for x i−1 ≤ x ≤ x i

x i+1 − x

h i+1 for x i ≤ x ≤ x i+1

0 for x < x i−1 , x > x i+1

 

 

(13)

where

h i = x i − x i−1

isthe length ofelement

i

. Thederivativesare

φ i (x) =

1

h i for x i−1 ≤ x ≤ x i

− 1

h i+1 for x i ≤ x ≤ x i+1

0 for x < x i−1 , x > x i+1

(14)

Theequationsfor elements0 and4havebeenleftout sin e wede ided that

u(0) = u(1) = 1

, so no basis fun tions are required. In general the basis

fun tionsfor the rstand last elementsare halfofthe fun tions sin ethere

isno

i−1

or

i+1

node,respe tively. Thehatfun tionsareshowninFigure2.

Themathemati al termfor hatfun tionsispie e-wise linear basis fun tions

Lookingatthethree riteriaabove, learlythefun tionsinEq. 13aresimple

anddened element-wise. Itiseasy to showthattheyarein

H 0 1

, sin e they

have square-integrable rst derivatives. They also satisfy the third riteria

sin e

φ i (x j ) = 1

if

i = j

and 0 otherwise. Hen e ea h fun tion ontributes to the value of

u N

at exa tlyone node and

α i = u N (x i )

.

It is less lear that the hat fun tions will give a ontinuous representation

of

v N

and

u N

. Let

v

be the sine fun tion with period 2 shown in Figure

3. At the nodes (0, 1, 2, 3, 4) sine has the values (0,0.7071,1,0.7071,0).

The representation

v N

on the nite element mesh is

v N = 0.7071φ 1 (x) +

(7)

0 1 2 3 4

h 1 h

2 h

3 h 4

1234

Figure1: Fourniteelementsontheinterval[01℄.

0 1 2 3 4

−1 0 1

h 1 h 2 h 3 h 4

Ω 1 Ω 2 Ω 3 Ω 4

φ 1 φ 2 φ 3

0 1 2 3 4

−1 0 1

h 1 h 2 h 3 h 4

Ω 1 Ω 2 Ω 3 Ω 4

φ 1 φ 2 φ 3

Figure2: Fourhatfun tions(top)andtheirderivatives(bottom)ontheinterval[01℄.

(8)

φ 2 (x) + 0.7071φ 3 (x)

. When the elements are summed up the sine wave

is approximated by pie ewise linear fun tions between ea h of the nodes,

and is exa tly represented at ea h node. When more nodes are used the

approximationimprovesand in the limitof

N → ∞

the sinewave wouldbe

exa tlyrepresented. In FEMwe willnever pro eedall the wayto the limit,

so the interval size

h

will always have nite size

h

. This is why the term

nite elements is used.

0 0.5 1 1.5 2 2.5 3 3.5 4

−1 0 1

h 1 h 2 h 3 h

4

1234

0.7071φ 1

φ 2

0.7071φ 3

sin(pi x) v

N

Figure3: Theniteelementapproximation of

sin (πx)

using ve nodesontheinterval

[01℄.

1.4 The Stiness Matrix

K

and the Load Ve tor

F

for Hat

Fun tions

Re allfromEq. 12thatea h element of the stinessmatrix

K

is given by

K ij = R 1

0

 φ i (x) φ j (x) + φ i (x) φ j (x)  dx

= P 4 e=1

R

e



φ i (x) φ j (x) + φ i (x) φ j (x)  dx

= P 4 e=1 K ij e

(15)

similarly

F i = Z 1

0

xφ i (x)dx = X 4 e=1

Z

Ω e

xφ i (x)dx = X 4

e=1 F i e

(16)

(9)

where we have used the property that

φ(x)

are dened pie ewise on ea h

element 1through 4. Inorder to ompute anapproximation ofthe solution

to the model ODE it is ne essary to ompute nine elements for

K ij

from

i, j = 1, 2, 3

and threeelementsfor

F

. Butsin e ea h of the fun tions

φ(x)

aredenedinthesamewayitispossibleto ompute

K e

and

F e

forageneri

element andthen to onstru t thematrix usingthe sumsabove. Consider a

generi interiorelement

Ω e

ontheinterval

x A

to

x B

. Wewillusea hange of

variablesandrewritethisintermsof

ξ

,adummyvariablefor

x

. Wewillhave

ξ = (0, h)

. On this element exa tly two of the hat fun tions are nonzero:

ψ A (ξ) = 1 − h ξ

and

ψ B (ξ) = h ξ

. Convin e yourself that this denition is

equivalent tothe previousdenitionof thehat fun tion,but withthe origin

shifted to the start of one of the interior elements. The two hat fun tions

have derivatives

ψ A (ξ) = − h 1

and

ψ B (ξ) = h 1

.

It is also important to noti e that for the hat fun tions

φ i (x) 6= 0

on only

the elements

i

and

i+1

. Thisresults ina tridiagonal sparsematrix

K

for

any number of elements in the mesh aswill be shownbelow. Using Eq. 15

you an see thatthereare threeintegrals that ontributeto

K ij

:

k AA = R h 0

 ψ e A (ξ)  2

+ [ψ e A (ξ)] 2  dξ

= R h 0



[1/h] 2 + [1 − ξ/h] 2 

dξ = 1/h + h/3 k AB = R h

0 ψ A e (ξ) ψ B e (ξ) + ψ e A (ξ) ψ e B (ξ)dξ

= R h

0 ((−1/h) (1/h) + (1 − ξ/h) (ξ/h))dξ = −1/h + h/6 k BB = R h

0

 ψ e B (ξ)  2

+ [ψ e B (ξ)] 2  dξ

= R h 0



[−1/h] 2 + [ξ/h] 2 

dξ = 1/h + h/3

(17)

Similarlythe omponentsthat ontributeto the loadve tor are:

F A e = R h

0 (x A + ξ) (1 − ξ/h) dξ = h 6 (2x A + x B ) F B e = R h

0 (x A + ξ) (ξ/h) dξ = h 6 (x A + 2x B )

(18)

wherethe

x A

and

x B

terms omefromevaluatingthefor ingfun tion

f (x) = x

at the endpoints ofthe generi element.

Thusea hgeneri interiorelement ontributestothe stinessmatrix a

2 × 2

submatrix

k e =

 1/h + h/3 −1/h + h/6

−1/h + h/6 1/h + h/3



(19)

(10)

f e = h/6

 2x A + x B

x A + 2x B



(20)

For the 4 element mesh we have derived the ontributions to the overall

stinessmatrix

K

from ea hnode isgiven by:

K 1 =

1/h + h/3 0 0

0 0 0

0 0 0

 K 2 =

1/h + h/3 −1/h + h/6 0

−1/h + h/6 1/h + h/3 0

0 0 0

K 3 =

0 0 0

0 1/h + h/3 −1/h + h/6 0 −1/h + h/6 1/h + h/3

 K 4 =

0 0 0

0 0 0

0 0 1/h + h/3

(21)

where the ontributions fromelements 1and 4have only oneentry be ause

only halfof the hat fun tion existson these elements. Similarly the ontri-

butions to theload ve tor are

F 1 = h/6

 2h

0 0

 F 2 = h/6

2h + 2h h + 4h

0

(22)

F 3 = h/6

 0 4h + 3h 2h + 6h

 F 4 = h/6

 0 0 6h + 4h

(23)

where

h = 0.25

for the model problem. Now

K = K 1 + K 2 + K 3 + K 4

and

F = F 1 + F 2 + F 3 + F 4

. The nalsystemof equations hassymmetri

anddiagonallydominant stinessmatrix

K

,whi hisveryni etoworkwith

mathemati ally. Thevalues of

u N

at ea h node isgiven by

α = K ˜ 1 F

and

u N = P 3

i=1 α i φ i (x)

.

Using this we get that the approximation to the model problem is

u = 0.0353φ 1 (x)+0.0569φ 2 (x)+0.0505φ 3 (x)

. Thisisnotaverya urateanswer,

sin e only four elements wereused. A more a urate approximation an be

obtainedbyusingmoreelements, butatthe ostofbuildingandinverting a

larger stinessmatrix

K

. The usualwayofestimating the errorof anFEM

approximation using linear basis fun tions (the hat fun tions we derived)

usingthe

L 2

or mean-square norm isthat

||e|| 0 < C 2 h 2

. This isan a-priori

(11)

substantially smaller.

Referen es

[1℄ Be ker, E. B., G. F. Carey, and J. T. Oden, Finite Elements an In-

trodu tion, Texas Institute for Computational Me hani s, UT Austin,

1981.

References

Related documents

This is the recurring motto of the unedited treatise Diez privilegios para mujeres preñadas 4 (Ten Privileges for Pregnant Women), written in 1606 by the Spanish physician

(In practice, by this definition, every fluid that flows near a solid boundary will be non-uniform - as the fluid at the boundary must take the speed of the boundary, usually

In the sequel we will abuse notation and simply denote ¯ u by

de Klerk, South Africa’s last leader under the apartheid regime, Mandela found a negotiation partner who shared his vision of a peaceful transition and showed the courage to

Note: if you want to burn your current movie production to a disc right away, go directly to the Create Disc module. In the Create Disc module you can create a disc menu, produce

Make measurements on timeslot 0 [FREQUENCY] {Timeslot Off} [Enter] Activate the ORFS measurement (figure 25) [MEASURE] {GMSK Output RF The default setting measures spectrum

The aim of this paper was to explore the effects on the French forest sector of three policies to mitigate climate change: a fuelwood consumption subsidy (substitution), a payment

Note: If there is paper in the paper tray, pull the paper release plate forward and remove the paper before loading the imaging film.. 1 Open the operation panel by grasping the