variation fem

37
Contents 2 Variational Formulation 3 2.1 Boundary Value problems ..................... 3 2.1.1 The Poisson equation in R 2 ................ 4 2.2 Variational formulation of BVP .................. 8 2.2.1 Euler- Lagrange equation ................. 9 2.2.2 Existence, Uniqueness of a Weak solution ........ 12 2.2.3 More general coecient .................. 15 2.2.4 Inhomogeneous boundary condition ........... 15 2.2.5 Question .......................... 16 2.3 Ritz-Galerkn Method ....................... 17 2.3.1 Inhomogeneous boundary conditions ........... 18 2.3.2 Noncoercive forms ..................... 19 2.4 Finite Element Method -A Concrete Ritz-Galerkin method .. 22 2.4.1 Finite element basis functions ............... 22 2.4.2 Assembly of stiness matrix ................ 25 2.5 Outline of Programming ...................... 27 2.5.1 Computation of a(φ i , φ j ) elementwise. ......... 29 2.5.2 Integration using reference element ............ 32 2.5.3 Numerical Integration ................... 32 2.6 The Equations of Elasticity .................... 33 2.7 Biharmonic equation ........................ 36 1

Upload: shant-danielian

Post on 17-Aug-2015

232 views

Category:

Documents


0 download

DESCRIPTION

dede

TRANSCRIPT

Contents2 Variational Formulation 32.1 BoundaryValueproblems . . . . . . . . . . . . . . . . . . . . . 32.1.1 ThePoissonequationinR2. . . . . . . . . . . . . . . . 42.2 VariationalformulationofBVP. . . . . . . . . . . . . . . . . . 82.2.1 Euler-Lagrangeequation . . . . . . . . . . . . . . . . . 92.2.2 Existence,UniquenessofaWeaksolution . . . . . . . . 122.2.3 Moregeneralcoecient . . . . . . . . . . . . . . . . . . 152.2.4 Inhomogeneousboundary condition . . . . . . . . . . . 152.2.5 Question . . . . . . . . . . . . . . . . . . . . . . . . . . 162.3 Ritz-GalerknMethod . . . . . . . . . . . . . . . . . . . . . . . 172.3.1 Inhomogeneousboundary conditions . . . . . . . . . . . 182.3.2 Noncoerciveforms . . . . . . . . . . . . . . . . . . . . . 192.4 FiniteElementMethod-AConcreteRitz-Galerkinmethod . . 222.4.1 Finiteelementbasisfunctions. . . . . . . . . . . . . . . 222.4.2 Assemblyofstinessmatrix. . . . . . . . . . . . . . . . 252.5 OutlineofProgramming . . . . . . . . . . . . . . . . . . . . . . 272.5.1 Computationofa(i, j)elementwise. . . . . . . . . . 292.5.2 Integrationusingreferenceelement . . . . . . . . . . . . 322.5.3 NumericalIntegration . . . . . . . . . . . . . . . . . . . 322.6 TheEquationsofElasticity . . . . . . . . . . . . . . . . . . . . 332.7 Biharmonicequation . . . . . . . . . . . . . . . . . . . . . . . . 3612 CONTENTSChapter2Variational Formulation2.1 BoundaryValueproblemsExample2.1.1(Onedimlproblem).u= fon(0, 1), withB.C.u(0) = u(1) = 0.Multiplyatestfunctionv H10(I)andintegrate(u, v) = _10uvdx= [uv]10 +_10uvdx =_fvdx.Thuswehave(u, v) = (f, v), v V= H10(I).IfthespaceH10(I)isreplacedby anitedimensionalspaceSh(I)ofpiecewisecontinuous,linearfunctionsonIwithuniformspacing,thenwegetAuh= fh,whereatypical rowis[ , 0, 1, 2, 1, 0 ]. FDMgivesrisetosimilarma-trixequation.xi1 xi xi+1i1 ii+1Figure2.1: Basisinone-dimension34 CHAPTER2. VARIATIONALFORMULATIONLethi= xixi1, Ii= [xi1, xi]. Letuh=

n1j=1cjj. Thenn1

j=1_10cjj(x)i(x)dx =_10f(x)i(x)dx, i = 1, 2, , n 1.Hence

