Vous êtes sur la page 1sur 58

Introduction to the Mathematics of the Finite Element Method

Kathryn Gillow
22nd January 2007

Introduction to the Mathematics of the Finite Element Method p. 1/33

FEM Motivation
Partial differential equations model a wide range of problems in biological and physical sciences.

Introduction to the Mathematics of the Finite Element Method p. 2/33

FEM Motivation
Partial differential equations model a wide range of problems in biological and physical sciences. The most interesting (and realistic) PDE models are typically complex and cannot be solved analytically.

Introduction to the Mathematics of the Finite Element Method p. 2/33

FEM Motivation
Partial differential equations model a wide range of problems in biological and physical sciences. The most interesting (and realistic) PDE models are typically complex and cannot be solved analytically. Need to resort to numerical methods to get an approximate solution to the PDE.

Introduction to the Mathematics of the Finite Element Method p. 2/33

Finite Element vs Finite Difference Methods


Finite element methods handle complex geometries more easily;

Introduction to the Mathematics of the Finite Element Method p. 3/33

Finite Element vs Finite Difference Methods


Finite element methods handle complex geometries more easily; handle boundary conditions in a systematic way;

Introduction to the Mathematics of the Finite Element Method p. 3/33

Finite Element vs Finite Difference Methods


Finite element methods handle complex geometries more easily; handle boundary conditions in a systematic way; treat nonlinearities more easily;

Introduction to the Mathematics of the Finite Element Method p. 3/33

Finite Element vs Finite Difference Methods


Finite element methods handle complex geometries more easily; handle boundary conditions in a systematic way; treat nonlinearities more easily; are built on a rigorous mathematical framework which allows algorithms to compute the solution to within a prescribed error tolerance;

Introduction to the Mathematics of the Finite Element Method p. 3/33

Finite Element vs Finite Difference Methods


Finite element methods handle complex geometries more easily; handle boundary conditions in a systematic way; treat nonlinearities more easily; are built on a rigorous mathematical framework which allows algorithms to compute the solution to within a prescribed error tolerance; are slightly more complex / less intuitive (at least at rst).

Introduction to the Mathematics of the Finite Element Method p. 3/33

Model D Problem
Consider the ODE
        

Introduction to the Mathematics of the Finite Element Method p. 4/33

Model D Problem
Consider the ODE
        

Also need boundary conditions at

Introduction to the Mathematics of the Finite Element Method p. 4/33

 

Model D Problem
Consider the ODE
        

Also need boundary conditions at


 

prescribe solution value, Dirichlet boundary condition; e.g.

Introduction to the Mathematics of the Finite Element Method p. 4/33

 

Model D Problem
Consider the ODE
        

Also need boundary conditions at


 

prescribe solution value, Dirichlet boundary condition; e.g. prescribe ux of solution value, Neumann boundary condition; e.g.
  

Introduction to the Mathematics of the Finite Element Method p. 4/33

 

Model D Problem
Consider the ODE
        

Also need boundary conditions at


 

prescribe solution value, Dirichlet boundary condition; e.g. prescribe ux of solution value, Neumann boundary condition; e.g.
  

prescribe combination of both, mixed or Robin e.g. boundary condition.


  

Introduction to the Mathematics of the Finite Element Method p. 4/33

 

Weak Formulation
(Also known as variational formulation or integral form.) Idea: multiply the equation by a (test) function and integrate over the range of interest. Gives

Introduction to the Mathematics of the Finite Element Method p. 5/33

Weak Formulation
(Also known as variational formulation or integral form.) Idea: multiply the equation by a (test) function and integrate over the range of interest. Gives

Integrate rst term on left by parts to get


Introduction to the Mathematics of the Finite Element Method p. 5/33

Weak Formulation: Dirichlet B.C.s


We have
      
Introduction to the Mathematics of the Finite Element Method p. 6/33

 


 

Weak Formulation: Dirichlet B.C.s

for all

We have

Suppose and then we choose and . Then the weak formulation is: nd such that , and


with


   

and

 

 

  

 

Introduction to the Mathematics of the Finite Element Method p. 6/33

Weak Formulation: Neumann B.C.s


We have
      
Introduction to the Mathematics of the Finite Element Method p. 7/33

 

We have

Suppose

  

 

and

 


 

 

    

Weak Formulation: Neumann B.C.s

then we have

