Variational Formulation
-
Upload
beverly-johns -
Category
Documents
-
view
82 -
download
0
description
Transcript of Variational Formulation
Variational Formulation
Weak Form
10H
on 0
in
u
fu
)1,0()1,0( )1,1(
PDEWith
BC
)( )(),(such that )( Find
10
10
HvvFvuaHu
where
fvdxdxvF
vdxdyuvua
)(
),(
BVP
Weak Formulation ( variational formulation)
on 0 in
ufu
)( )(),(such that )( Find
10
10
HvvFvuaHu
where
Multiply equation (1) by and then integrate over the domain
fvdxdydxdyuv
Green’s theorem gives
fvdxdyvdxdyudxdyn
uv
)1,0()1,0(
)(10 Hv
fvvu
fvdxdyvF
vdxdyuvua
)(
),(
)1,1(
Variational Formulation
Weak Formulation ( variational formulation)
)( )(),(such that )( Find
10
10
HvvFvuaHu
Infinite dimensional space
)(100, HVh
0,
0,
)(),(
such that Find
hhhhh
hh
VvvFvua
Vu
)(1
0 H 0,hV
} ,,, { 1321 spanVh
Finite dim subspaceSpace of all cont. pcw-linear
1312111050, ,,,, spanVh
Discrete Form Linear System
approximate u
131312121111101055 cccccuu h
1312111050, ,,,, spanVh
0,
0,
)(),(
such that Find
hhhhh
hh
VvvFvua
Vu
j
jjh cuu 13,12,11,10,5j
0, )(),( hhhhjjc VvvFvaj
,135,10,11,12 )(),( iiij
jjc Fa
vdxdyuvua ),(
,135,10,11,12 )(),( iij
ijj Fac
This is a linear system of 5 equations in 5 unknowns 131211105 ,,,, ccccc
)(),(
)(),(
)(),(
)(),(
)(),(
1313
1212
1111
1010
55
Fac
Fac
Fac
Fac
Fac
jjj
jjj
jjj
jjj
jjj
In expanded form
)(),(),(),(),(),(
)(),(),(),(),(),(
131313131312121311111310101355
551313512125111151010555
Facacacacac
Facacacacac
)F(
)F(
)F(
)F(
)F(
c13
c12
c11
c10
c5
*****13
*****12
*****11
*****10
*****5
131211105
13
12
11
10
5
In Matrix form
),( 1210 a dxdy1210
dxdyf 5
The approximate Solution
131312121111101055 cccccu
uu
h
h
)F(
)F(
)F(
)F(
)F(
c13
c12
c11
c10
c5
*****13
*****12
*****11
*****10
*****5
131211105
13
12
11
10
5
In Matrix form
),( 1210 a dxdy1210
dxdyf 5 Once this linear system is solved we obtain an approximation to the solution
Remark:
hu 13c5c
?),(2
1
2
1 hu ?),(4
1
4
3 hu13,10,5
?)(
j
jh Nu
Remark:
?),(8
1
2
1 hu
hu
12 13 5We are going to focus our attention in the efficient construction of this stiffness matrix
Sparsity
)F(
)F(
)F(
)F(
)F(
c13
c12
c11
c10
c5
*****13
*****12
*****11
*****10
*****5
131211105
13
12
11
10
5
In Matrix form
),( 1210 a dxdy1210
dxdyf 5
This matrix is sparse (many zeros) few non-zero entries
Remark:
0
dxdya 12101210 ),(
16
11210
sK s
dxdy
another example
312 triangles and 177nodes
Sparsity of the matrix# of nonzero =1153 %6.3
Use spy(A) to see sparsity
Sparsity
Local basis function and global basis function
Global basis function 512K
12 13
5125 K
If we restrict the function to the triangle K12 it becomes one of the local basis functions for K12
5
Matrix t
)12(?
K12 has 3 local basis functions )12(3
)12(2
)12(1 ,,
12345678910111213141516
1310111210111213555139678
41239678131011510111213
967812341011121213101112
Assembly of the Stiffness Matrix
)F(
)F(
)F(
)F(
)F(
c13
c12
c11
c10
c5
*****13
*****12
*****11
*****10
*****5
131211105
13
12
11
10
5
In Matrix form
),( 135 a dxdy135
dxdyf 5
This matrix is sparse (many zeros) few non-zero entries
Remark:
dxdya 135135 ),(
16
1135
sK s
dxdy
These few nonzero entries are computed by looping over all triangles
Remark:
129
135135 KKdxdydxdy
12345678910111213141516
1310111210111213555139678
41239678131011510111213
967812341011121213101112
129
)12(1
)12(2
)9(2
)9(1 KK
dxdydxdy
nonzero entry is a sum of integrals of local basis functions over a triangle
Remark:
Assembly of the Stiffness Matrix
Step1 primary stiffnes matrix
Step2 impose boundary condition
Loop over all triangles 1 -16. in each triangle, we calculate 3x3 matrix which involves calculating 9 integrals of all possible combination of local basis functions.
After we assemble the primary stiffness matrix in step1, we enforce the boundary condition by forcing the corresponding coefficient to be zero.
Step1 primary stiffnes matrix
find all gradients )(3
)(2
)(1 ,, kkk Step1a :
For k = 1 : 16
Find 9 integralsStep1b : K
ki
ki dxdy)()(
Add these contributions to the primary stiffness matrixStep1c :
End the loop
3,2,1, ji
K)( 1,1 yx
1
2
3 )( 3,3 yx
)( 2,2 yx
0
0
1
1
1
1
1
1
1
33
22
11
c
b
a
yx
yx
yx
)2/(
23
32
2332
1
1
1
K
xx
yy
yxyx
c
b
a
33
22
11
1
1
1
2
1
yx
yx
yx
K
0
1
0
1
1
1
2
2
2
33
22
11
c
b
a
yx
yx
yx
)2/(
31
13
3113
2
2
2
K
xx
yy
yxyx
c
b
a
1
0
0
1
1
1
3
3
3
33
22
11
c
b
a
yx
yx
yx
)2/(
12
21
1221
3
3
3
K
xx
yy
yxyx
c
b
a
ycxbaK111
)(1
ycxbaK222
)(2
ycxbaK333
)(3
)2/( K
xx
yy
yxyx
c
b
a
jk
kj
jkkj
i
i
i
with cyclic permutation of the index i,j k over 1,2,3
Find the gradients
K)( 1,1 yx
1
2
3 )( 3,3 yx
)( 2,2 yx
33
22
11
1
1
1
2
1
yx
yx
yx
K
ycxba iiiKi )(
)2/( K
xx
yy
yxyx
c
b
a
jk
kj
jkkj
i
i
i
with cyclic permutation of the index i,j k over 1,2,3
Find the gradients
function [area,b,c] = Gradients(x,y)area=polyarea(x,y);b=[y(2)-y(3); y(3)-y(1); y(1)-y(2)]/2/area;c=[x(3)-x(2); x(1)-x(3); x(2)-x(1)]/2/area;
i
iKi c
b)(
12345678910111213141516
1310111210111213555139678
41239678131011510111213
967812341011121213101112
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
Loop over all triangles 1 -16
9K
10
13
5)(2
1,
2
1
)(4
1,
4
3
)(4
3,
4
3
1
2
3
for example K9
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
Loop over all triangles 1 -16. for example K9
9K
10
13
5
)(2
1,
2
1
)(4
1,
4
3
)(4
3,
4
3
1
2
3
local basis functions)9(
3)9(
2)9(
1 ,,
Find gradient for each
ycxba jjjj )9(
cj
bjj
)9(
999
999
999
)9(3
)9(3
)9(3
)9(2
)9(3
)9(1
)9(2
)9(3
)9(2
)9(2
)9(2
)9(1
)9(1
)9(3
)9(1
)9(2
)9(1
)9(1
3
2
1
321
KKK
KKK
KKK
dxdydxdydxdy
dxdydxdydxdy
dxdydxdydxdy
Find 3x3 matrix
99 2
2
1
1)9(2
)9(1 KK
dxdyc
b
c
bdxdy
9
)( 2121 Kdxdyccbb
92121 )( Kccbb
9
)9(3
)9(2K
dxdyWe want to compute:
0
4)9(1
2
2)9(2
2
2)9(3
16/19 K
2
1
16
1 ))(8(
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
Loop over all triangles 1 -16. for example K9
9K
10
13
5
)(2
1,
2
1
)(4
1,
4
3
)(4
3,
4
3
1
2
3
local basis functions)9(
3)9(
2)9(
1 ,,
Find gradient for each
ycxba jjjj )9(
cj
bjj
)9(
999
99
99
)9(3
)9(3
)9(3
)9(2
)9(3
)9(1
)9(2
)9(3
)9(2
)9(22
1
)9(1
)9(32
1)9(1
)9(1
3
2
1
321
KKK
KK
KK
dxdydxdydxdy
dxdydxdy
dxdydxdy
Find 3x3 matrix
99 2
2
1
1)9(2
)9(1 KK
dxdyc
b
c
bdxdy
9
)( 2121 Kdxdyccbb
92121 )( Kccbb
9
)9(3
)9(2K
dxdyWe want to compute:
0
4)9(1
2
2)9(2
2
2)9(3
16/19 K
2
1
16
1 ))(8(
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
Loop over all triangles 1 -16. for example K9
9K
10
13
5
)(2
1,
2
1
)(4
1,
4
3
)(4
3,
4
3
1
2
3
local basis functions)9(
3)9(
2)9(
1 ,,
Find gradient for each
ycxba jjjj )9(
cj
bjj
)9(
2
1
2
12
1
2
12
1
2
1
03
02
11
321
Find 3x3 matrix
99 2
2
1
1)9(2
)9(1 KK
dxdyc
b
c
bdxdy
9
)( 2121 Kdxdyccbb
92121 )( Kccbb
9
)9(3
)9(2K
dxdyWe want to compute:
0
4)9(1
2
2)9(2
2
2)9(3
16/19 K
2
1
16
1 ))(8(
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
local basis functions
)9(3
)9(2
)9(1 ,,
Find gradient for each
ycxba jjjj )9(
cj
bjj
)9(
2
1
2
12
1
2
12
1
2
1
03
02
11
321
Find 3x3 matrix
99 2
2
1
1)9(2
)9(1 KK
dxdyc
b
c
bdxdy
9
)( 2121 Kdxdyccbb
92121 )( Kccbb
9
)9(3
)9(2K
dxdyWe want to compute:
0
4)9(1
2
2)9(2
2
2)9(3
16/19 K
2
1
16
1 ))(8(
Local to global
10
13
5 1
2
3
2
1
2
12
1
2
12
1
2
1
010
013
15
10135
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
local basis functions
)9(3
)9(2
)9(1 ,,
Find gradient for each
ycxba jjjj )9(
cj
bjj
)9(
2
1
2
12
1
2
12
1
2
1
03
02
11
321
Find 3x3 matrix
99 2
2
1
1)9(2
)9(1 KK
dxdyc
b
c
bdxdy
9
)( 2121 Kdxdyccbb
92121 )( Kccbb
9
)9(3
)9(2K
dxdyWe want to compute:
0
4)9(1
2
2)9(2
2
2)9(3
16/19 K
2
1
16
1 ))(8(
Local to global
10
13
5 1
2
3
2
1
2
12
1
2
12
1
2
1
010
013
15
10135
Step1 primary stiffnes matrix
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
)(
13
12
11
10
9
8
7
6
5
4
3
2
1
F
F
F
F
F
F
F
F
F
F
F
F
F
Loca
l to
glob
al 1 2 31 1 -1/2 -1/2 2 -1/2 1/2 0 3 -1/2 0 1/2
5 10 115 1 -1/2 -1/2 10 -1/2 1/2 0 11 -1/2 0 1/2
Triangle K10
K =1
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K =2
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K = 3
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K =4
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K =13
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K =14
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K =15
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
K =16
1/2 0 -1/2 0 1/2 -1/2 -1/2 -1/2 1
1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 4 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 -1 0 0 -1 -1 0 0 -1 0 -1 0 0 0 0 -1 -1 0
0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 -1 -1 0 0 0 -1 -1 0 0 2 0 0 0 -1 -1 0 0 2 0 0 0 -1 -1 0 0 2 -1 0 0 -1 0 0 -1 4 0 0 0-1 0 0 0 4 0 0-1 -1 0 0 0 4 0 0 -1 -1 0 0 0 4
Step1 primary stiffnes matrix
function A = StiffMat2D(p,t)np = size(p,2);nt = size(t,2);A = sparse(np,np);for K = 1:nt loc2glb = t(1:3,K); % local-to-global map x = p(1,loc2glb); % node x-coordinates y = p(2,loc2glb); % node y- [area,b,c] = Gradients(x,y); AK = (b*b'+c*c')*area; % element stiff mat A(loc2glb,loc2glb) = A(loc2glb,loc2glb)+ AK; % add element stiffnesses to Aend
12345678910111213141516
1310111210111213555139678
41239678131011510111213
967812341011121213101112
Assemble the Load vector L
)F(
)F(
)F(
)F(
)F(
c13
c12
c11
c10
c5
*****13
*****12
*****11
*****10
*****5
131211105
13
12
11
10
5
In Matrix form
),( 1210 a dxdy1210
dxdyf 5
dxdyf 5 K K
dxdyf 5
12
5
11
5
10
5
9
5
KKKK
dxdyfdxdyfdxdyfdxdyf
12345678910111213141516
1310111210111213555139678
41239678131011510111213
967812341011121213101112
12
)12(2
11
)11(1
10
)10(1
9
)9(1
KKKK
dxdyfdxdyfdxdyfdxdyf
Assembly of the Load Vector
Step1 primary Load vector
Step2 impose boundary condition
Loop over all triangles 1 -16. in each triangle, we calculate 3x1 matrix which involves calculating 3 integrals
After we assemble the primary load vector and stiffness matrix in step1, we enforce the boundary condition by forcing the corresponding coefficient to be zero.
The load vector b is assembled using the same technique as the primary stiffness matrix A, that is, by summing element load vectors BK over the mesh.
On each element K we get a local 3×1 element load vector BK with entries
BKi = ∫Kf φi dx; i = 1;2;3
Using node quadrature, we compute these integrals we end up with
BKi≈ 1/3f (Ni)|K|; i = 1;2;3
We summarize the computation of the load vector with the following Matlab code.