Finite Difference, Finite Element and Finite Volume Methods for the Numerical Solution of PDEs

Vrushali A. Bokil bokilv@math.oregonstate.edu
and

Nathan L. Gibson gibsonn@math.oregonstate.edu Department of Mathematics Oregon State University Corvallis, OR DOE Multiscale Summer School June 30, 2007

Multiscale Summer School – p. 1/8

Math Modeling and Simulation of Physical Processes

Define the physical problem Create a mathematical model
• •

Systems of PDEs, ODEs, algebraic equations Define initial and or boundary conditions to get a well-posed problem Discretize the domain → generate the grid → obtain discrete model Solve the discrete system Consistency, stability and convergence analysis

Create a discrete (numerical) model

• •

Analyze errors in the discrete system

Multiscale Summer School – p. 2/8

Contents
• •

• •

• •

Partial Differential Equations (PDEs) Conservation Laws: Integral and Differential Forms Classification of PDEs: Elliptic, Parabolic and Hyperbolic Finite Difference Methods Analysis of Numerical Schemes: Consistency, Stability, Convergence Finite Volume and Finite Element Methods Iterative Methods for Large Sparse Linear Systems

Multiscale Summer School – p. 3/8

Partial Differential Equations

PDEs: Mathematical models of continuous physical phenomenon in which a dependent variable, say u, is a function of more than one independent variable, say t (time), and x (eg., spatial position). Conservation Laws: PDEs derived by applying a physical principle such as conservation of mass, momentum or energy. These equations, govern the kinematic and mechanical behavior of general bodies. These laws can be written in either the strong or differential form, or an integral form. Well Posed Problem: Solution exits, is unique and depends continuously on the data. Boundary conditions on the (finite) boundary of the domain and/or initial conditions are required to obtain a well posed problem.

Multiscale Summer School – p. 4/8

for example • ut = ∂u ∂t • uxy = ∂2u ∂x∂y Multiscale Summer School – p. 5/8 . or • One space variable denoted by x and one time variable denoted by t Partial derivatives with respect to independent variables are denoted by subscripts. we will deal only with single PDEs (as opposed to systems of several PDEs) with only two independent variables. denoted by x and y.PDEs (continued) • • For simplicity. • Either two space variables.

6/8 .Well Posed Problems • Boundary conditions.e. i. conditions on the (finite) boundary of the domain and/or initial conditions (for transient problems) are required to obtain a well posed problem.. Properties of a well posed problem: • Solution exists • • • Solution is unique Solution depends continuously on the data Multiscale Summer School – p.

Classifications of PDEs • • The Order of a PDE = the highest-order partial derivative appearing in it. 7/8 . • The Heat equation ut = uxx is a second order PDE. Multiscale Summer School – p. • The advection equation ut + ux = 0 is a first order PDE. For example. For example • The advection equation ut + ux = 0 is a linear PDE. A PDE is linear if the coefficients of the partial derivatives are not functions of u. • The Burgers equation ut + uux = 0 is a nonlinear PDE.

Classifications of PDEs (continued)
Second-order linear PDEs in general form auxx + buxy + cuyy + dux + euy + f u + g = 0 are classified based on the value of the discriminant b2 − 4ac • b2 − 4ac > 0: hyperbolic • e.g., wave equation : u − u tt xx = 0 • Hyperbolic PDEs describe time-dependent, conservative physical processes, such as convection, that are not evolving toward steady state.

b2 − 4ac = 0: parabolic • e.g., heat equation utt − uxx = 0 • Parabolic PDEs describe time-dependent dissipative physical processes, such as diffusion, that are evolving toward steady state. b2 − 4ac < 0: elliptic • e.g., Laplace equation: uxx + uyy = 0 • Elliptic PDEs describe processes that have already reached steady states, and hence are time-independent.

Multiscale Summer School – p. 8/8

Parabolic PDEs: Initial-Boundary value problems

Example: One dimensional (in space) Heat Equation for u = u(t, x) ut = κuxx , 0 ≤ x ≤ A, t ≥ 0 The diffusion coefficient κ > 0 is a constant.

with
• •

Boundary conditions: u(t, 0) = u0 , u(t, A) = uA , and Initial conditions: u(0, x) = g(x)
t

domain of influence

tq

q
domain of dependence

0 0 xq A

x

Multiscale Summer School – p. 9/8

Elliptic PDEs: Boundary value problems

Example: Model of steady heat conduction in a two dimensional (in space) domain, governed by the Laplace equation for the temperature T = T (x, y) Txx + Tyy = 0, 0 ≤ x ≤ W, 0 ≤ y ≤ H

with boundary conditions
• •

T (x, 0) = T1 , T (x, H) = T2 T (0, y) = T3 , T (W, y) = T4
y H T3 yq q 0 0 T1 xq W x T4 T2

Multiscale Summer School – p. 10/8

Hyperbolic PDEs: Initial-Boundary value problems

Example: One-dimensional (in space) wave equation for u = u(t, x) utt = c2 uxx , 0 ≤ x ≤ L, t ≥ 0

with boundary conditions
• •

Boundary conditions u(t, 0) = u0 , u(t, L) = uL Initial Conditions u(0, x) = f (x), ut (0, x) = g(x)
t
domain of influence