Introduction to the Mathematics of the Finite Element Method p. 7/33

We have

Weak Formulation: Neumann B.C.s

for all .

Suppose

  

  

 

and




Thus the weak formulation is: nd

 

 



 

such that


 

then we have

 

Introduction to the Mathematics of the Finite Element Method p. 7/33

Weak Formulation: Robin B.C.s


We have
      
Introduction to the Mathematics of the Finite Element Method p. 8/33

 

Suppose have

Weak Formulation: Robin B.C.s

if

 

We have

 

 

   

   

 

and

 

 

   

then we

Introduction to the Mathematics of the Finite Element Method p. 8/33

Weak Formulation: Robin B.C.s contd


Thus the weak formulation is: nd

such that

and

for all

with

Introduction to the Mathematics of the Finite Element Method p. 9/33

The Finite Element Method


Look for an approximate solution to the integral form of the problem.

Introduction to the Mathematics of the Finite Element Method p. 10/33

The Finite Element Method


Look for an approximate solution to the integral form of the problem.

into subintervals FEM idea: split the interval (elements) and approximate the solution by a polynomial on each subinterval.
 

Nodes:

  

Introduction to the Mathematics of the Finite Element Method p. 10/33

Piecewise Linear Finite Elements


Easiest to approximate the solution by a linear polynomial (straight line) in each element, e.g.

Introduction to the Mathematics of the Finite Element Method p. 11/33

Piecewise Linear Basis Functions


We dene

  






otherwise

1
   

0
   

Introduction to the Mathematics of the Finite Element Method p. 12/33

The Finite Element Method


We let



and take for (Note the unknowns solution at the nodes


in . are the values of the nite element .)

 



Introduction to the Mathematics of the Finite Element Method p. 13/33

The Finite Element Method


This gives


i.e.

 



This may be rewritten as a matrix system is the vector of unknowns and

where

Introduction to the Mathematics of the Finite Element Method p. 14/33

Example
  

Let

and

so we solve

in

with boundary conditions and . The exact solution is . The weak formulation is to nd such that and

for all

with

Introduction to the Mathematics of the Finite Element Method p. 15/33

Element Load Vectors


Can work out entries in and element by element. Recall and . Let



and

is the element load vector.

Introduction to the Mathematics of the Finite Element Method p. 16/33

From

. . .

 

   

 

we get

 




Global Load Vector


 

 

Introduction to the Mathematics of the Finite Element Method p. 17/33

Global Load Vector


Hence
 

. . .
   


Introduction to the Mathematics of the Finite Element Method p. 18/33

Global Load Vector


Introduction to the Mathematics of the Finite Element Method p. 19/33

Gives


Similarly

 

 

  








 

 

and
  

This is the element stiffness matrix.

 

Element Stiffness Matrices

  




so let


Introduction to the Mathematics of the Finite Element Method p. 20/33

Global Stiffness Matrix


In general

 

Also

etc.

Introduction to the Mathematics of the Finite Element Method p. 21/33

 

Global stiffness matrix is

...

 

     

Global Stiffness Matrix

...
   





 

 

...

Introduction to the Mathematics of the Finite Element Method p. 22/33

Global Stiffness Matrix


Introduction to the Mathematics of the Finite Element Method p. 23/33

Apply Dirichlet Boundary Condition

Since we require we have that corresponds to removing rst column from matrix problem.

Introduction to the Mathematics of the Finite Element Method p. 24/33

Apply Dirichlet Boundary Condition

Since we require we have that corresponds to removing rst column from matrix problem.

we should Since the test functions must satisfy not use corresponds to removing rst row from matrix.

Introduction to the Mathematics of the Finite Element Method p. 24/33

Apply Dirichlet Boundary Condition

Since we require we have that corresponds to removing rst column from matrix problem.

we should Since the test functions must satisfy not use corresponds to removing rst row from matrix.

Now we have a matrix problem solved to nd the unknown coefcients


which can be , .


 

Introduction to the Mathematics of the Finite Element Method p. 24/33



Matlab Code

