BEM Matlab Freemat
BEM Matlab Freemat
BEM Matlab Freemat
com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 1
AbstractThe Boundary Element Method is developed
in its most simple form; for the solution of Laplaces
equation in an interior domain with a straight line
approximation to the boundary. The direct and indirect
approaches to the boundary element method are
included. The methods are developed in Freemat, a
language similar to Matlab.
The codes for the solution of Laplaces equation in a
general domain with a general (Robin) boundary
condition are developed. The codes are applied to a
typical test problem. The codes are made available as
open source (BEMLAP-MAT package) and can be
downloaded from this paper or from the websites listed
below
2
. The overall package is expected to become a
teaching aid in the MSc course
3
that is presently being
developed by the authors.
I. INTRODUCTION
The boundary element method (BEM) is an important
computational analysis technique that engineers and
scientists can apply to a range of problems There are a
number of textbooks on the BEM
1,2
. The purpose of this
article and the accompanying software is to meet the
needs of scientists and engineers who are somewhat
unfamiliar with the BEM, but have an understanding of
numerical methods and computer programming, or
would like to apply the BEM to appropriate engineering
problems with minimal fuss.
The application of the boundary element method to an
appropriate scientific or engineering problem essentially
requires a mesh of the boundary of the domain only, and
the determination of the boundary condition on the
surface. The computational solution then yields the
approximate solution at selected points in the domain.
1
School of Science and Technology, East Lancashire Institute of Higher
Education, Blackburn College UK.
2
www.east-lancashire-research.org.uk
2
www.kirkup.info/opensource
3
www.elihe.ac.uk
The BEM is generally more efficient to apply and
execute than competing methods, such as the finite
element or finite difference methods. Hence the
application of the BEM presents an attractive option to
scientists and engineers. The authors are developing an
MSc and this package is expected to act as a teaching
aid on one of the modules in that course
On the other hand the underlying mathematical
derivation and numerical analysis is extremely involved.
Unfortunately, most textbooks on the BEM concentrate
on the mathematics underlying the BEM, considering
the ranges of integral equation formulation, ranges of
element types, ranges of method derivation. In this
article the elegance of the solution method is not lost in
a mass of mathematical derivation and analysis. A
simple notation is used to assist in the understanding of
the development of the BEM.
In this work, the so-called direct and indirect
boundary element methods for the solution of the
interior Laplace equation are developed. Laplaces
equation is the most straightforward problem to which
the BEM can be applied. Laplaces equation also models
a number of physical phenomena, such as steady state
heat conduction and electrostatics. There is substantial
recent research on the application of the BEM to
Laplaces equation
3-10
.
Over recent decades, Matlab
11
has become an
increasingly important language for scientific
computation. Freemat
12
is a freely available alternative
compiler for Matlab. All codes are developed in
Freemat, but they can be also used in the Matlab
environment. Matlab/Freemat is based on Matrix
arithmetic, allowing an economy of coding and naturally
allows parallel processing, if it is available.
II. THE BOUNDARY ELEMENT METHOD
Over recent decades, the boundary element method
(BEM) has received much attention from researchers
and has become an important technique in the
computational solution of a number of physical
Stephen Kirkup
1
and Javad Yazdani
1
A Gentle Introduction to the Boundary Element
Method in Matlab/Freemat
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 2
problems and has therefore become a widely-used
technique in engineering analysis. In common with the
better-known finite element method (FEM) and finite
difference method (FDM), the boundary element method
is essentially a method for solving partial differential
equations (PDEs) and can only be employed when the
physical problem can be expressed as such. As with the
other methods mentioned, the boundary element method
is a numerical method and hence it is an important
subject of research amongst the numerical analysis
community. However, the potential advantages of the
BEM have seemed so considerable that the strongest
impetus behind its development has come from the
engineering community, in its enthusiasm to obtain
flexible and efficient computer-based solutions to a
range of engineering problems. The boundary element
method has found application in such diverse topics as
stress analysis, potential flow, electromagnetics, fracture
mechanics and acoustics.
The boundary element method is derived through the
discretisation of an integral equation that is
mathematically equivalent to the original partial
differential equation. The essential re-formulation of the
PDE that underlies the BEM consists of an integral
equation that is defined on the boundary of the domain
and an integral that relates the boundary solution to the
solution at points in the domain. The former is termed a
boundary integral equation (BIE) and the BEM is often
referred to as the boundary integral equation method or
boundary integral method. Over the last four decades
the term boundary element method has become more
popular. The other terms are still used in the literature
however, particularly when authors wish to refer to the
overall derivation and analysis of the methods, rather
than their implementation or application.
An integral equation re-formulation can only be
derived for certain classes of PDE. Hence the BEM is
not widely applicable when compared to the near-
universal adaptability of the finite element and finite
difference method. However, in the cases in which the
boundary element method is applicable, it often results
in a numerical method that is easier to use and more
computationally efficient than the competing methods.
The advantages in the boundary element method arise
from the fact that only the boundary (or boundaries) of
the domain of the PDE requires sub-division. (In the
finite element method or finite difference method the
whole domain of the PDE requires discretisation.) Thus
the dimension of the problem is effectively reduced by
one. For example an equation governing a three-
dimensional region is transformed into one over its
surface.
In cases where the domain is exterior to the boundary,
as it is in potential flow past an obstacle, or the
electrostatic field produced by charged surfaces in the
open, the extent of the domain is infinite and hence the
advantages of the BEM are even more striking; the
equation governing the infinite domain is reduced to an
equation over the (finite) boundary.
It is through the subdivision or meshing of the
boundary into panels of some standard shape, and the
approximation of functions on the boundary by low
degree polynomials that the integral equations are
converted into matrix-vector form. The solution of the
discrete form of the integral equation leads to the
approximate determination of the otherwise unknown
boundary functions. Following this, the solution at any
point in the domain can be found through numerical
integration over the boundary.
Returning to the comparison with the FEM, the
dimensions of the matrices in the BEM are expected to
be much smaller for the given expectation of accuracy,
since the BEM requires a mesh of the surface only,
whereas the FEM requires a mesh of the full domain; for
a given problem the FEM needs more elements.
However the matrices that arise in the FEM are sparse
and structured, making them amenable to special
methods of solution, whereas the matrices that arise in
the BEM are dense and have no particular apparent
structure.
Apart from using the simplest governing equation, we
are also considering only the simplest dimensional
space- 2D. We also use the simplest elements; flat
(straight line) panels with the surface functions
approximated by a constant on each panel. An empirical
analysis of the boundary element method with respect to
Laplaces equation is given in the first authors previous
work
13
.
III. THE INTERIOR LAPLACE EQUATION
The Laplace equation is the simplest elliptic partial
differential equation. It is one of the equations of
potential theory and they have been received extensive
mathematical analysis. It also serves as model elliptic
equations for learning, implementing and testing
numerical methods. In this article we are using the
Laplace equation in order to motivate our understanding
of the properties and practice of the boundary element
method.
The boundary element method in this paper is
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 3
developed to solve the two-dimensional Laplace
Equation
0
) ( ) (
2
2
2
2
y x
p p
) ( D p
or in the shorthand form:
0
2
p ) ( D p (1)
in an interior domain D, with an enclosing boundary S,
as illustrated in figure 1.
Fig 1. Illustration of the domain.
A boundary condition is determined on S. For this work
we assume that the boundary condition is of the
following general Robin or mixed form
) ( ) ( ) ( ) ( ) ( p p p p p f
n
b a
p
) ( S p , (2)
where ) (p a , ) (p b and ) (p f are real-valued functions
defined on S only and
p
n is the unit outward normal to
the boundary at p (assumed to be unique). The general
boundary condition includes the Dirichlet (essential)
boundary condition ( 0 ) ( , 1 ) ( p p b a ) and Neumann
(derivative) boundary condition ( 1 ) ( , 0 ) ( p p b a ).
Together, the governing partial differential equation
within a domain (eg (1)) and the boundary condition (2)
is called a boundary value problem (BVP). The solution
to such a problem is principally the determination of
(at points) in the domain D, whether by analytic or
numerical methods.
IV. INTEGRAL EQUATION REFORMULATION
The first stage in the development of a boundary
element method from a boundary value problem (like
(1)-(2)) is to rewrite the partial differential equation as
an integral equation. Traditionally, there have been two
ways of doing this; the direct method and the indirect
method. In this section we will go through the stages for
developing the integral equation formulations..
Greens function
In order to do this it is useful to introduce an influence
function; a function that determines the effect at a point
q of a unit source at a point p, this function is also often
known as a Greens function. For the two-dimensional
Laplace equation (1), the Greens function is known to
be
|) ln(|
2
1
) , ( q p q p G . (3)
The Greens function has the property
) (
2
q p q p G
where is the Dirac delta function.
Laplace Integral Operators
As a further set of building blocks, it is also useful to
define the set of Laplace integral operators:
q
dS G L ) ( ) , ( ) ( } { q q p p (4a),
q
q
dS
n
G
M ) (
) , (
) ( } { q
q p
p (4b),
q
q
t
dS
w
G
dS G
w
M
) (
) , (
) ( ) , ( ) ; ( } {
q
q p
q q p w p
(4c)
q
q
dS
n
G
w
N ) (
) , (
) ; ( } { q
q p
w p
(4d)
where is the whole or any part of S, is any real-
valued function, defined on .
When p, then we have the more particular form of
M
t
and N:
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 4
q
p
q
p
p
t
dS
n
G
dS G
n
M
) (
) , (
) ( ) , ( ) ; ( } {
q
q p
q q p n p
(4e)
q
q p
p
dS
n
G
n
N ) (
) , (
) ; ( } { q
q p
n p
(4f)
Note that the derivative
p
n
cannot always be taken
directly inside the integral in (4f), if we did then the
integral can be hypersingular, and therefore not defined
in the normal sense, when q=p. N is therefore not a true
integral operator, but belongs to the more general class
of pseudo-differential operators. For convenience, we
will continue to refer to L,M,M
t
and N as integral
operators, but we will also keep the special case on N in
mind.
Applying L and N to any function , any boundary
and any vector n
p
gives rise to a continuous function in
space. However the operators M and M
t
have jump
discontinuities at the boundary:
) ( } { ) (
2
1
) ( } { lim
0
p p n p M M
p
(5a)
) ; ( } {
) (
2
1
) ; ( } { lim
0
p
t
p p
t
M
M
n p
p n n p
(5b)
where p and is smooth at p.
Direct Method
The following equation arises as a result of Greens
second theorem
) ( ) ( } { ) ( } { p p p
S S
Lv M (pD). (6a)
where
p
n
v
) (p
. For points on S we apply the limit
(5a) in equation (6a):
) (
2
1
) ( } { ) ( } { p p p
S S
Lv M (pS). (6b)
Given these equations, the method of solution would
involve solving (6b) with the boundary condition (2) in
order to find approximations to and v on the boundary
and then use equation (6a) to compute at any chosen
points in the domain.
However, there is one notable case when this method
will not work as well. In the case of a pure Dirichlet
boundary condition, (6a) is effectively a Fredholm
integral equation of the first kind. It is well known that
the numerical solution of first kind equations is not as
efficient as it is for the equivalent second kind equation
(which equation (6b) would otherwise be) [14].
We can easily introduce another equation, using the
Laplace integral operators, that will be useful to us.
Differentiating equation (6a) with respect to a vector w,
gives:
) ( ) ; ( } { ) ; ( } { p w p w p
w
v M N
S
t
S
(pD).
(7a)
For points p near the boundary, with n
p
being the unique
unit outward normal at p, then (7a) becomes
) ( ) ; ( } { ) ; ( } { p n p n p
p
p S
t
p S
n
v M N (pD)
(7b)
Moving the point p to the surface and applying the
limit (5b) gives rise to the following equation on the
surface:
) (
2
1
) ; ( } { ) ; ( } { p n p n p v v M N
p S
t
p S
(8)
One disadvantage in using equation (8) as a basis for
solving the Laplace equation, is that it now contains the
hypersingular operator N. The other disadvantage is that
if we wish to solve the Neumann problem using
equation (8) then we have to solve over the operator N,
which leads to a similar loss of efficiency that is found
in solving first kind equations.
In order to avoid the problems with the Dirichlet
problem with equation (6b) and the Neumann problem
with equation (8), a hybrid equation is proposed:
) ( ))}
2
1
( {( ) ( )}
2
1
{( p p v I M L N I M
t
.
(9)
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 5
For suitable weighting parameter , equation (9) forms a
suitable basis for solving the Robin BVP and the special
cases of the Dirichlet and Neumann BVPs.
Once approximations to and v are found on the
boundary from equation (8) with the boundary condition
(2), we can use equation (6a) to determine and
approximation to for any point (p) in the domain.
Indirect Method
The alternative or indirect approach to obtaining an
integral reformulation of the PDE involves writing the
solution as a layer potential. The most obvious way of
doing this is to write
) ( } { ) ( p p
S
L (pDUS)
(10a)
where is a density function defined on S.
It is possible to solve the Dirichlet problem from
equation (10a). This would normally involve finding
on S by solving the integral equation (10a). However,
the same equation cannot be used for the Neumann
problem and, what is more, it requires solution to be
carried out over the first kind operator L.
By differentiating the equation (10a) with respect to
any vector w, we obtain
) ; }( { ) }( { ) ( w p p p
t
M L
w w
(pD)
(10b)
As p approaches the boundary and we take w=n
p
. and
on the boundary equation (10b) becomes
) (
2
1
) ; }( {
) }( { ) ( ) (
p n p
p p p
p
t
p p
M
L
n
v
n
(pS)
(10c)
where the jump discontinuity (5b) has been included.
Equation (10c) relates v on S to . Hence equation
(10c) can be used as a basis for solving the Neumann
problem. It is a second kind equation and so it is very
suitable as a basis for solution.
We do not have a more general solution method. To do
this let us introduce a hybrid single- and double-layer
potential:
) }( { ) }( { p p M L (pD)
(11a)
where
on the
boundary. Equation (11a) can then be employed to
compute an approximation to in the domain D.
V. THE DISCRETE OPERATORS
There is a variety of techniques for deriving the system
of linear equations from a given integral equation. In
general, a method can be derived by replacing the
integrals in an integral equation by a quadrature formula
or by a weighted residual method such as the Galerkin
method. Many methods for solving integral equations
can be used to develop a particular boundary element
method [15]. Of all the methods the method of
collocation is one of the most straightforward and most
popular and it is the one that we will be using in this
paper.
Collocation
The application of collocation to a boundary integral
equation requires that the boundary is represented by a
set of panels. For example a two dimensional boundary
can be approximated by a set of straight lines, as
illustrated in figure 2.
Fig 2. Illustration of the boundary divided into panels.
In order to complete the discretisation of the integral
equations, the boundary functions also need to be
approximated on each panel. It is the characteristics of
the panel and the representation of the boundary
function on the panel that together define the element in
the boundary element method. By representing the
boundary functions by a characteristic form on each
panel, the boundary integral equations can be simplified
into a linear system of equations. Most simply, the
boundary functions can be approximated by a constant
on each panel. The collocation (or representative) point
is at the centre of the panel (C
-1
collocation). The overall
process is that of discretising the integral operators and
the methods for carrying this out are covered in (for the
more general Helmholtz equation) [16].
Let the Sj ( for j = 1, 2, .., n) be the n panels that
represent an approximation to S in the boundary element
method. We may write
n
j
j
S S S
1
~
.
(12)
Following from equation (4a), we may write:
) ( } {
) , ( ) ( ) , (
) ( ) , ( ) ( ) , ( ) ( } {
1
1
~
1
~
~
p
q p q q p
q q p q q p p
j
j
S
n
j
j
n
j
S
q j
n
j
S
q
S
q q
S
S
Le
dS G dS G
dS G dS G L
(13a)
where in the final expression we have made the
approximation
j
) (q (a constant) on the j
th
panel
and e is the unit function. A similar discretisation can be
applied to the other integral operators:
) ( } { ) ( } {
1
p p
j
S
n
j
j S
Me M
(13b)
) ( } { ) ( } {
1
p p
j
S
t
n
j
j S
t
e M M ,
(13c)
and
) ( } { ) ( } {
1
p p
j
S
n
j
j S
Ne N .
(13d)
For any point p, ) ( } { p
j
S
Le , ) ( } { p
j
S
Me ,
) ( } { p
j
S
t
e M and ) ( } { p
j
S
Ne are termed the discrete
Laplace integral operators.
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 7
Simplifying the integrands
Writing G(p,q) as G(r) where r=|r| and r=q-p, the
Greens function (3) can be written as follows:
) ln(
2
1
) ( r r G .
(14)
The derivatives of G with respect to r:
r
r G
r
1
2
1
) ( ,
(15)
and
2 2
2
1
2
1
) (
r
r G
r
.
(16)
The normal derivatives of G:
q q
n
r
r
G
n
G
,
(17)
p p
n
r
r
G
n
G
,
(18)
and
) (
2
2 2 2
q p q p q p
n
r
n
r
r
G
n n
r
r
G
n n
G
.
(19)
The normal derivatives of r:
r n
r
q
q
n r.
,
(20)
r n
r
p
p
n r.
,
(21)
and
) . (
1
2
q p
q p
q p
n
r
n
r
r n n
r
n n .
(22)
Evaluating the integrals
In most cases of evaluating the discrete integrals in
(13a-d), the integrand is continuous and can be
approximated most efficiently by Gaussian quadrature.
For the case in which p lies on the element of
integration, the integral can be evaluated by a simple
formulae. Let the element have length a+b with the
point p lying a distance a from one end and a distance b
from the other, as illustrated in the figure 3.
a b
p
Figure 3. A general element with the collocation point
p lying on the element.
In the case illustrated in figure 3 we can derive the
following expressions:
) log log (
2
1
) ( } { b b a a b a Le p
(23a)
0 ) ( } { p Me
(23b)
0 ) ( } { p e M
t
(23c)
)
1 1
(
2
1
) ( } {
b a
Ne p
(23d)
VI. PARALLEL METHODS FOR APPROXIMATING THE
DISCRETE LAPLACE OPERATORS
We develop a potentially parallel method by avoiding
loops and using the in-built matrix/vector operations in
Matlab or Freemat. By doing this we are effectively
making each loop independent and therefore can be
carried out in parallel.
Firstly, we need to set up a general purpose Gaussian
quadrature rule (Gauss-Legendre). The routine gl.m sets
up an 8 point rule for integration over the interval [0,1].
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 8
gl.m
% function [wts,pts,n]=gl()
% Sets up a Gauss-Legendre Quadrature
% for integration over [0,1]
% with n=8 weights (wts) and points (pts)
function [wts,pts,n]=gl()
n=8;
wts= [ 5.061426814519E-02
0.111190517227
0.156853322939
0.181341891689
0.181341891689
0.156853322939
0.111190517227
5.061426814519E-02];
pts= [ 1.985507175123E-02
0.101666761293
0.237233795042
0.408282678752
0.591717321248
0.762766204958
0.898333238707
0.980144928249];
As a most useful building block, it would be helpful to
have a routine for evaluating the four Laplace integral
operators, That is for any point p, we wish to
compute ) ( } { p
j
S
Le , ) ( } { p
j
S
Me , ) ( } { p
j
S
t
e M and
) ( } { p
j
S
Ne . Given that many of the intermediate steps
for computing the operators are similar, it is more
efficient to compute them simultaneously. The operators
needed depend on the formulation used hence the
routine has the facility for setting the required operators.
The routine for doing this is l2lc.m. The method
follows the formulas given in section V. Given the
routine will be called many times, its efficiency is one of
the critical factors in the efficiency of the overall
boundary element method. In l2lc.m, loops are avoided
completely (replaced by vector operations) so that any
available parallelism can be taken advantage of.
l2lc.m
% function
[l,m,mt,n]=l2lc(p,vecp,qa,qb,lponq,needl,needm,needmt,needn)
% Returns the discrete Laplace operators for the observation point p,
% the derivatve at the observation point (if applicable) vecp, the
% coordinates of the edges of the element qa and qb, lponq states
whether
% p lies on the element (true) or not (false), and
needl,needm,needmt,needn
% state whether the discrete operators l,m,mt and n are needed (if
any
% operator is not needed then a corresponding zero is returned.
function [l,m,mt,n]=
l2lc(p,vecp,qa,qb,lponq,needl,needm,needmt,needn)
oo2pi=0.5/pi;
qbma=qb-qa;
qlen=norm(qbma);
pmqa=p-qa;
pmqb=p-qb;
normq(1)=-qbma(2)/qlen;
normq(2)=qbma(1)/qlen;
pqalen=norm(pmqa);
pqblen=norm(pmqb);
dnpdq=vecp*normq';
l=0;
m=0;
mt=0;
n=0;
if (lponq)
l=(qlen-(pqalen*log(pqalen)+pqblen*log(pqblen)))*oo2pi;
m=0;
mt=0;
n=-(1/pqalen+1/pqblen)*oo2pi;
continue
else
[w,x,npoints]=gl();
onesnp=ones(1,npoints);
delta=qbma'*x;
qasame=[qa(1).*onesnp; qa(2).*onesnp];
psame=[p(1)*onesnp; p(2)*onesnp];
q=qasame+delta;
rr=psame-q;
srr=rr.^2;
srr1=srr(1,1:npoints);
srr2=srr(2,1:npoints);
sr=srr1+srr2;
r=sqrt(sr);
if (needl)
g=-oo2pi*log(r);
l=qlen*(w*g');
end
if (needm|needmt|needn)
rnqr=-normq*rr;
rnq=rnqr./r;
rnpr=vecp*rr;
rnp=rnpr./r;
gr=-oo2pi/r;
wgr=(w.*gr);
end
if (needm)
m=qlen*(wgr*rnq');
end
if (needmt)
mt=qlen*(wgr*rnp');
end
if (needn)
rnprnq=rnp.*rnq;
dnpnq=vecp*normq';
dnpnqsame=dnpnq*onesnp;
rnpnq=-(dnpnqsame+rnprnq)./r;
grr=oo2pi/sr;
wgrr=w.*grr;
n=qlen*(wgr*rnpnq'+wgrr*rnprnq');
end
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 9
__________________________________________
VII. DEFINING THE BOUNDARY
A method is required for defining the boundary as a set
of panels. The easiest way of showing how this may be
done is by example. Figure 4 shows a square of
dimension 0.1 divided into 32 panels.
Figure 4. A square divided into 32 panels.
The description in the following Matlab/Freemat code
(square.m) involves listing the coordinates of the
vertices of the panels in vertpts and lists the indices of
the edges of each element in elemvert.
square.m
% function [vertpts,elemvert]=square
% Returns a list of edges of the panels that make up the square
% in vertpts and the list of elements that make up the boundary
% are defined by the indices of the two vertices in elemvert.
% Note that the vertices of each element in elemvert must be
% defined in the clockwise direction.
function [vertpts,elemvert]=square
vertpts=[0.00000000000 0.00000000000;
0.00000000000 0.01250000000;
0.00000000000 0.02500000000;
0.00000000000 0.03750000000;
0.00000000000 0.05000000000;
0.00000000000 0.06250000000;
0.00000000000 0.07500000000;
0.00000000000 0.08750000000;
0.00000000000 0.10000000000;
0.01250000000 0.10000000000;
0.02500000000 0.10000000000;
0.03750000000 0.10000000000;
0.05000000000 0.10000000000;
0.06250000000 0.10000000000;
0.07500000000 0.10000000000;
0.08750000000 0.10000000000;
0.10000000000 0.10000000000;
0.10000000000 0.08750000000;
0.10000000000 0.07500000000;
0.10000000000 0.06250000000;
0.10000000000 0.05000000000;
0.10000000000 0.03750000000;
0.10000000000 0.02500000000;
0.10000000000 0.01250000000;
0.10000000000 0.00000000000;
0.08750000000 0.00000000000;
0.07500000000 0.00000000000;
0.06250000000 0.00000000000;
0.05000000000 0.00000000000;
0.03750000000 0.00000000000;
0.02500000000 0.00000000000;
0.01250000000 0.00000000000];
elemvert=[1:32; 2:33]
elemvert(2,32)=1
VIII. MATRICES IN THE BOUNDARY ELEMENT
METHOD
The boundary element method is derived by applying
an integral equation method to the appropriate boundary
integral equation. The most straightforward method to
apply is that of collocation.
The initial development of the application of
collocation to give expressions for the discrete Laplace
operators is given in Section V. To continue the
development, approximations to the (unknown)
boundary functions whether that be and/or v in the
direct method, or in the indirect method are obtained
by replacing the boundary integral equation by a matrix-
vector equation and then solving it. Approximations to
in the domain can then be found by direct integration.
In the collocation method, the general point p in the
boundary integral equation (e.g. equations (9) for the
direct method or equation (11e) for the indirect method),
takes the value of every central point on each panel; the
collocation points: p=p
S1
, p
S2
,, p
Sn
.
For illustration, let us apply the collocation method to
boundary integral equation (10a) (for pS):
) ( } { ) ( p p
S
L (pS)
(24)
Following the development in equation (13a), the
following discrete form of equation (24) is obtained:
) ( } { ) ( } { ) (
1
p p p
j
S
n
j
j S
Le L .
Allowing p to take the value of p
Si
, a collocation points
gives the following:
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 10
) ( } { ) ( } { ) (
1
i S S
n
j
j i S S Si
j
Le L p p p .
Let us now introduce the notation:
) (
i S i S
p , ) (
i S i S
v v p , ) (
i S i S
p ,
n S
S
S
S
:
:
2
1
,
n S
S
S
S
v
v
v
v
:
:
2
1
,
Sn
S
S
S
:
:
2
1
,
) ( } { ] [
i S S ij SS
j
Le p L ,
) ( } { ] [
i S S ij SS
j
Me p M ,
) ( } { ] [
i S S
t
ij
SS
j
e M p M
t
,
) ( } { ] [
i S S ij SS
j
Ne p N ,
Returning to the integral equation (24): by applying the
collocation method it is then replaced by the following
equation:
S SS
S
L ,
Which can be solved for the Dirichlet case to return an
approximation to on S. (Although basing the BEM on
this first kind equation is not advised; this is meant to be
purely illustrative.)
Usually, the objective is to find the solution in the
domain. Returning to our illustrative boundary integral
equation (10a) (for pD):
) ( } { ) ( p p
S
L (pD)
(25)
For points p in the domain, we can approximate (p) as
before
) ( } { ) ( } { ) (
1
p p p
j
S
n
j
j S
Le L ,
except in its application, an approximation to (the
values of the
i
) has been obtained.
Let the solution be sought at the m domain points p =
p
D1,
p
D2
, ., p
Dm
) ( } { ) ( } { ) (
1
i D S
n
j
j i D S Di
j
Le L p p p .
Let us now introduce the notation:
) (
Di i D
p , ) (
i D i D
v v p , ) (
i D i D
p ,
m D
D
D
D
:
:
2
1
,
n D
D
D
D
v
v
v
v
:
:
2
1
,
) ( } { ] [
i D S ij DS
j
Le p L ,
) ( } { ] [
i D S ij DS
j
Me p M ,
) ( } { ] [
i D S
t
ij
DS
j
e M p M
t
,
) ( } { ] [
i D S ij DS
j
Ne p N .
Returning back to the example integral equation (24),
using this notation, approximations to the solution at
the domain points can be determined by the following
matrix-vector multiplication:
S DS
D
L .
It can be observed that there is a general case in
evaluating the required matrices; it is given a set of
points and a description of the boundary, a method for
evaluating the matrix components is required. The
routine for doing this is lbem2.m.
lbem2.m
% function [L,M,Mt,N] = lbem2(m,p,vecp,n,vertpts,elemvert,p_on,
needL,needM,needMt,needN)
% Sets up the matrices required in the boundary element method
% for m (observation) points p with a vector (derivative) direction of
% vecp at the points p. The boundary is made up of n elements;
vertpts lists the coordinates
% of the edges of the elements and elemvert lists the pairs of vertices
% that define each element. p_on idicates whether the point p(i) lies
on the ith panel.
% needL,needM,needMt,needN indicate which matrices are needed
by being set to true.
function [L,M,Mt,N] =lbem2(m,p,vecp,n,vertpts,elemvert,p_on,
needL,needM,needMt,needN)
[qa,qb]=vertices(n,vertpts,elemvert);
for (i=1:n)
for (j=1:n)
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 11
[L(i,j),M(i,j),Mt(i,j),N(i,j)]=l2lc(p(i,:),vecp(i,:),qa(j,:),qb(j,:),p_on&i==j,nee
dL,needM,needMt,needN);
end
end
Drawn from this general case is the special case in
which the points lie at the centres of the elements that
define the boundary. This special case is implemented
by the routine lbem2_on.m.
lbem2_on.m
% function [L,M,Mt,N]
=lbem2(n,vertpts,elemvert,p_on,needL,needM,needMt,needN)
% Sets up the matrices required in the boundary element method
% for a boundary made up of n elements. vertpts lists the coordinates
% of the edges of the elements and elemvert lists the pairs of vertices
% that define each element.needL,needM,needMt,needN indicate
which matrices
% are needed by being set to true.
function [L,M,Mt,N] =lbem2_on(n,vertpts,elemvert,
needL,needM,needMt,needN)
[qa,qb]=vertices(n,vertpts,elemvert);
p=(qa+qb)/2;
qbma=qb-qa;
for(i=1:n)
qlen(i)=norm(qbma(i,:));
end
for (i=1:n)
normp(i,1)=-qbma(i,2)/qlen(i);
normp(i,2)=qbma(i,1)/qlen(i);
end
[L,M,Mt,N]=lbem2(n,p,normp,n,vertpts,elemvert,true,
needL,needM,needMt,needN)
IX. BOUNDARY ELEMENT METHOD
Having, developed all the building blocks we may now
complete the coding for the boundary element methods.
In section IV, two classes of boundary integral equation
were introduced and these lead to two classes of
boundary element method; the direct method and the
indirect method.
Direct Method
For the chosen integral equation (9), the discrete
analogue for collocation points on S is as follows:
[ M
SS
+I+N
SS
]
S
= [L
SS
+(M
t
SS
-I)] v
S
(25)
with the general Robin boundary condition
i i i i i
f v for i=1..n .
(26)
The solution of this kind of system is not a standard
utility in Matlab/Freemat. Hence we introduce the
routing gls.m that carries out row operations to rewrite
a system like the above as a standard linear system and
then solve by the inbuilt Matlab/Freemat matrix-vector
solution method.
gls.m
% gls returns the solution x,y to a problem of the form
% A x = B y +c
% where A and B are n by n real matrices and c is a n-vector
% under the condition(s)
%
% {\alpha}_i x_i + {\beta}_i y_i = f_i for i=1..n.
%
% Clearly only one of {\alpha}_i or {\beta}_i can be zero for each i.
%
% The method employed involves forming a linear system of the form
Cz=d
% where the n by n matrix C and the vector d can be determined from
A,B
% and the {\alpha}_i and {\beta}_i. A standard LU factorisation
% solution method is then employed to return a solution. From this the
actual
% solutions x,y can be determined.
function [x,y]=gls(A,B,c,n,alpha,beta,F)
gamma=norm(B,inf)/norm(A,inf);
test=abs(beta)>abs(gamma*alpha);
for (i=1:n)
if (test(i))
Fob=F(i)/beta(i);
aob=alpha(i)/beta(i);
for (j=1:n)
c(j)=c(j)+Fob*B(j,i);
B(j,i)=-aob*B(j,i);
end
else
Foa=F(i)/alpha(i);
boa=beta(i)/alpha(i);
for (j=1:n)
c(j)=c(j)-Foa*A(j,i);
A(j,i)=-boa*A(j,i);
end
end
end
A=A-B;
y=A\c;
for (i=1:n)
if (test(i))
x(i)=(F(i)-alpha(i)*y(i))/beta(i);
else
x(i)=(F(i)-beta(i)*y(i))/alpha(i);
end
end
for (i=1:n)
if (test(i))
www.boundary-element-method.com
Report AR-08-14, East Lancashire Institute of Higher Education, Blackburn, UK. Page 12
temp=x(i);
x(i)=y(i);
y(i)=temp;
end
end
x=x';
Once the solution on the boundary is found to (25),
(26), the solution at any domain point can be found
through integrating over the boundary using equation
(6a).
Matlab/Freemat routine libem2.m returns the solution
in the domain and on the boundary using the direct
method.
libem2.m
% function [phi_D,phi_S,v_S] =
libem2(n_D,p_D,n_S,vertpts_S,elemvert_S,alpha_S,beta_S,f_S)
% Returns the solution phi_D at the n_D domain points p_D and at the
collocation points.
% The boundary is made up of n elements; vertpts lists the
coordinates
% of the edges of the elements and elemvert lists the pairs of vertices
% that define each element. alpha_S, beta_S and f_S determine the
Robin boundary condition.
function [phi_D,phi_S,v_S]
=libem2(n_D,p_D,n_S,vertpts_S,elemvert_S,alpha_S,beta_S,f_S)
% calculate phi_S, v_S, phi and v on the boundary
% calculate L_SS, M_SS, Mt_SS and N_SS, the discrete form of the
operators for the collocation points
[L_SS,M_SS,Mt_SS,N_SS]
=lbem2_on(n_S,vertpts_S,elemvert_S,true,true,true,true);
M_SSplus=M_SS+eye(n_S)/2;
Mt_SSminus=Mt_SS-eye(n_S)/2;
mu=norm(M_SSplus)/norm(N_SS);
for (i=1:n_S)
zero_S(i)=0.0;
end
[phi_S,v_S]=
gls(M_SSplus+mu*N_SS,L_SS+mu*Mt_SSminus,zero_S,n_S,
alpha_S,beta_S,f_S);
% calculate phi_S, v_S, phi and v on the boundary
% calculate L_DS, M_DS, the discrete form of the operators for the
domain points
% dummy values set to vecp_D, since it is not used
for (i=1:n_D)
vecp_D(i,1)=1;
vecp_D(i,2)=0;
end
[L_DS,M_DS,Mt_DS,N_DS]
=lbem2(n_D,p_D,vecp_D,n_S,vertpts_S,elemvert_S,false,true,true,fal
se,false);
phi_D=L_DS*v_S-M_DS*phi_S;
Indirect Method
For the chosen integral equation (11e), the discrete
analogue for collocation points on S is as follows:
{(L
SS
+(M
SS
-I))D
+((M
t
SS
+I)+N
SS
)D
=f
(27)
where the general Robin boundary condition is included
such that D and D
, the discrete
equivalent of the layer potential