n1j=1aijcj= fi (i = 1, 2, , n 1),whereaij=_10j(x)i(x)dx, fi=hi1 +hi2f(xi).Thetypical rowofAis_0, 1hi1,1hi1+1hi, 1hi+1, 0_2.1.1 ThePoissonequationinR2LetbeaboundeddomaininR2anddenoteitsboundary.Wesayafunctionudenedonis aclassical solutionof thePoissonequationwithhomogeneousboundaryconditionifuC2(), uC()andusatisfying___u(x, y) = f(x, y)for(x, y) u(x, y) = 0for(x, y) 1u(x, y) = 0for(x, y) 2,(2.1)whereistheLaplacianoperatorand1 2=and1 2isasetofmeasurezero. Itiswellknownthatforsucientlysmoothboundary,thereexistsauniqueclassicalsolutionof(2.1)providedthat1ismeasurable.Wewill assumethatisanormal domain, i.e., itadmitstheapplicationofdivergencetheorem:_uxidxdy=_uidS, i = 1, 2 u C1(), (2.2)whereiarethecomponentsofunitoutwardnormalvectorto.Fact: Every polygonaldomainoradomainwith piecewisesmoothbound-aryisanormaldomain.Asaconsequenceof(2.2)wehavetheGreensFormula._vudxdy=_vudS _u vdxdy. (2.3)Suppose thatuisaclassicalsolutionof(2.1)andthatv V= { C() : = 0on1}. Sincev = 0on1andu= 0on2,wesee(2.3)yields_vudxdy=_u vdxdy:= A(u, v).2.1. BOUNDARYVALUEPROBLEMS 5HenceusatisfyA(u, v) = (f, v) v V, (2.4)where(f, v) =_fvdxdy. A(u, v)isabilinearformdenedonH1()andiscalledtheDirichlet integralassociatedwiththeLaplaceoperator.The space Vcan be shown to be dense in H11() = {v H1() : v= 0 on1}. Itisnotdiculttoshowthat(2.4)actuallyholds foreveryv H11(),i.e,A(u, v) = (f, v) v H11(). (2.5)We now dene a generalized(weak) solution u H11() of (2.1)as a functionuinH11()whichsatisfy(2.5). WewillshowtheexistenceanduniquenessofthisweaksolutionusingtheLax-Milgramtheorem(Later). First. letu, v H11(),thenA(u, v) =_u vdxdy u1v1so that condition (i) of the Lax-Milgram theorem holds. Now the second condi-tion of the Lax-Milgram theorem holds by the Poincare inequality. Clearly, foru L2(), (f, v)denesaboundedlinearfunctionalonH11().Hencethereexists auniqueuH11() suchthat(2.5) holds. Moreover u1cf.Morecanbesaidaboutthesolutionif theboundaryissmootherandf as-suresmoreregularity: For example, if isof classCrandf Hr2(),thenu Hr() H11() (2.6)andur Cfr2. (2.7)Resultssuchas(2.6)and(2.7)areknownasellipticregularityestimates.AnexampleofFEMExample2.1.2(Poissonproblem).u = finu = 0on.Assume=[0, 1]2andthatwehavedividedinto2n2righttrianglesoflength h Let S0h() be the space of continuous, piecewise linear on each elementsatisfyingzeroboundarycondition. Let uh=

ujjwherejisthetentshape basis functionsatisfyingj(xi) =ij. Thenbymultiplyingiandintegratebyparttoget_

jujj idxdy=_fidx, foreachi = 1, 2, .6 CHAPTER2. VARIATIONALFORMULATIONWritinga(i, j) =_j idxdyweget

