0% found this document useful (0 votes)
88 views

L04 - 2D Finite Difference Method

This document summarizes a lecture on using finite difference methods to solve multidimensional partial differential equations. It discusses applying the method to 2D Poisson problems on orthogonal grids, including deriving approximations for derivatives and setting boundary conditions. It also introduces how to extend the approach to 3D problems by including additional nodes in the numerical stencil.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

L04 - 2D Finite Difference Method

This document summarizes a lecture on using finite difference methods to solve multidimensional partial differential equations. It discusses applying the method to 2D Poisson problems on orthogonal grids, including deriving approximations for derivatives and setting boundary conditions. It also introduces how to extend the approach to 3D problems by including additional nodes in the numerical stencil.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

University of Tripoli

Mechanical & Industrial Engineering Department


www.me.uot.edu.ly

ME626 Advance Numerical Analysis

Lecture 4:
FDM - Multidimensional Problems
Instructor: Samah Alghoul


 Outlines

➢Multidimensional Problems

➢2D Poisson

➢Introduction to 3D

➢ Higher-order Approximations

➢ Difference Approximations in Cylindrical Coordinate System

➢ Coordinate Transformation to Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 2


Two Dimensional Finite
Difference


6/29/2019
 Two Dimensional Finite Difference

› Consider Poisson equation in a


two-dimensional

› Finite difference
approximations to the
derivatives will now be derived
on the orthogonal grid,

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 4


 Two Dimensional Finite Difference
› Nodes are now denoted by the double
index (i, j)
▪ where i the nodal index in x direction
▪ and j the nodal index in y direction
› Index i starts from a value of 1 at the x=0
line and goes up to a value of N at the
x=L line.
› Index j starts from a value of 1 at the y=0
line and goes up to a value of M at the
y=H line.
› The nodes in the stencil are also denoted
by O, E, W, N, and S.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 5


 Two Dimensional Finite Difference

› Assume that the nodes are uniformly spaced both in the x and y directions, such that

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 6


 Two Dimensional Finite Difference

› 2D Taylor series expansions. Expanding φi + 1, j about φi, j,

cross-derivative

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 7


 Two Dimensional Finite Difference

› For cartesian grid yi +1, j = yi,j


› Also, xi+1,j- xi,j=∆x,
› Previous equation reduces to

› It is worth emphasizing that the reduction was possible because the grid is
orthogonal.
› If the grid were not orthogonal, the cross-derivative containing terms would
remain, making the derivation of the finite difference approximation
considerably more complicated.
6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 8
 Two Dimensional Finite Difference

› Following the same procedure for deriving the central difference scheme, we
also expand φi-1, j about φi, j, yielding

› Adding the last two equations

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 9


 Two Dimensional Finite Difference

› Expanding φi,j + 1 and φi, j-1 about φi, j and following the same procedure yields

› Substitution into Poisson PDE

› As in the 1D case, this equation is valid only for the interior nodes, i.e., for i =
2, 3,..., N-1 and M = 2, 3,..., M-1.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 10


 Two Dimensional Finite Difference: BC

› Consider the following boundary conditions on the four boundaries,

∅ = ∅𝑇

∅ = ∅𝐿 ∅′ = 𝐽𝑅

𝛼∅ + 𝛽∅′ = 𝛾
6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 11
 Two Dimensional Finite Difference: BC

› It is customary to let Dirichlet


boundary condition override all other
boundary conditions.
› (1,1) = L
› (N,M) = T

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 12


 Two Dimensional Finite Difference: BC

› We have a mathematical discontinuity


at the corner nodes where the two
Dirichlet boundary conditions meet.
› Therefore, either of the two boundary
values, or even an average value, may
be used.
› This is justified because the value
chosen for the corner node does not
impact the rest of the solution since
the two nodes adjacent to it also have
Dirichlet conditions.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 13


 Two Dimensional Finite Difference: BC

Bottom boundary condition (Robin)

› Use the same procedure described before, with the exception that the expansion
in y direction instead of in x direction.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 14


 Two Dimensional Finite Difference: BC

