1
Out
line
Fini
te E
lem
ent M
etho
d in
2-D
–B
ound
ary-
Val
ue P
robl
em–
Equi
vale
nt V
aria
tiona
lPro
blem
–FE
M A
naly
sis
•D
omai
n D
iscr
etiz
atio
n•
Elem
ent I
nter
pola
tion
•Fo
rmul
atio
n of
the
Syst
em o
f Equ
atio
ns•
A. E
lem
enta
l equ
atio
ns•
B. A
ssem
bly
•C
. Inc
orpo
ratio
n of
the
Third
-kin
d B
ound
ary
Con
ditio
n•
D. I
mpo
se th
e D
irich
letB
ound
ary
Con
ditio
n•
Solu
tion
of th
e Sy
stem
of E
quat
ions
Sam
ple
Prog
ram
App
licat
ions
2
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
mc.....Input data description
c
c nn
total number of nodes
c For i = 1 to nn, input:
c x(i) x-coordinate
c y(i) y-coordinate
c end for
c
c ne total number of elements
c For e = 1 to ne, input:
c alpha(e) value of alpha
c beta(e) value of beta
c f(e) value of f
c For i = 1 to 3, input:
c n(i,e) global node number
c end for
c end for
169
3
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
mc
c n1 number of nodes with prescribed values
c For i = 1 to n1, input:
c p(i) prescribed value of phi
c nd(i) global node number
c end for
c c ns number of segments on Gamma_2
c For s = 1 to ns, input:
cgamma(s) value of gamma
c q(s) value of q
c For i = 1 to 2, input
C ns(i,s) global node number
c end for
c end for
170
4
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
m
c.....Initialize the matrix [K]
do 1 i = 1, nn
do 1 j = 1, nn
1 k(i,j) = 0.
C c.....Start to assemble all area elements in Omega
do 4 e = 1, ne
171
5
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
m
c..... Calculate b^e_i and c^e_i (i=1,2,3)
i = n(1,e)
j = n(2,e)
m = n(3,e)
be(1) = y(j) -
y(m)
be(2) = y(m) -
y(i)
be(3) = y(i) -
y(j)
ce(1) = x(m) -
x(j)
ce(2) = x(i) -
x(m)
ce(3) = x(j) -
x(i)
C c..... Calculate Delta^e
deltae
= 0.5*(be(1)*ce(2)-be(2)*ce(1))
172
6
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
mc..... Generate the elemental matrix [K^e]
do 2 i = 1, 3
do 2 j = 1, 3
if (i.eq.j) then
del_ij
= 1.0
else
del_ij
= 0.0
endif
2 ke(i,j) = alphax(e)*(be(i)*be(j)
&+ ce(i)*ce(j))/(4.0*deltae)
&+ beta(e)*(1.+del_ij)*deltae/12.
c c..... Add [K^e] to [K]
do 3 i = 1, 3
do 3 j = 1, 3
3 k(n(i,e),n(j,e)) = k(n(i,e),n(j,e))+ke(i,j)
c4 continue
173
7
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
m
c.....Start to assemble all line segments on
Gamma_2
do 6 s = 1, ns
c.....Calculate the length of each segment
i = ns(1,s)
j = ns(2,s)
ls
= sqrt((x(i)-x(j))**2+(y(i)-y(j))**2)
c.....Compute [K^s]
ks(1,1) = gamma(s)*ls/3
ks(1,2) = gamma(s)*ls/6
ks(2,1) = ks(1,2)
ks(2,2) = ks(1,1)
c.....Add [K^s] to [K]
do 5 i = 1, 2
do 5 j = 1, 2
5 k(ns(i,s), ns(j,s))=k(ns(i,s), ns(j,s))
& +ks(i,j)
6 continue
174
8
FEM
Ana
lysi
s –Sa
mpl
e Pr
ogra
m
c.....Impose the Dirichlet
boundary condition
do 8 i = 1, n1
b(nd(i)) = p(i)
k(nd(i),nd(i)) = 1.
do 7 j = 1, nn
if(j.eq.nd(i)) go to 7
b(j) = b(j) -
k(j,nd(i))*p(i)
k(nd(i),j) = 0.
k(j,nd(i)) = 0.
7 continue
8 continue
175
10
Elec
trost
atic
Pro
blem
sPa
rtial
diff
eren
tial e
quat
ion:
Bou
ndar
y co
nditi
ons:
Con
tinui
ty c
ondi
tions
:
177
13
Elec
trost
atic
Pro
blem
s
Axi
sym
met
ric(b
ody
of re
volu
tion)
:
180
0
,,
,c
rx
yz
fρ
ρα
ερ
ρε
==
==