ja(i, j)uj= (f, i)Inmatrixform,itisAu = f, Aij= a(j, i).Aiscalledastinessmatrix.Example2.1.3(Neumannproblem).u +u = finun= gon.(2.8)Noteinthiscaseuisunknownattheboundary. SoV =H1()notH10().Ifg= 0,wehaveaninsulatedboundary.(u, v) + (u, v) = (u, v) + (u, v) < g, v>= (f, v).Sothevariational problemis: (V)Findu H1suchthata(u, v) = (f, v)+ < g, v>, v H1,wherea(u, v) = (u, v) + (u, v).Show: Ifu C2isthesolutionof(V)thenitisthesolutionof(2.8).Proof. Letubethesolutionof(V).Thena(u, v) = (u, v) =_unv + (u, v) = (f, v)+ < g, v> ._(u +u f)v =_(g un)vds, v H1.Restricttov H10. Thenwegetu +u f= 0in.Hencewehave_(g un)vds = 0, v H1whichprovesg=un. Theconditionun=giscalledthenatural boundarycondition. (Look at the space V , we did not impose any condition, but we gotB.Cnaturallyfromthevariationalformulation.)Remark2.1.1. This is equivalent tothe minimizationproblem(M): Findu H1()suchthatF(u) F(v)forallvwhereF(v) =12a(v, v) (f, v) .2.1. BOUNDARYVALUEPROBLEMS 7Moregeneral BoundaryConditions Dirichletcondition NeumanconditionExample2.1.4. pu = f, inu = u0on1(2.9)un= gon2:= \1.LetV1= {v H1(), v|1= 0}. Ifv V1( pu, v) = _punvds +_pu vdxdy= _2punvds +_pu v dxdy= (f, v).Thevariational formulationis: FindusatisfyingtheDirichletconditionsuchthata(u, v) = (v), v V1, (2.10)wherea(u, v) = (pu v)and(v) = (f, v)+ < pg, v>2.Remark2.1.2. Foraminimizationformulation,setF(v) =12a(v, v) (f, v) < pg, v>2.TakederivativeofF(u + v)w.r.tandsetitto0at = 0toobtain(2.10).HWShowthesolutionof(2.10)satises(2.9)withu0= 0.1. ConsidersolvingforG H10(I)(G, v) = v(xi), v H10(I). (2.11)LetG = axon(0, xi)andG = b(1 x)on(xi, 1).Aboveequationis_xi0avdx +_1xibvdx = av(xi) +bv(xi) = v(xi).Thusa + b=1andbycontinuityaxi=b(1 xi). sob=xi, a=1 xi.Integrating(2.11)bypartformally,(G, v) = v(xi).8 CHAPTER2. VARIATIONALFORMULATIONThismeansG(x) = (xi)SowehaveaGreensfunction.Choosingv= u uh,whereuhniteelementapproximationofu. wesee(u uh)(xi) = (G, (u uh)) = 0.Soinonedimensional case, uh(xi)=u(xi)foreachnode. Thisisnolongertrueforhigherdimensionalcase.2. Foraunitsquareshowthat__v2ds_1/2 CvH1 , v H1().Proof. LetusassumevC(). Chooseanypoint(x, y)onavertical linex = 1,weseev(1, y) =_1xvt(t, y)dt +v(x, y)v2(1, y) 2__1xv2t(t, y)dt_+ 2v2(x, y)_10v2(1, y)dy 2_10_10v2t(t, y)dtdy + 2_10v2(x, y)dy_10v2(1, y)dy 2_10_10v2x(x, y)dxdy + 2_10_10v2(x, y)dxdy.Otherintegralsareeasilytreated. Nowusedensityargument.3.v2L2() C1|v|21, +C2_v dx2. (2.12)4. Showthatthesolutionofthevariationalproblem:Findu V1,suchthata(u, v) = (f, v), v V1(2.13)solves(2.9)withu0= g = 0.2.2 Variational formulationofBVPInmanycases,secondorderBVPcanbecastintoaminimizationproblemofcertain(nonlinear)functional.2.2. VARIATIONALFORMULATIONOFBVP 9Denition2.2.1. LetV beasetinaHilbertspace. LetB(u0, ) = {u V:u u0 < }beaneighborhoodof u0. Letfbeareal valuedfunctiondenedonV . Wesayu0V isalocal minimizerof f ifthereexistsan>0suchthat f(u0)f(u), uB(u0, ). If f(u0) 0suchthat thefunctiondenedbyg(t)=f(u + t), |t| 0. (Coercive)(3) G(v)isaboundedlinearfunctional.Thenthereexistsauniquesolutionu HsatisfyingA(u, v) = G(v).Furthermore,if a is symmetric,then it is a unique minimizer of the functionalf(u) =12A(u, u) G(u).Lemma 2.2.1. (Friedrichs rst inequality) If 0is nontrivial, there is aconstant >0suchthat_ |u|2dxdy_u2dxdy, vV. If 0=,wehavePoincareinequality.HW.provePoincareinequalityassumingrstuissucientlysmoothandthenusedensityargument.BytheLemma,A(u, u)is coercive. Boundedness iseasytoshow. NowbyLax-Milgramlemma,thereexistsauniquesolutionu V suchthatA(u, v) = G(v), v V.Onecaneasilyseethatusatises(2.23)Example2.2.4. IfwechooseH= H10= {v H1, v|0= 0}andconsideru = gin (2.26)u = 0on0(2.27)u= 0on 0. (2.28)14 CHAPTER2. VARIATIONALFORMULATIONH.W.ApplyLax-Milgramtoshowtheexistenceofsolution.NextweconsiderRobinproblem.u = gin (2.29)u+ u = 0on. (2.30)ThenitscorrespondingvariationalproblemisExample2.2.5. (Robincondition)V= V. LetA(u, v) =_u vdxdy +_uvds, v V (2.31)G(v) =_gvdxdy, v V, (2.32)where C(), g L2(), 0 < 0 (x) 1, x .H.W.Showthatthisisequivalenttothep.d.e. above.Forthispurpose, weneedthefollowing.Lemma2.2.2. (Tracetheorem)ForanyuH1(), therestrictionof utoexistsandbelongstoL2()andsatises_u2ds u21, u H1().Lemma2.2.3. (Friedrichssecondinequality)If 0isnontrivial, thereisaconstant > 0suchthat_|u|2dxdy +_0u2ds u21, u H1().By Friedrichs 2nd inequality, one can easily show that A(u, u) min(0, 1)u21.Forboundedness, wenotethatA(u, u) _|u|2dxdy + 1_u2ds u21.bythetracetheorem.Notethatif(x) 0on,Aisnotcoercive.Toseethis,wenoteGreenssecondidentity:_(uv vu)dxdy=_(uvvu)ds.Setv = 1. Then_udxdy=_gdxdy= _uds.Thelastintegralisconservativeformandhencezero.2.2. VARIATIONALFORMULATIONOFBVP 152.2.3 Moregeneral coecientExample2.2.6. V= {v H1(), v= 0on0}.A(u, v) =_

