Beruflich Dokumente
Kultur Dokumente
Faculte
ni Mellal
Be
nie Mathe
matiques et Applications
Master Ge
rique
Analyse nume
TP 4
M
ethode des
el
ements finis
unidimensionnel P1
Realise par
Naoufel Hatime
26 Decembre 2015
1.4
Position du problme : . . . .
But du TP . . . . . . . . . . .
Approximation . . . . . . . .
1.3.1 Formulation variationel
1.3.2 Problme aproche . .
Partie pratique . . . . . . . .
1.4.1 Exemple . . . . . . . .
. .
. .
. .
du
. .
. .
. .
. . . . . .
. . . . . .
. . . . . .
problme
. . . . . .
. . . . . .
. . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
2
2
2
4
7
8
1.1
Position du problme :
Soient f,g deux fonctions continues sur ]-L,L[, nous cherchons approcher
le problme suivant :
00
u(L) = g(L)
1.2
But du TP
Le but de TP est de trouver une solution approche du problme prcdent en utilisant la mthode des lments finis P1 .
1.3
1.3.1
Approximation
Formulation variationel du problme
00
u(L) = 0
(1.2)
00
u (x)v(x)dx =
L
f (x)v(x)dx
L
f (x)v(x)dx
L
Or v/ = 0 ,alors ,
Z
f (x)v(x)dx
u (x)v(x) dx =
L
avec,
Z
a(u, v) =
u (x)v(x) dx
L
f (x)v(x)dx
L(v) =
L
1.3.2
Problme aproche
i (x) =
xxi
xi xi+1
xxi+1
xi xi+1
si xi1 x xi
si xi x xi+1
0 sinon
( indice de Kronecker ).
T rouver uh Vh
tel que
Z L
Z L
0
0
f (x)v(x)h dx vh V (II)
uh (x)v(x)h dx =
i=N
X
i ui
i=1
ui
i (x)j (x)dx =
f (x)j dx pourj = 1, ..., N
i=1
Ainsi on aura,
i=1
k=1
xk1
xk1
k=1
On pose
aij =
k=N
X
akij
k=1
Li =
k=N
X
k=N
X
k=1
Lki
i (x)j (x)dx
xk1
k=N
X
k=1
k=1
xk
xk
f (x)j dx
xk1
xk
xk
k1 (x)k (x)dx
xk1
Z xk
0
0
k (x)k (x)dx
k1 (x)k1 (x)dx
xk1
Ak =
Z xk
0
0
k (x)k1 (x)dx
xk1
xk1
Lk =
xk
f (x)k1 dx
xk1
Z xk
f (x)k dx
0
xk1
1.4
Partie pratique
On dfnit une fonction Matlab maillage qui return deux tableaux elt
qui fait associer chaque numero global dun element [xk , xk+1 ], et tableau
q aussi return les coordonnes des neouds.
On dfinit les fonctions chapeaux dans le fichier BLGG.m. On dfinit les
fonctions SM.m et Assemblage.m qui nous permet respectivement de calculer
et assembler la matrice de la matrice de masse
et le second membre, On dfinit la fonctions LimitCond.m pour ajouter
la condition de Dirichlet non homogne (la pnalisation) . En on intgre ces
fonctions dans un programme principal programmeP1.m dont les paramtres dentres sont L et N .
1.4.1
Exemple
00
u (x) = exp(x) x ] L, L[
u(L) = exp(L)
u(L) = exp(L)
(1.3)
3
0.0170
6
0.0073
9
0.0043
12
0.0029
15
0.0021
20
0.0014
Programme Principale
function [U,A,B,x]=programmeP1(L,N);
[x,elt]=maillage(L,N);
[A]=Assemblage(elt,x);
B=SM(elt,x);
[A,B]=LimitCond(A,B,x,elt);
V=ue(x);
U = A\B;
max(abs(V-U))
plot(x,U,*k,x,V,--r);
legend(Solution approche,Solution exact);
end
Les fonctions
function [x,elt]=maillage(L,N)
h=2*L/(N+1);
i=0:N+1;
x=h*i-L;
for k=1:N+1
elt(k,:)=[k,k+1];
end
end
10
function [A]=Assemblage(elt,x)
next=[2 1 2];
nt=length(elt);
ne=length(x);
A=zeros(ne,ne);
h=x(2)-x(1);
for k=1:nt
for k1=1:2
i1=elt(k,k1);
i2=elt(k,next(k1));
i3=elt(k,next(k1+1));
[phii,phixi]=BLGG(x(i1),x(i1),x(i2),x(i3));
for k2=1:2
j1=elt(k,k2);
j2=elt(k,next(k2));
j3=elt(k,next(k2+1));
[phij,phixj]=BLGG(x(j1),x(j1),x(j2),x(j3));
x1=h*phixi*phixj;
A(i1,j1)=A(i1,j1)+x1;
end
end
end
end
function [B]=SM(elt,x)
nt=length(elt);
ne=length(x);
h=x(2)-x(1);
11
B=zeros(ne,1);
for k=1:nt
% for k1=1:2
i1=elt(k,1);
i2=elt(k,2);
B(i1)=B(i1)+(2*f1(x(i1))+f1(x(i2)))*h/6;
B(i2)=B(i2)+(f1(x(i1))+2*f1(x(i2)))*h/6;
end
end
function [A,B]=LimitCond(A,B,x,elt)
cte=1e30;
nt=length(elt);
ili=elt(1,1);
ilf=elt(nt,2);
A(ili,ili)=cte;
B(ili)=cte*ue(x(ili));
A(ilf,ilf)=cte;
B(ilf)=cte*ue(x(ilf));
end
function y=f1(x)
y=-exp(x);
end
function [phi,phix]=BLGG(x,a,b,c)
if (a<=x && x<=b)
phi=(x-a)/(b-a);
phix=1/(b-a);
12
13