Professional Documents
Culture Documents
06 Finite Elements Basics
06 Finite Elements Basics
06 Finite Elements Basics
Basic formulation
Basis functions
Stiffness matrix
Poisson‘s equation
Regular grid
Boundary conditions
Irregular grid
Numerical Examples
Ax b |*y
yAx yb y n
We first look at Poisson’s equation
u ( x) f ( x)
where u is a scalar field, f is a source term and in 1-D
2
2 2
x
Finite element method 2
Poisson‘s equation
uv fv
... and integrate this equation over the whole domain. For
reasons of simplicity we define our physical domain D in the
interval [0, 1].
uv fv
Das Reh springt hoch,
das Reh springt weit,
D D
warum auch nicht,
1 1
uvdx fvdx es hat ja Zeit.
0 0
Domain D
The key idea in FE analysis is to approximate all functions in
terms of basis functions j, so that
N
u u~ cij i
i 1
Finite element method 4
Basis function
N
~
u u cij i i 1
where N is the number nodes in our physical domain and ci are real
constants.
0 0
1 1
( u )vdx vudx
0 0
uvdx fvdx
0 0
... with u being the unknown. This is also true for our
approximate numerical system
1 1
u
0
~vdx fvdx
0
... where ...
N
u~ cij i
i 1
0
u
~vdx fvdx
0
... remember that v was an arbitrary real function ...
if this is true for an arbitrary function it is also true if
v jj
0
u
~vdx fvdx
0
n
1 1
0
i 1
cij i j k dx f j k dx
0
n 1 1
c j j dx f j dx
i 1
i i k k
0 0
... probably not to your surprise this can be written in matrix form
bi Aik g k
A b gkT
ik i
Finite element method 10
The solution
... with the even less surprising solution
bi A T 1
ik gk
remember that while the bi’s are really the coefficients of the basis
functions these are the actual function values at node points i as well
because of our particular choice of basis functions.
10
... otherwise we are
free to choose any 9
function ...
8
To assemble the stiffness matrix we need the gradient (red) of the basis
functions (blue)
10
9
8
7
6
5
4
3
2
1
n 1 1
c j j dx f j dx
i 1
i i k k bi Aik g k
0 0
1
g k f j k dx
1
Aik j i j k dx
0 0
Note that ji are continuous functions defined in the interval [0,1], e.g.
x xi 1
x x for xi 1 x xi
i i 1
x x Let us – for now – assume a
j i ( x) i 1 for xi x xi 1
xi 1 xi
regular grid ... then
0 elsewhere
Finite element method 14
Stiffness matrix –regular grid
x xi 1 ~
x x for xi 1 x xi x
for dx ~
dx 1 x 0
i i 1 ~
x x x
j i ( x) i 1 for xi x xi 1 ~
j i ( x ) 1 for 0~
x dx
xi 1 xi dx
0 elsewhere 0 elsewhere
~
x x xi
dx xi xi 1
xi
dx
Finite element method 15
Regular grid - gradient
1 / dx for dx ~
x 0 ~
~ x x xi
j i ( x ) 1 / dx for 0 ~x dx
0 dx xi xi 1
elsewhere
ji
1/dx
xi
dx
-1/dx
Finite element method 16
Stifness matrix - elements
10
1 9
Aik j i j k dx
8
7
6
5
0 4
3
2
1
A22 j 2j 2 dx j j dx j j dx
2 2 2 2
0 x2 dx x2
0 dx
1 1 2
2
dx dx dx 2
dx
0
dx
dx
Aik j i j k dx
8
7
6
5
0 4
3
2
1
......and
and......
x1 dx x1 dx
1 1
1
A12 j1j 2 dx j j dx
1 2 dx
0 x1 x1
dx dx
1 1
dx
2
dx
0
dx
dx
A21 A12
Aik j i j k dx
8
7
6
5
0 4
3
2
1
1 1
1 2 1
Aij
1
dx
1 2 1
1 1
u ( x) f ( x)
... which we turned into the following formulation ...
n 1 1
c j j dx f j dx
i 1
i i k k
0 0
N N 1
u~ cij i with b.c. u~ cij i u (0)j1 u (1)j N
i 1 i 2
where u(0) and u(1) are the values at the boundaries of the domain [0,1].
How is this incorporated into the algorithm?
c j j dx f j dx
i i k k u ( x) f ( x)
i 1 0 0
c j j dx f j dx u(0) j j dx u(1) j j dx
i 2
i i k k 1 k n k
0 0 0 0
boundary condition
... the system feels the boundary conditions through the (modified) source term
A=zeros(nx);
0.15
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
% Quelle
0.25
s=(1:nx)*0;s(nx/2)=1.;
% Randwert links u_1 int{ nabla phi_1 nabla
u(x)
0.2
Matlab FD code (red) phij }
u1=0.15;
0.15 s(2) =u1/dx;
% Randwert links u_nx int{ nabla phi_nx nabla
phij0.1
}
unx=0.05; s(nx-1)=unx/dx;
Matlab FEM code (blue)
0.05
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
10
9
1
Aik j i j k dx
8
6
0 5
x1 h1 x1 h1
1 1
1
A12 j1j 2 dx j1j 2dx dx
0 x1 x1
h1 h1
1 1 1
h
2 dx A21
h1 0 h1 i=1 2 3 4 5 6 7
1 1 + + + + + + +
Aii h1 h2 h3 h4 h5 h6
hi 1 hi
Finite element method 25
Example
Stiffness matrix A
u ( x) f ( x) for i=2:nx-1,
for j=2:nx-1,
if i==j,
A(i,j)=1/h(i-1)+1/h(i);
Domain: [0,1]; nx=100; elseif i==j+1
dx=1/(nx-1);f(x)=d(1/2)
Boundary conditions: A(i,j)=-1/h(i-1);
u(0)=u0; u(1)=u1 elseif i+1==j
A(i,j)=-1/h(i);
else
A(i,j)=0;
i=1 2 3 4 5 6 7 end
+ + + + + + + end
h1 h2 h3 h4 h5 h6 end
0.3
0.25
Matlab FD code (red)
u(x)
0.2
0.15
0.05
0
+ FEM grid points 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
The solution for the values at the nodes for some partial
differential equations can be obtained by solving a linear
system of equations involving the inversion of (sometimes
sparse) matrices.