plugin cs3200 finite differences

Upload: ramkumar121

Post on 05-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Plugin Cs3200 Finite Differences

    1/25

    Chapter 3

    Finite Difference Methods

    3.1 Introduction

    The finite difference methods have dominated computational science since its inception and were

    the method of choice in the 1960s and 1970s. While other methods, such as the finite element

    method and boundary element have enjoyed recent popularity, finite difference methods are still

    utilized for a wide array of computational engineering and science problems.

    Briefly, the finite difference method can be characterized as follows. Finite Difference Method

    Utilizes uniformly spaced grids.

    At each node, each derivative is approximated by an algebraic expression which references

    the adjacent nodes.

    A system of algebraic equations is obtained by evaluating the previous step for each node.

    The system is solved for the dependent variable.

    3.2 Taylor Series

    Before proceeding to discuss the mathematical formalities of the finite difference method, it would

    probably be a good idea to review some facts concerning Taylors series. From elementary cal-

    culus, we remember that the Taylor series formula is used to expand a function, as a power

    series,

    (3.1)

    For the numerical treatment of field equations, we often represent the Taylor series in somewhat

    different forms. Usually, we replace and in the previous formula by and respectively.

    41

  • 7/31/2019 Plugin Cs3200 Finite Differences

    2/25

    42 CHAPTER 3. FINITE DIFFERENCE METHODS

    Here, is denoted as an increment in and is assumed positive. The Taylor series now becomes

    (3.2)

    For the treatment of many problems, it is convenient to take only the first two terms of the right

    hand side of the previous equation,

    (3.3)

    where the expression , represents the error of the approximation is proportional to . From

    this relationship, we can easily define what is known as the first order, forward difference approx-

    imant to ,

    (3.4)

    Likewise, we can define the first order, backward difference approximant to (just substitute

    for in the expansion),

    (3.5)

    If instead, we take terms up to and including on the right hand side of the two previous equations,

    then subtract them, we can obtain,

    (3.6)

    This is the second order, central difference approximation to . Taking up to forth order yields,

    (3.7)

    the terms and having canceled. Now we can obtain the second order, central difference

    approximation to

    (3.8)

    Now that were warming up, lets see what excitement awaits us by considering the Taylor series

    for a function of two independent variables, ,

    (3.9)

    likewise,

    (3.10)

    thus, we can generate first and second (and higher) order approximations for partial derivatives,

    for example:

    (3.11)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    3/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 43

    (3.12)

    (3.13)

    (3.14)

    It is easy to show that there are equivalent expressions for time,

    (3.15)

    as well as for other spacial variables and mixed partial derivatives,

    (3.16)

    Alright, now that we know everything about how to derive difference formulations from Taylors

    series, lets talk about how to use such results in approximating a field problem.

    3.3 Finite difference formulation for Elliptic Equations

    As a simple illustration, lets consider Laplaces equation for a planar region, with Dirichlet

    boundary data on the boundary of the region, . To make this even simpler still, consider the

    region to be bounded by the lines , , , and . We now discretize the bounded

    region with a square mesh as show in Figure 3.3. We note that we can use non-square elements, but

    for now, squares will suffice. We might ask ourselves the pertinant question, how many squares

    do we use to discretize the solution domain? While we intuitively know that our solution will

    probably get better as the discretization level increases, how fast it will get better and how much it

    will cost are other questions to think about. We impose a mesh of grid points and define to be

    the distance between mesh points. The interior grid points are given by , where

    . Now we look up above for the Taylors series expansion which represents second

    order approximations for and and substitute them in:

    (3.17)

    (3.18)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    4/25

    44 CHAPTER 3. FINITE DIFFERENCE METHODS

    y

    x

    (0,0) (1,0)

    (1,1)(0,1)

    .. ..

    .. ..

    .. ..

    .. ..h

    h

    Figure 3.1: Discretization for Laplaces Equation.

    As we mentioned before, we chose a uniform grid such that . This yields the

    simplification,

    (3.19)

    Which is the finite difference approximation of Laplaces equation. If we had carried a higher

    order term through the calculations, we would have found out that the local truncation error is

    (3.20)

    which is usually written as , such that the error is proportional to the space constant squared.

    Note that five points are involved in the approximation of the Laplacian (points to the left, right,

    above and below of a central point, ) such that this is called the five pointformula.

    We will derive similar relationships for parabolic and hyperbolic problems. As such, it is

    often convient to use a stencil notation when discussing difference equations for the second order

    Laplacian on a Cartesian grid (or one that is logically rectangular). Below, we define the stencil

    for 2D problems, however, we will create 3D stencils later in this chapter.

    First, lets create a general stencil notation and then look at different finite difference stencils.

  • 7/31/2019 Plugin Cs3200 Finite Differences

    5/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 45

    i,j1

    i,j+1

    i+1,jui,j

    u

    ui1,j

    u4

    Figure 3.2: Five point finite difference stencil for the Laplacian operator.

    A general stencil can be represented as

    ... ... ...

    ......

    ...

    (3.21)

    This defines a discrete set of grid operations

    (3.22)

    We will mainly consider five-point or nine-point stencils (or their 3D equivalent). The five-point stencil is of the form:

    (3.23)

    and the nine-point stencil of the form:

    (3.24)

    When using stencil notation, we usually must restrict the stencil application to the domainexcluding the boundaries. Near the boundaries, the stencils often have to be modifed due to

    boundary conditions.

    Using Figure 3.3 and the notation above, we can now rewrite equation (3.19) in stencil form

    (3.25)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    6/25

    46 CHAPTER 3. FINITE DIFFERENCE METHODS

    Figure 3.3: Five point finite difference stencil within a 2D domain.

    One often finds the following notation to denote the discrete Laplacian,

    (3.26)

    The above stencil works for areas within the solution domain that are not close to a boundary, such

    as in Figure 3.3

    However, for nodes near boundaries, we would need to modify the stencil, for example, for the

    situation in Figure 3.3, we would use

    (3.27)

    and for the situation in Figure 3.3 we would use

    (3.28)

    If we have Dirichlet boundary conditions, then we know the values of the mesh points (nodes)

    on the region of the boundary, we are left applying the approximation to internal mesh points.

    This yields a linear system of equations of equations of the function . We usually write the

    system as:

    (3.29)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    7/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 47

    Figure 3.4: Five point finite difference stencil within a 2D domain near a boundary.

    Figure 3.5: Five point finite difference stencil within a 2D domain near a boundary.

  • 7/31/2019 Plugin Cs3200 Finite Differences

    8/25

    48 CHAPTER 3. FINITE DIFFERENCE METHODS

    where is an matrix of block tridiagonal form:

    . . .

    . . .

    . . .

    (3.30)

    Here, is the identity matrix and is the tridiagonal matrix,

    . . .

    . . .

    . . .

    (3.31)

    The vector consists of the unknown values at the nodes and is of dimension , while is

    the vector consisting of boundary data (with non-zero elements).

    Thus the solution to our problem can be found by solving for the vector ,

    (3.32)

    since is nonsingular, we will obtain a unique solution.

    3.3.1 Laplaces Equation A Numerical Example

    To illustrate the method, consider the steady-state heat conduction problem defined over our unit

    square. We want to find the finite difference approximation to Laplaces equation subject to the

    Dirichlet boundary conditions,

    (3.33)

    If we discretize our square into a uniform mesh with as shown in Figure 3.3.1. The nodes

    are numbered from , where nodes represent the interior

    nodes which we are solving for. We can apply the finite difference memthod using equation 3.19.

    Writing out a few of the nodes, we obtain for

    (3.34)

    and for

    (3.35)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    9/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 49

    . . . . .

    . . . . .

    . . . . .

    . . . . .

    . . . . .0 .50 1.0

    0

    .50

    1.0

    h =.25

    }

    Figure 3.6: Mesh used for the numerical solution of the steady-state heat equation.

    We continue the process for all nine interior nodes numbered from the left corner, proceeding

    along the x-axis, and obtain the following linear sys-

    tem of equations (notice that we have multiplied through equations 3.34 and 3.35 by a negative 1):

    (3.36)

    Upon solving the linear system, we obtain a vector of the temperatures. It is interesting to look

    at the distributions of temperature as a function of the number of elements (and thus step-size, ).

    The solution of the system shown in figure 3.3.1 and equation 3.36, we obtain the temperature

    distribution in 3.3.1. Youll note that the solution does not look very smooth. This is because

    we a fair amount of error due to inadequately discretizing the solution domain. As we increasethe number of elements (and thus decrease the step-size), we are able to reduce the discretization

    area. Figures 3.3.1, 3.3.1, and 3.3.1 show the iso-tempurature contours for succesive double of the

    number of elements along the x and y axes. As you can see, the solutions become smoother as we

    increase the number of elements (although there is still a problem near the bottom corners). Note

    that we have significantly increased the computational costs to obtain a more accurate solution.

    We started with a system of equations, and ended up using a system of equations.

  • 7/31/2019 Plugin Cs3200 Finite Differences

    10/25

    50 CHAPTER 3. FINITE DIFFERENCE METHODS

    1 1.5 2 2.5 3 3.5 4 4.5 51

    1.5

    2

    2.5

    3

    3.5

    4

    4.5

    5

    Figure 3.7: Temperature distribution, shown as iso-temperature contours for the solution of

    Laplaces equation from example 3.3.1. Here we have divided up the solution domain into 8

    panels with .

    1 2 3 4 5 6 7 8 91

    2

    3

    4

    5

    6

    7

    8

    9

    Figure 3.8: Iso-temperature contours for the solution of Laplaces equation from example 3.3.1.

    Here the solution domain is divided into 64 panels with .

  • 7/31/2019 Plugin Cs3200 Finite Differences

    11/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 51

    2 4 6 8 10 12 14 16

    2

    4

    6

    8

    10

    12

    14

    16

    Figure 3.9: Iso-temperature contours for the solution of Laplaces equation from example 3.3.1.

    Here the solution domain is divided into 256 panels with .

    5 10 15 20 25 30

    5

    10

    15

    20

    25

    30

    Figure 3.10: Iso-temperature contours for the solution of Laplaces equation from example 3.3.1.

    Here the solution domain is divided into 1024 panels with .

  • 7/31/2019 Plugin Cs3200 Finite Differences

    12/25

    52 CHAPTER 3. FINITE DIFFERENCE METHODS

    Since the solution of a system of equations is , we increased the number of operations by a

    factor of 37 and our storage costs by a factor of 100 (assuming double precision floats).

    We have increased the solution accuracy by uniformly dividing the number of elements into

    smaller paritions. However, as you might imagine, this isnt necessarily the most computationally

    efficient way to decrease the discretization error. It would seemingly make sense to only increasethe number of elements in the regions with the largest amount of error. But how do we do that

    if the finite different methodology utilizes uniform partitions? One answer is to use overlapping

    grids. We will address this method later on in the section on Adaptive Methods.

    I note that this problem can be solved analytically using a Fourier series [26]:

    (3.37)

    thus we can compare our finite difference solution with the solution generated by the Fourier series

    [26]:

    Node Fourier Solution Finite Difference Solution Absolute Error

    (1,1) 129.608 128.571 -1.0

    (2,1) 162.159 158.036 -4.1

    (1,2) 54.608 56.250 1.6

    (2,2) 75.000 75.000 0.0

    (1,3) 20.391 21.429 1.0

    (2,3) 28.624 29.464 0.8

    Table 3.1: Comparison of F.D. and Fourier Solutions

    3.3.2 Poissons Equation

    Before going on, lets take a minute to extend our method to including solving Poissons equation.

    The Poisson equation has a right hand side which does not equal zero,

    (3.38)

    Since we have already discretized the left hand side of the equation in 3.19, we simply need to add

    the right hand side,

    (3.39)

    Such that our solution can be written as,

    (3.40)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    13/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 53

    . .. . .

    . .. . .

    . .. . .

    . .. . .

    . .. . .1 2

    N+2N+1

    N

    2N

    N2

    Figure 3.11: Natural ordering for the interior grid points.

    where we have multiplied through by minus one. As an illustration of the kind of system this

    produces, we order the points in natural or row wise ordering and look at the system for .

    (3.41)

    Where, for the Dirichlet problem, the boundary data is given as:

    (3.42)

    We can then generalize the Poisson problem with Dirichlet boundary conditions as the

    linear system,

    . . .. . .

    . . ....

    ...(3.43)

    where

    (3.44)

    (3.45)

    (3.46)

    (3.47)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    14/25

    54 CHAPTER 3. FINITE DIFFERENCE METHODS

    3.3.3 Poissons Equation - A Numerical Example

    To illustrate the finite difference method as applied to Poissons equation, consider same steady-

    state heat conduction problem defined over our unit square as in our last example. This time we

    find the finite difference approximation to Poissons equation subject to the Dirichlet boundary

    conditions,

    (3.48)

    with the additional source term at the center of the square.

    We again discretize our square into a uniform mesh with as shown in Figure 3.3.1.

    This time, we can the finite difference memthod using equation 3.40.

    Upon solving the resulting linear system, we obtain a vector of the temperatures. Again we

    look at the distributions of temperature as a function of the number of elements (and thus step-size,

    ).

    1 1.5 2 2.5 3 3.5 4 4.5 51

    1.5

    2

    2.5

    3

    3.5

    4

    4.5

    5

    Figure 3.12: Temperature distribution, shown as iso-temperature contours for the solution of Pois-

    sons equation. Here we have divided up the solution domain into 8 panels with .

    Again we notice that as the number of elements increase (and the step-size decreases), the

    solution becomes smoother - and our computational costs increase.

  • 7/31/2019 Plugin Cs3200 Finite Differences

    15/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 55

    1 2 3 4 5 6 7 8 91

    2

    3

    4

    5

    6

    7

    8

    9

    Figure 3.13: Temperature distribution, shown as iso-temperature contours for the solution of Pois-

    sons equation. Here we have divided up the solution domain into 16 panels with .

    2 4 6 8 10 12 14 16

    2

    4

    6

    8

    10

    12

    14

    16

    Figure 3.14: Temperature distribution, shown as iso-temperature contours for the solution of Pois-sons equation. Here we have divided up the solution domain into 32 panels with .

    3.3.4 Iterative Finite Difference Methods for Elliptic Equations

    As you will recall from CS 5210, iterative methods are powerful techniques for approximating

    the solution to a large-scale linear system, . Some of the simpler iterative methods have

  • 7/31/2019 Plugin Cs3200 Finite Differences

    16/25

    56 CHAPTER 3. FINITE DIFFERENCE METHODS

    5 10 15 20 25 30

    5

    10

    15

    20

    25

    30

    Figure 3.15: Temperature distribution, shown as iso-temperature contours for the solution of Pois-

    sons equation. Here we have divided up the solution domain into 64 panels with .

    straightforward extensions to iterative methods for solving finite difference approximations for

    elliptic equations.

    Recall the Gauss-Seidel method. We first split the matrix into two pieces, . For

    the Jacobi method, and , where and are the lower and upper triangular

    parts of the matrix respectively. For the Gauss-Seidel method, the splitting is and

    . This leads to the Gauss-Seidel technique for solving :

    (3.49)

    We can cast a five-point finite difference approximation of Laplaces equation as an iterative

    method:

    (3.50)

    which can easily be extended to a Gauss-Seidel method for Poissons equation:

    (3.51)

    Similarly, one can write a Successive Over Relaxation (SOR) point iteratiion method for Poissons

    equation:

    (3.52)

    where

    (3.53)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    17/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 57

    Some properties of these iterative methods for finite difference approximations of elliptic equations

    include

    The Dirichlet boundary condition can be applied by setting at all of the boundary

    nodes for

    The initial estimate, can be chosen arbitrarily.

    The value for the right hand side is determined by .

    The methods as stated above are to be applied to a natural node ordering as shown in Figure

    3.11.

    The in the SOR method is the relaxation parameter. If then the SOR method reduces

    to the Gauss-Seidel method.

    3.3.5 Example: Algorithm for Finite Difference Approximation for Pois-

    sons Equation

    Here we provide a simple algorithm to solve the two-dimensional Poisson equation with Dirichlet

    boundary conditions for a rectangular (or square) region using an iterative Gauss-Seidel or SOR

    method.

    Algorithm FD 1: Iter Poisson(imax,jmax, ,kmax,tol,rmax)

    Function: Solves a two-dimensional Poisson equation using GS or SOR.

    Output: , the approximations of

    Inputs: imax and jmax - the number x and y intervals, , kmax - the number of iterations, tol

    - tolerance, rmax - max residual, and - the and intervals, Dirichlet boundary

    conditions on the lower, right, upper, and left edges of the sqaure respectively,

    - the right hand side

    Begin

    Define parameters

    Set boundary conditions

    For i to DoFor j to Do

    End

    Calculate the k-th iterate

  • 7/31/2019 Plugin Cs3200 Finite Differences

    18/25

    58 CHAPTER 3. FINITE DIFFERENCE METHODS

    For k to Do

    For i to Do

    For j to Do

    End

    End

    Calculate Residual

    If rmax tol then converged, otherwise, continue the loop as long as k kmax

    End

    Output SolutionEnd

    3.3.6 Neumann Boundary Conditions

    Now lets consider another type of boundary conditiont that occurs frequently in engineering field

    problems, the Neumann problem. The Neumann boundary condition, which is often denoted as the

    natural boundary condition (as opposed to the Dirichlet boundary condition which is often termed

    the essential boundary condition) is concerned with the flux (i.e. the normal of the gradient) at the

    boundary. The so-called, Neumann problem (when the Neumann boundary condition is appliedover the entire boundary) requires the solution of over subject to,

    on (3.54)

    For many physical situations, is equal to zero. This occurs when there is a so-called, no-flux

    boundary condition, such that the solution domain is somehow isolated and the field is not allowed

    to flow outside the domain. A simple example is in electrostatics when the solution domain is

    surrounded by a non-conducting media (like air) such that the current (flux) cannot flow outside

    the conducting solution domain. Suppose that the right edge of the square domain has a no fluxboundary condition. We would then write equation (3.54) as

    (3.55)

    Then the Laplacian difference equation operator for the point is

    (3.56)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    19/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 59

    The value for is unknown because it lies outside of the domain . What we can do is to

    use either a first order difference operator or a centered difference operator to approximate this

    quantity.

    (3.57)

    This yields an approximation that , which has an accuracy of . Substituting

    equation (3.57) into equation (3.56) yields

    (3.58)

    The stencil for this Neumann condition is show in Figure 3.3.6 in the bottom right corner. The

    stencils for the other three edges of a square domain are shown in Figure 3.3.6.

    n,j+1

    n1,j1,j

    1,j+1 u

    i,m

    i,m1

    4u

    n,j1

    2u 2,j4u 2u n,j

    2u

    u1,j1

    4

    u

    4ui+1,ui1,1

    i,2

    i1,mu u

    u

    uui,1

    i+1,1

    u

    Figure 3.16: Stencils for Neumann no flux boundary conditions applied to a square domain.

    While a zero Neumann condition is often the case, it is not always the case, therefore lets look

    at the general case. To illustrate how to incorporate non-zero Neumann boundary conditions into

    our finite difference formulation, lets consider our example of solving a heat conduction problem

    on the unit square [27].

  • 7/31/2019 Plugin Cs3200 Finite Differences

    20/25

    60 CHAPTER 3. FINITE DIFFERENCE METHODS

    . . . . .

    . . . . .

    . . . . .

    . . . . .

    . . . . .

    20

    20

    20

    20

    20

    20

    20

    20

    20

    . . . . .

    . . . . .1 2 1

    a b a

    a b a

    203 4 3

    u = 15

    u = 15

    1 2 1

    3 4 3

    5 6 5

    Figure 3.17: Set-up for the the steady-state heat equation with Neuman boundary conditions.

    3.3.7 Poissons Equation with Neumann Boundary Data - A Numerical Ex-

    ample

    Consider our unit square as a steel plate which is uniformly generating heat at each point a t a rate

    of . The thermal conductivity of the plate is cal/sec cm C/cm. Forthis problem, Poissons equation holds

    (3.59)

    Assume that the top and bottom faces are perfectly insulated so that no heat is lost, but the upper

    and lower edges lose heat according to

    C/cm (3.60)

    in the outward direction as shown in Figure 3.3.7. Furthermore, the right and left edges are heldat a constant temparture C. Our goal is to find the steady-state tempartures within the area

    of the plate. In this problem, the upper and lower edge temperatures are also unknown, which

    increases the number of unknowns we need to solve for. Because of the symmetry, we can limit

    ourselves to a system of values. We now apply the five-point difference formula to the system.

    We notice that at the upper and lower edges, we cannot form the five-point combination as there

    are not enough points outside the boundary. We get around this by extending our mesh to include

  • 7/31/2019 Plugin Cs3200 Finite Differences

    21/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 61

    an additional row (upper and lower) of exterior points. This gives us the following set of equations:

    (3.61)

    (3.62)

    Now we apply the Neuman boundary condition utilizing the difference formula for the first partialderivative. Note that we make sure to choose the order of the points so that it reflects that the

    outward normal is negative, since heat is flowing outwardly.

    (3.63)

    We now eliminate the exterior rows of points we added and then solve our system of equations.

    Now lets generalize things a bit, the Neumann conditions for Laplaces equation on the unit

    square can be summarized as,

    (3.64)

    (3.65)

    along the and axis respectively. The minus signs denote that the gradients always are pointing

    outward, away from the boundary. We now apply a finite grid of points to the square (as we did

    before). Then we apply the five point formula to all of the grid points within the domain

    . When we apply our five point formula to the points on we note that it involes the set of

    points: , where , which lie outside

    the boundary. We use the derivative boundary conditions to eliminate these points outside of the

    boundary. Recalling the Taylor series approximation for first order partial derivatives,

    (3.66)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    22/25

    62 CHAPTER 3. FINITE DIFFERENCE METHODS

    (3.67)

    we use these as replacements for the exterior points in the five point formula,

    (3.68)

    (3.69)

    (3.70)

    (3.71)

    where . These may be used in the five point formula along

    respectively.

    The equations which arise from the Neumann problem then can be written as,

    (3.72)

    where the matrix now has the form,

    . . .. . .

    . . .(3.73)

    Here, is the identity matrix of order and now is the tridiagonal matrix,

    . . .. . .

    . . . (3.74)

    thus the solution to the general Neumann problem is,

    (3.75)

    One can prove that the matrix is singular, and thus, does not have a unique solution. Usually the

    field problems that we encounter in engineering and science have mixed boundary conditions, i.e.

    portions of the surface have Neumann boundary conditions, while other portions have Dirichlet

    boundary conditions, thus rendering a nonsingular matrix (and unique solution).

  • 7/31/2019 Plugin Cs3200 Finite Differences

    23/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 63

    .

    .

    ..

    u

    u

    u

    u

    1

    2

    3

    4

    d

    d

    d d1

    23

    4

    hh

    h

    h

    u0

    .

    Figure 3.18: Irregular spacing for the five-point finite difference formulation.

    3.3.8 Irregular Regions

    So far weve treated solution domains in which the boundary coincided with nodes from our mesh.

    For many problems, we will have irregular domains and thus must re-think our approach. One

    approach to this problem is to continually subdivide our mesh into smaller and smaller grid points

    such that the uniform mesh can approximate the irregular boundary. While this will usually work,

    this adds a tremendous amount of additional computation since we must usually add a large number

    of additional degrees of freedom. Another approach is to redefine our difference formulas to take

    into account the irregular region. Still other approaches use domain decomposition approaches

    with meshes of different levels of refinement, interpolation methods, and/or combinations of all the

    above. Lets explore the option of modifying the difference formulas to account for the irregularboundary.

    Consider the case of using the five-point formula but for unequal lengths between nodes as

    shown in Figure 3.3.8. Along the line from to to , we have the following approxmations

    for the first derivatives:

    (3.76)

    (3.77)

    Since

    (3.78)

    we have

    (3.79)

    A similar expression exists for . Combining and rearranging, we obtain

    (3.80)

  • 7/31/2019 Plugin Cs3200 Finite Differences

    24/25

    64 CHAPTER 3. FINITE DIFFERENCE METHODS

    u = 100

    1 2 3

    4 5 76

    8 9 10 11 12

    u = 0

    Figure 3.19: Example of a curved boundary.

    We then use this new operator for points adjacent to the boundary points when the boundary points

    do not coincide with the mesh, instead of our standard five-point rule. If there are Neuman bound-

    ary conditions on the curved part of the boundary, then we must go back and re-derive the approx-

    imation for the Neuman condition (this gets rather invovled) [26].

    3.3.9 Numerical Example: Curved Boundary

    Consider the following example of solving the steady-state heat flow equation on a semicircularplate of radius . The temperature at the base is and the temperature on the circumference is .

    The analytic solution is

    (3.81)

    We now impose a uniform mesh on the semicircular region as shown in Figure 3.3.9. Notice that

    the mesh points, dont coincide with the boundary. What we do is use the geometry

    to figure out what the values for . It turns out that the short part for and

    for . We continue to apply this method for the rest of the points using our newnon-uniform operator. For this particular problem, the finite difference solution is in very good

    agreement with the analytic solution. As you can imagine, this method would not be very efficient

    for domains with many different curved regions. A more reasonible way to approach the problem

    would be to simply use the mesh point which is closest to the point on the boundary - in effect,

    perturbing the actual region. Obviously one introduces errors by using this method, however, if the

    distance between the mesh point and boundary is not too large, then the result can be satisfactory.

  • 7/31/2019 Plugin Cs3200 Finite Differences

    25/25

    3.3. FINITE DIFFERENCE FORMULATION FOR ELLIPTIC EQUATIONS 65

    Now, if you are working on circular or cylindrical boundaries, then you can use a finite dif-

    ference approximation for Laplaces or Poissons equation in polar or cylindrical coordinates. For

    example, consider the two-dimensional Laplaces equation in polar coordinates:

    (3.82)

    One defines a grid in polar coordinates . Represent the solution as .

    Then one can use a centered difference representation of equation (3.82). This yields a polar

    coordinate finite difference version of Laplaces equation.

    (3.83)

    3.3.10 Higher Order Approximation

    Thus far, we have discussed the five-point stencil. By including nearest neighbors on a 2D stencil,

    we can decrease the truncation error and increase the accuracy (at a computational cost, of course).

    This yields the so-called nine-point finite difference approximation for the Laplacian operator:

    (3.84)

    Or in stencil format:

    (3.85)

    The truncation error for the nine-point difference formula is on the order of for Poissons

    equation and for Laplaces equation

    3.3.11 The Laplacian Operator in Three Dimensions

    We can extend the finite difference formulation to three-dimensions by just adding the approxima-

    tion for the z-axis

    (3.86)

    or

    (3.87)

    Now the value is the arithmetic average of its six nearest neighboring values instead of four in

    the two-dimensional case.