aijuxivxjdxdy +_cuv dxdy, v V (2.33)G(v) =_gvdxdy, v V, (2.34)where0, gL2(), aij=ajiC(), cC(), c0. Assumethereexistsaconstant > 0suchthat

aijij

2i, x , i R.(This is equivalent to: Eigenvalues of {aij} are positive. Then we have A(u, u) u21, u V.)ThecorrespondingboundaryvalueproblemisLu = gin (2.35)u = 0on0(2.36)uL= 0on 0, (2.37)whereLu =

xi_aijuxj_+cuanduListheconormal derivativedenedbyuL=

iaijuxj.HW.Showdetails.2.2.4 InhomogeneousboundaryconditionConsiderLu = gin (2.38)u = (x, y)on. (2.39)whereLu = (pux)x(puy)y +quon. TakeV= H10()andletA(u, v) =_(puxvx +puyvy +quv)dxdy (2.40)G(v) =_gvdxdy. (2.41)LetH1() = {u H1(); u = on}.16 CHAPTER2. VARIATIONALFORMULATION2.2.5 Question(1)Givenu H1()howdowedeneitsrestrictionto?(2)GivenH1()isthereu H1()suchthattherestrictionofutois?Answertotherstquestionisthetraceandtraceinequality. AnswertothenextquestionistrueifandonlyifH1/2(). Nowthefunctionaltobeminimizedisf(u) =12A(u, u) G(u), u H1().SinceH1()isnotalinearspace,Lax-Milgramlemmadoesnotapply. In-stead,foranyxedu H1(),wecanwriteH1() = {u H1() : u = v +u, v H10()}anddenef(v) = f(v +u) f(u) (2.42)=12A(v +u, v +u) G(v +u) 12A(u, u) G(u) (2.43)=12A(v, v) +A(u, v) G(v) (2.44)=12A(v, v) G(v) (2.45)whereG(v) :=G(v) A(u, v). NowLax-Milgramlemmaasserts thatthereexistsauniqueelementu0 H10()suchthatA(u0, v) = G(v), v H10()andhenceA(u0 +u, v) = G(v), v H10().Letu = u0 +u,thenu H1()andsatisesA(u, v) = G(v), v H10().Itiseasytoverifythatu0minimizesfoverH10(). SinceA(u, v) G(v) = (Lu g, v), v H10(),uisthegeneralizedsolutionof(2.38),(2.39).2.3. RITZ-GALERKNMETHOD 17NonhomogenousRobinConditionInthiscase,wehaveinsteadof(2.39),u + (x, y)u = (x, y)on, (2.46)where(x, y) C(), (x, y) L2()and0 < 0 (x, y) 1.If u H1()is a weaksolutionof (2.38),(2.46), thenintegrationby parts,(Lu g, v) = A(u, v) G(v) _puvds (2.47)= A(u, v) G(v) _p( u)vds, v H1(),(2.48)LetA(u, v) = A(u, v) +_puv ds, u, v H1() (2.49)G(v) = G(v) _pv ds, v H1(). (2.50)ThenwehaveA(u, v) =G(v), v H1(). (2.51)ApplyLax-Milgramlemma(H.W.Checkconditions)to(2.49)togetauniqueu H1()satisfying(2.51).Onecanshowthesolutionofthisproblemsatises(2.38)and(2.46). In-deed,setv H10(). Thenusatises(2.38). Hencewehave_p(u + u )vds = 0, v H1().ThisshowsthatusatisesthenonhomogenousB.C.(2.46).2.3 Ritz-GalerknMethodLetShbeanitedimensionalsubspacesofH10(). Consideru = fin (2.52)u = 0on. (2.53)Thevariationalformulationistondauh ShsatisfyingA(uh, vh) = f(vh), vh Sh.Ritz(1908)usedpolynomials of higherdegree tosolvethe variationalprobleminanitedimensionalsubspace.18 CHAPTER2. VARIATIONALFORMULATION(1)Chooseanicebasis{i}forShsothattheconditionnumberofAisnottoolarge.(2)Letuh=

