You are on page 1of 21

DISCRETIZATION OF PARTIAL DIFFERENTIAL

EQUATIONS
Goal: to show how partial dierential lead to sparse linear
systems
See Chap. 2 of text
Finite dierence methods
Finite elements
Assembled and unassembled nite element matrices
Why study discretized PDEs?
Still the most important source of sparse linear systems
Will help understand the structures of the problem and
their connections with meshes in 2-D or 3-D space
Also: iterative methods are often formulated for the
PDE directly instead of a discretized (sparse) system.
40 Csci 8314 January 25, 2012
A typical numerical simulation
Physical Problem

Nonlinear PDEs

Discretization

Linearization (Newton)

Sequence of Sparse Linear Systems Ax = b


41 Csci 8314 January 25, 2012
Example: discretized Poisson equation
Common Partial Dierential Equation (PDE) :

2
u
x
2
1
+

2
u
x
2
2
= f, for x =
_
x
1
x
2
_
in
where = bounded, open domain in R
2
.
x
x
1
2

n
+ boundary conditions:
Dirichlet: u(x) = (x)
Neumann:
u
n
(x) = 0
Cauchy:
u
n
+ (x)u =
=

2
x
2
1
+

2
x
2
2
is the Laplace operator or Laplacean
42 Csci 8314 January 25, 2012
Discretization of PDEs - Basic approximations
Formulas derived from Taylor series expansion:
u(x + h) = u(x) + h
du
dx
+
h
2
2
d
2
u
dx
2
+
h
3
6
d
3
u
dx
3
+
h
4
24
d
4
u
dx
4
()
Simplest scheme: forward dierence
du
dx
=
u(x + h) u(x)
h

h
2
d
2
u(x)
dx
2
+ O(h
2
)

u(x + h) u(x)
h
Centered dierences for second derivative:
d
2
u(x)
dx
2
=
u(x + h) 2u(x) + u(x h)
h
2

h
2
12
d
4
u()
dx
4
,
where


+
.
43 Csci 8314 January 25, 2012
Notation:

+
u(x) = u(x + h) u(x)

u(x) = u(x) u(x h)


Operations of the type:
d
dx
_
a(x)
d
dx
_
are very common [in-homogeneous media].
The following is a second order approximation:
d
dx
_
a(x)
du
dx
_
=
1
h
2

+
_
a
i
1
2

u
_
+ O(h
2
)

a
i+
1
2
(u
i+1
u
i
) a
i
1
2
(u
i
u
i1
)
h
2
Show that
+
_
a
i
1
2

u
_
=

_
a
i+
1
2

+
u
_
44 Csci 8314 January 25, 2012
Finite Dierences for 2-D Problems
Consider the simple problem,

2
u
x
2
1
+

2
u
x
2
2
_
= f in (1)
u = 0 on (2)
= rectangle (0, l
1
) (0, l
2
) and its boundary.
Discretize uniformly :
x
1,i
= i h
1
i = 0, . . . , n
1
+ 1 h
1
=
l
1
n
1
+ 1
x
2,j
= j h
2
j = 0, . . . , n
2
+ 1 h
2
=
l
2
n
2
+ 1
45 Csci 8314 January 25, 2012
Finite Dierence Scheme for the Laplacean
Using centered dierences for both the

2
x
2
1
and

2
x
2
2
terms
- with mesh sizes h
1
= h
2
= h :
u(x)
1
h
2
[u(x
1
+ h, x
2
) + u(x
1
h, x
2
)+
+u(x
1
, x
2
+ h) + u(x
1
, x
2
h) 4u(x
1
, x
2
)]
1
1 -4 1
1
The ve-point stencil
46 Csci 8314 January 25, 2012
The resulting matrix has the following block structure:
A =
1
h
2
_
_
B I
I B I
I B
_
_
Matrix for 7 5 nite
dierence mesh
With
B =
_
_
_
_
_
_
_
4 1
1 4 1
1 4 1
1 4 1
1 4
_
_
_
_
_
_
_
.
47 Csci 8314 January 25, 2012
Finite Elements: a quick overview
Background: Greens formula
_

v.u dx =
_

vu dx +
_