› As shown, any node on the bottom boundary, with the exception of the two
corners, has nodes both to its right as well as to its left.
› Therefore, the same procedure that was used earlier to derive the second
derivative in x can still be applied to these boundary nodes. Therefore, we
obtain

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 15


 Two Dimensional Finite Difference: BC

› In order to satisfy the governing equation at the boundary, we now substitute


previous derivative into the PDE to yield

› for i=2,3, ..., N-1

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 16


 Two Dimensional Finite Difference: BC

Right Boundary Condition (Neumann)

› It requires two backward Taylor series expansions to approximate the second


derivative in x, as follows:

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 17


 Two Dimensional Finite Difference: BC

› Substitute the boundary equation into previous equations for the first derivative
and use the same procedure to cancel the third derivative.
› This yields,

› Substituting into PDE

› This equation is valid for j=2,3, …, M-1

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 18


 Two Dimensional Finite Difference: BC

Right Bottom Corner


› The result is a combination of the two expressions derived for the two
boundaries and may be written as

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 19


 Two Dimensional Finite Difference: Summary

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 20


 Two Dimensional Finite Difference: Summary

› Interior nodes: i= 2,3,…, N-1 & j=2,3,…,M-1

› Left boundary: j=1,2,3,…,M

› Right boundary: j=2,3,…,M-1

› Bottom boundary: i=2,3,…, N-1

› Top boundary: i=2,3,…,N

› Right bottom corner:

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 21


 Two Dimensional Finite Difference

Global Node Numbering


› Because the solution is a 1D column matrix, not a 2D matrix, this implies
combining the i and j indices into a single unique number assigned to the node.
› One way to number the nodes is to start from the left bottom corner and
number the nodes along the bottom most row 1 through N, then turn around
and number the second row of nodes N + 1 through 2N, and so on.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 22


 Two Dimensional Finite Difference

› This procedure can actually be


derived by using the node’s i and j
indices, as follows:
k = (j - 1) N + i
› the five nodes in the stencil now
have the indices
▪ O→k
▪ W→k-1
▪ E→k+1
▪ S → k-N
▪ N → k+N

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 23


 Two Dimensional Finite Difference

› Once the nodes have been numbered uniquely, all nodal equations must first be
rearranged in the following general form:

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 24



Two Dimensional Finite Difference: Fill [A] & [Q] for interior
nodes

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 25


 Two Dimensional Finite Difference

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 26



Two Dimensional Finite Difference: Fill [A] & [Q] for right
boundary nodes

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 27


 Two Dimensional Finite Difference: Transform 1D to 2D

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 28


Multidimensional
Problems: 3D


 Multidimensional Problems: 3D
› In 3D, the stencil extends in the third
direction and includes two additional nodes,
F (for forward) and B (for backward).
› Global index, k, is:

› the procedure to be followed is exactly the


same as for 2D.
› Taylor series expansions must be performed
in individual directions to derive expressions
for each of the three partial second
derivatives and subsequently substituted into
the governing equation to obtain the discrete
nodal equation.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 30


Higher-Order
Approximations


 Higher-order Approximations
› So far we used second order accurate schemes.
› In many applications second-order accuracy is often considered inadequate,
such as computation of :
▪ turbulent flow
▪ acoustics calculations.

› In such a scenario, a higher-order scheme is warranted so that the same


accuracy can be attained with a coarser grid.

› Our objective is to derive a difference approximation for the second derivative


that shall have accuracy better than second order on a uniform grid.
 Higher-order Approximations

› Consider 1Poisson equation in a two-dimensional

› Higher order Approximation of the seconded derivative

Derive this
formula

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 33


 Higher-order Approximations

› In the event that the boundary condition is not of the symmetry or periodic
type, it is customary to revert back to a lower-order scheme for nodes adjacent
to the boundary.
› It goes without saying that such an approach will contaminate the accuracy of
the nodes where the fourth-order scheme is being used.
› As to how much the solution will be contaminated is problem dependent
(depending on the nonlinearity of the solution).

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 34


 Higher-order Approximations

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 35


 Higher-order Approximations

› =0 at x =0
› =1 at x=1

› S = ex
› The Analytical Solution (x) = ex + (2-e) x -1

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 36


 Higher-order Approximations

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 37


 Higher-order Approximations

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 38


 Higher-order Approximations

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 39


 Higher-order Approximations

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 40


