Download as pdf
Download as pdf
You are on page 1of 191
A Beginner’s Course in Boundary Element Methods © 2007 WT Ang by WHYE-TEONG AN Website: www.ntu.edu,sg/home/mwtang/bemsite.htm ‘Comments on this document may be sent to the author at wtang@pmail.ntu.edu.sg, No part of this document may be reproduced and distributed in any form or used in any ‘way for material profits without prior written permission of the author. ‘The author does not bear any responsibility for injuries and/or damages to persons or properties that arise from the use of ideas or methods contained in this document. Contents 1 Two-dimensional Laplace's Eaquation Ld 12 13 ld 15 16 LT 18 19 1.10 Exercises Introduction... . « Findamental Solution Reciprocal Relation . Boundary Integral Solution Boundary Element Solution with Constant Elements Formulae for Integrals of Constant Elements Implementation on Computer . Numerical Examples . Summary and Discussion 2 Discontinuous Linear Elements 2 22 23 24 25 26 27 Introduction Boundary Element Solution with Discontinuous Linear Elements Formulae for Integrals of Discontinuous Linear Elements Implementation on Computer. Numerical Examples. Summary and Discussion Exercises 3 Two-dimensional Helmholtz Type Equation 31 32 33 Introduction Homogeneous Helmholtz Equation 3.2.1 Fundamental Solution 3.2.2 Boundary Integral Solution 3.2.3 Numerical Procedure . i 3.2.4 Implementation on Computer . Helmholtz Type Equation with Variable Coefficients 3.3.1 Integral Formulation 3.3.2 Approximation of Domain Integral 3.33 Duabreciprocity Boundary Element Method of BT 87. 58. 58. 59 60, 0 7 7 73 i) CONTENTS 3.34 Implementation on Computer... .. 0. . 00.0% 7 34 Summary and Discussion... 2.0.0... c ee eee eee 87 35 Exercises... 0.2... 0. BeeP ie eee eee Perio eee ‘Two-dimensional Diffusion Equation 91 4.1 Introduction a 4.2, Dualreciprocity Boundary Element Solution... 0... ...... 93 43 Timestepping Approach»... 0.00 e eee eee eee 96 44 Implementation on Computer 0.0.00 even ee 100 4.5 Numerical Examples 106 4.6. Summary and Discussion : a 47 Exercises 113 Green’s Functions for Potential Problems 15 BA Introduction 6... eee eee eee eee eee ee TB 52 Half Plane... . REE eer eect eeeiee eae 5.2.1 Two Special Green's Functions eee 116 5.2.2 Applications... 0.0... ee ce ee eee eee eee 1B 5.3 Infinitely Long Strip... . « sees 182 5.3.1 Derivation of Green's Functions by Conformal Mapping»... 13: 5.3.2 Applications 136 5.4 Exterior Region of a Circle 140 54.1 Two Special Green's Functions... 2.0... eo 40 542 Applications... .. . Cece cope eer 2 5.5 Summary and Discussion 145 5.6 Exercises : 45 ‘Three-dimensional Problems 147 Gf Introdaction tote rete et ee eee eee ee wees “7 6.2 Laplace's Equation . . Ree eee eee tlary 6.21 Boundary Value Problem... 10. ............00. Mt 6.22 Fundamental Solution eae ur 6.2.8 Reciprocal Relation eee 143 6.24 Boundary Integral Equation... 00.0... e eee ee 8 6.25 Boundary Element Method. « Eee Heer 6.2.6 Computation of DY'(¢,1,¢) and Pen ng). : 152 62.7 Implementation on Computer . . seers 155 6.3 Homogencous Helmholtz Equation. . . cece ness 167 641 Helmholtz Type Equation with Variable Coefficients... 2.0... 173 6.4.1 Duskreciprocity Boundary Element Method . : 173 64.2 Implementation on Computer 176 6.5 Summary and Discussion... 0. e eee ee eee es 18H 6.6 Bxercises 184 Chapter 1 TWO-DIMENSIONAL LAPLACE’S EQUATION 1.1 Introduction Perhaps a good starting point for introducing boundary element methods is through, solving boundary value problems governed by the two-dimensional Laplace's equation (ay ‘The Laplace's equation occurs in the formulation of problems in many diverse fields of studies in engineering and physical sciences, such as thermostatics, elasto- statics, electrostatics, magnetostatics, ideal fluid flow and flow in porous media. ‘An interior boundary value problem which is of practical interest. requires solving Eq, (1.1) in the two-dimensional region R (on the O:ry plane) bounded by a simple closed curve C subject to the boundary conditions & = filz,y) for (x,y) EC, % = falx,y) for (2,9) € Cx, (12) where fy and fy are suitably prescribed functions and C; and C3 are non-intersecting, curves such that Ci UC; = C. Refer to Figure 1.1 for a geometrical sketch of the problem. ‘The normal derivative 64/n in Eq, (1.2) is defined by a ae et 55" where nz and ny are respectively the zr and y components of a unit normal vector to the curve C. Here the unit normal veetor {r,rig] on Cis taken to be pointing away from the region R. Note that the normal vector may vary from point to point on C. Thus, [ne, ry] is a function of « and y. ‘The boundary conditions given in Eq. (1.2) are assumed to be properly posed so that the boundary value problem has a unique solution, that is, itis assumed that, one can always find a finetion (2, y) satisfying Eqs. (1.1)-(1.2) and that there is only one such function, (13) 2 ‘Two-dimensional Laplace’s Equation oo (EE is specified here) Gi (is specified here) Figure Ll For a particular example of practical situations involving the boundary value problem above, one may mention the classical heat conduetion problem where denotes the steady-state temperature in an isotropic solid. Eq. (1.1) is then the temperature governing equation derived, under certain assumptions, from the law of conservation of heat energy together with the Fourier’s heat flux model. ‘The heat flux out of the region R across the boundary C is given by —s26/0n, where is the thermal heat conductivity of the solid. Thus, the boundary conditions in Eq. (1.2) imply that at each and every given point on C either the temperature or the heat flux (but not both) is known. To determine the temperature field in the solid, one has to solve Eq. (1.1) in R to find the solution that satisfies the prescribed boundary conditions on C. In general, it is difficult (if not impossible) to solve exactly the boundary value problem defined by Eqs. (1.1)-(1.2). The mathematical complexity involved depends on the geometrical shape of the region R and the boundary conditions given in Eq. (1.2). Exact solutions can only be found for relatively simple geometries of R (such as a square region) together with particular boundary conditions. For more complicated geometries or general boundary conditions, one may have to resort to mumerical (approximate) techniques for solving Eqs. (1.1)-(1.2) This chapter introduces a boundary element method for the numerical solution of the interior boundary value problem defined by Eqs. (1.1)-(1.2). We show how 1 boundary integral solution can be derived for Eq. (1.1) and applied to obtain a simple boundary clement procedure for approximately solving the boundary value problem under consideration. The implementation of the numerical procedure on the computer, achieved through coding in FORTRAN 77, is discussed in detail. ‘Fundamental Solution 3 1.2, Fundamental Solution If we use polar coordinates r and 9 centered about (0,00), as defined by x = rcosd and y= rsin8, and introduce U(r, ) = o(r-e0s8,r'sin ), we can rewrite Eq. (1.1) as 10) dv) 18) Onan) + 9 gg? = 9 (14) For the case in which y is independent of 8, that is, if y is a function of r alone, Eq. (1.4) reduces to the ordinary differential equation d a 4 ir [v(r)]) =0 for r £0. (1.5) ‘The ordinary differential equation in Eq. (1.5) can be easily integrated twice to yield the general solution w(r) = Aln(r) +B, (1.6) where A and B are arbitrary constants. From (1.6), it is obvious that the two-dimensional Laplace's equation in Eq. (2.1) admits a class of particular solutions given by O(e,u) = Aln y/x? + y? + B for (2,y) # (0,0). (1.7) If wo choose the constants A and B in (1.7) to be 1/(2x) and 0 respectively and shift the center of the polar coordinates from (0,0) to the general point (£7), a particular solution of Eq. (1.1) is 1 O(2,¥) = xn Vw EP + (y= 0)? for (x,y) # (En). (18) cS As we shall see, the particular solution in Eq. (1.8) plays an important role in the development of boundary element methods for the numerical solution of the interior boundary value problem defined by Bqs. (1.1)-(1.2). We specially denote this particular solution using the symbol (x, y;,1), that is, we write 1 Fine - 9 + v—9))- (1.9) (2,436.7) We refer to ®(2,y;§,n) in Eq. (1.9) as the fandamental solution of the two- dimensional Laplace’s equation. Note that ®(c, y;§,1) satisfies Eq. (1.1) everywhere except at (£,7) where it is not well defined. 4 ‘Two-dimensional Laplace’s Equation 1.3. Reciprocal Relation If 6; and ¢ are any two solutions of Eq. (1-1) in the region R bounded by the simple closed curve C’ then it can be shown that [ (6558 — 6, 22)aste,y) = (110) Eq. (1.10) provides a reciprocal relation between any two solutions of the Laplace's equation in the region F bounded by the curve C. It may be derived from the ‘two-dimensional version of the Gauss-Ostrogradskii (divergence) theorem as explained below. According to the divergence theorem, if F= u(x,y)i+v(x, y)j is a well defined vector function such that V-F = du/dz + Av/dy exists in the region R bounded by the simple closed curve C then [Ena fi U-E dedy, é fl that is, du, av [ [ung + vnyjds(r,y) = J i et tata, 2 where n= [rz,r] is the unit normal vector to the curve C, pointing avay from the region R. Since $; and gy are solutions of Eq. (1.1), we may write Fo, Fo. Ox? * By? Por, Poa Oe OF =0, If we multiply the first equation by dy and the second one by @ and take the difference of the resulting equations, we obtain a, a pepe - Ge) a, a6 00, 6155) * By % oy Mag) = * ay oy which can be integrated over R to give [lens 6. B+ 5 8 ~ 6, Peytedy =0 Boundary Integral Solution 5 Application of the divergence theorem to convert the double integral over R. into a line integral over C’ yields BG, , Ob / Wer ge Os 2 which is essentially Eq. (1.10). ‘Together with the fundamental solution given by Eq. (1.9), the reciprocal relation in Eq. (1.10) can be used to derive a useful boundary integral solution for the two-dimensional Laplace’s equation. Ob _ 4, be et (Orgy — OG )ny|ds(x,y) = 0 1.4 Boundary Integral Solution Let us take & = ®(2,y;£,n) (the fimdamental solution as defined in Eq. (1.9) and gy = @, where ¢ is the required solution of the interior boundary value problem defined by Bas. (1.1)-(1.2) Since (x, y;£,n) is not well defined at the point (€,1), the reciprocal relation in Eq. (1.10) is valid for = (2, ys.) and $, = 6 only if (£,n) does not lie in the region RUC. Thus, recon 5. Ceangsn)) ~ eCerai6n J a (9(@,y))]ds(x, y) for (fn) € RUC. (ay) A more interesting and useful integral equation than Eq, (1.11) ean be derived from Eq, (1.10) if we take the point (£,7) to lie in the region RUC. For the case in which (£,7) lies in the interior of R, Eq. (1.10) is valid if we replace C by C'UC2, where C, is a circle of center (£,7) and radius © as shown in Figure 1.2". This is because (x, y;E,7) and its first order partial derivatives (with, respect to x or y) are well defined in the region between C’ and C,, Thus, for C and Cc in Figure 1.2, we can write J 0.0. wém) — Pens Mg-(Ole.wisle.0) obce [ (ote, = = flote.n 2 ee.né.m) ~ %eré.nZ(olesa)idsten). (112) & that is, (P(x, 95 €,n)) — (2,936, n) > (Ole, y))]ds(x, y) "The divergence theorem is nat only applicable for simply connectod regions but also for multiply connected ones such as the one shown in Figure 1.2. For tho region in Figure 1.2, the unit normal vector to C: (the inner boundary) points towards the center of the circle 6 ‘Two-dimensional Laplace’s Equation Figure 1.2 Eq, (1.12) holds for any radins = > 0, so long as the circle C. (in Figure 1.2) lies completely inside the region bounded by C. ‘Thus, we may let © 0* in Eq. (1.12). This gives fe = in, [Iolo 5,86 nS) ~ Bee Gsn) gloat. d WE Haas &M) — Blew & 2 (Ole, w)|dae0) (1.13) Using polar coordinates r and @ centered about: (€,1) a8 defined by 2 — € = rosé and y—1 = rsin#, we may write Hum) = ge ln(r), FM WSO) = me Cong] + my 5 Ca ng cos + ny sind Stee eee (a4) ‘The Taylor's series of (2, y) about the point (£,7) is given by Sash ane (e-9'(y-ny* oz,y) = (oapoe aa 9-2 (ona lesen mB)! On the circle C., r = ¢, Thus, sy e cost Osin™* 9 Hay) = (Garpgane le wl) elena pe Sake * leweten Mon) for (xu) €C:. (1-15) Boundary Integral Solution T Similarly, we may write grltetll= OY GaayeatgaleewD | ™ cost 8 sin™* 9 Elm — Br Using Eqs. (1.14), (1.15) and (1.16) and writing ds(x, y) = ed@ with @ ranging from 0 to 27, we may now attempt to evaluate the limit on the right hand side of Eq. (1.18). On C., the normal vector (ne, ny] is given by [—cos4, —sin @]. Thus, én) for (x,y) € C. (1.16) fen gC nS. ride) . = -da6n i- a com gm ang bette rd 7 em Kon— Bl Gera Joos sin™* 06 mate stem} > ~o&n) met (1.17) and [ens.n 2 focandste.v) 4 - LL we ae oem) ewe) Inte) F Penis eeeeat aren | com sin oa = 0 ase0t, (118) since 2" In(e) + 0 as © + 0* for m=0, 1, 2, Consequently, as ¢ — 0*, Eq. (1.13) yields 46 = fev) (Cea gsm) ~ WCe aig.) (Oe) d for Gn) ER. (1.19) Together with Eq. (1.9), Bq. (1.19) provides us with a boundary integral solution for the two-dimensional Laplace’s equation. If both ¢ and 2¢/2n are known 8 ‘Two-dimensional Laplace’s Equation at all points on C, the line integral in Eq. (1.19) can be evaluated (at least in theory) to calculate 6 at any point (£,7) in the interior of R. From the boundary conditions (1.2), at any given point on C, either ¢ or 49/An, not both, is known, however. ‘To solve the interior boundary value problem, we must find the unknown @ and 84/8n on C2 and C; respectively. As we shall see later on, this may be done through manipulation of data on the boundary C only, if we ean derive a boundary integral formula for (6,7), similar to the one in Eq. (1.19), for a general point (&,7) that lies on C. For the case in which the point (€,) lies on C, Ea. (1.10) holds if we replace the curve C by DU D,, where the curves D and D, are as shown in Figure 1.3. (If Cy is the circle of center (£7) and radius c, then D is the part of C' that lies outside C. and D, is the part of C, that is inside R,) Thus, felon) (Cea esn)) ~BCes4i6.m) 2 (Olewd island = = floceng oeas.m — Bens. (OCe waaay). (1.20) a Let us examine what happens to Eq. (1.20) when we let ¢ —» 0*. Ase — 0°, the curve D tends to C. Thus, we may write | @ = = im. [lotead 5. (Ce 0) ~ Been Gsn) 5 (lava (S(2, y))}ds(e,9) (te) 2 BC, y:8,0)) — Beas (121) Figure 1.3 Boundary Integral Solution 9 Note that, unlike in Eq. (1.13), the line integral over C in Eq. (1.21) is improper as its integrand is not well defined at (€,) which lies on C'. Strictly speaking, the line integration should be over the curve C’ without an infinitesimal seginient that contains the point: (€,7), that is, the line integral over C' in Eq. (1-21) has to be interpreted in the Cauchy principal sense if (€,) lies on C. ‘To evaluate the limit on the right hand side of Eq. (1.21), we need to know what happens to D, when we let ¢— 0. Now if (€,) lies on a smooth part of C (not at where the gradient of the curve changes abruptly, that is, not at a corner point, if there is any), one can intuitively see that the part of C inside C, approaches an infinitesimal straight line as + 0°. ‘Thus, we expect D- to tend to a semi-circle as = 0°, if (Gn) lies on a smooth part of C.. It follows that in attempting to evaluate the limit on the right hand side of Eq. (1.21) we have to integrate over only half a circle (instead of a full circle as in the case of Eq. (1.13)) ‘Modifying Eqs. (1.17) and (1.18), we obtain ! a mMidste,e) = ~So&n, [(@,y)]ds(z,y) = 0. tim. fo@.n69 Hence Eq, (1.21) gives 5ol6.n) [rPlernd (Ce wi.) ~ Beas 6sa) 5 (Olav) Iles) 3 for (£,1) lying on a smooth part of C. (1.22) ‘Together with the boundary conditions in Eq, (1.2), Eq. (1.22) may be applied to obtain a numerical procedure for determining the unknown ¢ and/or 44/An on the boundary C. Once @ and 8¢/An are known at all points on C, the solution of the interior boundary value problem defined by Eqs. (1-1)-(1.2) is given by Eq. (1.19) at any point (£7) inside R. More details are given in Section 1.5 below. For convenience, we may write Eqs. (1.11), (1.19) and (1.22) as a single equation given by a ND 5q (P(e 938.) — O(a, 93650), AE n)olE0) = [ive (9(x,y))]ds(x,y), ge (1.23) iff we define { 0 if (Gn) ¢ RUC, ME.n) 1/2 it (En) = ‘on a smooth part of C, (1.24) 1 Gne 10 ‘Two-dimensional Laplace’s Equation 1.5 Boundary Element Solution with Constant Elements We now show how Eq. (1.23) may be applied to obtain a simple boundary clement procedure for solving numerically the interior boundary value problem defined by Eqs. (1.1)-(1.2). ‘The boundary C is approximated as an N-sided polygon with sides C?, C®), 7 C%Y and CO), that o eM uc®y.-.ueruCem, (1.25) The sides or the boundary elements C®, C®, ---, C&D and C™ axe constructed as follows. We put N well spaced out points (e'),y(), (2), y®), s+, (282), X®-D) and (2\"),y) on C, in the order given, following the counter clockwise direction. Defining (2,9) = (xl, y), we take C®) to be the boundary element from (2'*), y®) to (xl), yD) for k= 1, 2,--+ , N. As an example, in Figure 1.4, the boundary C = Ci U Ce in Figure 1.1 is approximated using 5 boundary elements denoted by C®), C®), C8), C@ and C®. For a simple approximation of @ and 6/An on the boundary C, we assume that these functions are constants over each of the boundary elements. Specifically, ‘we make the approximation: o~d"” and % = pt for (x,y) EC (k=1, LN), (1.26) where 6” and p are respectively the values of @ and 0¢/dn at the midpoint of cw, 2,9) Van 9%) (ey) 9%) (2,9) = 02, 9) Figure 1.4 Boundary Element Solution with Constant Elements a With Eqs. (1.25) and (1.26), we find that Eq. (1.23) can be approximately written as ME n)olEsn) Tea ) PPA En)). (127) where AMPED =f ensmastey), AMG = | Flecengoses (128) oo For a given k, either 3” or p (not both) is known from the boundary conditions in Eq, (1.2). Thus, there are N’ unknown constants on the right hand side of Ba. (1.27). To determine their values, we have to generate N equations containing the unknowns. If-we let (6,7) in Eq, (1.27) be given in turn by the midpoints of C®, C®, +, C&D and CO, we obtain Laem) 39 for m= 1,2, (1.29) where (2), 7”) is the midpoint of C™. In the derivation of Eq. (1.29), we take 4(z™,y!)) = 1/2, since (2, 7) ‘being the midpoint of CO lies on a smooth part of the approximate boundary CM U C@U--- UCR UCM, Eq. (1.29) constitutes a system of N linear algebraic equations containing the N unknowns on the right hand side of Eq. (1.27). We may rewrite it as Lai = $7 om) for m= 1,2, (1.30) ot 2 ‘Two-dimensional Laplace’s Equation where a, (9 and 2 are defined by gis [ 0 for any point (£,7). To see why this is trne, consider the straight line defined by the parametric equations x = 2 — nf) and y = y® + tn® for —co < t < 00. Note that OW) is a subset of this straight line (given by the parametric equations from ¢ = 0 to 4 =1). Bq, (1.34) also holds for any point (2,y) lying on the extended line. If (€,) does not lie on the line then A# + B®(€,n)t + B(€,n) > 0 for all real values of t (that is, for all points (2, y) on the line) and hence 44!) £"(€, 9) — (BO (€,n)? > 0. On the other hand, if (€,9) is on the line, we ean find exactly one point (2,y) such that AM? + BY (E,n)t + EE, n) = 0. As each point (x,y) on the line is given by a unique value of ¢, we conclude that 4A“ £(€,n) — [B®(, n)|? = 0 for (€,n) lying ‘on the line. From Egg. (1.28), (1.33) and (1.34), F{(€,n) and F{*!(€,n) may be written APG) = © fae BE ne+ BE met em) = 2 fale = 8) + niu =n) WGN = a | aera ES bee (1.36) ‘The second integral in Eq. (1.36) is the easiest one to work out for the case in which 4A“) B)(€, n) — [B® (€,n)]? = 0. For this case, the point (£,7) lies on the straight line of which the element Cis a subset. Thus, the vector [x'*) — ¢, y(#) — n} is perpendicular to [n{"),n{*)}, that is, no) (x —€)-+n{ (y* —m) =0, and we obtain FY (En) =0 for 4AM LE, n) — [BE n)P = 0. (1.37) From the integration formula / ECE Ee ree recta ee abt bi+e ae — for real constants a, b and ¢ such that dae ~ b > 0, ul ‘Two-dimensional Laplace’s Equation wwe find that copa — 6) + nly — m) nV4AWE® (En) — (BOE mE a + BME, a Belen TAD EOE m) — Bem for 4A B(E,n) — [BM (E,n)]? > 0. (1.38) FPEn) x[arctan( ) ~arotan(— PE) 16 4A“ B(E,n) — |B (En)? = 0, we may write Oy? 4 Be ) ( BOE, AML + BOE, t+ BO En) = AME a Thus, FOG) = fu A e+ BED a for samme 1) — [B&,n)P =0. (1.39) Now if (£,7) lies on a smooth part of C™), the integral in Eq. (1.39) is im- proper, as its integrand is not well defined at the point f = ta = —BM(E,n)/(2A®) € (0,1). Strictly speaking, the integral should then be interpreted in the Cauchy princi- pal sense, that is, to evaluate it, we have to integrate over 0, to —¢|Ulty-+e, 1] instead ‘of [0,1] and then let ¢ — 0 to obtain its value. However, in this case, it turns out ‘that the limits of integration t = to — € and t = fo +¢ eventually do not contribute anything to the integral. Thus, for 4A) E\)(€,) — (B® (€,1)|? = 0, the final ana- lytical formula for A") (€,) is the same irrespective of whether (£,1) lies on C® or not. If (£,n) lies on C, we may ignore the singular behaviour of the integrand and apply the fundamental theorem of integral calculus as usual to evaluate the definite integral in Eq. (1.39) directly over [0, 1] ‘The integration required in Eq. (1.39) can be easily done to give oo BEN) AMGEN) = Foti) +04 aay BE), BEM _ yy 2A”) 2A | for 4A B™(€,n) — ane = BOEn) DA) jini (140) Jplemeatation on Computer 15 Using Jisae +Mbe)dt = t[ln(a)—2)+ (0+ Pte? + fey 4 +4 Vee aretan( 722%) + constant for real constants a, b and c such that dac — 8? > 0, we obtain “ Bn), En) FPGn) = Flin) Saas med BY En) BO En) , BOEn) ++ S40 +a + aay (VED EME = BOE IE rr 2A + BOE n) JAAP BOE, n) — (BOE DP BOE n) » AAD EO(E,n) — [BOE n)P for 44 B(€,n) — [BE n)>0. (1.41) x[arctan( ) —aretan( 1.7 Implementation on Computer We attempt now to develop double precision FORTRAN 77 codes which can be used to implement the boundary element procedure described in Section 1.5 on the computer. In our discussion here, syntaxes, variables and statements in FORTRAN 77 are written in typewriter fonts, for example, xi, eta and A=L*#240. One of the tasks involved is the setting up of the system of linear algebraic ‘equations given in Eqs. (1.30) and (1.31). To do this, the functions F{")(¢,n) and FS (E,n) have to be computed using the formulae in Section 1.6. We create a sub- routine called CPF which accepts the values of &,n, 2), y®, nf), nl and € (stored in the real variables xi, eta, xk, yk, nkx, nky and L) in order to calenlate and return the values of «F!")(€,n) and *#!"(¢,y) (in the real variables PF1 and PF2). ‘The subroutine CPF is listed below subroutine CPF(xi,eta,xk,yk,nkx,nky,L,PF1,PF2) double precision xi,eta, xk, yk,nkx,nky,L,PF1,PF2, & A,B,E,D,BA,EA 16 ‘Two-dimensional Laplace’s Equation AsL+#2d0 Be2d0+L+ (-nkys (xk-xi) ¢nloxt (yk-eta)) E>(xk-xi)*#240+ (yk-etia) #4240 Dedsqrt (dabs (4d0*A¥E-B##240) ) BASB/A EA-E/A if (D.1t.0,000000000140) then PFi=0.5d0+L+ (@log(t) +(140+0 .5408BA) dog (dabs (140#0. 540+BA)) & -0.SdO#BA¥dlog (dabs (0. 540*BA))-140) PF2-0d0 else PF1=0.. 2540+L*(240* (d1og(L)-140)-0. 5d0+BA¥d10g(dabs(EA)) +(1d0+0. 540*BA) *dLog (dabs (140+BA+EA)) & +(D/A)*(datan ( (240*A+B)/D) ~datan(B/D))) PF2+L+ (nloc* (xk-xi) +nky+ (yk-eta))/D & ¥(datan((240#A+B) /D)-datan(B/D)) endif return end CPF is repeatedly called in the subroutine CELAP1. CELAPA reads in the mum- ber of boundary elements (V) in the real variable N, the midpoints (=),9) in the real arrays xm(1:N) and ym(1:N), the boundary points (x,y) in the real arrays xb(1:N+1) and yb(1:N+1), the normal vectors (n{), n{) in the real arrays mx(1:N) and ny (1:1), the lengths of the boundary elements in the real array 1g(1:N) and the types of boundary conditions (on the boundary elements) in the integer ar- ray BCT(1:N) together with the corresponding boundary values in the real array BCV(1:N), set up and solve Eq. (1.30), and return all the values of 6° and pl” in the arrays phi(1:N) and dphi(1:X) respectively. (More details on the arrays BOT(1:N) and BOV(1:N) will be given later on in Section 1.8.) ‘Thns, a large part of the boundary element procedure (with constant elements) for the numerical solution of the boundary value problem is executed in CELAP. The subroutine CELAP1 is listed as follows subroutine CELAPI (N,2m,ym,xb,yb,nx,ny,1g,BCT,BCV, phi ,dphi) integer m,k,N,BCT(1000) double precision xm(1000) ,ym(1000) ,xb(1000) ,yb(1000) Jplemeatation on Computer i & nx(1000) ,ny (41000) ,1g(1000) ,BCV(1000) ,A(1000,1000) , & B(1000) ,pi,PF1,PF2,del,phi (1000) ,dphi (1000) ,F1,F2, & 2(1000) pi=ddosdatan(140) do 10 mt,N B(m)=00 do § k-1,N call CPF (xm(m) ,ym(m) ,xb (kc) ,yb() ,mx(k) ,ny (eo) ,1g(k) ,PF1, PF2) FI-PFi/pi F-PF2/pi if (K.eq.m) then del=1d0 else del=040 endif if (BCT(k).eq.0) then AGO =-FL (m) +BCV (k)* (F240. 5d0%de1) Am, k)=F2-0.5d0+de1 Bm) =B(m) +BOV (ie) «F endif 5 continue 10 continue call solver(A,B,N,1,2) do 15 m=i,N if (BCT(m).eq.0) then phi (m)=BCV(m) phi (m)=Z(n) else phi (m)=2(m) phi (m)=BCV(n) endif 16 continue return end 18 ‘Two-dimensional Laplace’s Equation ‘The values of al in Eq. (1.30) are kept in the real array A(1:N,1:0), the sum 6) + 0") 4... +!) on the right hand side of the equation in the real array BCL:N) and the solution 2) in the real array Z(1:8). To solve for 2), an LU decomposition is performed on the matrix containing the coefficients a‘ to obtain a simpler system that may be easily solved by backward substitutions. This is done in the subroutine SOLVER (listed below together with supporting subprograms DAXPY, DSCAL and IDAMAX') which accepts the integer W (giving the number of unknowns), the real arrays ACL:N,1:W) and B(1:N)and the integer 1ud to return 2(1:0). In general, the integer ud may be given any value except 0. However, if we are solving two different systems of linear algebraic equations with the same square matrice [a], one after the other, 1ud may be given the value 0 the second time SOLVER is called. ‘This is because it is not necessary to perform the LU decomposition on the same square matrix again to solve the second system after solving the first. If 1ud is given the value 0, SOLVER assumes that the square matrix has already been properly decomposed before and avoids the time consuming decomposition process. In CELAPA, since the square matrix has not been decomposed yet, the value of 1 is passed into ud when we call SOLVER. ‘The subroutine SOLVER and its supporting programs are listed as follows. subroutine SOLVER(A,B,N,1ud,Z) imteger 1da,N,ipvt(1000), info, ud, IDAMAX, & j,k, kpt,1 nt kb double precision A(1000, 1000) ,B(1000) ,2(1000) ,¢ ,AMD(1000, 1000) ‘common /1udemp/ipvt: AMD nmi="-1 do § i=1,N 2(4)=BG) 5 continue if (lud.eq.0) goto 99 The main part of SOLVER for decomposing the square matrix A and solving AX — BB is re- spectively taken from the codes in the LINPACK subroutines DGEFA and DGESL written by Clove Moler. ‘The supporting subprograms DAXPY, DSCAL and IDAMAK written by Jack Dongarra are also from LINPACK. DGEFA, DGBSL, DAXPY, DSCAL and IDAMAX are all in the publie domain and may be downloaded from Netlib website at bttp://www.ncthborg. Permission for reproducing the codes here was granted by Netib’s editor-in-chief Jack Dongarra. Jplemeatation on Computer 19 do 6 i=t,N do 6 j AND (4, 5) 6 continua info if (nmt.1t.1) go to 70 do 60 k-1,nmt kpi-k+t ‘LRIDAMAX (N-Ic+4, AMD (ie, 51) et ipvt (k= if (AMD(L,K).eq.0.040) goto 40 if (1.eq.h) goto 10 ‘t=AMD(L,k) AND (1, K)=AMD (ke, ) AND (i, Kt 10 continue ‘te-1.040/AMD i, ) call DSCAL(N-K, ¢, AMD(c#4 16) ,1) do 30 j-kpt,N teAMDCL, 5) if (1.eq.k) go to 20 ‘AND, j)=AMD, 5) AND (i, j)=t 20 continue call DAXPY(N-K,t, AMD(K+1, kc) ,1,AMD(k+1, 5), 1) 30 continue goto 50 40 continue info-k 50 continue 60 continue 70 continue ipvt(N)- if (AMD(W,N) .eq-0.040) info=N if (info.ne.0) pause "Division by zero in SOLVER!” 20 "Two-dimensional Laplace's Equation 99 continue if (nmt.1t.1) goto 130 do 120 k=1,nmi leipvt Gc) z(1) if (1.0q-k) goto 110 2()=2() 20) 110 continue call DAXPY(N-Kc,£ ,AMD(lct4 le) ,1,Z(ic+4) ,1) 120 continue 130 continue do 140 kb=1,N keN+1-kb Z(e) = 2) /AND (ic 6) t=2(1) call DAXPY (k-1,t,AMD(4 ie) ,1,2(1) ,1) 140 continue return end subroutine DAXPY(N,da,dx, incx,dy,incy) double precision dx(1000) ,ay(1000) ,da imteger i, incx, incy,ix,iy,m,mp1,N if (-1e.0) return if (da .eq. 0.040) return if (incx.eq.1and. incy.eq.1) goto 20 i ayst if (incx.1t.0) ixe(-MH1)sinextt if(incy.1t.0) iy=(-Ne1)xincy+1 Jplemeatation on Computer a 10 20 30 40 50 do 10 int,¥ dy (iy) ay (iy) +dardx (ix) ixeixtiner iysiytincy continue return m=noa(N,4) if( meq. 0) go to 40 do 30 i-t.n ay (2) ay (1) tdaae(4) continue if(W.1t.4) return mpi=mtt do 50 ismpi,N,4 dy (4) =ay (4) #daax(4) dy (241) =dy (441) +davdx(i+1) dy (442) =dy G42) +darax (42) dy (£43) =dy (443) +dardx (+3) continue return end, subroutine DSCAL(N,da,dx, incx) double precision da,dx(1000) integer i, incx,m,mp1,,N,nincx if (-1e.0.0r-incx.1e.0) return if (inex.eq.1) goto 20 inex = Weinex do 10 i=1,ninex, inex dx(i)=daxdx (4) 2 10 20 30 40 "Two-dimensional Laplace's Equation continue return memod(N,5) if(m.eq.0) goto 40 do 30 i=1,m x(a) = daxdx(i) continue if(.1t.5) return mpi=m+t do 50 i=mpi,N,5 dx (i) =da*dx (i) dx (i+1) =damdx(i+1) x (1+2)=dardx(i+2) x (1+8)=dardx(i+3) return end function IDAMAX(N,dx, incx) double precision dx(1000) ,dmax integer i, incx, ix,N,IDAMAK IDAMAK = 0 if (l.1t.1.or.incx.1e.0 ) return IDAMAK = if (il.eq.t)return if (incx.eq-1) goto 20 ix=4 dnax = dabs(ax(1)) Jplemeatation on Computer 3 do 10 4-2," if (dabs (@x(ix)).1e-dmax) goto 5 DAMA) anax=dabs (ax(ix)) 5 ixeixtince 10 continue return 20 dnax=dabs (dx(1)) do 30 12,8 if (dabs(ax(i)) .1e.dmax) goto 30 ‘Once the values of 3“ and p(* are returned in the arrays phi(1:¥) and dphi(1:N) by CELAP1, they can be used by the subroutine CELAP2 to compute the value of @ at any chosen point (6,1) in the interior of the solution domain, In the listing of CELAP2 below, xxi and eta are the real variables which carry the values of & and 1 respectively. The computed value of $(€,7) is returned in the real variable pint. Note that the subroutine CPF is called in CELAP2 to compute F{")(€,n) and TF Gn). subroutine CELAP2(N,xi,eta,xb,yb,nx,ny,1g,phi,dphi,pint) integer N,i double precision xi,eta,xb(1000) ,yb(1000) ,nx(1000) ,ny(1000) , & 1g(1000) ,phi.(1000) ,dphi (1000) ,pint., sum, pi, PF1,PF2 pin4d0*datan(140) sun=0d0 do 10 i=1,N call CPF(xi,eta,xb(4) ,yb(4) ,ax(i) ,ny (4) ,1g(4) ,PFA,PF2) sun=sum+phi (i)+PF2-éphi (i) #PF1 mu ‘Two-dimensional Laplace’s Equation 10 continue pint=oum/pi return end 1.8 Numerical Examples We now show how the subroutines CELAP1 and CELAP2 may be used to solve two specific examples of the interior boundary value problem described in Section 1.1 Example 1.1 ‘The solution domain is the square region 0 < x < 1,0 < y < 1. The boundary conditions are =0 on 0 = cos (zy) on 1} ro0, y>0, g= Seos(4arctan(®)) on the arc a? +y?=4, 2>0, y>0. This boundary value problem may be solved numerically using the boundary clement procedure with constant elements as in Example 1-1. To do this, we only have to modify the parts in the program EX1PT1 that generate input data for the arrays xb(1:N1), yb(1:N+1), BCT(1:0) and BCV(4:N). Before we modify the program, we have to work out formulae for the boundary points (2), y!), (2, y), (el yl) and (2, yl"), Let us discretize each of the straight sides of the boundary into Np elements and the arcs on 2? +y? = 1 and 2?+y? =4 into 2Np and SN elements respectively, so that N = 12Np, Specifically, the boundary points are given by [m=] (c™,y™) = (1+ 0) for m= 1,2,+++ No, inim*No), ylmtN0)) (oe HE) asin UE

You might also like