v
u
n
ds.
= gradient operator. In 2-D:
u =
_
u
x
1
u
x
2
_
,
The dot indicates a dot product of two vectors.
u = Laplacean of u
n is the unit vector that is normal to and directed
outwards.
Frechet derivative:
u
v
(x) = lim
h0
u(x + hv) u(x)
h
Greens formula generalizes the usual formula for inte-
gration by parts
Dene
a(u, v)
_

u.v dx =
_

_
u
x
1
v
x
1
+
u
x
2
v
x
2
_
dx
(f, v)
_

fv dx.
Denote:
(u, v) =
_

u(x)v(x)dx,
49 Csci 8314 January 25, 2012
With Dirichlet BC, the integral on the boundary in
Greens formula vanishes
a(u, v) = (u, v).
Weak formulation of the original problem: select a
subspace of reference V of L
2
and then solve
Find u V such that a(u, v) = (f, v), v V
Finite Element method solves this weak problem...
... by discretization
50 Csci 8314 January 25, 2012
The original domain is approximated by the union
h
of
m triangles K
i
,
Triangulation of

h
=
m
_
i=1
K
i
.
Some resitrictions on angles,
edges, etc..
V
h
= { |
|
h
continuous
|
h
= 0,
|K
j
linear j}

|X
== restriction of to the subset X
Let x
j
, j = 1, . . . , n == the nodes of the triangulation
51 Csci 8314 January 25, 2012
Can dene a (unique) hat function
j
in V
h
associated
with each x
j
s.t.:

j
(x
i
) =
ij
=
_
1 if x
i
= x
j
0 if x
i
= x
j
.
Each function u of V
h
can be expressed as
u(x) =
n

i=1

i
(x). ()
The nite element approximation consists of writing the
Galerkin condition for functions in V
h
:
Find u V
h
such that a(u, v) = (f, v), v V
h
Express u in the basis {
i
} (see *), then substitute
above
52 Csci 8314 January 25, 2012
Result: the linear system
n

j=1

ij

i
=
i
where

ij
= a(
i
,
j
),
i
= (f,
i
).
The above equations form a linear system of equations
Ax = b
A is Symmetric Positive Denite
Prove it
53 Csci 8314 January 25, 2012
The Assembly Process: Illustration
If triangle K does
not belong to
*both* nonzero
domains of
i
and
j
then
a
K
(
i
,
j
) = 0
i
j
l
k
m
If triangle K be-
longs to *both*
nonzero domains
of
i
and
j
then
a
K
(
i
,
j
) = 0
l
k
l
k
m
So: a
K
(
i
,
j
) = 0 i i {k, l, m} and j {k, l, m}.
54 Csci 8314 January 25, 2012
The Assembly Process
FEM mesh
1
2 3
4 5
6
1
2
3
4
Assembled matrix
1 2 3 4 5 6
1
2
3
4
5
6
A simple nite element mesh and the pattern of the corre-
sponding assembled matrix.
A
[1]
A
[2]
A
[3]
A
[4]
The element matrices A
[e]
, e = 1, . . . , 4 for the nite
element mesh shown above
Can view each element as contributing a 33 submatrix
A
[e]
to A - (spread out)
Can use the matrix in un-assembled form - To multiply
a vector by A for example we can do
y = Ax =
nel

e=1
A
[e]
x =
nel

e=1
P
e
A
K
e
(P
T
e
x).
56 Csci 8314 January 25, 2012
Can be computed using the element matrices A
K
e
- no
need to assemble
The product P
T
e
x gathers x data associated with the
e-element into a 3-vector consistent with the ordering of
the matrix A
K
e
.
Advantage: some simplication in process
Disadvantage: cost (memory + computations).
57 Csci 8314 January 25, 2012
Resources: A few matlab scripts
These (and others) will be posted in the resources page
in class web-site
>> help fd3d
function A = fd3d(nx,ny,nz,alpx,alpy,alpz,dshift)
NOTE nx and ny must be > 1 -- nz can be == 1.
5- or 7-point block-Diffusion/conv. matrix. with
A stripped-down version is lap2D(nx,ny)
>> help mark
[A] = mark(m)
generates a Markov chain matrix for a random walk
on a triangular grid. A is sparse of size n=m*(m+1)/2
58 Csci 8314 January 25, 2012
Explore A few useful matlab functions
* kron
* gplot for ploting graphs
* reshape for going from say 1-D to 2-D or 3-D arrays
Write a script to generate a 9-point discretization of
the Laplacean.
59 Csci 8314 January 25, 2012

You might also like