Difference Approximations in
Cylindrical Coordinate System


 Cylindrical Coordinate System

➢The cylindrical shape is probably the second most commonly encountered


regular shape in engineering applications.
➢In many applications, angular symmetry is valid, making the computations so-
called 2D axisymmetric.
➢ The cylindrical coordinate system has three independent variables (three
coordinates):
▪ Radial, r
▪ Angular or Azimuthal, 
▪ Axial, z
 Cylindrical Coordinate System

› In the cylindrical coordinate system, the Poisson equation is written as

› As in the case of Cartesian coordinates, one can formulate 1D, 2D, and 3D
problems in the cylindrical coordinate system.
› Formulating a 1D problem in the z direction is no different than formulating a
1D problem in the Cartesian coordinate system.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 43


 Cylindrical Coordinate System

› A 1D problem in  direction is rarely encountered for practical applications.


› The most common scenario for which a 1D problem may be formulated is one
where the solution in the radial direction is sought.
› For example, trying to determine the temperature distribution inside a long
nuclear fuel rod would require solution of the 1D heat conduction equation in
radial coordinates.
› Therefore, we start our discussion with an ordinary differential equation in
radial coordinates, written as

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 44


 Cylindrical Coordinate System

› In order to derive finite difference approximations for the first and second
derivatives, we perform two Taylor series expansions as before – one forward
and one backward – as follows:

› where ∆r = r0 / (N -1)
6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 45
 Cylindrical Coordinate System

› The first derivative, is derived by subtracting second from first equation

› While, adding to derive an approximation for the second derivative

› Substituting in Poisson yields the necessary finite difference equation for the
interior nodes:

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 46


 Cylindrical Coordinate System: BC

› The procedure for the treatment of the boundary conditions is almost identical
to the Cartesian coordinate system.
› A boundary condition at the axis, i.e., at r=0 represents the axis of symmetry,
the symmetry boundary condition is appropriate at that location and is written
as

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 47


 Cylindrical Coordinate System

› this boundary condition may be applied by itself,


or it may be substituted into the governing equation.
› An attempt to satisfy the governing equation at the boundary reveals a
difficulty:
› the first derivative containing term, becomes undefined at r = 0 (= 1/0).
› Strictly speaking, the governing equation is not valid at the boundary and must
be satisfied at the boundary only in a limiting sense.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 48


 Cylindrical Coordinate System

› Thus, instead of substituting r = 0, we take the limit of this term as r


approaches zero.
› To do so, we apply L’Hospital’s rule, as follows:

› Substituting, we obtain a governing equation at axis of the cylinder (r=0)

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 49


 Cylindrical Coordinate System

› A scenario often encountered in engineering analysis is the 2D axisymmetric


scenario – one where there is no azimuthal (or angular) variation of the
dependent variable and only radial and axial variations.
› Flow through a pipe is the most common example of angular symmetry
because no-slip (zero velocity) conditions prevail around the circumference of
the pipe.
› To extend the 1D radial calculations to 2D axisymmetric calculations, one only
needs to include the second derivative with respect to z in addition.
› Since this term is identical to any of the derivatives in the Cartesian coordinate
system, it can be treated in exactly the same manner, as discussed in the
preceding sections.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 50


Coordinate Transformation to
Curvilinear Coordinates


 Curvilinear Coordinates
› If the nodes are not placed along the Cartesian grid lines, Taylor series expansions
result in nonzero cross-derivative containing terms.
› Derivation of finite difference approximations becomes quite complicated and tedious.
› The basic is to transform the governing differential equation written in Cartesian
coordinates to a new coordinate system.
› This new coordinate system may have axes that are either straight lines or curves.
› For the general case of curved axes, the new coordinate is known as a curvilinear
coordinate system.
› When these curved axes align exactly with the outer contour of the computational
domain (or body), the resulting mesh is called a body-fitted mesh or body-fitted grid.
 Curvilinear Coordinates

› The main difference


– in the Cartesian coordinate system the unit vectors (or basis vectors) are global,
– in a curvilinear system, the basis vectors are local (locally tangential to the curve) and are
known as covariant basis vectors.