Nj=1cjj.ThenitbecomesA(N

j=1cjj, i) = f(i), i = 1, ..., NorA c =f, (2.54)whereAij=A(j, i)andf(i)=_fidxdy. SuchAiscalledthestinessmatrixandf iscalledaloadvector. AisSPDandhencethesystemhasauniquesolution.Thusfarwehavenoassumptionontheshape(support, degrees, etc.) ofbasis functions. If Often, weusecontinuous functions whicharepiecewiselinearontriangularelements. Notethatinthiscase,Aij= 0onlyifthenodei, jareadjacent. Thusthematrixissparse.2.3.1 InhomogeneousboundaryconditionsConsidersolvingu = fin (2.55)u = on. (2.56)Fromearlierdiscussions, thevariational formulationistondauh= uh+u, uh ShsatisfyingA( uh, vh) = f(vh), vh ShwhereuisanyfunctioninH1()={uH1(), u=on}. Thenitamountstond uh ShsuchthatA( uh, vh) = f(vh) A(u, vh), vh Sh.Inmatrixform,A c =fwherefi= fiA(u, i).TheRitzapproximationisthenuh=N

j=1cjj+u.2.3. RITZ-GALERKNMETHOD 19Assume the number of unknowns onthe boundaryis p. One oftentrytoconstructuintheformu=N+p

j=N+1jj(2.57)N+p

j=N+1jj(x, y) = (x, y), (x, y) . (2.58)Herejisthepiecewiselinearbasisfunctionassociatedwithboundary.2.3.2 NoncoerciveformsLetV andHbeHilbertspaceswithV HanduH uV , u V. (2.59)LetA(, )beaboundedbilinearformonVV ,i.e,|A(u, v)| uVvV , u, v V. (2.60)LetVnbeasequenceof nitedimensional subspaceof V andsupposethatthereexistpositiveconstantsandsuchthatuVuHsupvVn|A(u, v)|vV, u Vn. (2.61)Finally, suppose there exists a sequence of positive numbers {n} with limnn=0,andsuchthatforeveryen V satisfyingA(en, ) = 0, Vn,thenitistruethatenH nenV. (2.62)Theorem2.3.1. Let uV be givenandconsider the problemof ndingun VnsuchthatA(u un, ) = 0, Vn. (2.63)Ifconditions(2.59)-(2.62)hold, thenthereexistsanintegerN0,independentof u, suchthat (2.63) has auniquesolutionunfor all nN0. Moreover,thereexistaconstantCsuchthatu unV C minVnu V(2.64)u unH Cn minVnu V. (2.65)20 CHAPTER2. VARIATIONALFORMULATIONProof. Assumeun Vnisasolutionof(2.63). ThenA(un, v) = A(u , v), , v Vn.Hencefrom(2.60)and(2.61),unVunH supVnV =1|A(un, )|= supVnV =1|A(u , )| u V, Vn.(2.66)Wemayassume 0. By(2.62)withen= u un,weget( n)u unV u unVu unH.Bytriangleinequalityu unVu unH u V+ u H(2.67)+( unV unH). (2.68)Combining,using(2.66),wehave( n)u unV u V+ u H+ u V(2.69) ( + + )u V, Vn. (2.70)The estimate uH uVcomes from (2.59). Since limn= 0,thereexistsanintegerN0suchthatn /(2)forn N0. Thenu unV Cu V, Vn,whereC=2(++). Thus (2.64) holds. (2.65) follows immediatelyfrom(2.62).Sofarwehaveshownthatif unVnisasolutionof (2.63), thenthereexistsN0suchthat(2.64)and(2.65)holds. Nowweshallshowexistencebyprovinguniqueness.Wenowshowuniqueness:Assumeunandvnaretwosolutionsof(2.63),wn= unvnsatisesA(wn, ) = 0, Vn.Thenwnisasolutionof(2.63)forthecaseu = 0. Thenfrom(2.64),wnV CminVn0 V= 0.Thusun=vn,whenn>N0. Nowweneedtoshowtheexistenceofun. Werewrite(2.63)asA(un, ) = G(), Vn,whereG() = A(u, ). Butinthecaseofnitedimension,existenceisequiv-alenttouniqueness.2.3. RITZ-GALERKNMETHOD 21AnObservationConcerningRitz-GalerkinMethodswithIndeniteBilin-earFormsAlfredH. SchatzMath. comp. Vol. 28, No. 128, 1974, 959-962Some new error estimatesfor RITZ-GALERKIN methods with minimal regu-larity assumptions A H. SCHATZ and J. WANG, Math. comp. Vol. 65, 1996,Pages19-27Remark2.3.1. I. Inapplications, V is usuallytakenas H1() andHisL2(). Then(2.62) implies that the L2-error goes tozerofaster thantheH1()-error. Note that assumption(2.61) is implied by either one of thefollowing:(2.61)A(, )iscoercive;(2.61)thereexistconstants > 0andsuchthatu2Vu2H A(u, u), u V. (2.71)H.W.Provethisstatement.Example2.3.1. LetV= H10(),andA(u, v) = (Lu, v) + (bTu, v) + (cu, v),withG(v) =(g, v), vV. Withtheassumptionthat biC1(), wecanshowthat_bTuvdxdyn

