19.06.2015 Views

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.1 A Diffusion Problem and Its Discretization<br />

Our time-dependent model problem for teaching purposes is naturally the simplest<br />

extension of the Poisson problem into the time domain, i.e., the diffusion<br />

problem<br />

∂u<br />

∂t = ∇2 u+f in Ω, for t > 0, (64)<br />

u = u 0 on ∂Ω, for t > 0, (65)<br />

u = I at t = 0. (66)<br />

Here, u varies with space and time, e.g., u = u(x,y,t) if the spatial domain Ω is<br />

two-dimensional. The source function f and the boundary values u 0 may also<br />

vary with space and time. The initial condition I is a function of space only.<br />

A straightforward approach to solving time-dependent PDEs by the finite<br />

element method is to first discretize the time derivative by a finite difference<br />

approximation, which yields a recursive set of stationary problems, and then<br />

turn each stationary problem into a variational formulation.<br />

Let superscript k denote a quantity at time t k , where k is an integer counting<br />

time levels. For example, u k means u at time level k. A finite difference<br />

discretization in time first consists in sampling the PDE at some time level, say<br />

k:<br />

∂<br />

∂t uk = ∇ 2 u k +f k . (67)<br />

The time-derivative can be approximated by a finite difference. For simplicity<br />

and stability reasons we choose a simple backward difference:<br />

∂<br />

∂t uk ≈ uk −u k−1<br />

, (68)<br />

∆t<br />

where ∆t is the time discretization parameter. Inserting (68) in (67) yields<br />

u k −u k−1<br />

= ∇ 2 u k +f k . (69)<br />

∆t<br />

This is our time-discrete version of the diffusion PDE (64). Reordering (69) so<br />

that u k appears on the left-hand side only, shows that (69) is a recursive set of<br />

spatial(stationary)problemsforu k (assumingu k−1 isknownfromcomputations<br />

at the previous time level):<br />

u 0 = I, (70)<br />

u k −∆t∇ 2 u k = u k−1 +∆tf k , k = 1,2,... (71)<br />

Given I, we can solve for u 0 , u 1 , u 2 , and so on.<br />

We use a finite element method to solve the equations (70) and (71). This<br />

requires turning the equations into weak forms. As usual, we multiply by a<br />

test function v ∈ ˆV and integrate second-derivatives by parts. Introducing the<br />

symbol u for u k (which is natural in the program too), the resulting weak form<br />

59

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!