Finite difference approximation of boundary conditions along irregular boundaries
-
Upload
bruce-hunt -
Category
Documents
-
view
229 -
download
4
Transcript of Finite difference approximation of boundary conditions along irregular boundaries
INTERNATIONAL JOURNAL FOR NUMERICAL METHODS IN ENGINEERING, VOL. 12,229-235 (1978)
FINITE DIFFERENCE APPROXIMATION OF BOUNDARY CONDITIONS ALONG IRREGULAR BOUNDARIES
BRUCE HUNT Civil Engineering Department, University of Canterbury, Christchurch, New Zealand
INTRODUCTION
The approximation of normal derivatives along a curved boundary becomes a major difficulty in obtaining finite difference solutions for irregular regions. A number of authors (for example, Allen,’ Fox,’ Greenspan3 and Parker and Ma4) have suggested various solutions to this problem. However, most of these suggested methods are fairly cumbersome to use since they require the use of different formulas for various combinations of mesh and boundary geomet- ries. This note shows a different way to approximate a quite general boundary condition along curved boundaries. The method uses a uniformly spaced mesh, is simple, general, relatively easy to program and appears to give accurate results.
THE FINITE DIFFERENCE APPROXIMATION
Let a, fi and F be piecewise continuous functions prescribed along a boundary, and let d4ldn be the derivative of 4 in the direction of the outward normal. A finite-difference approximation will be obtained for the following boundary condition:
The dependent variable, 4, will be approximated near node 0 in Figure 1 with a truncated Taylor expansion
840 840 1 2 a240 aY 2 ax axay
4 = 4 o + z ( x -xo)+-(y -yo)+- T ( X -xo) +-(x -xo)(y -yo)
in which A is the spacing between nodes in both the x and y directions. The five unknown derivatives at point 0 in equation (2) can be found by evaluating equation (2) at points 1-5 and solving the resulting set of simultaneous equations. This gives the following approximations:
(0029-598 1 /78/02 12-0229$01 .OO @ 1978 by John Wiley & Sons, Ltd.
Received 8 December 1975 Revised June 1976 and February 1977
229
230 B. HUNT
_I Figure 1. Finite difference mesh near a boundary
Equation (2) can be evaluated at point P, the point on the boundary which is closest to node 0, by setting
(x - XO) = EN^
(Y - Y 0) = EN,
(8)
(9)
The direction cosines of the unit normal, N, and N,, are always positive in Figure 1, and E is positive or negative depending upon whether point 0 lies inside or outside, respectively, of the solution domain. Substitution of equations (8) and (9) into equation (2) gives an approximation for 4 at point P.
~ P = ~ O + ( ~ N , + * N ~ ) E + - ( ~ N ~ + ~ - N ~ N , + - T N ~ ) ~ 1 a240 a240 2 2 +O(A3) (10) aY 2 ax axay aY
Equation (10) holds for all points along a line which passes through point 0 and is normal to the boundary. Thus, E is arc length in the outward normal direction, and equation (10) can be differentiated with respect to E to obtain
Substitution of equations (3)-(7) into equations (10) and (11) and substitution of equations (lo) and (11) into equation (1) give the final result
co40 + el41 - c242 - c343 + c444 + cs4s = FP (12)
BOUNDARY CONDITIONS ALONG IRREGULAR BOUNDARIES
The constants in equation (12 ) are given by
in which
23 1
The error term in equation (12) is O(aA2+pA3), and a little reflection shows that equations ( 1 2 b ( 2 0 ) hold for all of the possibilities that are shown in Figure 2 if the nodes are numbered in the way shown and if N, and Ny are absolute magnitudes of the outward pointing, unit normal components.
02 05
0 1
.I 1.
5. 2.
Figure 2. Mesh geometries for application of equation (12)
232 B. HUNT
EXAMPLES
Equation (12) was tested by comparing exact and numerical solutions of the Laplace equation subjected to the boundary condition given by equation (1). The following three cases were considered: (a, p)= (1, 0) everywhere along the boundary, which is known as the Neumann problem; (a, p ) = (0, 1) everywhere along the boundary, which is known as the Dirichlet problem; (a, p ) = ( 1 , O ) and (0, l ) along separate portions of the boundary, which is known as the mixed problem. The solution of the Neumann problem is only unique to within an additive constant, and numerical solutions of the Neumann problem were made unique by specifying a value of 4 at either one interior or one boundary point. It was decided to consider only problems with exact solutions given by products of trigonometric and exponential functions since equation (12) and the central difference approximation of the Laplace equation give exact results for all second-degree polynomial solutions.
The first problem that was considered has the exact solution
4 = cos x cosh y (21) Equation (21) was taken to hold within the irregular region shown in Figure 3, and boundary conditions for the numerical calculations were obtained by evaluating equation (21), and its normal derivative, upon the chosen boundary. Percentage errors, rounded off to the nearest 0.1 per cent, are shown in Figure 3 for the Dirichlet and Neumann problems, respectively. The numerical solution for the Dirichlet problem is noticeably more accurate than the corresponding
A Percent Error
I -0.7 (Oirichlet Problem) -0.9 -0.9 -0.9
1 0.0 20 0% -0.1
-0.9 -0.9 -0.9 -1.0 -1.0
-1.2lNeumann 4 I h = 0.1 units
! 00 I 80 0.0 2 0 0% -0.1
00 i 0'0 0% om0 om0
0.0 0% 0% om0 0% -0.9 -3.9 -1.0 -0.9 -1.0
-0.8 -0.E -1.0 - 1 . 1 -0.9
-0.7 -0.e -0.a -0.9 - 1 . 1 -1.2 - 1 . 4 -1.6 -1.9 -2.2
1 0.0 0% 20 0% 20 oao 03 - 0 5 -0'1 -0e2
1
-0.6 -0.6 -0.E -0.9 - 1 . 1 -1.2 -1.4 -1.7 -1.9 -2.3
ao 0% 0% 0% 0% 0'0 0% -07 -0.1 -0'2 0.0 -0.4 -0.6 -0.9 -1.0 -1.2 -1.4 -1.7 -2.0 -2.4
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.2 a2 -0.3 -0.6 -0.8 -1.0 -1.2 -1.4 - 1 . 7 -2.0 -2.4
Figure 3. Percentage errors calculated for the first example
BOUNDARY CONDITIONS ALONG IRREGULAR BOUNDARIES 233
solution for the Neumann problem, and solution of the approximating sets of algebraic equations by the Gauss-Seidel iterative technique required about 28 times as many iterations for the Neumann problem as for the Dirichlet problem. The reverses in boundary curvature in Figure 3 do not appear to affect error magnitudes significantly in either solution.
The second problem that was considered has the exact solution
4 = ey(cos x +sin n) (22) within the circle of unit diameter that is shown in Figure 4. Percentage errors for the Dirichlet and Neumann problems are shown below the corresponding nodes in Figure 4, and, once again, errors are larger for the Neumann problem. The result of halving the node spacing is shown in Figure 5 for the Neumann problem. The corresponding Dirichlet solution, which is not shown, had a maximum error magnitude of 0.4 per cent. With both node spacings, about 15 times as many iterations were required to obtain a solution of the Neumann problem as for the Dirichlet problem. Percentage errors for the mixed problem, which were obtained by setting (a, p ) = (1, 0) and (0,l) along the top and bottom halves of the circle, respectively, are shown in Figure 6.
Finally, the writer would like to point out that use of equation (12) makes it relatively easy to write a program that is general enough to solve almost any elliptic boundary-value problem which has equation (1) for its boundary condition. On the other hand, certain combinations of boundary conditions and boundary geometry may still require special treatment. For example special consideration may have to be given to boundary conditions at sharp corners where the unit normal cannot be prescribed uniquely. This was not a difficulty for the solution shown in
Percent Error 0
- 0.1 (Dirichlet Problem Y 2.LlNeumann ‘ 8 )
-3.4 -2.6 -1.9 006 - 5.2
X - oe2 -0.1 0:o 0.1 -5.3 -2.9 -2.0 -1 .5 -1.0 I \:: -; I)
-0.4 0.2 -0.4 -0.4 -0.6 -0.6 v
Figure 4. Percentage errors calculated for the second example
234 B. HUNT
Percent Error
- 0.SINeumonn Problem 1
I J . 1
-2.1 -1:s -1:l -0:g -Of7 -0!6 -0;s -0;6 -0% -0% -A6 --' -1.9 -1.3 -l!O -Of8 -0:7 -0:s -Of6 -0% -0% -0% -0.7 . . . . .
-0!8 -0:7 -0.6 -0.6 -0.6 -0.6 -0.6
-Of5 -Of5 -Of5 -Of6 -0:s
-0:2 -Or4 -Of5 -0:s -0:s b -0% -d Figure 5. Percentage errors for the second example with a smaller node spacing
Y Percent Error t 0.5IMixed Problem I
. 1
/ 0 3 7 7 = O h O : 4 A = 0.1 units
\ \.
0.5 0.3 0.2 0.1 Or1 Or1 -0.1 / I / 1 \
0.8 0:5 $3 0:2 0.1 O!O or0 O!O 0.0
0:8 0:5 0:3 0:2 0; 1 0:o or0 or0 o:l\
Y - 0.9 Of6 Of4 Of3 0!2 0.1 0:l Of0 O!O O!l
0.0 0:3 Of3 0:2 0:2 1 1 o;l OlO $0 i0 d0 1 I 1. oft 0:2 of2 0:2 o!r otl O!l 0:o of0 oto 0.0
Figure 6. Percentage errors for the mixed problem
BOUNDARY CONDITIONS ALONG IRREGULAR BOUNDARIES 235
Figure 3 because singularities did not occur in the exact solution at the sharp corners. Thus, the outward unit normal at the lower right hand and upper left hand corners were chosen in the positive x and y directions, respectively, and the outward unit normal at the origin was chosen in either the negative x or y direction.
REFERENCES
1. D. N. de G. Allen, ‘The application of relaxation methods to satisfy normal-gradient boundary conditions associated with three-dimensional partial differential equations’, Quart J. Mech. and Appl. Math. I, 43-5 1 (1962).
2. L. Fox, Numerical Solution of ordinary and Partial Differential Equations, Pergamon Press, London, 1962. 3. D. Greenspan, Introductory Numerical Analysis of Elliptic Boundary Value Roblems, Harper and Row, New York,
4. R. Parker and C. Y. Ma, ‘Normal gradient boundary condition in finite difference calculations’, Znt. J. num. Meth. 1965.
Engng, 7,395411 (1973).