tq

q
slope = slope =

+c

–c

0 0

domain of dependence

xq

L

x

Multiscale Summer School – p. 11/8

2. 1. x1 . ∀j x xm+1 = L xm q 0 = x0 q x1 q x2 q . . . L]. T ] into discrete time levels tn with time step ∆t. L] into m + 2 grid points x0 .Finite Difference Methods (FDM): Discretization Suppose that we are solving for u = u(t. T ] × [0. . we have ∆x = ∆xj . ∆x ' E • We similarly discretize the temporal domain [0. such that ∆xj = xj+1 − xj .. . 12/8 . . xj−1 xj xj+1 .. . xm+1 = L. xm . . x) on the domain Ω = [0. j = 0. . . . m • In the case that the m + 2 spatial points xj are equally spaced. . Multiscale Summer School – p. • We discretize the domain Ω by partitioning the spatial interval [0. q q q q q q q E .

xj ) • Thus. n n • The boundary conditions determine the values of U0 and Um+1 for all n. . U2 . 13/8 . Um ] at each time level tn . .Finite Difference Methods: Discretization • The numerical solution to the PDE is an approximation to the exact solution that is obtained using a discrete representation to the PDE at the grid points xj in the discrete spatial mesh at every time level tn . Multiscale Summer School – p. The initial conditions determine the values of U 0 at each spatial grid point. the numerical solution is a collection of finite values. Let us denote this numerical solution as U such that n Uj ≈ u(tn . . n n n U n = [U1 . .

we approximate ux (xj ) ≈ u(xj + h) − u(xj ) (Forward difference) h u(xj ) − u(xj − h) ≈ (Backward difference) h u(xj + h) − u(xj − h) (Centered difference) ≈ 2h Multiscale Summer School – p. i.Finite Difference Methods (continued) • Recall the definition of the derivative from introductory Calculus: ux (xj ) = lim u(xj + h) − u(xj ) h→0 h u(xj ) − u(xj − h) = lim h→0 h u(xj + h) − u(xj − h) = lim h→0 2h • We use these formulae with a small finite value of h = ∆x.. 14/8 .e.

Multiscale Summer School – p. For example. • Errors in the approximations to the derivative are calculated using Taylor approximations around a grid point xj . u(xj+1 ) = u(xj + ∆x) (∆x)2 + O((∆x)3 ) = u(xj ) + ux (xj )∆x + uxx (xj ) 2 • Thus.Error in FDM: Local Truncation Error • The local truncation error (LTE) is the error that results by substituting the exact solution into the finite difference formula. u(xj+1 ) − u(xj ) ∆x + uxx (xj ) + O((∆x)2 ) ux (xj ) = ∆x 2 • The forward difference is a first order accurate approximation to the partial derivative ux at xj and the LTE is O(∆x). 15/8 .

as ∆x goes to zero. • Note that the LTE in all these approximations goes to zero Multiscale Summer School – p.Error in FDM: LTE • The backward difference is a first order accurate approximation to the partial derivative ux at xj and the LTE is O(∆x). • The centered difference is a second order accurate approximation to the partial derivative ux at xj and the LTE is O((∆x)2). 16/8 .

0) = α. . . Initial Condition u(t. j = 0. . Boundary Condition at x = 1 • Discretize the spatial domain [0. . E q 0 = x0 q x1 q x2 q . Denote the spatial grid points by xj . . 0 ≤ x ≤ 1. . 17/8 . Boundary Condition at x = 0 u(t. 1) = β. t ≥ 0 u(0. .FDM for Parabolic PDEs: The Heat Equation • Consider the initial-boundary value problem for the heat equation ut = κuxx . ∆x ' E x xm xm+1 = 1 q q Multiscale Summer School – p. x) = f (x).. xj−1 xj xj+1 . 1. q q q q q .. m + 1. 1] into m + 2 grid points using a uniform mesh step size ∆x = 1/(m + 1) .

T .. q q q q q .. q ∆t q q q q x2 q q q q . xj ) q q q q q q q q q q q q T q q q t T t c1 q q t2 q q q q q q q t0 0 = x 0 x1 q . q q q q q q q q q (t2 .FDM for Parabolic PDEs: The Heat Equation • Similarly discretize the temporal domain into temporal grid points tk = k∆t for suitably chosen time step ∆t. 18/8 .. . xj−1 xj xj+1 . . ∆x ' E x xm+1 = 1 xm q q E • The space-time grid can be represented as .. α = u k uk 0 1 uk 2 k k uk j−1 uj uj+1 k uk um+1 = β m tk = k∆t q 0 = x0 q x1 q x2 q . . . . xm xm+1 = 1 Ex T Multiscale Summer School – p. . . xj−1 xj xj+1 . q . k • Denote the approximate solution at the grid point (tk . . xj ) as Uj .

. .FDM for Parabolic PDEs: The Heat Equation • Replace ut by a forward difference in time and uxx by a central difference in space to obtain the explicit FDM • k+1 k k k k Uj − U j Uj+1 − 2Uj + Uj−1 =κ ∆t (∆x)2 =⇒ k+1 Uj = k Uj κ∆t k k k + Uj+1 − 2Uj + Uj−1 . . j = 1. 2. 19/8 . m (∆x)2 • Associated to this scheme is a Computational Stencil k+1 k q q T   s d q   q dq q q j q k−1 q j+1 j−1 Multiscale Summer School – p.

Scheme is first order accurate in time and second order accurate in space • How do we choose the values of ∆t and ∆x?? Multiscale Summer School – p. • The local truncation error is O(∆t) + O((∆x)2 ). 0 • From Initial condition: Uj = f (xj ) for all values of j. 20/8 . • We note that k k • From Boundary conditions: U0 = α and Um+1 = β for all values of k.FDM for Parabolic PDEs: The Heat Equation • This is an explicit FDM for the heat equation: Solution at time level k + 1 is determined by solution at previous time levels only.

8 0.1 0 0 0. r=0.6 0.FDM for Parabolic PDEs: The Heat Equation A simulation with an initial condition that has a discontinuous derivative at x = 0.3 0.9 0.4 0.01.5 0.2 0.5.4 0. 21/8 . 1 0.2 0.7 0. dt=1e−05.8 1 In the above 1 κ∆t ≤ r= ∆x 2 with ∆x = 0.01 and ∆t = 10−5 Multiscale Summer School – p.6 0.1 Exact Solution Initial function dx=0.

• In general high frequencies get rapidly damped as compared to low frequencies. we see a rapid smoothing effect of this initial discontinuity as time evolves. • In the above we assumed that the value of 1 κ∆t ≤ r= ∆x 2 Here ∆x = 0. We say that the heat equation is stiff. 22/8 .5.FDM for Parabolic PDEs: The Heat Equation • Initial condition has a discontinuous derivative at x = 0. • However.01 and ∆t = 10−5 • What happens if this value is greater than 1/2? Multiscale Summer School – p.

They have to satisfy a stability condition.4 0. r=1 −1. • Thus.8 1 • We see unstable behavior of the numerical solution when r > 1/2! The numerical solution does not stay bounded.5 x 10 282 1 0.FDM for Parabolic PDEs: The Heat Equation 1.2 0.5 −1 dx=0.0001. ∆t and ∆x cannot be chosen arbitrarily.5 0 0. 23/8 .6 0. Multiscale Summer School – p. dt=0.5 0 −0.01.

. . .Implicit FDM for Parabolic PDEs: The Heat Equation • Replace ut by a forward difference in time and uxx by a central difference in space to obtain the Implicit FDM • k+1 k+1 k+1 k+1 k Uj+1 − 2Uj Uj − Uj + Uj−1 =κ ∆t (∆x)2 =⇒ k+1 Uj = k Uj κ∆t k+1 k+1 k+1 + Uj+1 − 2Uj + Uj−1 . m (∆x)2 • Associated to this scheme is a Computational Stencil k+1 q q q k q T q q j q q q j+1 k−1 j−1 Multiscale Summer School – p. 2. 24/8 . j = 1.

• The implicit FDM is unconditionally stable • However.4 0.8 1 • We see stable behavior of the numerical solution! The numerical solution remains bounded even when r > 1/2. the implicit scheme is still first order accurate in time and second order accurate in space.3 0.2 0.1 dx=0.FDM for Parabolic PDEs: The Heat Equation 1 0.4 0.8 0. • Thus. ∆t and ∆x can be chosen to have the same order of magnitude. 25/8 .9 0. a system of equations must be solved at each step. Multiscale Summer School – p. Also.01.01.6 0.7 0.2 0. r=100 Exact Solution Initial function 0 0 0. dt=0.5 0.6 0.

. . . k−1 • • j−1 Multiscale Summer School – p. Uj+1 − 2Uj + Uj−1 + Uj+1 − 2Uj 2(∆x)2 • Associated to this scheme is a Computational Stencil k+1 q q q k q T q q j q • q q j+1 This method is unconditionally stable. It is second-order accurate in time However a system of equations must be solved at each time step. 26/8 .Crank-Nicolson for The Heat Equation • • Replace ut by a forward difference in time and uxx by a central difference in space to obtain the Implicit FDM k+1 Uj − k Uj ∆t =⇒ k+1 Uj κ = 2 k Uj+1 − k 2Uj + k Uj−1 (∆x)2 ! κ + 2 k+1 k+1 k+1 + Uj−1 Uj+1 − 2Uj (∆x)2 = k Uj j = 1. m ” κ∆t “ k k+1 k+1 k+1 k k + + Uj−1 . 2.

27/8 .First vs Second Order Accuracy 0 −2 −4 Slope =1: First order accurate log2(LTE) −6 −8 −10 Slope =2: Second Order accurate −12 −14 −14 −12 −10 −8 log (∆ x) 2 −6 −4 −2 0 Multiscale Summer School – p.

Runge-Kutta methods etc.Method of Lines (MOL) Discretization • Another way of solving time dependent PDEs numerically is to discretize in space but not in time. • This results in a large coupled system of ODEs which we can then solve using numerical methods developed for ODEs. Multiscale Summer School – p. • The method of lines approach can be used to analyze the stability of the numerical method for the PDE by analyzing the eigenvalues of the matrix of the resulting system of ODEs using the ideas of absolute stability for ODEs. such as Forward and Backward Euler method. Trapezoidal methods. 28/8 .

This is usually proved by invoking Taylor’s theorem. • Fourier analysis on the grid (von Neumann analysis) • Computing the domain of dependence of the numerical method. Stability can be proven using either • Eigenvalue analysis of the matrix representation of the FDM. Stability is harder to prove than consistency. 29/8 . • Stability implies that the numerical solution remains bounded at any given time t.Analysis of FDM • Consistency implies that the local truncation error goes to zero as ∆x and ∆t approach zero. • Lax-Equivalence Theorem : A consistent approximation to a well-posed problem is convergent if and only if it is stable Multiscale Summer School – p.

Any growth in the solution will be due to the presence of terms involving G. 30/8 . Here eiαm x = cos(αm x) + i sin(αm x). • To analyze the growth of different Fourier modes as they evolve under the numerical scheme we consider each frequency separately.Von Neumann Analysis for Time-dependent Problems • Example: The analytical solutions of the heat equation ut − κuxx = 0 can be found in the form ∞ u(t. • Thus requiring that this amplification factor G is bounded by one as k → ∞ gives rise to a relation between ∆t and ∆x called the von Neumann stability condition. x) = −∞ eβm t eiαm x 2 with βm + καm = 0. Multiscale Summer School – p. x) = eβm t eiαm x k • In the discrete case we assume that Uj = Gk eiαm j∆x with G = eβm ∆t . namely let u(t.

x) = f (x). u(x. 31/8 . t ≥ 0 u(0.FDM for Hyperbolic PDEs: The Advection Equation • Consider the initial value problem for the Advection equation ut + aux = 0. 0 ≤ x ≤ 1. Initial Condition • The solution u(x. t) T u(x. 0) ¨ ¨T ¨ c ¨ ¨ ¨ c¨ E   ¨¨ ¨ ¨ ¨¨ T   ¨¨ ¨¨ ¨¨   ¨¨ ¨ T¨ ¨   ¨ c ¨ ¨ E x      x1 x2 x3 t Characteristic x − at = x3 • Information propagates along characteristics Multiscale Summer School – p. t) = f (x − at) is a wave that propagates to the right if a > 0 and to the left if a < 0.

. m = Uj + =⇒ Uj ∆x • Associated to this scheme is a Computational Stencil k+1 k q   T q   q q q j q q q q j+1 k−1 j−1 • Scheme is explicit • First order accurate is time and space • ∆t and ∆x are related through the Courant number a∆t ν= ∆x Multiscale Summer School – p. 32/8 .FDM for the Advection Equation • Replace ut by a forward difference in time and ux by a backward difference in space to obtain the explicit FDM • k+1 k k k Uj − Uj Uj+1 − Uj +a =0 ∆t ∆x a∆t k+1 k k k Uj − Uj−1 . j = 1. . . 2.

0) r r r r r r r r r ∆x ' E rCharacteristic x − at = x0 r r ∆t T c r rE x r r r r rb r (x0 .Courant Friedrich Lewy (CFL) Condition • The CFL Condition : For stability.e. • For the advection equation CFL condition for stability is |ν| ≤ 1. 33/8 . t T a∆t ∆t t T a∆t ∆t b r (x0 . i. ∆x .. It is not a sufficient condition. 0) rCharacteristic x − at = x0 r r r r ∆t T c r r r rE ∆x ' E x • CFL is a necessary condition for stability of explicit FDM applied to Hyperbolic PDEs. the Domain of dependence of the PDE must lie within the domain of dependence of the numerical scheme. at each mesh point. ∆t ≤ |a| Multiscale Summer School – p.

34/8 .Elliptic PDEs: Laplace Equation • Time-independent problems • Consider the Boundary value problem for the Laplace equation in two spatial dimensions uxx + uyy = 0. 0 ≤ x ≤ 1. 0 ≤ y ≤ 1 with boundary conditions prescribed as shown below y u=1 T u=0 u=0 E u=0 x Multiscale Summer School – p.

. b . boundary node yJ+2 = 1 b b b b r r r r r r b b r r b r b r b r r r r r r b b r r r r r r b b r r r r r r b b r r r r r r b b r r r r r r b T b b b b b b b b Ex T =1 y yJ+1 yJ . . .FDM for Elliptic PDEs: Laplace Equation • Discretize the mesh using uniform mesh step in both the x and y directions as below. . r r b 0 = y0 0 = x 0 x1 . . b . . xL+1xL+2 Multiscale Summer School – p. b b b r r ∆y T r c r r ' E ∆x r r r r r b x2 y2 y1 r r b . . 35/8 . xj−1 xj xj+1 . ..

k = 0 • The Stencil for this FDM is called the Five-Point Stencil k+1 q q q q q q j q q q j+1 k k−1 j−1 Multiscale Summer School – p.k−1 Uj+1. yk ) to obtain the difference scheme Uj.k + Uj−1.Elliptic PDEs: Laplace Equation • Replace both the second order derivatives uxx and uyy with centered differences at each grid point (xj .k + Uj−1.k−1 − 4Uj. 36/8 .k − 2Uj.k+1 − 2Uj.k + =0 (∆x)2 (∆y)2 • If ∆x = ∆y this becomes Uj+1.k+1 + Uj.k + Uj.k + Uj.

The vector U is the solution vector at the interior grid points.2 U2.Elliptic PDEs: Laplace Equation • This FDM gives rise to a system of linear equations of the form AU = b • • • • • The right hand side vector b contains the boundary information. 37/8 . • When m = 2. The matrix A is block tridiagonal if ordered in a natural way The structure of A depends on the ordering of the grid points. This system can be solved by iterative techniques or direct methods such as Gaussian elimination.1 U1.1 U2. the system AU = b can be written as      −4 1 1 1 −4 0 1 0 −4 0 1 1 0 1 1 −4      U1.2   0 0 1 1          =   Multiscale Summer School – p.

38/8 .Discretization of Elliptic PDEs increasing j increasing i −4 1 1 • • • • • 1 −4 1 • • • • • • • • • • • • • • 1 1 1 • • • • 1 1 1 • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 1 −4 1 1 • • • • • 1 1 −4 1 −4 • 1 −4 1 −4 1 −4 • 1 −4 1 1 −4 1 −4 • 1 1 • • • 1 1 1 • • • • • • • • • • • • • • 1 1 1 −4 each block (L + 1) × (L + 1) J+1 blocks J + 1 blocks Multiscale Summer School – p.

Finite Element Method Features • Flexibility • Complicated geometries • High-order approximations • Strong mathematical foundation Multiscale Summer School – p. 39/8 .

40/8 . Need M equations Discretizing derivatives results in linear system Multiscale Summer School – p.Basic Idea M u(x) ≈ u(x) = ˆ j=1 • • • uj φj (x) φj are basis functions uj : M unknowns.

1D Elliptic Example −u = f. elastic cord with fixed ends Solution must be twice differentiable This is unnecessarily strong if f is discontinuous Multiscale Summer School – p. 41/8 . u(0) = u(1) = 0 • • • 0<x<1 For example.

0 u v dx − u v|1 = 0 1 1 u v dx = 0 0 f vdx. Multiscale Summer School – p.Weak Formulation Multiply both sides by an arbitrary test function v and integrate 1 1 −u vdx = 0 1 0 0 1 f vdx f vdx. this equation must hold for all v such that the equation makes sense (v is square integrable). Since v was arbitrary. 42/8 . and v(0) = v(1) = 0.

• • • • 0 f vdx ∀v ∈ V Fewer derivatives required for u If f continuous. same u as strong form Infinite possibilities for v Want to find u on a discrete mesh Multiscale Summer School – p. 43/8 .Weak Formulation 2 Find u ∈ V such that 1 1 u v dx = 0 1 where V = H0 ([0. 1]).

. . on each subinterval) functions such that v ∈ Vh is ˆ continuous on [0. let Vh be piecewise linear (i. . . < xM +1 = 1 be a partition of the domain with hj = xj − xj−1 and h = max hj .Finite-dimensional Subspace • • • Let 0 = x0 < x1 < . . For example. want that functions in Vh can get arbitrarily close to functions in V . M + 1. For decreasing h. Nodes xi are sometimes denoted Ni • • Multiscale Summer School – p. . 1] and v (0) = v (1) = 0. Use the partition to define a finite-dimensional subspace Vh ⊂ V . ˆ ˆ We may introduce basis functions φj (x) such that φj (xi ) = δij for i.e. j = 0. 44/8 . .

uN x 1 x Multiscale Summer School – p. 45/8 . . . . . Ni (x) ui x 1 x .Basis Functions u1 Finite methods for partial differential equations ui 1 19 ui ui Ωi 1 uN xi 1 x1 xi 1 xi xN x u1 x 1 x .

M. . Note: • When u and v in same subspace: Galerkin ˆ ˆ • If support of φi is entire space: Spectral • If Vh not a subspace of V : Non-conforming Multiscale Summer School – p. . 46/8 . v or 1 0 1 u φj dx = ˆ f φj dx 0 j = 1.Finite Element Method Find u ∈ Vh such that ˆ 1 1 u v dx = ˆˆ 0 0 f v dx ˆ ∀ˆ ∈ Vh . . .

. and then Aξ = b Multiscale Summer School – p. . M such that 1 M i=1 ξi φi (x) ξi φi φj dx = i=1 f φj dx 0 j = 1. 1 0 φi φj dx • Thus if A = (aij ) with aij = b = (bi ) with bi = 1 0 f φi dx. 47/8 . . .Linear System • • Can represent u = ˆ 1 M 0 Find ξi for i = 1. . M. . . .

  .... 0 · · · · · · 0 −1 2 Multiscale Summer School – p. . For the piecewise linear basis functions we have chosen it will be tridiagonal. .  1  0 −1 2 −1 .Stiffness Matrix • • • The M × M matrix A is called the stiffness matrix. . For the special case when hj ≡ h we have   2 −1 0 · · · · · · 0 ..   . −1 2 −1 .  .  .. ... .  . 48/8 . ... .. −1 2 −1  . 0  .. .   h  . ..   .

and therefore the equations determining u are ˆ ξi+1 − 2ξi + ξi−1 = hfi h • which are exactly the same as FDM. The advantage of the FEM formulation is the generality it allows (e.g. uniform h was not required). then bi = hfi . 49/8 ..Compare to FDM • Note that if Trapezoid rule is used to approximate the right hand side. Multiscale Summer School – p.

50/8 . on ∂Ω. 1] Assume homogeneous Dirichlet boundary conditions Then the 2D Possion problem is: 1 Find u ∈ V := H0 (Ω) such that −∆u = f u=0 in Ω. 1] × [0. y) ∈ [0.Multidimensional Problem • • • Let Ω be the unit square (x. Multiscale Summer School – p.

Variational Formulation Find u ∈ V such that a(u. v)Ω := Note: used Green’s formula and v = 0 on ∂Ω. v)Ω . 51/8 . v)Ω := Ω ∀v ∈ V. (f. v)Ω = (f. Ω v. Multiscale Summer School – p. u· f v. where a(u.

u ˆ ∀ˆ ∈ Vh . v Multiscale Summer School – p. v ˆ Find u ∈ Vh such that ˆ ˆ a(ˆ.P1 Finite Element We introduce a triangulation Th of Ω into triangles Ki . and a finite dimensional subspace: 1 Vh := {ˆ ∈ H0 (Ω) : v |Ki ∈ P1 (Ki )}. 52/8 . v )Ω . v )Ω = (f.

where ξj = u(Nj ).. Multiscale Summer School – p. i. j = 0.Using Basis Functions Representing u and v in terms of nodal basis functions ˆ ˆ {φi }M of Vh . or in matrix form. . . . and ˆ bi = (f. Aξ = b. M + 1. φi ). φj ) = (f. φj )Ω is SPD.e. . M. j=1 i = 1. 53/8 . φj (Ni ) = δij for i=1 i. Aij = a(φi . . . . . φi )Ω . we get the following system of algebraic equations: M ξj a(φi .

54/8 . z} ∈ [0.Multidimensional Problem • • • Let Ω be the unit cube {x. on ∂Ω. Multiscale Summer School – p. 1] Assume homogeneous Dirichlet boundary conditions Then the 3D Possion problem is: 1 Find u ∈ V := H0 (Ω) such that −∆u = f u=0 in Ω. y.

v)Ω = (f. u· f v. v)Ω := Ω ∀v ∈ V. where a(u. v)Ω .Variational Formulation Find u ∈ V such that a(u. Multiscale Summer School – p. v)Ω := Note: used Green’s formula and v = 0 on ∂Ω. Ω v. 55/8 . (f.

v ˆ ¨ ¨ ¨©¢¨©  ¢   §   ¢ ¡  ¢ ¡ ¦ ¥¦ ¥§¥ Find u ∈ Vh such that ˆ ˆ a(ˆ. 56/8 . v ¤ £¢£¤  ¢ Multiscale Summer School – p. u ˆ ∀ˆ ∈ Vh . v )Ω . v )Ω = (f.Q1 Finite Element We introduce a triangulation Th of Ω into 3-D rectangles Ki . and a finite dimensional subspace: 1 Vh := {ˆ ∈ H0 (Ω) : v |Ki ∈ Q1 (Ki )}.

φj ) = (f.Using Basis Functions Representing u and v in terms of nodal basis functions ˆ ˆ {φi }M of Vh . .. . φj (Ni ) = δij for i=1 i. . M. . 57/8 . M + 1. j=1 i = 1. φi ). j = 0. and ˆ bi = (f. we get the following system of algebraic equations: M ξj a(φi .e. . where ξj = u(Nj ). i. or in matrix form. Multiscale Summer School – p. Aξ = b. Aij = a(φi . . . . φj )Ω is SPD. φi )Ω .

58/8 . Multiscale Summer School – p. 1] Assume Neumann boundary conditions Then the 2D Possion problem is: Find u ∈ V := H 1 (Ω) such that −∆u = f ∂u =g ∂n in Ω. on ∂Ω. y) ∈ [0. 1] × [0.Neumann Problem • • • Let Ω be the unit square (x.

v)Ω + g. v)Ω = (f. 59/8 . ∂u ∂n Note: used Green’s formula and = g on ∂Ω. v where a(u. Ω v. (f.Variational Formulation Find u ∈ V such that a(u. ∀v ∈ V. u· f v. v)Ω := g. v)Ω := Ω ∂Ω . v ∂Ω := ∂Ω gv. Multiscale Summer School – p.

v Multiscale Summer School – p. v u ˆ ∂Ω .P1 Finite Element We introduce a triangulation Th of Ω into triangles Ki . and a finite dimensional subspace: Vh := {ˆ ∈ H 1 (Ω) : v |Ki ∈ P1 (Ki )}. v ˆ Find u ∈ Vh such that ˆ ˆ ˆ a(ˆ. v )Ω = (f. 60/8 . v )Ω + g. ∀ˆ ∈ Vh .

φj )Ω is SPD. and ˆ bi = (f. φi )Ω + g. . where ξj = u(Nj ). φi ∂Ω . Multiscale Summer School – p. Aξ = b. φj ) = (f. φi j=0 ∂Ω . .Using Basis Functions Representing u and v in terms of nodal basis functions ˆ ˆ {φi }M +1 of Vh . . 61/8 . M +1 or in matrix form. Aij = a(φi . i = 0. we get the following system of i=0 algebraic equations: M +1 ξj a(φi . . φi )+ g.

62/8 .Mixed Boundary Let Ω be the unit cube. Γ1 Ω Γ0 Multiscale Summer School – p. and Γ1 = ∂Ω \ Γ0 . Γ0 the face at z = 0. Then we want to approximate u in Ω.

on Γ1 . 63/8 . in Ω. on Γ0 .Mixed Robin Boundary Find u ∈ V := H 1 (Ω) such that −∆u = f ∂u α0 u + β 0 =0 ∂n ∂u =0 α1 u + β 1 ∂n Note: assume βi = 0. Multiscale Summer School – p.

1. v)Ω + α0 β0 u. where a(u. v)Ω .v ∂n = (f. j = 0. Multiscale Summer School – p. v)Ω and (f. Γ1 = (f. v)Ω . v −1 + α1 β1 u. v Γ0 Γ1 ∂u .Variational Formulation Find u ∈ V such that a(u. v)Ω − or −1 a(u. v Γj := Γj uv. 64/8 .v ∂n − Γ0 ∂u . v)Ω are the same as above and u.

v )Ω . v )Ω + α0 β0 u. 65/8 . and the finite dimensional subspace Vh := {ˆ ∈ H 1 (Ω) : u|Ki ∈ Q1 (Ki )} u ˆ to get the finite element problem: Find u ∈ Vh such that ˆ −1 a(ˆ. v Multiscale Summer School – p. v ˆ ˆ Γ0 Γ1 = (f. ˆ ∀ˆ ∈ Vh .Finite Element Method We introduce the triangulation Th as before. v u ˆ ˆ ˆ −1 + α1 β 1 u .

β0 β1 Multiscale Summer School – p. A. α0 0 α1 1 G := G + G . and b are similar to those above and G0 := φi . 66/8 . φj ij 1 Gij Γ0 . where ξ. φj Γ1 . := φi .Using Basis Functions Representing u and v in terms of nodal basis functions ˆ ˆ {φi }M of Vh we get the following matrix equation: i=1 (A + G)ξ = b.

space-time rectangular in t dimension Popular to use FEM for spatial discretization and FDM for time Performing FEM first results in semi-discrete formulation This is equivalent to a coupled system of ODEs Multiscale Summer School – p. 67/8 .Parabolic and Elliptic • • • • • Build off of elliptic FEM If boundary not moving.

in ∂Ω × (0. in Ω. T ]. L2 (Ω)) ∩ L2 ([0. 0) = u1 (·) in Ω. T ).Scalar Wave Problem 1 Find u ∈ H 2 ([0. Multiscale Summer School – p. T ]. 0) = u0 (·) ut (·. in Ω. 68/8 . H0 (Ω)) such that 1 u − ∆u = f 2 tt c u=0 u(·.

Variational Formulation 1 Find u(·. 2 c (u(·. 0). ∀v ∈ V. v)Ω . 0). v)Ω . T ] → V := H0 (Ω) such that 1 (utt . Multiscale Summer School – p. t) : [0. v)Ω + a(u. v)Ω = (u1 (·). v)Ω = (f. (ut (·. v)Ω = (u0 (·). ∀v ∈ V. v)Ω . ∀v ∈ V. 69/8 .

v )Ω + a(ˆ. 0). v ∀ˆ ∈ Vh . v )Ω . v )Ω . 0). v )Ω = (u0 (·). v )Ω = (u1 (·). 70/8 . v ∀ˆ ∈ Vh . v Multiscale Summer School – p. ˙ ˆ ˆ ∀ˆ ∈ Vh . T ] → Vh such that ˆ 1 (¨h . u ˆ (uh (·. v )Ω . t) : [0. v )Ω = (f. u ˆ u ˆ ˆ 2 c ˆ (ˆ(·.Semi-discrete Formulation Find u(·.

∀t ∈ (0. i Lij := (φi . ˙ Lξ(0) = χ1 . φj )Ω . φi )Ω . 1 ¨ Lξ(t) + Aξ(t) = b. Multiscale Summer School – p. A. and b are as above. i χ1 := (u1 .Using Basis Functions In matrix form. and χ0 := (u0 . 2 c Lξ(0) = χ0 . φi )Ω . 71/8 . T ). where ξ.

. n = 1. . 1 ξ n+1 − 2ξ n + ξ n−1 n n L + Aξ = b . and k := tn − tn−1 . i n = 1. . . we introduce a (uniform) partition of the interval [0. . 2 2 c k Lξ 0 = χ0 . NT . Lξ 1 = χ0 + kχ1 .Fully Discrete Formulation In order to discretize in time. NT .T]: 0 = t0 < t1 < · · · < tNT = T . . . where ξin ≈ ξi (tn ) and bn := bi (tn ). Multiscale Summer School – p. . 72/8 .

it is possible to make L diagonal by using a quadrature rule (Trapezoid) for the integration. 73/8 . • • • • Multiscale Summer School – p. in 1D consistent mass matrix requires a smaller time step than lumped. Since Lij := (φi . When to lump is an important question. for example. numerical dispersion analysis can show. and a linear solve! Mass lumping can reduce accuracy. The resulting explicit method is exactly the FDM. especially in higher dimensions.Mass Lumping • Note that the fully discrete formulation is still implicit. thus a linear solve at each time step must be performed. φj )Ω .

Many types of finite elements exist. or degrees of freedom in locations other than vertices (e. first or second derivatives as degrees of freedom. and more easily applied to slanted or curved boundaries. 74/8 . K may be mapped to reference domain (e.g.. 1]) for easy integration (especially quadrature rules). including some with quadratic or cubic basis functions. [−1. centroid). More general than FDM. especially involving normal derivative boundary conditions. • • • Multiscale Summer School – p. Technically speaking a finite element is a triple: geometric object..g. then global matrix assembled. finite-dimensional linear function space. and a set of degrees of freedom.Other Considerations • • Integration performed in “local” coordinates.

t) + V ∂V f (u) · n = 0 • where f is flux function. 75/8 . The general principle is that the rate of change of u(x.Conservation Laws • • Many PDEs are derived from physical models called conservation laws. Nonlinear conservation laws can result in discontinuities in finite time even with smooth initial data. t) within a volume V is equal to the flux past the boundary ∂ ∂t u(x. Multiscale Summer School – p.

Finite Volume Method • • Rather than pointwise approximations on a grid. Suppose region Vi = [xi−(1/2) . FVM approximates the average integral value on a reference volume. Multiscale Summer School – p. • We can apply a quadrature rule. 76/8 . to the remaining integral to get a semi-discrete form xi+(1/2) − xi−(1/2) ut (xi ) + f (ui+(1/2) ) − f (ui−(1/2) ) = 0. for example Midpoint. xi+(1/2) ] then xi+(1/2) ut dx + f (ui+(1/2) ) − f (ui−(1/2) ) = 0 xi−(1/2) where we have applied Gauss’s theorem and integrated xi+(1/2) analytically the resulting term xi−(1/2) fx (u)dx.

using centered differences on the remaining derivatives yields ui+1 − 2ui + ui−1 = hfi h for h = xi+(1/2) − xi−(1/2) . xi+(1/2) ] then xi+(1/2) xi+(1/2) uxx dx = xi−(1/2) xi−(1/2) f dx. Evaluating the left hand side analytically and the right via Midpoint gives ux (xi+(1/2) ) − ux (xi−(1/2) ) = xi+(1/2) − xi−(1/2) fi Finally.FVM Example Consider the elliptic equation uxx = f (x) on a control volume Vi = [xi−(1/2) . Multiscale Summer School – p. 77/8 .

Natural choice for heterogeneous material as each grid cell can be assigned different material parameters. Multiscale Summer School – p. accuracy and stability. There exist theory for convergence.FVM Summary • • • • Applies to integral form of conservation law. 78/8 . Handles discontinuities in solutions.

79/8 .Systems of Linear Equations • • • For implicit methods must choose a linear solver. Direct (LU factorization) • More accurate • May be cheaper for many time steps • Banded (otherwise fill-in) Iterative • If accuracy less important than speed • Matrix-free • Sparse • SPD Multiscale Summer School – p.

g. e. 80/8 .Iterative Methods • • • Successive Over Relaxation (SOR) • Simple to code • ω = 1 is Gauss-Seidel Conjugate Gradient • SPD • Eigenvalues clustered together (Precondition) Generalized Minimum Residual (GMRES) • Non-SPD. convection-diffusion with upwinding • Krylov method: builds orthonormal basis which may get big (Restart) • Preconditioning helps (Incomplete Cholesky) Multiscale Summer School – p.

T. 3. Johnson. Cambridge University Press. Kelley. C. D. 1992. 5. Society for Industrial & Applied Mathematics.. 1995. Knoxville. 2001. Master’s thesis. Numerical Methods for Partial Differential Equations. Numerical solution of partial differential equations by the finite element method. Fast Solvers. Finite Elements: Theory. 81/8 . N. Solving a Fluid-plate Interaction Problem Using Finite Element Methods with Domain Decomposition Strategies. Gibson.L.References 1. William Ames. Braess. Cambridge University Press New York. 2001. University of Tennessee. and Applications in Solid Mechanics. Iterative Methods for Linear and Nonlinear Equations. 4. Multiscale Summer School – p. Inc. Academic Press. 1987. C. 2.

Joaquim Peiro and Spenser Sherwin. McGraw-Hill. Volume I: Methods and Models. Springer. Scientific Computing: An Introductory Survey. Finite Element and Finite Volume Methods For Partial Differential Equations. Multiscale Summer School – p. Langtangen. 2003. 82/8 . Springer. in Handbook of Materials Modeling. 2005. Finite Difference. Heath Michael. H. 7. Computational Partial Differential Equations: numerical methods and Diffpack programming. 8. 2002.References (Cont) 6.P. T.

Sign up to vote on this title
UsefulNot useful