i=1_biuxivdxdy (2.72) b1vn

i=1uxi b1nu1v1. (2.73)andhenceA(u, v)isbounded. Furtherwecanshowthat_(bTu)udxdy= 12_( b)u2dxdyanditfollowsthatA(u, u) = (Lu, u) + (, u2)where = c 12 div b. Hencewithc0= max ||,wehaveA(u, u) u21c0u2, u H10(). (2.74)Thisisaspecial caseofGardingsinequality.Let H=L2(). Thenassumption(2.59) is satisedand(2.74) yields(3). Hence(2.61) is alsosatised. WeconcludefromTheorem2.3.1andremarkthatifthereexists u H10()suchthatA(u, v) = G(v), v H10(),22 CHAPTER2. VARIATIONALFORMULATIONthenforanyfamilyofsubspaces{VN} H10()satisfyingassumption(2.62),theGalerkinsolutionuNexistsandhasthepropertiesu uN CminVNu 1, u uN NCminVNu 1,whereuisthegeneralizedsolutionoftheboundaryvalueproblemKu +bTu +cu = gin, (2.75)u = 0on. (2.76)Notethat theassumptioninExample2.2.6thatc(x)0isnotneededhere.Notealsothat if c0

1(2.87)= a(u, v) +a(u, v)1(2.88)andG(v) = (g, v)+ < p, v>1(2.89)= G(v) +G(v)1(2.90)Thenasshownbefore,thesolutionuminimizesthefunctionalf(u) =12a(u, u) G(u) u H1().IfuisanyfunctioninH1()onecanseeH1() = H10() +u= {u H1() : u = u0 +u, u0 H10()}and(2.85)isequivalenttondingu0 H10()suchthata(u0 +u, v) = G(v), v H10()Let VNbe N-dimensional subspace of H10() with basis functions 1, , N,Ritz-GalerkinequationisK = Gwherekij= a(j, i), Gi= G(i) a(u, )ThenuN=

ii, uN= u0 +u.Inpracticeonereplaces ubyalinear combinations of basisfunctions, i.e,u=

i0ii. Herei 0meansthatirunsthroughtheindexof nodesbelongingto0.2.5. OUTLINEOFPROGRAMMING 272.5 OutlineofProgrammingTwoways: Oneisvertexbasedanotheriselementbased. SecondmethodismoregeneralbecauseitcanhandleFEMbasedontheedgedofsalso.Letuslistsomenotations: L: Totalnumberofelements M: Totalnumberofnodes 0: thepartofboundary whereDirichletconditionisimposed M0: thenumberofnodeson0 J0: theindexsetofnodenumbersofnodeson0(Dirichletcondition) 1: thepartofboundary whereNeumannconditionisimposed L1: thenumberofelementedgeson1 N: numberofnodesin 1(Totalunknowns) J: indexsetofnodenumbersofnodesin 1 Q: numberofintegrationpointsineachelementItisimportantforapplicationto(1) placenodesattheendpointsof0.(2) assignnodesto0ratherthanto1(when01 = ).Suppose wehaveu=

