intro gal erkin

3
Introduction to Ritz-Galerkin Discretization Ritz-Galerkin discretization is the basis for finite element methods and for spectral meth- ods. The low-level introduction presented here will illustrate some of the basic concepts and it will enable us to solve simple 1-d problems. The underlying theory and higher-dimensional implementation are quite involved and will be discussed in detail later. An Illustrative Example. Consider the 1-d Poisson equation with homogeneous Dirichlet boundary conditions, Au def = - d 2 u dx 2 = f (x), 0 <x< 1, u(0) = u(1) = 0. (1) We approximate the unknown solution by a linear combination of given basis functions, u N (x)= N j =1 α j φ j (x). (2) The basis functions φ j are required to satisfy homogeneous Dirichlet boundary conditions. Due to linearity, u N will satisfy the same boundary conditions. In our previous discussion of analytic solutions, the φ j s were taken to be the eigenfunctions for the negative Laplacian operator, A in eqn (1). Here we allow other basis functions, e.g., piecewise polynomials or special functions other than sines. We define the residual error associated with the approximation (2) in eqn (1) to be r N (x)=(Au N )(x) - f (x). In order to select the coefficients α j in eqn (2), we require the residual to be orthogonal to each of the basis functions, 1 0 r N (x) φ i (x) dx =0, i =1,...,N. (3) From the linearity of the differential operator A and the linearity of integration, we obtain N j =1 α j 1 0 (Aφ j )(x) φ i (x) dx = 1 0 f (x) φ i (x) dx, i =1,...,N. This linear system can be rewritten as = b, where the coefficient matrix A and right- hand-side vector b have entries [A] i,j = 1 0 (Aφ j )(x) φ i (x) dx, i =1,...,N, j =1,...,N, (4) [b] i = 1 0 f (x) φ i (x) dx, i =1,...,N. (5) When the φ j s are chosen to be globally defined special functions like sines or cosines, Ritz-Galerkin discretization is called a spectral method. (”Spectral” refers to eigenvalues and 1

Upload: fradmard

Post on 14-Dec-2015

224 views

Category:

Documents


0 download

DESCRIPTION

gelerkin

TRANSCRIPT

Page 1: Intro Gal Erkin

Introduction to Ritz-Galerkin Discretization

Ritz-Galerkin discretization is the basis for finite element methods and for spectral meth-ods. The low-level introduction presented here will illustrate some of the basic concepts andit will enable us to solve simple 1-d problems. The underlying theory and higher-dimensionalimplementation are quite involved and will be discussed in detail later.

An Illustrative Example. Consider the 1-d Poisson equation with homogeneous Dirichletboundary conditions,

Audef= −d2u

dx2= f(x), 0 < x < 1, u(0) = u(1) = 0. (1)

We approximate the unknown solution by a linear combination of given basis functions,

uN(x) =N∑

j=1

αjφj(x). (2)

The basis functions φj are required to satisfy homogeneous Dirichlet boundary conditions.Due to linearity, uN will satisfy the same boundary conditions. In our previous discussionof analytic solutions, the φjs were taken to be the eigenfunctions for the negative Laplacianoperator, A in eqn (1). Here we allow other basis functions, e.g., piecewise polynomials orspecial functions other than sines.

We define the residual error associated with the approximation (2) in eqn (1) to be

rN(x) = (AuN)(x)− f(x).

In order to select the coefficients αj in eqn (2), we require the residual to be orthogonal toeach of the basis functions,∫ 1

0rN(x) φi(x) dx = 0, i = 1, . . . , N. (3)

From the linearity of the differential operator A and the linearity of integration, we obtain

N∑j=1

αj

∫ 1

0(Aφj)(x) φi(x) dx =

∫ 1

0f(x) φi(x) dx, i = 1, . . . , N.

This linear system can be rewritten as Aα = b, where the coefficient matrix A and right-hand-side vector b have entries

[A]i,j =∫ 1

0(Aφj)(x) φi(x) dx, i = 1, . . . , N, j = 1, . . . , N, (4)

[b]i =∫ 1

0f(x) φi(x) dx, i = 1, . . . , N. (5)

When the φjs are chosen to be globally defined special functions like sines or cosines,Ritz-Galerkin discretization is called a spectral method. (”Spectral” refers to eigenvalues and

1

Page 2: Intro Gal Erkin

eigenfunctions of a linear operator, but ”spectral” functions can be used for an operator evenif they are its eigenfunctions.)

When the φjs are chosen to be piecewise polynomials, Ritz-Galerkin discretization iscalled a finite element method. For simplicity of implementation, it is advantageous to usevery low degree polynomials. This may require integration by parts to assemble the matrixA in eqn (4). When A is the negative Laplacian,

[A]i,j = −∫ 1

0

d2φj

dx2φi(x) dx =

∫ 1

0

dφj

dx

dφi

dxdx. (6)

Note that the boundary terms vanish because the φis satisfy homogeneous Dirichlet boundaryconditions.

Now consider continuous piecewise linear ”hat” basis functions defined on an equispacedgrid {xi = ih | i = 1, . . . , N} with h = 1/(N + 1),

φi(x) =

(x− xi−1)/h, xi−1 ≤ x ≤ xi,(xi+1 − x)/h, xi ≤ x ≤ xi+1,0, otherwise.

(7)

These have piecewise constant derivatives

dφi

dx=

1/h, xi−1 < x < xi,−1/h, xi < x < xi+1,0, x < xi−1 or x > xi+1.

(8)

Note that each φi is only piecewise continuously differentiable with discontinuities in thederivatives at grid points xi±1 and xi. Hence expression (4) for the matrix coefficients is notvalid. On the other hand, expression (6) is valid and yields

[A]i,j =

−1/h, if |i− j| = 1,2/h, if i = j,0, otherwise.

(9)

The entries of the vector b in eqn (5) can be approximated by applying the trapazoidalrule on each subinterval xj−1 < x < xj,

[b]i = 0 +∫ xi

xi−1

f(x)x− xi−1

hdx +

∫ xi+1

xi

f(x)xi+1 − x

hdx + 0 ≈ h f(xi). (10)

The error of this approximation is O(h2) provided f ∈ C2[0, 1].

Remark. The above Ritz-Galerkin-Finite Element discretization yields a coefficient matrixA and right-hand-side vector b whose entries differ from those in the finite difference caseby a factor of h. If we multiply both A and b by h, then the formulas are identical to thefinite difference case.

It should be noted that the finite element derivation can be carried out even when u doesnot have the C4 continuity that was required in the finite difference derivation. In particular,

2

Page 3: Intro Gal Erkin

if f(x) = δ(x−x) is the Dirac delta ”function” centered at x ∈ (0, 1), then the exact solutionto the Poisson equation (1) is piecewise linear,

u(x) =

{x(1− x), 0 ≤ x ≤ x,x(1− x), x ≤ x ≤ 1.

The right-hand-side vector can be evaluated exactly,

[b]i = φi(x), i = 1, . . . , N,

and the finite element solution can be shown to be exact.

In the case of the 1-d linear steady-state diffusion equation with variable diffusivity,

Au = − d

dx

(κ(x)

du

dx

).

If we proceed as above and apply midpoint quadrature, we obtain

[A]i,j =∫ xj

xj−1

κ(x)1

h

dφi

dxdx +

∫ xj+1

xj

κ(x)−1

h

dφi

dxdx (11)

= O(h2) +1

h

−κ(xi−1/2), j = i− 1,κ(xi−1/2) + κ(xi−1/2), j = i,−κ(xi+1/2), j = i + 1,0, otherwise.

(12)

This is identical to the result obtained using finite volume discretization.

Exercises

1. Verify formula (9) for the entries of the matrix A from finite element discrization ofPoisson’s equation.

2. Verify formula (11) for the entries of the matrix A from finite element discretization ofthe steady-state diffusion equation.

3