% solve -u=1 on (0,1) with u(0)=0 and u(1)=0 using FEM N=4; % number of elements x=linspace(0,1,N+1); % set up mesh h=1/N; % h=constant mesh size K=zeros(N+1,N+1); % set up empty stiffness matrix f=zeros(N+1,1); % set up global load vector for i=1:N % loop over elements Kele=[1 -1;-1 1]/h; % compute entries in element stiffness matrix fele=[h/2;h/2]; % compute entries in element load vector K(i:i+1,i:i+1)=K(i:i+1,i:i+1)+Kele; % add to global stiffness matrix f(i:i+1)=f(i:i+1)+fele; % add to global load vector end K(1,:)=[]; % apply Dirichlet boundary condition by K(:,1)=[]; % removing first row and column of stiffness matr f(1)=[]; % and first row of load vector U=K\f; % compute solution to matrix problem U=[0;U]; % add value at x=0 to solution vector plot(x,U,rx-) % plot solution hold on fplot(x-0.5*x2,[0,1],b) % plot exact solution
Introduction to the Mathematics of the Finite Element Method p. 25/33

Results
0.5 FEM solution exact solution

0.4

0.3

0.2

0.1

0 0

0.2

0.4

0.6

0.8

Introduction to the Mathematics of the Finite Element Method p. 26/33

References
K ENNETH E RIKSSON , D ON E STEP, P ETER H ANSBO & C LAES J OHNSON . Computational Differential Equations. CUP 1996. J.N. R EDDY. An Introduction to the Finite Element Method. McGraw Hill 1993. E NDRE S LI . Finite Element Methods for Partial Differential Equations. See
http://web.comlab.ox.ac.uk/oucl/work/endre.suli/fem.ps

Introduction to the Mathematics of the Finite Element Method p. 27/33

1.5

0.5 2

2D Example

0.5

1.5

 
 

 

 

 


 

Introduction to the Mathematics of the Finite Element Method p. 28/33

2D Example: Solution Steps


Find the weak formulation of the problem.

Introduction to the Mathematics of the Finite Element Method p. 29/33

2D Example: Solution Steps


Find the weak formulation of the problem. Set up the nite element mesh.

Introduction to the Mathematics of the Finite Element Method p. 29/33

2D Example: Solution Steps


Find the weak formulation of the problem. Set up the nite element mesh. Work out the element stiffness matrices and load vectors.

Introduction to the Mathematics of the Finite Element Method p. 29/33

2D Example: Solution Steps


Find the weak formulation of the problem. Set up the nite element mesh. Work out the element stiffness matrices and load vectors. Assemble the full stiffness matrix and load vector.

Introduction to the Mathematics of the Finite Element Method p. 29/33

2D Example: Solution Steps


Find the weak formulation of the problem. Set up the nite element mesh. Work out the element stiffness matrices and load vectors. Assemble the full stiffness matrix and load vector. Solve the linear system.

Introduction to the Mathematics of the Finite Element Method p. 29/33

2D Weak Formulation
As before we multiply by interest to get

and integrate over region of

Introduction to the Mathematics of the Finite Element Method p. 30/33

2D Weak Formulation
As before we multiply by interest to get

and integrate over region of

Using Greens theorem (multi-dimensional version of integration by parts) gives

Introduction to the Mathematics of the Finite Element Method p. 30/33

2D Weak Formulation contd


Weak formulation: nd conditions such that

satisfying the Dirichlet boundary

for all functions

which are zero on the boundary.

Introduction to the Mathematics of the Finite Element Method p. 31/33

2D Weak Formulation contd


Weak formulation: nd conditions such that

satisfying the Dirichlet boundary

for all functions

which are zero on the boundary.

This might look a bit complicated but . . .

Introduction to the Mathematics of the Finite Element Method p. 31/33

2D Weak Formulation contd


Weak formulation: nd conditions such that

satisfying the Dirichlet boundary

for all functions

which are zero on the boundary.

This might look a bit complicated but . . . . . . fortunately there are software packages which will do it all for you!!

Introduction to the Mathematics of the Finite Element Method p. 31/33

2D Example: Solution
2

1.8

1.6

1.4
1.5

1.2
1

0.8

0.5

0.6
0 2

0.4
1.5 2 1 1 0.5 0.5 0 0 1.5

0.2

0.2

0.4

0.6

0.8

1.2

1.4

1.6

1.8

Introduction to the Mathematics of the Finite Element Method p. 32/33

2D Adaptive Example
2

1.8

0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 2 1.5 1 1 0.5 0 0 0.5 1.5 2

1.6

1.4

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

1.4

1.6

1.8

Introduction to the Mathematics of the Finite Element Method p. 33/33

Vous aimerez peut-être aussi