› Figure shows a Cartesian coordinate system (x1, x2, x3) and a general
curvilinear coordinate system (ξ1, ξ2, ξ3).
› In the case of the Cartesian coordinate system, the unit vectors 𝑥ො1 𝑥ො2 𝑥ො3 are
global, while in the case of the curvilinear coordinate system, the unit vectors
𝜉෡1 , 𝜉෡2 , 𝜉෡3 are local.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 53


 Curvilinear Coordinates

› The transformation from (x1, x2, x3) to (ξ1, ξ2, ξ3) is called forward
transformation and may be written as

› In most cases, the forward transformation can be written in explicit functional


form.
› The opposite transformation, called backward transformation, cannot usually
be written in explicit form.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 54


 Curvilinear Coordinates

› As an example, if we transform from Cartesian to spherical coordinates, we can


write the following relationships:
▪ x = r sin cosψ,
▪ y = r sin sinψ,
▪ z = r cos
› i.e., the forward transformation relationships are explicit.
› However, the backward transformation cannot be written in such explicit form.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 55


 Curvilinear Coordinates

› Since PDEs contain derivatives, our first task is to express each partial
derivative in the Cartesian coordinate system in terms of partial derivatives in
the curvilinear coordinate system.
› Using the chain rule of partial derivatives, we may write Jacobian of the backward
Chain rule of calculus transformation

gradient of the scalar φ in the Cartesian


6/29/2019 coordinate Curvilinear coordinate system 56
 Curvilinear Coordinates

› For a 3D system, the forward transformation may be written as

› Therefore, we may write

❖ Cartesian tensor notations have been used for the sake of compactness ( it corresponds to summation for i=1,2,3).
6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 57
 Curvilinear Coordinates

› Similarly, the backward transformation may be written as


ξ1 = ξ1(x1, x2, x3) , ξ2 = ξ2(x1, x2, x3) , ξ3= ξ3(x1, x2, x3)
› using this general description, we may write

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 58


 Curvilinear Coordinates

› Substituting we obtain  into x › Grouping terms containing dx1, dx2, and


dx3 separately on the right-hand side

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 59


 Curvilinear Coordinates

› Therefore,

Jacobian of the forward Jacobian of the


transformation backward transformation

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 60


 Curvilinear Coordinates

› it is evident that the Jacobian of the backward transformation is the inverse of


the Jacobian of the forward transformation.
› Denoting the Jacobian of the forward transformation by [J], one maywrite

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 61


 Curvilinear Coordinates

› Since [J] is at most a 3 × 3 matrix, its inverse can be determined easily using
Cramer’s rule, and subsequently, last equation may be written as

› where ij are the cofactors of the matrix [J], and J its determinant.
› It can be shown that the cofactors can be inserted inside the derivatives [see
derivation of Eq. (C.12) in Appendix C]

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 62


 Curvilinear Coordinates

› We will now transform the Poisson equation to the curvilinear coordinate


system. To do so, we begin by writing the Poisson equation in Cartesian tensor
notations:

› here the quantity ikij represents a matrix–matrix multiplication (or tensor


product) and is often written using a new symbol as

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 63


 Curvilinear Coordinates

› Substitute and expand

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 64


 Curvilinear Coordinates

› the governing equation in transformed coordinates will have cross-derivatives


when the off-diagonal components of the [B] matrix are nonzero.
› This will happen when the ξ1, ξ2, and ξ3 lines are not perpendicular to each
other.
› As we will see shortly in an example, finding finite difference approximations
to cross-derivatives is somewhat difficult.
› For this reason, many mesh generation algorithms make use of conformal maps
or angle preserving transformations in which if one starts with an orthogonal
mesh on a regular rectangle or brick and then transforms it to a nonregular
shape, the curves still intersect perpendicular to each other, although the grid
lines become curves.

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 65


 Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 66


 Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 67


 Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 68


 Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 69


 Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 70


 Curvilinear Coordinates

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 71


72


21 22 23 24 25

16 17 18 19 20

11 12 13 14 15

6 7 8 9 10

1 2 3 4 5

6/29/2019 ME 626 ADVANCED NUMERICAL METHODS 73

You might also like