i0ii H1(),thenweconsiderVNgivenbyVN= span{ilinearoneachelementand, i H10().LetTh= {K}beatriangulationofthedomainandletVhbethespaceofcontinuous,piecewiselinearfunctions.K= G, kij= a(j, i), i, j J,Gi= G(i) a(u, i) = G(i)

jJ0(Nj)a(j, i), i J,kij=_(pj i +qji) +_1pjids, Gi=_fi +_pids.Somegeneralissues:(1) Inputdata: , 0, 1, f, g, ,coecients,etc.(2) ConstructionandrepresentationofTh28 CHAPTER2. VARIATIONALFORMULATION(3) ComputationofelementstinessmatrixaKandbK(4) AssemblyofglobalstinessmatrixK,G(5) SolverofK= G(6) Presentationof result. DiscreteL2, H1-error. Numerical Table,order ofconvergence,graphics.Remarkon(2): quasiuniformessentiallythesamesize. Oroftendesir-abletovary the sizeof triangleadaptiveorsuccessiverenement. Conform-ing: vertexshouldnotlieintheinteriorofanedge.Weneedtocomputekij. Assumea(i, j)iscomputedsomehow.(1) kij:= a(j, i), i, j= 1, , M(2) Gi:= G(i), i = 1, , M(3) kij:= kij+a(j, i)1, i, j, = 1, , M(4) Gi:= Gi +G(i)1, i = 1, , M(5) Forj J0:(a) Gi:= G(i) (Nj)kij, i J(b) kij:= 0 = kji, i J(c) kji:= 0, i J0, i = j(d) Gj:= (Nj); kjj= 1Since ki,jis symmetric, the computationin(1), (3) and(5) are done forj= 1, , ionlytosavetimeandmemory. (Forplaceswherekjiappearsforkijwecomputeforj> iinstead. FordetailsseeAxellsonp. 185)Remark2.5.1. (1) Weusedfull matrixnotationkijfor simplicityof pre-sentation; However, oneneedtoexploit thesparsenessof thematrixtosavememory. Soit maybenicetoprovideasinglearrayKSingle[5 M](for5pointstencil)fork[i, j] andwritesubroutinessuchas(1) DoubleToSingle(i, j), 1 i, j M(2) SingleToDoublbe(j), j= 1, , MMThenstep(a)of(5)maylooklikethis:KSingle[DoubleToSingle(i, j)]= a(j, i)Hereonedonotsavea(j, i). Instead,assoonasitiscomputed,itisstoredintoKSingle[DoubleToSingle(i, j)] asshowninthenext.2.5. OUTLINEOFPROGRAMMING 29Onecanuseclassletodenematrix-functionthat lookslikeA(i, j)buthassinglearraystructureoflength5M.(2) The true number of unknowns are N, not M. The (d) of step (5) meansweappendthefollowingidentityequationstotheNNequations;u(Ni) = (Ni), i J02.5.1 Computationofa(i, j)elementwise.a(i, j)=

K_K(pi j+qij) :=

KaKijwhere the summation runs through the common support of iand j. We ndthisbycomputingthecontributionofaK(i, j)calledtheelement stinessmatrix.Somenotations:L: numberoftriangles(elements)M: numberoftotalnodesK, = 1, , L: theelementsZ: 2 Mmatrix,Z(j, i), j= 1, 2coordinatesofnodei.-vertexcoordi-natestable.T: 3 Lmatrix,T(, ), = 1, 2, 3denotestheglobalnodenumberingof-thtriangle-elementnodetable.Atriangulationmayberepresentedbytwomatricessuchas2 MmatrixZ, and3 LmatrixT: Z(j, i), j =1, 2representsthe(x, y)-coordinateofnodeNi, i=1, , n, whileT(j, ), j =1, 2, 3denotethevertexnumberingof the-thtriangle. Nodeorderingisimportantif wewanttouseGaussianelimination(Forinstance,weintendtostoreAasabanded matrix,hopefullywithsmallband)Example2.5.1. Letusdivideaunitsquareby4 4uniformmesheswhereeachsmallrectangleiscutthroughalineofslope1. Labelallthevertexnodes1, 2, 3, , 25 lexicographically. Label the element as K1/K2, K3/K4, , K7/K8, Computeelement stinessmatrixforeachtriangle, andaddall thecon-tributiontothreeverticesasKrunsthroughall element. If i =j, Krunsthroughall element havingthenodei asavertex. If i=j, Krunsthroughall elementhavingij asanedge. Inthisway, weassembletheglobal matrixAall together(notforeachentry)30 CHAPTER2. VARIATIONALFORMULATIONK1K2K3K4K11v1v2v3v4v5v6v11v10v7v8v9v11v13v14Figure2.5: LabelofelementsandverticesConsiderK=K11. Itsverticesare7, 8and11. Fortheelement matrixweneedtocomputeaK(i, j)fori, j= 7, 8, 11.aK(7, 7) =_K(1h, 1h) (1h, 1h) = 1aK(7, 8) =_K(1h, 1h) (1h, 0) = 12aK(7, 11) =_K(1h, 1h) (0,1h) = 12aK(8, 8) =_K(1h,1h) (1h, 1h) =12aK(8, 11) =_K(1h, 0) (0,1h) = 0aK(11, 11) =_K(0,1h) (0,1h) =12TheelementstinessmatrixAK11(correspondstothevertices7,8and11)is__1, 12, 1212,12, 012, 0,12__= a12,Generateelementmatricesforall elementK=1, 2 ,additscontribu-tion to all pair of vertices (i, j). Let L be the number of elements and let Tbethe 3L matrix whose -th column denotes the three global indices of verticesof-thelement. Forexample,T(, 11) = [7, 8, 11]t.Z=_0 1.0 2.0 3.0 4.0 0 1.0 0 0.0 0.0 0.0 0.0 1.0 1.0 _(2.91)2.5. OUTLINEOFPROGRAMMING 31T=__1 2 2 3 2 7 3 8 6 6 7 7 __(2.92)(3)Computationofelementstinessmatrix.Let K Th. Then T(, ), = 1, 2, 3 are the global numbering of verticesofK. Thexi-coordinatesofverticesareZ(i, T(, )), i = 1, 2a,=_K(p +q)dxsatises(NT(,)) = ,, , = 1, 2, 3b=_Kfdx +_Kgds, = 1, 2, 3.Thentheassemblyofglobalstinessmatrixisasfollows:(4) Assemblyof global stiness matrix: Let a(M, M), b(M) be arrays.Initiallyseta(i, j) = 0, b(i) = 0, i, j= 1, , M.Foreach = 1, 2, , L,compute(a)andb= (b)andseta(T(, ), T(, ))+ = a, , = 1, 2, 3b(T(, ))+ = b, = 1, 2, 3.Remark2.5.2. 1). Thisprocesscorrespondstostep(1)and(2)inprevioussection.2). Inpracticewedonot usethefull arraya(M, M). Insteaduseeitherbandedmatrixif Gaussianeliminationisused(Howbigisthebandandwhathappenstothebandduringtheelimination?) orstoreonlynonzeroelementifiterativemethodsareused.For FEM software site; see //free.kaist.ac.kr www.netlib.org, http://gams.nist.gov( )http://www.ms.uky.edu/skim/LectureNotes/Finite element method (FEM) is a powerful and popular numerical method onsolvingpartial dierential equations(PDEs), withexibilityindealingwithcomplex geometric domains and various boundary conditions. MATLAB (Ma-trixLaboratory)isapowerful andpopularsoftwareplatformusingmatrix-basedscriptlanguageforscienticandengineeringcalculations. Thisprojectis on the development of an nite element method package in MATLAB basedonaninnovativeprogrammingstyle: sparsematrixlization. Thatistorefor-mulatealgorithms interms of sparsematrixoperations tomakeuseof theuniquestrengthofMATLABonfastmatrixoperations. iFEM,theresultingpackage, isagoodbalancebetweensimplicity, readability, andeciency. Itwillbenetnotonlyeducationbutalsofutureresearchandalgorithmdevel-opmentonniteelementmethod.Thispackagecanbedownloadedfromhttp://ifem.wordpress.com/32 CHAPTER2. VARIATIONALFORMULATION2.5.2 IntegrationusingreferenceelementaKij=_K(pi j+qij)dxdyInpracticeKisnotsonice. Itisingeneral positionbutgoodthingistheyareaneequivalenttoaxednicereferenceelementK. Sowewill takeadvantageof this. LetF( x)=B x + bbetheanemapKKandx=( x) = (F( x)).Notingthat = BT,wesee_K(pij+qij)dx =_K( p(BT i)(BTj)+ qij)Jd xd y (2.93)whereJisthedeterminantof B. Tosavecomputational costincomputing(2.93)wedoasfollows: Alittleofalgebrashowsthat(2.93)isaKij=_K_[ pJ[E1i xj xE2(i y j x +i xj y) +E3i yj y] +J qij_d xd ywhereJ= x xy yx yy x, E1= x2 x +y2 y(2.94)E2= x xx y +y xy y, E3= x2 x +y2 x(2.95)Commentonsolvingalgebraicequation.(1) Usebandedstorage(2) Iterativemethodordirectmethod?(3) Useasmanymodulesaspossible.(4) Inputappropriatedata. (0 < c0 p(x, y) < c1)(5) ChecktheerrorbydiscreteL2,H1innerproduct.2.5.3 Numerical IntegrationWereplaceintegralbycertainweightedsumoffunctionvalues:I=_K(x, y)dxdy Q

i=1wi(xi, yi)wherewiand(xi, xi)areindependentof . Weassumetriangleistherighttrianglewithverticesat(0, 0),(1, 0)and(0, 1).2.6. THEEQUATIONSOFELASTICITY 33Q = 1(P0) Q = 3(P2) Q = 7(P3)Figure2.6: QuadraturepointsfortriangleExample2.5.2. Q = 1. (exactforlinearfunction). Quadraturepoint(13,13),w =12._Kdxdy |K|(13, 13)Example2.5.3. Q = 3(exactforquadraticfunction). Quadraturepointsare(12, 0),(12,12)and(0,12)w =16. Thus_Kdxdy |K|3_(12, 0) + (12, 12) + (0, 12)_Example2.5.4. Q = 7(exacttocubicfunction)WithA = |K|A403

i=1g(vi) +A153

i