8.2 Degenerate Quadrangles . ... Chapter 1. Introduction. In this work different aspects surrounding the import of geometries from Computer .... Figure 3.2 shows a mesh consisting of triangular elements. Each triangle is made up of three ..... a function of the percentage of movement of node 81 along this distance. Acoustic.
Optimization of Meshes from CAD Programs for Acoustic Boundary Element Calculations
Author: Ren´e Christensen Supervisor: Peter Møller Juhl Date: March 3rd, 2003
University of Southern Denmark
Preface This master thesis describes work carried out at the Institute of Physics, University of Southern Denmark in Odense. The project period was 6 months, taking its start September 2nd, 2002 and handed in at March 3rd, 2003. My thanks go to Peter Møller Juhl for providing excellent guidance throughout the project period; Jan Abildgaard Pedersen at Bang & Olufsen for contributing with subjects to adress in this project; and Carsten Højg˚ ard Jensen at Bang & Olufsen for providing several test cases.
Odense, March 2003 Ren´e Christensen
ii
Abstract The Boundary Element Method is a numerical method used for solving acoustic sound field problems. The method involves the description of a domain by a mesh. CAD programs are often used for making these meshes, and this presents some problems. This work describes some of these problems, possible solutions and additional topics. Some examples are mesh refinement, mesh joining and frequency interpolation. Existing software from the OpenBEM package has been used and additional MATLAB programs have been developed.
iv
Contents 1 Introduction
1
2 Symbols and Definitions 2.1 List of Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 4 4
3 The 3.1 3.2 3.3 3.4 3.5
. . . . . . .
6 6 7 9 11 14 14 15
. . . . .
16 16 19 20 25 25
. . . .
28 28 29 31 32
6 Convergence Analysis and Integration Points 6.1 Convergence Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 The Effect of the Number of Integration Points . . . . . . . . . . . . 6.3 Concluding Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . .
33 34 36 38
3.6
Boundary Element Method Helmholtz Integral Equation . . Geometric Discretization . . . . The Local Coordinate System . The Numerical Integration . . . MATLAB Implementation . . . 3.5.1 Nodes and Topology . . Concluding Remarks . . . . . .
4 Ill-shaped Triangles 4.1 Pointy Triangles . . . . . . 4.1.1 Condition Numbers 4.2 Flat Triangles . . . . . . . . 4.2.1 Condition Numbers 4.3 Concluding Remarks . . . .
. . . . .
5 Mesh Refinement 5.1 Program Strategy . . . . . . . 5.2 The Program, refinemesh.m 5.3 Program Test . . . . . . . . . 5.4 Concluding Remarks . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
v
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
. . . . . . .
. . . . .
. . . .
CONTENTS
vi
7 Incompatible Meshes 7.1 Program Strategy . . . . . . . . . 7.2 The Program, merge.m . . . . . . 7.2.1 MATLAB Implementation 7.3 The Excess Nodes . . . . . . . . 7.4 Program Test . . . . . . . . . . . 7.5 Special Cases . . . . . . . . . . . 7.6 Concluding Remarks . . . . . . .
. . . . . . .
40 41 44 44 47 48 53 56
. . . . .
57 57 59 61 61 63
Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
64 64 65 66
. . . . .
. . . . .
67 67 70 71 71 75
11 Discussion 11.1 Discussion of Mesh Refinement . . . . . . . . . . . . . . . . . . . . . 11.2 Discussion of Incompatible Meshes . . . . . . . . . . . . . . . . . . . 11.3 Discussion of Frequency Interpolation . . . . . . . . . . . . . . . . .
77 77 77 78
12 Conclusion
79
A List of Programs A.1 Mesh Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.2 Additional Programs . . . . . . . . . . . . . . . . . . . . . . . . . . .
83 83 85
B Mathematics B.1 Green’s Function, Singularity . . . . B.2 The Jacobian and the Normal Vector B.3 The Spatial Angle . . . . . . . . . . B.4 Differentiating Green’s Function . .
86 86 86 87 88
8 Changing Triangular Elements 8.1 Program Strategy . . . . . . . 8.2 Degenerate Quadrangles . . . 8.3 The Program, tri2quad.m . . 8.4 Program Test . . . . . . . . . 8.5 Concluding Remarks . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
to Quadrilateral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9 Meshes with both Triangular and 9.1 The Program, TriQuadEquat.m . 9.2 Program Test . . . . . . . . . . . 9.3 Concluding Remarks . . . . . . .
Quadrilateral . . . . . . . . . . . . . . . . . . . . . . . . . . .
10 Frequency Interpolation 10.1 Interpolating Matrix Elements . . . . . . . . . . 10.1.1 Linear and Quadratic Interpolation . . . . 10.2 The Programs, interplin.m and interpquad.m 10.3 Program Test . . . . . . . . . . . . . . . . . . . . 10.4 Concluding Remarks . . . . . . . . . . . . . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . . .
. . . .
. . . . .
. . . .
. . . . .
. . . .
. . . . .
. . . .
. . . . .
. . . .
. . . . .
. . . .
. . . . . . . . . . . .
. . . . .
. . . .
. . . . . . . . . . . .
. . . . .
. . . .
. . . . . . . . . . . .
. . . . .
. . . .
. . . .
Chapter 1
Introduction In this work different aspects surrounding the import of geometries from Computer Aided Design (CAD) programs for use in acoustic calculation programs based on the Boundary Element Method (BEM) are examined. Most CAD programs are capable of exporting geometries. Different export formats are often available with the Stereo Lithography (STL) being one of the most universal. When using the STL format the surface of a geometry is described by a mesh of triangles surrounding the surface. While this a totally adequate way of describing geometries, these meshes are not in general suited for use in acoustic calculations since the criteria for meshes are different in the two situations. This project works with a number of the problems connected with the interpretation of the STL format into satisfactory calculation meshes. This includes examining the effect of ill-shaped triangles in the meshes; subdivision of triangles; operating with calculation meshes with both traingular and quadrilateral elements; and incompatible meshes. Existing software capable of performing BEM calculations was used in this work. The program package containing this software is called OpenBEM. In addition to this package the author has developed several programs directed at the optimization of calculation meshes. In chapter 3 the Boundary Element Method is examined. The general theory is described and it is explained how the meshes are related to the acoustic calculations. Meshes from CAD programs sometimes have triangles that are extremely pointy, i.e. one of the sides in the triangle is much smaller than the two other sides. Such triangles are refered to as being ill-shaped. Another type of ill-shaped triangle is the flat triangle, where one of the corners in the triangle is near its adjecent side. Chapter 4 is an examination of how ill-shaped triangles in a mesh affect the acoustic calculations. 1
2
Another result of using meshes from CAD programs is that large planar surfaces are sometimes represented using only one quadrangle or two triangles. This is sufficient to describe the geometry of the surface. However, such meshes are rarely suited for use in acoustic calculations. Chapter 5 describes a program developed in this project that refines meshes with large triangles. The triangles are divided into smaller triangles until the mesh meets some user defined demand regarding triangle size versus calculation frequency. In this work the meshes only have planar elements. This is associated with the assumption that the acoustic variables vary linearly along the geometric elements in the mesh. In chapter 6 a convergence analysis has been carried out. This analysis shows how the calculation error is related to number of elements in the mesh, and additionally, what effect the choice of planar elements have on the slope of this error. In this chapter it is also examined how the number of integration points per element affects the error, and finally the calculation error when using meshes with triangular elements is compared to the error when using quadrilateral elements. Oftentimes it is wanted to describe a surface using more than one mesh. This could for example be the case if one part of the surface is to have a given velocity, and the other part is to be static. The CAD programs can easily cover a surface with more than one mesh and still represent the geometry of the surface satisfactory. However, in order to perform any acoustic calculations using such meshes, they have to be joined at some time and this is not always easily done. Some CAD programs describe the open edges, i.e. where the meshes meet, differently for the two meshes. Such meshes are called incompatible. Chapter 7 describes a program developed in this project capable of joining meshes that are not compatible. To the knowledge of the author such a program has never been developed before. Sometimes it is wanted to change the triangular elements in a mesh into quadrilateral elements. Chapter 8 describes a program developed in this project that is capable of just that. It examines the triangular element mesh and joins certain pairs of triangles into quadrangles without distorting the geometry of the mesh. The OpenBEM program package provides means for calculating using meshes with either triangular elements or quadrilateral elements. In this project some of the existing software was combined to make it possible to carry out acoustic calculations using meshes with both triangles and quadrangles. This is described in chapter 9. Finally a method for speeding up calculations was examined. BEM calculations can be very time consuming especially at high frequencies. An interpolation scheme which reduces the calculation time is described in Chapter 10.
3
Introduction
In this thesis references to litterature are indicated by a number in square brackets. E.g. [3] is the third piece of litterature in the bibliography. A CD is included in the back of this thesis. The CD contains this thesis in PDF format along with the LATEX source files, and the programs and test cases used in this work.
Chapter 2
Symbols and Definitions In acoustics as well as in other areas of physics most results depend on a certain definition. To minimize confusion a list of symbols and definitions are included here.
2.1
List of Symbols
These are symbols used in this work with SI units included. Symbol c f ω ρ0 λ k p v j
Description Speed of sound Frequency Angular frequency Static density Wave length Wave number Sound pressure Surface normal velocity √ Complex number, −1
Unit [m/s] [Hz] [rad/s] [kg/m3 ] [m] [1/m] [P a] [m/s]
Table 2.1: List of symbols with description and units. Additional letters are used as indices. E.g. m and n are used to indicate node numbers, M and N indicate the total number of nodes and geometric elements, respectively, and i and j are used when summing or integrating several times.√When used in a subscript, j is a real number, otherwise it is the complex number −1.
2.2
Definitions
The acoustic variables are assumed to be time-harmonic, meaning that they can be written as spatial dependant part multiplied with a sinusoidal, time dependant part. The time dependant part is in this thesis the exponential ejωt with a positive sign 4
5
Symbols and Definitions
in the exponent. The time dependant part is omitted so that the acoustic variables in the thesis are only spatial dependant. The complex particle velocity is denoted u and its unit is metres per second. The complex velocity potential, φ, is related to the complex sound pressure, p, and the particle velocity, u, in that: u = −∇φ and p = jωρφ. The quantities u and φ are not used in this thesis. In equations matrices are written in bold capital letters whereas vectors (in linear algebra a vector is a one-dimensional matrix) are written in bold lower case letters. In the text matrices and vectors are simply refered to by their name. An example: ”. . . A=2b, so the A matrix is simply a vector equal to two times vector b ”. In physics and engineering vectors are used to specify magnitude and direction. Such vectors are written as some characteristic letter with an arrow over it. In some cases the vector has a subscript indicating either the direction of the vector or the order of several vectors. A vector from some point a to another point b will consequently be written as ~vab , whereas the first out of several normal vectors will be written as ~n1 . In this work it is assumed that the sound fields in question are all solutions to Helmholtz equation: ∇2 p + k 2 p = 0
(2.1)
The Laplacian, that is, the operator ∇2 , takes the form ∇2 =
∂2 ∂2 ∂2 + + , ∂x2 ∂y 2 ∂z 2
in a Cartesian coordinate system. The solution to the inhomogenous Helmholtz equation (∇2 + k 2 )G(~r, ~r0 ) = −4πδ(~r − ~r0 )
(2.2)
is knowns as Green’s function. It is sound the sound pressure at ~r generated by a point source at ~r0 , normalized by letting jωρq = 1, with q being the volume velocity −jkR of the point source. The free-space Green’s function, G(R), is equal to e R where R is |~r − ~r0 |. Oftentimes Green’s function is written as G(P, Q) with ~r0 extending from the coordinate origin to point P and ~r extending from origin to point Q. In some litterature the free-space Green’s function additionally has a factor 4π in the denominator. In that case the corresponding equation is (∇2 + k 2 )G(~r, ~r0 ) = −δ(~r − ~r0 )
Chapter 3
The Boundary Element Method The Boundary Element Method , BEM for short, is a numerical method used for solving radiation and scattering problems in acoustics. The method involves discretizing the boundary of some domain. If the domain e.g. is outside a solid or hollow radiating body, the problem is called exterior and the boundary to be discretized is in this case the surface of the body. If the domain of interest is inside the body the problem is called interior : In case of a hollow body the boundary to be discretized is the inside surface of the body. This chapter gives a brief introduction to the method with the emphasis on the aspects most relevant for this project. The method is described in much greater detail in [2] and [3], with [3] being the primary source of inspiration for this chapter.
3.1
Helmholtz Integral Equation
In figure 3.1 a body is placed in a homogenous, fluid medium which extends to infinity in all directions. The surface of the body is denoted S. Two arbitrary points, P and Q, are shown in the medium and on the surface, respectively. Helmholtz Integral Equation (3.1) gives the relation between the sound pressure in point P , p(P ), and the sound pressure and surface normal velocity in point Q, p(Q) and v(Q), respectively. Z C(P )p(P ) =
p(Q) S
∂G(P, Q) + jkz0 v(Q)G(P, Q)dS + 4πpI (P ) ∂n
(3.1)
The equation states that if the sound pressure and normal velocity is known everywhere on the surface of the body then the sound pressure at any point P in the medium can be calculated. The surface normal velocity, v, is defined as ~v · ~n, with the normal unit vector ~n pointing outwards from the surface, into the medium. The characteristic impedance z0 equals ρ0 c. The part called pI (P ) is the incoming sound pressure in point P , i.e. the sound pressure present when the body is removed. The total sound pressure in point P is 6
7
The Boundary Element Method
Figure 3.1: A surface S placed in a medium. A vector ~r extends from the coordinate origin to a point Q at the surface. Another vector ~r0 extends from origin to a point P in the medium.
the sum of a scattering and an incoming sound field, thus p(P ) = pI (P ) + psc (P ). C(P ) is the spatial angle in point P . It is found as Z ∂(1/R) dS, (3.2) C(P ) = 4π + ∂n S for exterior problems, and Z ∂(1/R) C(P ) = dS (3.3) ∂ν S for interior problems with ν being an inward normal unit vector (see [3] for further details). R is the distance from point P to Q: q R = |~r − ~r0 | = (xQ − xP )2 + (yQ − yP )2 + (zQ − zP )2 (3.4)
3.2
Geometric Discretization
Since the surface in question can have a complex shape the integration is not in general immediately possible. Therefore the surface is approximated with simpler shaped elements, representing the geometry to a certain degree. In this report the shape of these elements is either a planar triangle or a planar quadrangle. Figure 3.2 shows a mesh consisting of triangular elements. Each triangle is made up of three points or nodes, and several triangles share one or more nodes.
3.2 Geometric Discretization
8
Figure 3.2: A triangular element mesh on the surface on a spherical body. Each bold dot in the figure is a node. By approximating the surface by N planar elements equation 3.1 can be rewritten:
C(P )p(P ) ≈
N Z X j=1
p(Q)
Sj
∂G(P, Q) + jkz0 v(Q)G(P, Q)dSj + 4πpI (P ) ∂n
(3.5)
Considering only a scattering problem at a rigid object simplifies matters additionally, since the normal velocity in this case is zero: C(P )p(P ) ≈
N Z X
p(Q)
Sj
j=1
∂G(P, Q) dSj + 4πpI (P ) ∂n
(3.6)
The equation is a sum of integrals and each integration is to be performed over a known area, namely one of the N elements. The mesh has M nodes. If the sound pressure is to be found in each of the nodes, M equations have to be obtained. In order to do that, M calculation (or collocation) points are placed at the nodes on the surface of the body. Equation 3.6 then becomes: C(Pi )p(Pi ) ≈
N Z X j=1
Sj
p(Q)
∂G(Pi , Q) dSj + 4πpI (Pi ), ∂n
(3.7)
with i running from 1 to M, and p(Pi ) being the scattered sound pressure at node i. The equation can be written as M equations:
9
The Boundary Element Method
C(P1 )p(P1 ) ≈
N Z X j=1
C(P2 )p(P2 ) ≈
∂G(P1 , Q) dSj + 4πpI (P1 ) ∂n
p(Q)
∂G(P2 , Q) dSj + 4πpI (P2 ) ∂n
Sj
N Z X j=1
p(Q)
Sj
.. . C(PM −1 )p(PM −1 ) ≈
(3.8) N Z X j=1
C(PM )p(PM ) ≈
3.3
∂G(PM −1 , Q) dSj + 4πpI (PM −1 ) ∂n
p(Q)
∂G(PM , Q) dSj + 4πpI (PM ) ∂n
Sj
N Z X j=1
p(Q)
Sj
The Local Coordinate System
In this project the sound pressure is assumed to vary linearly between the nodes. The sound pressure on one of the planar triangles can therefore be found as a linear combination of the sound pressures in the three nodes of the triangle. However, since the nodes of the triangle can be located arbitrarily in the global coordinate system, the linear combination is not easily obtained. In order to simplify calculations a local coordinate system is introduced. Each triangle in the global xyz-coordinate system is mapped onto a parent element in a local ξ1 ξ2 -coordinate system. The coordinate systems are illustrated for a planar quadrangle and a planar triangle in figures 3.3 and 3.4, respectively. The xyz-coordinates are connected to the ξ1 ξ2 -coordinates through so-called shape functions in the following way:
x(ξ1 , ξ2 ) = y(ξ1 , ξ2 ) = z(ξ1 , ξ2 ) =
n X α=1 n X α=1 n X
Nα (ξ1 , ξ2 )xα Nα (ξ1 , ξ2 )yα
(3.9)
Nα (ξ1 , ξ2 )zα
α=1
The shape functions Nα determine the transformation. The number n is equal to 3 for triangles, since each of the three nodes in a triangle has three xyz-coordinates, and n is 4 for quadrangles. The shape functions for linear (i.e. planar) triangular elements and linear quadrilateral elements, respectively, are listed in table 3.1. The acoustic variables, i.e. sound pressure and normal velocity, may also be expressed by the shape functions:
3.3 The Local Coordinate System
10
Figure 3.3: In A) a quadrangle is placed in the xyz-coordinate system. In B) the quadrangle has been mapped onto the parent triangle in a ξ1 ξ2 -coordinate system. The nodes are denoted P1 to P4 .
Figure 3.4: In A) a triangle is placed in the xyz-coordinate system. In B) the triangle has been mapped onto the parent triangle in a ξ1 ξ2 -coordinate system. The nodes are denoted P1 to P3 .
11
The Boundary Element Method Linear Quadrangles N1 (ξ1 , ξ2 ) 14 (1 − ξ1 )(1 − ξ2 ) N2 (ξ1 , ξ2 ) 14 (1 + ξ1 )(1 − ξ2 ) N3 (ξ1 , ξ2 ) 14 (1 + ξ1 )(1 + ξ2 ) N4 (ξ1 , ξ2 ) 14 (1 − ξ1 )(1 + ξ2 )
Linear Triangles N1 (ξ1 , ξ2 ) ξ1 N2 (ξ1 , ξ2 ) ξ2 N3 (ξ1 , ξ2 ) 1 − ξ1 − ξ2
Table 3.1: Shape functions for linear quadrilateral elements and linear triangular elements.
p(ξ1 , ξ2 ) =
n X
Nα (ξ1 , ξ2 )pα
(3.10)
Nα (ξ1 , ξ2 )vα
(3.11)
α=1
and v(ξ1 , ξ2 ) =
n X α=1
Shape functions for higher order elements exist. E.g. a quadratic triangle described by six nodes has six corresponding shape functions. Until now the coordinate transformation has introduced only one obvious advantages, namely that the acoustic variables can be found everywhere on the geometric elements by the use of shape functions. However, transforming an arbitrary geometric element from the mesh in the xyz-coordinate system to the ξ1 ξ2 -coordinate system makes integrating both systematic and easier.
3.4
The Numerical Integration
The so-called Gauss-Legendre quadrature integration formula in one-dimension is as follows (the i in the summation is not to be confused with the i in equation 3.7): Z
1
f (x)dx ≈ −1
l X
f (xi )wi
(3.12)
i=1
The integration of a function f (x) in the interval [−1, 1] is performed by summing l products of weight functions, wi , and function evaluations, f (xi ). The l evaluation points, xi and weight functions can be found in mathematical tables, e.g. in [1]. The two coordinates ξ1 and ξ2 for the quadrilateral element vary between −1 and 1. A two-dimensional Gauss-Legendre quadrature formula is obtained by combining two one-dimensional Gauss-Legendre quadrature formulas: Z
1
−1
Z
1
−1
f (ξ1 , ξ2 )dξ1 dξ2 ≈
l X l X j=1 i=1
f (ξ1,i , ξ2,j )wi wj
(3.13)
3.4 The Numerical Integration
12
The evaluation points and weights for each of the two ξ-axes are the same as for the one-dimensional case. The integration formulas for the triangular parent element is not readily derived from the one-dimensional case. However, tables with calculations points and weights that apply to the triangular parent element do exist, e.g. see [1], and for more advanced formulas see [8] and [9]. Now the first of the equations in equation array 3.8 is examined further: C(P1 )p(P1 ) ≈
N Z X j=1
p(Q)
Sj
∂G(P1 , Q) dSj + 4πpI (P1 ) ∂n
(3.14)
Or with the sum written out: Z ∂G(P1 , Q) ∂G(P1 , Q) dS1 + p(Q) dS2 C(P1 )p(P1 ) ≈ p(Q) ∂n ∂n S2 S1 | {z } | {z } Element 1 Element 2 Z ∂G(P1 , Q) +... + p(Q) dSN +4πpI (P1 ) ∂n S | N {z } Z
(3.15)
Element N
The integration over element 1 can now be used to illustrate the numerical integration. First the element is mapped onto its parent element. Since a coordinate transformation is performed, the corresponding Jacobian must be calculated. When transforming a planar surface in the xyz-coordinate system to a planar surface in the ξ1 ξ2 coordinate system, the Jacobian is found as: ° ° x ° ∂~r ° ∂~ r ° where ~r = y J(ξ1 , ξ2 ) = ° × ° ∂ξ1 ∂ξ2 ° 2 z
(3.16)
This expression is examined further in P section B.2, appendix B. In addition to the Jacobian, it was found that p(ξ1 , ξ2 ) = nα=1 Nα (ξ1 , ξ2 )pα . The integration over the first element can now be rewritten: Z
∂G(P1 , Q) dS1 ≈ p(Q) ∂n S1 =
Z
n X
SP arent α=1 Z n X
pα
α=1
Nα (ξ1 , ξ2 )pα
SP arent
Nα
Equation 3.14 can therefore be written as:
∂G(P1 , Q) J(ξ1 , ξ2 )dSP arent ∂n
∂G(P1 , Q) JdSP arent ∂n
(3.17)
13
The Boundary Element Method
C(P1 )p(P1 ) =
Z
n N X X
pα
SP arentj
j=1 α=1
Nα
∂G(P1 , Q) JdSP arentj + 4πpI (P1 ) ∂n
(3.18)
This equation describes a scattering case for point P = P1 . Including the omitted term from equation 3.5 for a given collocation point gives the general expression:
C(Pi )p(Pi ) ≈
N X n X
Z pα
j=1 α=1
Z
jkρ0 cvα
SP arentj
SP arentj
Nα (ξ1 , ξ2 )
∂G(Pi , Q) J(ξ1 , ξ2 )dSP arentj + ∂n
Nα (ξ1 , ξ2 )G(Pi , Q)J(ξ1 , ξ2 )dSP arentj +
4πpI (Pi ),
(3.19)
with i running between 1 and M . In order to describe the acoustic problem, i.e. the equations found by inserting in equation 3.19, in a systematic way suited for computer solving, a matrix formulation is used: Cp = Ap + jkρ0 cBv + 4πpI ,
(3.20)
with
C(P1 ) 0 0 C(P2 ) C= .. .. . . 0 0 a11 a12 a21 a22 A= . .. .. .
... ... .. .
0 0
a1M
a2M
C(PM ) . . . aM 1 . . . aM 2 .. . aM M
b11 b21 .. .
b12 b22 .. .
... ... .. .
b1M
b2M
,
(3.21)
(3.22)
and B=
bM 1 bM 2 , bM M
(3.23)
where elements in matrix A are related to the derivative of Green’s function, and elements in matrix B are related to Green’s function. There are M rows in each matrix corresponding to the M equations; the M columns, however, are not so obvious: E.g. what is to be found in the A matrix element a15 ? The number 1 in the
3.5 MATLAB Implementation
14
subscript corresponds to the first node being adressed, i.e. P = P1 . All of the nodes belong to several of the geometric elements, and the number 5 corresponds to the geometric elements to be integrated all sharing node 5. So if, say, element 8 (N = 8) has node 5 as its third node (α = 3) one contribution to matrix element a15 equals: Z SP arent8
(1 − ξ1 − ξ2 )
∂G(P1 , Q) J(ξ1 , ξ2 )dSP arent8 ∂n
(3.24)
If a total of five elements have the node 5, then four additional contributions along with the one in equation 3.24 add up to the matrix element a15 . The integration is calculated numerically; if one integration point per element is used, and the element is a triangle, then 1 − ξ1 − ξ2 = 1/3 (because the integration point is located at (ξ1 , ξ2 ) = ( 13 , 31 )), the weight is 1/2 and the derivative of Green’s function is to be evaluated in the appropriate integration point in the xyz coordinate system found by inserting in equation array 3.9.
3.5
MATLAB Implementation
Using the software package OpenBEM, acoustic problems can be solved on a computer using the method described in this chapter. The package includes several separate MATLAB programs and a description of them all is beyond the scope of this work. However, in order to understand how some of of the programs developed in this project work, it is important to know how meshes are represented in MATLAB.
3.5.1
Nodes and Topology
The meshes used for acoustic calculations are almost exclusively made using CAD programs. All CAD programs offer several formats in which the meshes can be saved. Two formats are of interest: One is the STL format where meshes are represented using only triangles. The coordinates corresponding to the nodes in the mesh are arranged three and three, with three nodes representing a triangle. The other format is in this work denoted the ANSYS format, since the program ANSYS saves its meshes in this format. In the ANSYS format one mesh is represented by two structures: One holds all of the node coordinates, the other holds the topology, i.e. how the nodes are connected to make up the geometric elements. The ANSYS format supports meshes with both quadrangles and triangles. A quadrangle is in the topology structure represented by its four nodes, and a triangle is described as a degenerate quadrangle, i.e. it is represented by four nodes with one of nodes being duplicated. The ANSYS format is actually similar to how meshes are represented in all of the MATLAB programs. One matrix holds the mesh nodes and another matrix hold the topology. The nodes matrix has as many rows as the number of nodes in the mesh, and the topology matrix has as many rows as the number of elements in the mesh.
15
The Boundary Element Method
When having read an STL files the nodes matrix in the MATLAB program has either 3 or 4 columns; the first three columns hold the x, y and z coordinates, respectively, and if there is a fourth column, it holds the body number for each node. The body number is used to indicate which nodes belong to which mesh, when several meshes are read. The topology matrix also has either 3 or 4 columns; the first three hold the three nodes that make up each triangle and the fourth, if any, holds the body number for each triangle. Similarly, when working with the ANSYS format the first three columns in the nodes matrix hold the coordinates and if their is a fourth, it holds the body number. The topology matrix has either 4 or 5 columns; the first four hold the nodes needed to describe the geometric elements and the fifth holds the body numbers. The triangle in figure 3.4 B) described in STL format would have the following nodes and topology matrices when body numbers are omitted: 1 0 0 £ ¤ nodes: 0 1 0 and topology: 1 2 3 0 0 0 STL meshes can be read using the program fmerge.m from the OpenBEM package, giving the nodes and the topology as illustrated above. When additionally running rawbodyfind.m, the body numbers (along with other quantities) are found. The same triangle described in the ANSYS format would have the following nodes and topology matrices when body numbers are omitted: 1 0 0 £ ¤ nodes: 0 1 0 and topology: 1 2 2 3 0 0 0 ANSYS meshes can be read using the programs readnodes.m and readelements.m which give the nodes and the topology, respectively. When additionally running bodyfind.m, the body numbers (again, along with other quantities) are found.
3.6
Concluding Remarks
With the boundary element method described in this chapter acoustic problems with no obvious analytical solution can be solved numerically using the programs in the OpenBEM package. The mesh surrounding the boundary in question is described by its nodes and the topology of these nodes. This mesh determines the matrices used in the acoustic calculations.
Chapter 4
Ill-shaped Triangles (and Their Influence on Acoustic Calculations) Since CAD programs make meshes to accommodate the geometry of some body, these meshes may include some triangles that are not well fitted for acoustic calculations. The effect of using meshes with ill-shaped triangles for acoustic calculations has been examined. Two types of such triangles were incorporated in two meshes. The two meshes used for the calculations are essentially the same, in order to make the errors of the two cases comparable to each other.
4.1
Pointy Triangles
A pointy triangle has one side length which is considerably shorter than the other two. Two of the nodes are therefore relatively close together. In figure 4.1 a spherical mesh is illustrated. The mesh has 80 nodes and 156 triangular elements. The marked nodes make up two triangles. An additional node, node 81, was added to the mesh and the two triangles were divided into four, with node 81 as a common node for the four triangles, see figure 4.2. Node 81 was successively shifted towards node 1 to obtain different aspect ratios, i.e. the ratio between the longer respectively the shorter side of a triangle. As node 81 is moved downwards the two lower triangles become increasingly pointy. The aspect ratios of the two triangles are equal at all times since their shorter side lenghts are common (node 1 to node 81) and their longer side lengths (node 1 to node 39 and node 1 to node 16, respectively) are equal. The test body is a sphere with a radius a of 1. This body is chosen because of the possibility of determining an accurate, analytical solution to different acoustical problems involving a sphere, e.g. pulsation or oscillation. As a rule of thumb there should be 5 nodes pr wavelength when calculating with BEM in order to obtain an 16
17
Ill-shaped Triangles
Figure 4.1: Spherical mesh made up of triangles. Four nodes indicated by bold dots make up two triangles.
Figure 4.2: The four nodes marked in figure 4.1 and an added node, node 81, now make up four triangles.
4.1 Pointy Triangles
18
error of less than 10%. In the test sphere the typical distance between two nodes is 0.4 which corresponds to a maximum wave length of 2. This wave length gives a maximum wave number k of approximately 3. Calculations have been carried out using four different values of ka. The aspect ratio was varied between 2.4 and 3.3 · 1011 . The error E is found as the ratio between the of the L2 norm of the residual vector and the L2 norm of the analytical solution: v u M uX u ((Re{pana [i]} − Re{pBEM [i]})2 + (Im{pana [i]} − Im{pBEM [i]})2 ) u u i=1 krk2 =u E= u M M kpana k2 X X u t ((Re{pana [i]})2 + (Im{pana [i]})2 ) i=1
(4.1)
i=1
In equation 4.1 M is the number of nodes, pana is the analytically calculated sound pressure and pBEM is the sound pressure calculated with boundary element method. Re{} is the real part of a complex value; Im{} is the imaginary part. The error is sometimes denoted the global error. A local error can be found for one or more nodes. In figure 4.3 the global errors corresponding to the different aspect ratios for the two triangles are plotted. Three integration points per triangle were used. 0.085
0.08
Global Error, E; 3 IPs per triangle
0.075
ka=0.5 ka=1 ka=1.5 ka=2
0.07
0.065
0.06
0.055
0.05
0.045
0.04
0.035 0 10
2
10
4
10
6
10 Aspect Ratio
8
10
10
10
12
10
Figure 4.3: The global error as a function of the aspect ratio for the two pointy triangles calculated for four different values of ka. IPs is short for integration points. It is seen from figure 4.3 that the global error tends to a constant for the four different values of ka as the aspect ratio increases, and the increase in error is relatively limited. This indicates that meshes which contain a few triangles with extremely
19
Ill-shaped Triangles
large aspects errors can result in acceptable results when used in acoustical calculations. In figure 4.4 the local errors corresponding to the different aspect ratios are plotted. The local error is found by inserting the nodes 1, 16 and 81 (constituting one of the pointy triangles) into equation 4.1. This local error for higher aspect ratios is about twice that of the error at lower aspect ratios. So seemingly, a mesh consisting primarily of pointy triangles should be useable for acoustic calculations, but the error would be about about twice that of a more well-shaped mesh. 0.12
Local Error; nodes 1, 16 and 81; 3 IPs per triangle
0.11
0.1
ka=0.5 ka=1 ka=1.5 ka=2
0.09
0.08
0.07
0.06
0.05
0.04 0 10
2
10
4
10
6
10 Aspect Ratio
8
10
10
10
12
10
Figure 4.4: The local error as a function of the aspect ratio for four different values of ka. Nodes 1, 16 and 81 were used in equation 4.1.
4.1.1
Condition Numbers
A condition number is a measure of a system’s sensitivity to changes in the coefficients describing the system. The higher the sensitivity, the higher the condition number. A system described by highly sensitive coeffecients is called ill-conditioned. In the boundary element method the coefficients are the matrix elements in the A and B matrices. The condition number for the A matrix is plotted in figure 4.5. The condition number is rather constant as a function of aspect ratio. When the condition number is below circa 10, the system is considered well-conditioned. In this case the condition numbers are all at about 2, so in addition to the error being quite constant as a function of the aspect ratio, the system is well-conditioned.
4.2 Flat Triangles
20
2.3
ka=0.5 ka=1 ka=1.5 ka=2
2.25
Condition Numbers; 3 IPs per triangle
2.2
2.15
2.1
2.05
2
1.95
1.9
1.85
1.8 0 10
2
10
4
10
6
10 Aspect Ratio
8
10
10
10
12
10
Figure 4.5: The condition number for matrix A as a function of aspect ratio for the two pointy triangles.
4.2
Flat Triangles
Another type of ill-shaped triangle is the flat triangle. The flat triangle has three relatively equally sized sides with one node close to its subtending side. Figure 4.6 shows the mesh used for examining the effect of a flat triangle in the mesh. The mesh is the same as in figure 4.1 only seen from a different angle. In figure 4.7 an additional node, node 81, has been added midway between nodes 6 and 14. Node 81 was successively moved up towards a point located midway between nodes 7 and 14, making the upper triangle increasingly flat. The initial distance from this point to node 81 is denoted ”Path” in figure 4.7, and the error is found as a function of the percentage of movement of node 81 along this distance. Acoustic calculations were carried out using both 3 and 4 integration points, respectively, per triangle. In figure 4.8 the global error is plotted. Three integration points per triangle were used. When comparing figure 4.8 to figure 4.3 it can be seen that the global errors in the two cases are similar at low aspect ratios and low percentage of movement, respectively. This is also to be expected since the meshes are very much alike when the triangles are not pointy or flat, respectively, and in both cases three integration points per triangle are used. As node 81 is moved upwards the global error increases noticeably at about 70% along the path. The local for the flat triangle (nodes 7, 14 and 81) was calculated and is plotted in figure 4.9.
21
Ill-shaped Triangles
Figure 4.6: Spherical mesh made up of triangles. Four nodes indicated by bold dots make up two triangles.
Figure 4.7: The four nodes marked in figure 4.6 and an added node, node 81, now make up four triangles. The cross is located midway between nodes 7 and 14. The distance denoted ”Path” is the constant distance from the point indicated by the cross to the point where node 81 is currently placed.
4.2 Flat Triangles
22
0.11
ka=0.5 ka=1 ka=1.5 ka=2
0.1
Global Error, E; 3 IPs per triangle
0.09
0.08
0.07
0.06
0.05
0.04
0.03
0
10
20
30
40 50 60 % of movement along path
70
80
90
100
Figure 4.8: Global error when using 3 integration points.
0.9
ka=0.5 ka=1 ka=1.5 ka=2
Local Error; nodes 7, 14 and 81; 3 IPs per triangle
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0
10
20
30
40 50 60 % of movement along path
70
80
90
100
Figure 4.9: Local error (nodes 7, 14 and 81) when using 3 integration points.
23
Ill-shaped Triangles
The local error for the flat triangle also increases at about ”70% along path”, so this triangle is seemingly responsible for the increase in the global error. The range ”70 to 80 % along path” was examined further. The global error in this range is plotted in figure 4.10. A closer inspection of the error for each of the three nodes in the flat triangle revealed that the increase is solely due to node 81. The error for this node alone for ka = 0.5 in the troublesome range is plotted in figure 4.11. In both cases only one value of ka is used, namely ka = 0.5. 4
ka=0.5 3.5
Global Error; 3 IPs per triangle
3
2.5
2
1.5
1
0.5
0 70
71
72
73
74 75 76 % of movement along path
77
78
79
80
Figure 4.10: Global error in the range ”70 to 80% along path” when using 3 integration points and ka = 0.5. At about 73.8% along the path the global error is more than 3.5 or 350% and The local error for node 81 is about 100. So the accuracy of the acoustic calculations is extremely low when only a single flat triangle with some specific proportions is present in the mesh. The calculations were repeated using the same mesh, only this time using four integration points per triangle. From figure 4.12 it is seen that the global error now is unaffected by the one flat triangle in the mesh. The local error for the flat triangle (figure 4.13) varies very little as node 81 is moved along the path.
4.2 Flat Triangles
24
100
ka=0.5
90
Local Error; node 81; 3 IPs per triangle
80
70
60
50
40
30
20
10
0 70
71
72
73
74 75 76 % of movement along path
77
78
79
80
Figure 4.11: Local error (node 81) in the range ”70 to 80% along path” when using 3 integration points and ka = 0.5.
0.085
0.08
Global Error, E; 4 IPs per triangle
0.075
0.07
0.065
0.06
0.055
0.05
ka=0.5 ka=1 ka=1.5 ka=2
0.045
0.04
0.035
0
10
20
30
40 50 60 % of movement along path
70
80
90
100
Figure 4.12: Global error when using 4 integration points.
25
Ill-shaped Triangles
0.085
Local Error; nodes 7, 14 and 81; 4 IPs per triangle
0.08
0.075
ka=0.5 ka=1 ka=1.5 ka=2
0.07
0.065
0.06
0.055
0.05
0.045
0.04
0
10
20
30
40 50 60 % of movement along path
70
80
90
100
Figure 4.13: Local error (nodes 7, 14 and 81) when using 4 integration points.
4.2.1
Condition Numbers
The condition number for the A matrix when using three integration points per triangle is plotted in figure 4.14. In figure 4.15 the range ”70 to 80% along path” is examined further. Finally, figure 4.16 shows the condition number for matrix A when using four integration points. When using three integration points the condition number increases to about 1300 in the range ”70 to 80% along path”, in addition to the increase in error. Furthermore, as the triangle becomes very flat the condition number increases much more dramatically, e.g. at ”99% along path” and with ka = 0.5 the condition number is 920; at ”99.99% along path” the condition number is 9.2 · 106 ; and at ”99.99999% along path” the condition number is 9.2 · 1010 . This does, however, not result in an increase in the error. When using four integration points the condition number is about 2, in addition to the constant error which is below 10%.
4.3
Concluding Remarks
Ill-shaped triangles do affect the acoustical calculations. A few pointy triangles in a mesh will result in slight increase in the error, and many pointy triangles in a mesh could double the error compared to a mesh with more well-shaped triangles. Pointy triangles are quite common in meshes from CAD programs, and much effort should not be directed at removing them.
4.3 Concluding Remarks
26
30
ka=0.5 ka=1 ka=1.5 ka=2
Condition Numbers; 3 IPs per triangle
25
20
15
10
5
0
0
10
20
30
40 50 60 % of movement along path
70
80
90
100
Figure 4.14: The condition number for matrix A when using 3 integration points per triangle.
1400
ka=0.5
Condition Numbers; 3 IPs per triangle
1200
1000
800
600
400
200
0 70
71
72
73
74 75 76 % of movement along path
77
78
79
80
Figure 4.15: The condition number for matrix A when using 3 integration points per triangle. The range of interest is ”70 to 80 % along path”.
27
Ill-shaped Triangles
2.5
Condition Numbers; 4 IPs per triangle
2.4
ka=0.5 ka=1 ka=1.5 ka=2
2.3
2.2
2.1
2
1.9
1.8
0
10
20
30
40 50 60 % of movement along path
70
80
90
100
Figure 4.16: The condition number for matrix A when using 4 integrations points per triangle. A more dramatic increase in the error is found when using flat triangles. At some distinct proportion of a flat triangle the error increases to unacceptable levels when using three integration points. With this proportion the triangle really is not very flat, so such triangles could occur in any mesh. However, when using four integration points per triangle the problem disappears. The increase in error when the triangle has a certain proportion and three integration points are used is accompanied by an increase in condition number for the A matrix. For extremely flat triangles the error is about the same as for more well-shaped triangles. However, the system matrix is extremely ill-conditioned when one such flat triangle is present and three integration points per triangle are used. To overcome the problems with the flat triangles four integration points should be used instead of three. The error then becomes more or less constant as a function of ”flatness” and the A matrix remains well-conditioned. The reason for the problem with flat triangles is not known to the author. It may be a result of the integrations points being located on the sides of the triangle when using three integration points, as oppose to the being located inside the triangle when using four integration points.
Chapter 5
Mesh Refinement When meshing using a CAD program, one may find that the elements in the mesh differ a lot in size. That is because most CAD programs try to represent the geometry of the body as accurately as possible. On large planar surfaces only a few elements are needed, whereas more elements are needed where the geometry is more complex. Such meshes do not in general provide accurate results when used in acoustic calculations, and therefore a program that refines meshes has been made. The program works with meshes having only triangular elements in them, and the format is STL. Figure 5.1 shows a typical mesh1 . A cube has been fitted with a hemisphere, which could illustrate a dome on a loudspeaker. Five of the sides of the cube are represented by only two triangles each. This is sufficient to describe the geometry of the body since the sides are planar. In contrast, the dome is represented by several smaller triangles to describe its curvature. From some of these triangles connections are made to the corners of the cube, resulting in some rather pointy triangles.
5.1
Program Strategy
The stategy chosen for refining meshes is as follows. The user inputs the mesh nodes and topology along with the wave number for which the mesh is to be refined. From the wave number a maximum length is calculated; the sides of the triangles have to be smaller than this length. A requirement for 5 nodes per wave length is assumed in the program; this number can of course easily be changed. The program adresses the elements one at a time, checking if the longer side in each triangle meets the requirement regarding the maximum length. If this is not the case, a new node is introduced midway along the longer side. Now two new triangles are made from the three original nodes of the triangle and the new node. These triangles are added to the topology and the original triangle is removed (or actually marked, so it won’t be adressed for refinement later on in the program, and then 1
Provided by Bang & Olufsen
28
29
Mesh Refinement
Figure 5.1: A typical mesh representing a cube fitted with a hemisphere. A): Perspective view. B): Side view.
eventually removed at the end of the program along with all other marked elements) from the topology. However, the original side which was too long was common for both the element which is currently adressed and another element which has not yet been adressed. So this other element is identified, ”removed” from the topology list, and two additional triangles are added to the topology. In some cases one or more sides in some of the triangles are not shared with other triangles, because the mesh is not closed. If such a side is too long, only the original triangle is removed from the topology list, and two new triangles are added. Figure 5.2 shows the procedure for a single triangle, i.e. its three sides are not shared with any other triangles. Dividing the triangle in figure 5.2 A) into two triangles turns out to be insufficient to meet the length requirement, so the two new triangles are also refined.
5.2
The Program, refinemesh.m
As mentioned, the program which is called refinemesh.m works with triangular elements meshes in STL format. The mesh to be refined is read using fmerge.m; one of the programs in the OpenBEM package. Then refinemesh.m is called with the nodes and the topology in STL format and a desired wave number. A program called modifymesh.m is used by refinemesh.m; here the triangular elements are adressed
5.2 The Program, refinemesh.m
30
Figure 5.2: A) A single triangle with all three of its sides being longer than some maximum length, lm . B) A new node is introduced midway on the longer side, the original triangle is removed and two new triangles are added. C) One of the two new triangles is adressed. The longer of its side is too long, so two new triangles replace it. D) The other triangle is adressed and refined. E) The four resulting triangles.
31
Mesh Refinement
one at a time: If the longest side in a triangle is longer than the maximum length, two new triangles (or four if another triangle shares the side with the currently adressed triangle) are introduced as described. When modifymesh.m has adressed all of the elements once, it returns to refinemesh.m with a variable indicating if any changes were made to the mesh. If no changes were made, the mesh was already acceptable for acoustic calculations at the chosen wave number before running the program. If changes were made, modifymesh.m is run again with the ”new” mesh. In this way the mesh is successively refined until no changes are made in modifymesh.m, and refinemesh.m outputs the refined mesh nodes and topology in STL format.
5.3
Program Test
The mesh shown in figure 5.1 has been refined by the program using a wave number of 0.1. The result is shown in figure 5.3. Notice that k = 0.1 corresponds to a frequency of only 5.5 Hz. That is due to the coordinates in figure 5.1 and 5.3 being interpreted as in being in metres. If instead centimeters are used the refined mesh is useable for wave numbers of up to about 10, a frequency of 550 Hz. The geometry of the body is represented precisely as well as before refining, but now the mesh is also acceptable for use in acoustical calculations. Before the mesh was refined it had 36 nodes and 68 triangles. The number of nodes is now 1052 and the number of triangular elements is 2100.
Figure 5.3: The mesh form figure 5.1 after being refined to accommadate acoustic calculations using wave numbers below 0.1. A): Perspective view. B): Side view.
5.4 Concluding Remarks
5.4
32
Concluding Remarks
The developed program makes CAD meshes with large triangles compared to the wave length acceptable for use in acoustic calculations. If the geometry is well described as a starting point, this will also be the case after refinement. The mesh can be refined to meet any requirement to the frequency.
Chapter 6
Convergence Analysis and Integration Points The Boundary Element Method relies on the ability to evaluate integrals numerically. Different integration formulas exist, and different errors are associated with these formulas. Common for them all is that the integration of a function is performed by evaluating the function for some distinct values and then make an assumption as to how the function varies in the intervals between these distinct values. An example is the left Riemann sum illustrated in figure 6.1. A function f (x) is to be integrated in the interval [a, b], thus Z
b
f (x)dx
(6.1)
a
The integral can evaluated using the left Riemann sum: RnL
=h
n−1 X
f (a + sh),
(6.2)
s=0
where the interval [a, b] is divided in to n equally spaced subintervals, each with the size h = b−a n . When using the left Riemann sum one assumes that the function is constant in each subinterval. The left Riemann sum is said to be an integration formula of order one (q=1) since halving the size h would halve the error. If one instead made the assumption that the function varies linearly in each subinterval, the resulting integration formula would have an order of two (q=2), with the error decreasing to one fourth when halving the size h. When halving h the number of function values doubles. In general the relationship between the error and the number of function evaluations can be expressed as 33
6.1 Convergence Analysis
34
Figure 6.1: A function f (x) is integrated numerically as a sum of areas using the left Riemann sum.
error ∝ (number of function evaluations)−q
(6.3)
If q=2, the error as a function of evaluations plotted in a double logarithmic scale log(y2 /y1 ) would have a slope of -2, with the slope n = log(x , where (x1 , y1 ) and (x2 , y2 ) 2 /x1 ) are two points on the plotted curve. So if one knows the assumption on how the function varies in the subintervals, one also knows the slope of the curve describing the error (synthesis); thus if one knows the slope, one also knows the assumption. The latter is called a convergence analysis. A convergence analysis has been carried out for both for triangular and quadrilateral element meshes. In this project it is assumed the acoustical variables, the complex sound pressure p and the complex surface velocity v, vary linearly between the nodes in the meshes. Therefore a slope of -2 is expected to come out of the convergence analysis.
6.1
Convergence Analysis
The acoustic problem in question was a scattering one with a plane wave travelling towards a body. The body chosen for meshing was a sphere with radius a = 1. Two values for ka, k being the wave number, were chosen, namely ka = 1 and ka = 2. Three planar quadrilateral element meshes and three planar triangular element meshes were used in solving the scattering problem. The error when using quadrilateral element meshes is plotted in figure 6.2. Four integration points per quadrangle were used. The error when using triangular element meshes is plotted in figure 6.3. Three integrations points per element were used. The error is plotted as function of nodes along the circumference, and not as a function of the total number of nodes in the mesh, in order to get a slope that is
35
Convergence Analysis and Integration Points
comparable to the one-dimensional case. The number of nodes along some specific line in the mesh, in this case the circumference, is related to the total number of nodes as: (nodes along circumference)2 ∝ all nodes
(6.4)
When this is inserted in equation 6.3 with the number of nodes along the circumference as the number of function evaluations, one gets error ∝ (nodes along circumference)−q but this also equals √ error ∝ ( all nodes)−q = (all nodes)−q/2 So with an assumption of linear variation between nodes, one gets a slope of -2 when the error is plotted as function of the number of nodes along the circumference, but -1 when plotted as a function of the total number of nodes. 0
10
Global Error, E; 4 IPs per quadrangle
ka=1 ka=2
−1
10
−2
10
−3
10
0
10
1
10 Number of nodes along circumference
2
10
Figure 6.2: The error as a function of the number of nodes along the circumference for ka = 1 and ka = 2. Quadrilateral elements with 4 integration points per quadrangle were used. The dotted line indicates a slope of -2.
The error plotted in figure 6.2 has a slope of -2 as expected, as does the error plotted in figure 6.3.
6.2 The Effect of the Number of Integration Points
36
0
10
Global Error, E; 3 IPs per triangle
ka=1 ka=2
−1
10
−2
10
−3
10
0
10
1
10 Number of nodes along circumference
2
10
Figure 6.3: The error as a function of the number of nodes along the circumference for ka = 1 and ka = 2. Triangular elements with 3 integration points per triangle were used.
6.2
The Effect of the Number of Integration Points
The effect of the number of integration points per element has been examined for both quadrilateral and triangular element meshes. A mesh with quadrangles was made on a sphere with radius a = 1, and from this mesh a triangular element mesh was created by dividing each quadrangle into two triangles using the program makediag.m (see appendix A). Doing this gives two meshes with the same number of nodes and with the exact same representation of geometry. The meshes are shown in figure 6.4. An acoustical problem with the sphere oscillating in the x-direction was calculated using both the quadrangle mesh and the triangle mesh. Different numbers of integration points were used. The errors are plotted for the quadrangle mesh and the triangle mesh in figure 6.5 and figure 6.6, respectively. When using quadrilateral elements, increasing the number of integration points has very little effect on the error as seen by the coinciding curves. When using triangular elements the lowest error is found when using three integration points per element. Also overall the triangular element mesh with three integration points per element gives the lowest error of the six. The calculation time was examined for the six cases: When using quadrilateral elements the calculation time is about 30% shorter than when using triangles. That is a result of the number of quadrilateral elements being only half that of the triangular
37
Convergence Analysis and Integration Points
Figure 6.4: A) The quadrilateral element mesh used in the acoustic calculations. B) The triangular element mesh used in the acoustic calculation is actually the mesh in A) fitted with diagonals.
0.066
0.065
0.064
Global Error, E
0.063
0.062
0.061
0.06
0.059
4 IPs 16 IPs 64 IPs
0.058
0.057 0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
ka
Figure 6.5: The error when using the quadrilateral element mesh in figure 6.4 A) with 4, 16 and 64 integration points per element, respectively.
6.3 Concluding Remarks
38
0.066
0.065
0.064
Global Error, E
0.063
0.062
0.061
0.06
0.059
3 IPs 4 IPs 7 IPs
0.058
0.057 0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
ka
Figure 6.6: The error when using the triangular element mesh in figure 6.4 B) with 3, 4 and 7 integration points per element, respectively.
ones, but the number of nodes being the same for the two. The calculation times1 for the three cases with quadrangles and the three cases with triangles are shown in table 6.1. Calculation time, ¤ 4 IPs 27 secs 16 IPs 30 secs 64 IPs 34 secs
Calculation time, M 3 IPs 40 secs 4 IPs 41 secs 7 IPs 41 secs
Table 6.1: Calculation time for the six cases. IPs is short for integration points. Increasing the number of integration points results in a slight increase in calculation time, but this does not improve the accuracy for the cases chosen in this chapter.
6.3
Concluding Remarks
A convergence analysis has been carried out. It validated the assumption of the acoustic variables varying linearly along the elements. 1
On an Intel PentiumII 350 MHz, 512 MB RAM
39
Convergence Analysis and Integration Points
Using quadrilateral elements meshes will result in faster calculations than using triangular element meshes. The accuracy for the two cases are approximately the same when the geometry is represented to the same degree in both cases.
Chapter 7
Incompatible Meshes Incompatible meshes are meshes that are not easily merged. Such meshes are often the result of a body being divided into several bodies before meshing. The CAD program responsible for the meshing usually cannot be informed that the meshes are to be merged later on, so the resultant meshes might not be readily merged even though their geometries are the same. A program capable of merging incompatible would therefore be useful; however, to the knowledge of the author no such program has been made previously. A first attempt at a merging program is described in this chapter. There can be different reasons for dividing a body. E.g. when part of the original body is to have one surface velocity and part of it another velocity, it is an advantage to know the node numbers of the different parts. An example is a loudspeaker consisting of a cabinet and a driver unit. The driver is to be given a certain surface velocity whereas the cabinet is to have zero velocity. If the whole loudspeaker is meshed at once, the node numbers for the driver are mixed with node numbers for the cabinet. If instead the cabinet and driver are meshed individually, it is easier to handle the velocity distribution. Another area for operating with incompatible meshes is when calculations are to be carried out for an acoustic problem involving more than one medium. For example, the speed of sound is lower in air than in water; thus for a given frequency the wave length is smaller in air than in water. Therefore the air requires a relatively finer mesh than the water.
When dealing with incompatible meshes two terms are important to know: Open edge and open segment. An open segment (some places in this chapter refered to simply as a segment) is a line from one node to another which is only part of one geometric element. I.e. if a triangle in a mesh shares only two of its three sides with other triangles, this triangle has one open segment. An open edge (or an edge) is numerous, interconnected open segments. 40
41
Incompatible Meshes
When merging open edges the challenge is really to merge the open segments. If two meshes are compatible, the number of nodes along the open edge of one mesh equals the number of nodes along the open edge on the other mesh, and the node coordinates are pairwise the same, i.e. each node along one open edge coincides with a node on the other open edge. A simple case of incompatibility is one where the number of nodes along the edges are the same, but the coordinates pairwise differ slightly. The solution could be either to round the coordinates to a lesser amount of significant numbers, or to move each node on one edge to the nearest node on the other edge. A more difficult case of incompatibility is non-matching numbers of nodes along the edges. The program developed is capable of merging such meshes. Three demands have to be met for the program to work: The geometries of the open edges to be merged have to be the same (you cannot use the program to merge a square edge and a circular edge), the open edges cannot be too far apart (the edges should more or less coincide) and the input format has to be STL (the meshes have to be made up of planar triangular elements). If these three demands are met, meshes can be merged together regardless of the distribution of open segments along the edges, and the output format will remain STL. Additionally, no new nodes are created, i.e. the resultant mesh consists exclusively of nodes that are found in the two original meshes, and finally the order of the meshes is not important, e.g. if one of the meshes is fine (small elements) and the other is rougher, it does not matter which one them is read first; the resulting mesh is the same.
7.1
Program Strategy
Using the existing acoustic calculation software (the program fmerge.m followed by rawbodyfind.m) the meshes to be merged are read in their STL-format, so that the nodes, the topology and the open segments on each body is known. This information is passed on to the merge program, merge.m. The program takes its starting point in the first segment of the first read mesh. This segment is associated with two nodes and one triangular element on the mesh. The strategy now is to align 10 fictitious nodes or points uniformly along the segment, and use them along with the two real nodes as ”probes”, giving a total of 12 probes. In this case a probe is merely a point used for finding distances. The two end probes, probe 1 and 12 differ from the 10 other probes in that they 1): Are real nodes and therefore they 2): Are both probes in two segments, whereas the 10 other probes only belong to only one segment. Figure 7.1 helps illustrate the principle: 12 probes for one open segment on the first read mesh are created. The probe-to-probe distance is given as the length of
7.1 Program Strategy
42
the current segment divided by (the number of nodes minus one). The distances from the first of the probes (one of the two real nodes on the segment) to all of the nodes on the open edge on the second mesh are calculated. The node on the open edge on the second mesh closest to the probe is found. If two nodes are equally close, the program chooses one of them. The distance from the probe to the closest node is compared to distance from one probe to the next probe: If the distance from the probe to the closest node is smaller than the probe-to-probe distance the node number is saved along with the distance. If the distance is larger, the closest node is not close enough to be taken into consideration (since either one or more of the other eleven probes or one or more of the probes on another segment are closer to this node than the current probe) and it is ignored.
Figure 7.1: Twelve probes, indicated by crosses, consisting of two nodes, indicated by bold dots, and ten fictitious nodes are aligned along an open segment on the first meshes. The distance between the two meshes is grossly exaggerated; the dashed line indicates the plane in which both open edges actually lie. Open segments are indicated with a thicker line.
The program now adresses the second of the 12 probes, i.e. the first of the 10 fictitious nodes. As with the first probe the distances from the nodes on the adjacent edge are found, the smallest distance is compared to the probe-to-probe distance and the node number is kept or ignored accordingly. The program continues until all of the 12 probes have been adressed.
43
Incompatible Meshes
The next step is to check if some of the probes have found the same candidate (i.e. the node closest to the probe) on the open edge of the second mesh. No more than two probes can, at this point, have the same candidate if the requirements to the meshes are met. So if two probes have the same candidate, the distances saved along with the node number are compared. The probe with the shorter distance keeps the node as its candidate; the other probe loses the node as a candidate. If the two distances are exactly the same the program just picks arbitrarily between the two probes. The program now has a list of nodes corresponding to the 12 probes. The composition of this list determines how to merge the two meshes. Any open segment falls into one of several cathegories or cases according to the probes and their candidates or lack thereof. These cases can be grouped in differerent ways. In this section the cases are grouped based on how they appear visually; in subsection 7.2.1 they are grouped based on how they appear topologically which is how they are actually considered in the program. In figure 7.2 one group, group 1, consisting of only one case is illustrated. The segment on body 1 has been fitted with probes (not illustrated) and it has been found that the probes 1 and 12 have a candidate each and the rest of the probes have no candidates. The program therefore alters the topology list so that the segments share nodes (see subsection 7.3 for more on the changes done in the topology).
Figure 7.2: In group one there is only one case. The segment currently being adressed is indicated by a thicker line. The distance between the segments on the left of the arrow is exaggerated; they are located at the dotted line. The arrow points to the result of the operation. Only probes 1 and 12 have a candidate on the adjacent mesh. The two triangles are merged by using the same two nodes to describe both segments (see subsection 7.3). Segments on mesh 2 that will be checked off, preventing them from being adressed later on, are indicated with a filled square. Group 2 is illustrated in figure 7.3. It has three different cases where several of the probes on the open segment on mesh 1 have candidates. The program alters the topology list accordingly, to create new triangles (again, see subsection 7.3). Note that even though all of the drawn triangles on mesh 2 share a common node, this of course does not have to be the case. Situations which visually differ
7.2 The Program, merge.m
44
from eachother may very well be treated alike in the program. An example of this is found in figure 7.5. Figure 7.4 shows group 3 with the last two cases. In the first case only one probe has a candidate and the topology matrix is changed accordingly (once again, see subsection 7.3). In the second case none of the probes have a candidate, so the segment merely remains open for now. Now the first open segment on the first mesh has been dealt with. Before moving on to the next segment, the program checkes if any of the open segments on mesh 2 have had both their nodes associated (see section 7.3) with two probes on the currently adressed open segment. This is e.g. the case for the segment on mesh 2 in figure 7.2: During the adressing of the segment on mesh 1, the segment on mesh 2 has had both its nodes associated with two probes (here the probes are the two real nodes), and this segment is checked off in a list and will not be adressed when the program adresses the open segments (if any) on the second open edge. Failing to check off such segments will result in defect meshes, except when dealing with meshes where all segments belong to group one in figure 7.2; in that case, however, a much simpler merge program would suffice. In the figures a small filled square is used to indicate open segments that will not be adressed individually and fitted with probes. The program now moves on to the second open segment (which does not have to be in continuation of the first, but most likely is anyway) and the process is repeated. When all open segments on the open edge of the first mesh have been adressed, the program moves on to the second open edge on mesh 2. If any of the segments on mesh 2 have not been checked off, the program adresses them in the same way as described throughout this section.
7.2
The Program, merge.m
The program merge.m can be run after reading two meshes with fmerge.m and rawbodyfind.m, two programs from the OpenBEM package. The input is the nodes matrix and topology matrix in STL format with bodynumbers and a variable called segmopen from rawbodyfind with information on the open segments in the two meshes. The output is the nodes matrix and the topology matrix.
7.2.1
MATLAB Implementation
As mentioned, a different grouping than described in section 7.1 is used in the developed MATLAB program. There still are three groups but each group now includes cases that are topologically similar. The first group is one where none of the probes have a candidate. This group has only one case equivalent to the situation in figure 7.4 B). The second group is one where one, and only one, probe has a candidate.
45
Incompatible Meshes
Figure 7.3: This is the second group. The segment currently being adressed is indicated by a thiscker line. The distance between the segments on the left side of an arrow is exaggerated; they are located at the dotted line. The arrows point to the result of the operation. Open segments on mesh 2 that will be checked off, preventing them from being adressed later on, are indicated with a filled square. In A) both probe 1 and probe 12 have candidate along with some of the other probes. In B) only probe 1 (or probe 12) has a candidate along with some of the other probes. One of the open segments on mesh 2 will be adressed later on in the program. In C) three fictitious probes have a candidate each. New triangles are made using nodes from both meshes. Two of the open segments on mesh 2 will be adressed later on in the program.
7.2 The Program, merge.m
46
Figure 7.4: The third group has two cases. The segment currently being adressed is indicated by a thicker line. The distance between the segments on the left side of an arrow is exaggerated; they are located at the dotted line. The arrows point to the result of the operation. In A) probe 1 (or 12) is the only probe that has a candidate. New triangles are made accordingly. In B) none of the probes have a candidate and the program moves on to the next open segment. Segments on mesh 2 that will be checked off, preventing them from being adressed later on, are indicated with a filled square. In this group there are no such segments.
47
Incompatible Meshes
This group includes three cases: Two of the cases are both equivalent to the situation in figure 7.4 A), with probe 1 having a candidate in the one case, and probe 12 having a candidate in the other. The third case in the second group is illustrated in figure 7.5 A) and B). It is actually a special case of the situation in figure 7.3 C).
Figure 7.5: In the MATLAB implementation this case belongs to the second group. The mesh vurrently being adressed is indicated by a thicker line. From the merge program’s point of view the situation in A) is exactly the same as in B). The third and last group is one where more than one of the probes have a candidate. This group handles all of the remaining situations, e.g. the one depicted in figure 7.2.
7.3
The Excess Nodes
If a node on mesh 1 is very near a node on mesh 2, the two nodes should be regarded as coinciding. The triangles which are described by these nodes should be modified so that only one of the two nodes is actually used in the topology list. So one could say that one of the two nodes should have a higher priority than the other. The program operates using such a node priority: When adressing segments on mesh 1, the nodes on mesh 2 have the higher priority; when adressing segments on mesh 2, the nodes on mesh 1 have the higher priority. This was chosen as a starting point and has not been changed, since the program operates properly using this priority.
7.4 Program Test
48
A more important point to make on the nodes is that none of the excess nodes that are removed from the topology matrix are actually moved from the nodes matrix. This means that the nodes matrix for the resulting mesh contains as many nodes as the two incompatible meshes combined. Therefore the resultant mesh is not acceptable for acoustic calculations: The system matrices are M × M in size with M being the number of nodes. All nodes have to be part of a closed mesh, but some of the nodes in the resultant, merged mesh are not part of any of the geometric element, so the matrices will not describe a proper acoustic problem. The solution is of course to remove the excess nodes, but this has to be done with some care. When reducing the number of rows in the nodes matrix, the node numbers change. And when the node numbers are changed, the topology matrix must be changed accordingly. Furthermore, if one knows the node numbers for the nodes that are to have a certain normal velocity before the merge, the program should provide some sort of ”translation list”, indicating what these node numbers have been changed to after the merge. The fact that the resultant meshes are not readily acceptable for acoustic calculations is of course important, but it should not be neither difficult nor very time consuming to work out the problems regarding the nodes. A quick fix to the problem actually exists: After refining the mesh, run the program matlab2stl.m with the nodes and topology lists (without body numbers). This creates an STL file that describes the resulting mesh without including the excess nodes. This STL file is read with fmerge.m and the resultant mesh is now acceptable for acoustic calculations. It may still be unclear which nodes to give a certain velocity, but it should be possible to work it out.
7.4
Program Test
Four test meshes with different open edges were designed to adress some of the possible cases that the open segments must fall under. Two open upper boxes, box 2 and 3, and two open lower boxes, box 1 and 4, have been merged together, forming four closed boxes without any open segments. Figures 7.6 to 7.9 illustrates the four open boxes, and figures 7.10 to 7.13 the four resultant meshes.
49
Incompatible Meshes
Figure 7.6: The first of four test cases, box 1. The thicker line indicates the open edge.
Figure 7.7: The second of four test cases, box 2. The thicker line indicates the open edge.
7.4 Program Test
50
Figure 7.8: The third of four test cases, box 3. The thicker line indicates the open edge.
Figure 7.9: The fourth of four test cases, box 4. The thicker line indicates the open edge.
51
Incompatible Meshes
Figure 7.10: Box 1 and box 2 have been merged. There are no open segments.
Figure 7.11: Box 3 and box 4 have been merged. There are no open segments.
7.4 Program Test
52
Figure 7.12: Box 1 and box 3 have been merged. There are no open segments.
Figure 7.13: Box 2 and box 4 have been merged. There are no open segments.
53
7.5
Incompatible Meshes
Special Cases
As it could be expected, some special cases exist, that are not readily processed by the program. One special case actually isn’t that special: When a fine mesh is to be merged with a rougher mesh, 12 probes per segment might not be enough. When there are not enough probes to adress all of the candidates, the resulting mesh is bound to have open segments. The solution is simple: Increase the number of probes per segment. Figure 7.14 illustrates the problem.
Figure 7.14: The number of probes (probes are indicated by crosses) along the open segment on mesh 1 is too low to accomadate the (locally) fine mesh 2. The three probes illustrated all find their respective candidate, but since they can only have one candidate each, one of the two middle nodes on mesh 2 will be floating with respect to the resultant mesh. Note that the distances from the middle probe to each of the two middle nodes may or may not be equal; eitherway only one of the two nodes can be picked as a candidate for the middle probe.
7.5 Special Cases
54
Another special case is linked to the fact that 2 probes per segment, the ”real” nodes, are actually used as probes for two segment, since each node on an open edge connects two open segments. But since two segments in continuation are not necessarily equal in length, their probe-to-probe distances are also not necessarily the same. This means that their ”resolution” (a small segment has more probes per length unit than does a larger segment, and the smaller segment therefore has better resolution) is also not same, and this may cause problems. One such situation is found in a test case provided by Bang & Olufsen. A dome and and cabinet have been meshed separately using the CAD program ProEngineer. At first glance the two meshes actually look compatible with seemingly the same number and placement of nodes along the two open edges. However, this is not the case: The open edge on the dome has two more nodes than the open edge on the cabinet and each of these two nodes are placed extremely close to another node. The two pairs of close nodes are furthermore placed close to, and on either side of, a node on the cabinet mesh. The situation illustrated in figure 7.15 is found two places in the test case. In the figure it is assumed that the dome mesh was read before the cabinet mesh.
Figure 7.15: This situation can be found two places in the test case provided by Bang & Olufsen. Two nodes on the dome mesh are close together near a node on the cabinet mesh.
55
Incompatible Meshes
The problem is that when using only a few probes per segment, e.g. 12, the ”resolution”, i.e. the cabability of the probes to probe for candidates, is too low. The 12 probes actually suffice when it comes to the segment between the two very close nodes; one of the middle probes on this short segment gets the adjacent node as candidate, and the situation is similar to the one depicted in figure 7.5 B). None of the two shown segments on the cube are checked off during this operation. When the program adresses the first of these two segments (after having adressed all of the open segments on the dome), the top node, acting as a probe, gets one of the two close nodes as candidate. However when adressing the second segment on the cabinet mesh, the top node, again acting as a probe, gets the other of the two close nodes as candidate, effectively considering the three top nodes as being coinciding. The result of this is two one-dimensional triangles in the final mesh. A one-dimensional triangle is one with two of its nodes having the same node number; such triangles are not acceptable in the existing acoustic calculation programs. This scenario assumes that the small segment on the dome is read before the other two of the three segments on the dome. This need not be the case, but the end result is the same, regardless of the order of segment adressing: Two one-dimensional triangles for each of the two small segments present on the dome mesh. This problem can attacked in different ways. One option is argue that the geometries of the two edges are not, locally, the same, and that the program therefore cannot be expected to work. This is, however, rather fruitless. A fix to the problem is simply to get rid of one-dimensional triangles in the final mesh. This option is available in the current program. Another fix is quite peculiar: Simply read the cabinet mesh before reading the dome mesh. This results in a mesh that has no open segments; this is, however, only a curiousity caused by the structure of the MATLAB program; it cannot be considered as a real solution to the problem and should not be expected to work with the special cases in general. The ”proper” solution is actually the same as with the low resolution problem; increase the number of probes per segment. The number of probes has to be increased until the larger probe-to-probe distances (remember that even though the probe-to-probe distance is constant for a given segment, each segment has its own characteristic probe-to-probe distance) are so small that the two close nodes can be distinguished from each other and be candidates for separate probes. Using 200 probes per segment results in a mesh which is both without open segments and processed as one (hopefully) would expect after reading section 7.1, regardless of the order of the two meshes. The four triangles that were one-dimensional when using too few probes are now two-dimensional (but very thin). The only drawback is an increase in calculation time, but most computers should be able to merge the test case within a few minute. Also note that the final mesh in this case is not equivalent to the final mesh when using just a few probes per segment and reading the cabinet mesh before the dome mesh: Consider it as a fluke, with no practical meaning.
7.6 Concluding Remarks
56
The situation just described can actually be generalized some. Whenever a smaller segment is in continuation of a larger one, their different resolutions may present problems. The larger segment might see a node as a candidate for its first or last probe, whereas the smaller segment with the greater resolution sees the same node as a candidate for one of its ”middle” probes. The power of the current program is that it works by attacking one open segment at a time without considering any of the other segments. This happens under the assumption that all segments belong two one and only one case in a group as described earlier. Even though this strategy is acceptable (and actually quite elegant) in theory, the implementation somewhat distorts it. The fixed number of probes per open segment was chosen as a starting point. Now it seems that the program would be even more versatile if the probe-to-probe distance was approximately the same along the open edge. An alternative would be to operate with a fixed maximum length instead of it being equal to the probe-toprobe distance. With a fixed number of probes per segment an additional problem actually exists. The probe-to-probe distance is equal to the maximum allowable distance from a probe to a node. But since the probe-to-probe distance varies with segment length, longer segments have a larger maximum allowable distance which effectively gives the probes longer ”reach”. Therefore the demand with regards to the distance between the open edges on the two meshes, is interconnected with the segment length: The probes on a small segment have a short reach, so the two open edges have to (at least locally) be closer together. This problem would also disappear if a fixed probeto-probe distance or a fixed maximum length were to implemented. More special cases may exist. Some of them may challenge the demand with regards to geometry, others may not. Eitherway it seems that special cases always can be dealt with by increasing the number of probes per segment, especially if changes with regards to the distance between probes were to be made.
7.6
Concluding Remarks
With the program developed, maybe the first of its kind, incompatible meshes can actually be merged. Some special cases can be handled with the program in its current state, but with some improvements these cases might be handled more elegantly.
Chapter 8
Changing Triangular Elements to Quadrilateral Elements Meshes from CAD program are often made up of triangular elements, corresponding to the STL format. It is sometimes wanted to change some of these triangles into quadrangles, as this results in fewer elements and therefore faster calculation. A program has developed that makes this transformation possible. If a triangle mesh describes the geometry of a body in a sufficient manner, then a transformation of triangles into quadrangles must not distort the geometry in a significant way. The program developed finds pairs of triangles whose normal vectors only differ slightly, and merges the pairs into quads.
8.1
Program Strategy
Each triangle in a closed mesh shares its three nodes with three other triangles. This is illustrated in figure 8.1. A triangle, in this case the first element in the topology list with the nodes 1, 2 and 3, is surrounded by three other triangles. Thus, there are three possible candidates for merging with the first element. The unit normal vector of triangle 1, ~e1 , is found as the cross product of a vector from node 1 to node 2 and a vector from node 1 to node 3, divided by the length of this crossproduct, −→ −→ 12 ×v13 . i.e. ~e1 = v−→ |v12 ×− v→ 13 | The first candidate shares node 1 and node 2 with element 1. The third node of the candidate is found (it is denoted node 4) and another unit normal vector, ~e2 , is − −→ v→ 14 ×v12 . If the unit normals ~ found as − e1 and ~e2 are the same, then the two triangles → − |v14 ×v→ 12 | are in the same plane. If the two triangles are not in the same plane their normals are also not the same. In general the length of a cross product of two vectors, ~a and ~b, equals the length of the one vector times the length of the other vector times sine to the angle φ between the vectors, i.e. |~a × ~b| = |a||b| sin φ. If the normals ~e1 and ~e2 are crossed, 57
8.1 Program Strategy
58
Figure 8.1: A triangle consisting nodes 1,2 and 3 has three possible candidates for a transformation to a quadrangle. Node numbers are in circles.
the expression reduces to |~e1 × ~e2 | = sin φ, since the length of both vectors is one. This expression is used in the program: The user inputs the maximum allowable angle φ. Two adjacent triangles whose normals are wider apart than this angle will not be considered as being in the same plane and are therefore not candidates for a transformation. Even if the first candidate is approximately in the same plane as the currently adressed triangle the two triangles may not be valid for transformation. In this work a quadrangle has to have four nodes and also none of its internal angles must superseed π radidans. In figure 8.2 three situations are illustrated. In each case the two triangles are in same plane, but located differently relative to each other. In situation A) transforming the two triangles would result in a valid quadrangle, since none of the angles in the resultant quadrangle would superseed π radidans. In B) this would not be the case, since one of the angles would be larger than π and the two triangles should therefore not be joined. In C) one of the angles in the resulting angles will be exactly π. In its current state the program accepts this as a valid quadrangle (see section 8.2), but this can easily be changed. The angle check is performed in the following way: A unit normal vector is found −→ −→ 14 ×v13 . In case A) this unit vector points in the same direction as ~ e1 . as ~e3 = v−→ |v14 ×− v→ 13 | When adding these two vectors and calculating the length of the resultant vector, the result is 2. In B) the addition of the vectors ~e1 and ~e3 result in a null vector with a length of 0. In C) the unit vector ~e3 is actually equal to ~e1 : The cross product −→ v−→ 14 × v13 results in a null vector, so dividing by the length of this cross product would give infinity. Instead the program sets ~e3 to ~e1 , so the addition of ~e1 and ~e3 results in 2~e1 with a length of 2. So to check if the resultant quadrangle is valid, it is examined if |~e1 + ~e3 | is ”about 2”: If the situation is as illustrated in A), but with the two triangles not being exactly in the same plane the length will be less than,
59
Changing Triangular Elements to Quadrilateral Elements
Figure 8.2: Three situations with pairs of triangles located in the same plane. In A) the two triangles can be merged into a valid quadrangles. In B) the resulting quadrangle would not be valid. In C) the resulting quadrangle is degenerate in that three of its nodes are aligned.
but close to, 2. In the program the triangles-to-quadrangle transformation happens if the length is larger than 1.5. If one wants the situation in C) to be excluded as a valid one, ~e3 should be set equal to 0 instead of ~e1 , so that the length is always 1 and therefore smaller than 1.5. −→ −→ 23 ×v24 . These A similar check is done using the vectors ~e1 and ~e4 , where ~e4 = v−→ |v23 ×− v→ 24 | vectors are used to check if the candidate extends to the ”right” instead of to the ”left” as in B). If the first candidate is valid, the two triangles are removed (or actually checked off for removal later on) and a quadrangle is added using the four nodes. Checking off the candidate also ensures that it will not be considered as a candidate for any of the other triangles as the program proceeds. If the first candidate is not valid for transformation the program moves along to the second candidate which may or may not be valid. After having examined the three candidates the program continues to the next triangle (that has not been checked off) in the topology matrix and examines if any of its three (if the mesh is closed) candidates are valid for transformation.
8.2
Degenerate Quadrangles
As mentioned in section 8.1 quadrangles which have one internal angle equal to π radians are assumed to be acceptable for use in acoustic calculations. It has been tested if this is a valid assumption. Calculations were carried out using a mesh with only triangular elements. Then the calculations were repeated using a mesh with the exact same geometry, but with several of the triangles replaced with degenerate quadrangles. A degenerate quadrangle (here) looks like a triangle, since three of its four nodes are aligned. The mesh was made using a program called degen.m which makes several triangles in a mesh into quadrangles by adding nodes and altering the
8.2 Degenerate Quadrangles
60
topology (see a description of degen.m in appendix A) In figure 8.3 the mesh which has both triangular and quadrilateral elements is illustrated. The mesh has 137 nodes and 156 elements; 95 degenerate quadrangles and 42 triangles. The nodes added by degen.m are marked. The other mesh which has only triangular element looks like the one in figure 8.3, only without the added nodes. This mesh has 80 nodes and 156 triangular elements.
Figure 8.3: A mesh both triangular and quadrilateral elements. The nodes depicted are present in the degenerate quadrangles. Calculations were carried out for both a scattering case and an oscillating case. Three integration points per triangle were used for both meshes; four integration points per quadrangle were used for the mesh in figure 8.3. The calculated errors for two values of ka are listed in table 8.1. Oscillating Sphere Scattering Sphere
ka = 1 ka = 2 ka = 1 ka = 2
Error, Triangles 0.075 0.036 0.022 0.049
Error, Mixed 0.062 0.050 0.020 0.046
Table 8.1: Calculation results for the two meshes. Mixed is triangles and degenerate quadrangles. The errors are all below 10% and fairly similar for the two meshes, so degenerate
61
Changing Triangular Elements to Quadrilateral Elements
squares do not seem to affect calculation accuracy negatively.
8.3
The Program, tri2quad.m
The program has three inputs; the nodes and the topology in STL format without body numbers and a maximum allowable angle (in degrees) between the normals of the triangles and their candidates. The output is the nodes (the same nodes as the input) and the topology in ANSYS format with quadrangles and triangles.
8.4
Program Test
The program has been used on a few test cases. In figure 8.4 a spherical mesh consisting exclusively of triangles is illustrated. It has 322 nodes and 640 geometric elements. In figure 8.5 the sphere mesh has been run through the program using a maximum angles of 10 degrees. It still has the 322 nodes, but now there are 332 elements; 308 quadrangles and 24 triangles. The geometry of the mesh has not changed significantly.
Figure 8.4: A spherical mesh consisting exclusively of triangles. In figure 8.6 the mesh from figure 5.3 has been illustrated once again. This mesh has 1052 nodes and 2100 triangles. In figure 8.7 the mesh has been run through tri2quad.m with a maximum angle of 1 degree. The resulting mesh has 1052 nodes and 1228 geometric elements; 356 triangles and 872 quadrangles.
8.4 Program Test
62
Figure 8.5: The spherical mesh from figure 8.4, after running the program tri2quad.m.
Figure 8.6: This is actually figure 5.3 illustrated once again. A): Perspective view. B): Side view.
63
Changing Triangular Elements to Quadrilateral Elements
Figure 8.7: The triangular element mesh illustrated in 8.6, after running the program tri2quad.m. A): Perspective view. B): Side view.
8.5
Concluding Remarks
In order to reduce calculation time, triangular elements in a mesh can be changed into quadrilateral elements. A program developed in this work does just that.
Chapter 9
Meshes with both Triangular and Quadrilateral Elements The existing OpenBEM program package provides means for making BEM calculations using meshes consisiting of either triangular or quadilateral elements. In some cases it would be useful to be able to handle meshes with both types of elements in them. As described in chapter 8 the program called tri2quad.m can analyze a mesh consisting purely of triangular elements, and convert some of these triangles into quadrangles with the motive being shorter calculation time. And in chapter 6 a program called makediag.m was used to split quadrangles into triangles. The resultant meshes can have both triangular and quadrilateral elements in them which calls for a program that can make acoustic calculations using such meshes.
9.1
The Program, TriQuadEquat.m
An existing program called bodyfind.m is used for reading meshes with their topology in ANSYS format, i.e. quadrangles are described by their four nodes and triangles are described as degenerate quadrangles with one node being duplicated. The program examines each elements and establishes if they are triangular or quadrilateral; this information, however, is not output to the user. A slightly modified program called bodyfindII.m was made. It has an additional output variable, geometry, which is an N × 1 vector, with N being the number of elements. The vector contains ones and zeros: A zero corresponds to the element being qudrilateral; a one means that the element is triangular. A calculation program called TriQuadEquat was made by combining two existing program and their respective sub routines. TriEquatII is one of the two existing programs. It makes calculations using triangular element meshes in STL format (with bodynumbers) and it therefore uses integration routines corresponding to triangles. The other program, FastEquat, makes calculations using quadrilateral element meshes and the appropriate integration schemes. The combined program is input with the nodes and topology, both with bodynumbers, and the variable 64
65
Meshes with both Triangular and Quadrilateral Elements
geometry. Like the two other calculation programs it adresses the elements one at a time and calculates the corresponding matrix elements. The only difference is that it uses one set of calculation routines when the currently adressed geometric element is a triangle and another set of routines when it is a quadrangle.
9.2
Program Test
The program was tested using a three different meshes. The three meshes were all made around a sphere with a radius a of one. The first mesh was made up purely of quadrangles. The second mesh was made up of purely of triangles; it was made using the first mesh and the program makediag.m. The third mesh was a combination of the two: The lower half of the mesh had quadrilateral elements in it, the upper half had triangles. The calculations were made considering the sphere oscillating in the x-direction. The third mesh is illustrated in figure 9.1. The two meshes consisting purely of quadrilateral and triangular elements, respectively, can be found in figure 6.4.
Figure 9.1: A mesh consisting of both triangles and quadrangles used in testing the program TriQuadEquat.m. The calculations were made for two values of ka. Three integration points were used for the triangular elements; 64 integration points were used for the quadrilateral elements. The results are shown i table 9.1. The results for the first two meshes are the same as when using the respective programs in the OpenBEM package. The results for the combined mesh lie somewhere between the two, indicating that the program works as intended.
9.3 Concluding Remarks
Quadrilateral Elements Triangular Elements Combined Mesh
66
ka = 1 ka = 2 ka = 1 ka = 2 ka = 1 ka = 2
Error 0.06028 0.02553 0.05774 0.02477 0.05902 0.02517
Condition Number 2.01 1.76 2.02 1.81 2.01 1.78
Table 9.1: Calculation results when using the three meshes. The listed condition numbers are for the A matrix.
9.3
Concluding Remarks
A program capable of performing acoustic calculations using meshes consisting of both quadrangles and triangles has been made by combining existing software. The program has been tested on different types of meshes consisting purely of quadrangles, purely of triangles and a mesh with both types of elements and it has been found to be satisfactory.
Chapter 10
Frequency Interpolation The boundary element method provides means for solving acoustic problems. The meshes made when using this method have to meet the frequency demand: The higher the frequency, the finer the mesh. However, as the mesh gets finer the calculation time increases, making calculations tedious. If one were to make acoustic calculation over a frequency interval, one would probably pick out certain discrete frequencies, make the appropriate meshes for each frequency, and perform the calculation for each frequency using their individual meshes. Now the acoustic variables are known at the chosen frequencies. In order to get a curve showing, let’s say, the sound pressure as a function of frequency, one could choose to interpolate the known sound pressures. The resulting curve could give some idea of the sound pressure, but any rapid changes in each of the interpolation intervals would not show. In [7] an interpolation scheme is suggested where the coefficients to the sound pressure and normal velocity, i.e. the elements in the A and B matrices, are interpolated, instead of the acoustic variable. This litterature assumes that the acoustic variables are constant over each geometric, whereas the assumption in this report is that the acoustic variables vary linearly over each element. This introduces a few differences between the two, but the underlying idea is the same.
10.1
Interpolating Matrix Elements
Each matrix element in the matrices A and B are essentially sums of integrals involving Green’s function as described in chapter 3. If the A and B matrices are known for two distinct frequencies, f1 and f2 , the A and B matrices for some frequency f in the interval [f1 , f2 ] could be found by interpolating the known matrix elements. For the interpolation scheme to work properly in a certain interval, the elements have to vary in a predictable manner in that interval. E.g. if a linear interpolation is chosen, the elements are assumed to vary linearly in the interval. Also, the same mesh has to used for the disctinct frequencies; the matrices have to have the same dimensions and each matrix element in one of the A matrices calculated explicitly 67
10.1 Interpolating Matrix Elements
68
has to refer to the same node pair mn (i.e. the same distance R is used in Green’s function) as in the other A matrices. Green’s function is as follows: G(R) =
e−jkR R
The nominator is cyclic in that adding j2π to its exponent does not change its value. Also, it varies more rapidly with frequency when R is large than when R is smaller. In [7] it is suggested that in order to get the elements to vary in a similar manner, a factor containing the node distances be pulled out. Figure 10.1 illustrates a situation with the collocation point P placed at some node m. Another node n is of interest in that the geometric elements which have this node in their topology will contribute to the same matrix element in the A and B matrices, respectively. The triangular element currently adressed has node n in its topology. The integration is performed by evaluating a function (consisting of shape function, Green’s function and the Jacobian) at an integration point Q, and weighted with some value. In this case there are three integrations points so the ~ weight is 61 . The distance from node m to node n equals the length of the vector R, denoted R. R is found as |~r − ~r0 |.
Figure 10.1: A vector ~r extends from origin to an integration point Q. Another vector ~r0 extends from origin to a node m. Another node n is also depicted. Finally ~ extends from node m to point Q. a vector R An alternative description of R is |~rmn −~rQn |, with ~rrm being a vector from node m to node n and ~rQn being a vector from the integration point Q to node n. So three equivalent ways of expressing Green’s function are:
69
Frequency Interpolation
G(R) =
e−jk|~r−~r0 | e−jk|~rmn −~rQn | e−jkR = = R |~r − ~r0 | |~rmn − ~rQn |
(10.1)
A far-field approximation is applied. It is assumed that the distance from node m to node n is much larger than the distance from point Q to node n, i.e. |~rmn | À |~rQm |, or alternatively rmn À rQm . If this is the case, it is resonable to assume that |~rmn − ~rQm | ≈ rmn − rQm . Thus Green’s function can be written as follows: G(R) =
e−jkR e−jk(rmn −rQn ) ejkrQn ≈ = e−jkrmn R rmn − rQn rmn − rQn
(10.2)
The term e−jkrmn is constant for each integration to be performed. So a matrix element in the B matrix could with the far-field approximation applied be written as: Z
Z
S
Nα (ξ1 , ξ2 )G(R)J(ξ1 , ξ2 )dS ≈ e
−jkrmn S
Nα (ξ1 , ξ2 )
ejkrQn J(ξ1 , ξ2 )dS (10.3) rmn − rQn
The reader may at this point wonder: ”If the far-field approximation had been |~rmn − ~rQm | ≈ rmn + rQm instead of rmn − rQm , wouldn’t the the part equal to jkr
e Qn rmn −rQn
−jkrQn
in the integration become remn +rQn instead, and what would the effect be?” The answers are ”Yes!” and ”None!”. Remember that the goal is not to explicitly calculate but to interpolate. The result of the integration in equation 10.3 is calculated explicitly for some distinct frequencies. The expotential part outside the integration would be same in both cases and the fact that is varies faster as a function of frequency than the exponential part inside the integration is really the key to the interpolation scheme: In order to get a more accurate interpolation the faster varying exponential is kept away during the interpolation and returned at the end. The far-field approximation provides the means for dividing one distance into two distances, with one being both rapidly varying and constant during the each integration. The matrix elements in the A and B matrices, amn and bmn , respectively, can be approximated using the far-field approximation:
and
amn ≈ e−jkrmn · a ˆmn
(10.4)
bmn ≈ e−jkrmn · ˆbmn
(10.5)
where a ˆmn and ˆbmn are integrals involving slower varying exponentials. Similarly the ”hatted” matrix elements can be found as:
and
a ˆmn ≈ ejkrmn · amn
(10.6)
ˆbmn ≈ ejkrmn · bmn
(10.7)
10.1 Interpolating Matrix Elements
70
ˆ The ”hatted” matrix elements a ˆmn and ˆbmn make up the matrices Aˆ og B.
10.1.1
Linear and Quadratic Interpolation
ˆ calculated for two The interpolation is carried out using the matrices Aˆ and B or more wave numbers, depending on the interpolation order. E.g. when using a linear interpolation the scheme is as follows: The A and B matrices are calculated explicitly for one wave number k0 and for another wave number k1 , giving a total of four matrices; A(k0 ), B(k0 ), A(k1 ) and B(k1 ). The respective ”hatted” matrices are ˆ 0 ) are found as: calculated, for example the elements in matrix A(k a ˆmn (k0 ) ≈ ejk0 rmn · amn (k0 )
(10.8)
ˆ 0 ) and A(k ˆ 1 ) a matrix A(k) ˆ By using the matrices A(k is calculated, with k being ˆ a wave number in the interval [k0 , k1 ]. The elements in A(k) are calculated using linear interpolation: a ˆmn (k) =
k − k0 k − k1 a ˆmn (k0 ) + a ˆmn (k1 ) k0 − k1 k1 − k0
(10.9)
ˆ Similarly, the elements in the B(k) kan be found as: ˆbmn (k) = k − k1 ˆbmn (k0 ) + k − k0 ˆbmn (k1 ) k0 − k1 k1 − k0
(10.10)
Finally the elements in the A and B matrices for the interpolation wave number k, A(k) and B(k), are found as: amn (k) ≈ e−jkrmn · a ˆmn (k)
(10.11)
bmn (k) ≈ e−jkrmn · ˆbmn (k)
(10.12)
and
The system matrices have now been calculated for a given wave number by use of linear interpolation, a much faster approach than calculating the matrices explitcitly. Quadratic interpolation can of course also be applied. Here explicit calculations have to be carried out for three values of the wave number, k0 , k1 and k2 , giving the ˆ ˆ following elements in A(k) and B(k) matrices: a ˆmn (k) = L0 (k)ˆ amn (k0 ) + L1 (k)ˆ amn (k1 ) + L2 (k)ˆ amn (k2 )
(10.13)
and ˆbmn (k) = L0 (k)ˆbmn (k0 ) + L1 (k)ˆbmn (k1 ) + L2 (k)ˆbmn (k2 ) with L0 , L1 and L2 defined as:
(10.14)
71
Frequency Interpolation
L0 (k) = L1 (k) = L2 (k) =
10.2
(k − k1 )(k − k2 ) (k0 − k1 )(k0 − k2 ) (k − k0 )(k − k2 ) (k1 − k0 )(k1 − k2 ) (k − k0 )(k − k1 ) (k2 − k0 )(k2 − k1 )
(10.15) (10.16) (10.17)
The Programs, interplin.m and interpquad.m
Two interpolation programs have been developed; interplin.m and interpquad.m. The former uses linear interpolation, whereas the latter uses quadratic interpolation. In both cases the far-field approximation is implemented. With interplin.m the inputs are rmn (a matrix holding the distances between all of the nodes; is known after the first program run), the nodes matrix, two A matrices and two B matrices calculated for two values of k using the same mesh in both cases, the two respective values of k for these matrices, and finally the desired calculation k. The outputs are the interpolated A and B matrices and rmn (this way the distances only have to be calculated once for a given mesh/interpolation range). The other program interpquad.m has three extra inputs since three A matrices, three B matrices and three k values have to be known in order to perform a quadratic interpolation. The interpolation itself can in MATLAB be performed in a matter of seconds even for large system matrices. The most time consuming step is actually calculating the node distances, as this may take a few minutes. However, once these distances have been calculated for a given mesh/frequency range, they are saved, making the following calculations in this range pass very fast.
10.3
Program Test
The program interplin.m was tested using disc with a radius of 2 and a thickness of 0.3 placed in a sound field of a plane wave travelling in the positive x-direction. The sound pressure in point (−1, 0, 0) was calculated. Figure 10.2 illustrates the disc mesh. The sound pressure was calculated explicitly for 15 values of k between 0.1 and 1.5 to have a reference. Then a linear interpolation was carried out with k0 equal to 0.1 and k1 equal to 1.5, i.e. the two end points in the range in question. The sound pressure was calculated by interpolating, and the result is plotted in figure 10.3 along with the sound pressure calculated explicitly. The interpolated sound pressure is very similar to the reference. To examine the effect of using the far-field approximation, the interpolation was repeated; this time the matrix elements were interpolated directly without omitting the rapidly
10.3 Program Test
72
Figure 10.2: The disc shaped mesh used for testing interplin.m.
1000
900
Absolute value of Sound Pressure
800
700
600
500
400
300
200
100
0
0
0.5
1
1.5
Wave number, k
Figure 10.3: The solid line is the absolute value of the sound pressure calculated using linear interpolation with far-field approximation with k0 = 0.1 and k1 = 1.5. The dotted line is the absolute value of the sound pressure calculated explicitly.
73
Frequency Interpolation
varying exponential while interpolating. The result is plotted in figure 10.4 along with reference pressures. 1000
900
Absolute value of Sound Pressure
800
700
600
500
400
300
200
100
0
0
0.5
1
1.5
Wave number, k
Figure 10.4: The solid line is the absolute value of the sound pressure calculated using linear interpolation without far-field approximation with k0 = 0.1 an k1 = 1.5. The dotted line is the absolute value of the sound pressure calculated explicitly. Without the far-field approximation the accuracy of the interpolation is much poorer, especially for higher frequencies. To further underline the importance of performing the far-field approximation, another interpolation was carried out. Again the matrix elements were calculated directly without the far-field approximation, but this a quadratic interpolation was performed with k0 = 0.1, k1 = 0.8 and k2 = 1.5. The result is plotted in figure 10.5 along with the reference. The result is more accurate than when using linear interpolation, but again the higher frequencies present some trouble for this interpolation scheme. Another test case was chosen to further examine the potential of the interpolation program interplin.m. In [5] measurements have been carried out using different cabinets to examine the agreement between theoretical result found by use of Vanderkooy’s diffraction theory (see [4]) and the measurements. One of the cabinets has been modeled in a CAD program and fitted with meshes. Acoustic calculations have been carried out using the same conditions as in [5]: The calculation point is located 2.3 metres in front of the cabinet and at the same height as the center of the piston. Figure 10.6 shows the cabinet. The curve plotted in figure 10.7 is the level of the sound pressure divided by the free-field sound pressure. It is taken from [5].
10.3 Program Test
74
1000
900
Absolute value of Sound Pressure
800
700
600
500
400
300
200
100
0
0
0.5
1
1.5
Wave number, k
Figure 10.5: The solid line is the absolute value of the sound pressure calculated using quadratic interpolation without far-field approximation with k0 = 0.1, k1 = 0.8 and k2 = 1.5. The dotted line is the absolute value of the sound pressure calculated explicitly.
Figure 10.6: The dimensions of the test case. (Figure borrowed from [5]).
75
Frequency Interpolation
Figure 10.7: The solid curve is level of the sound pressure divided by the free-field sound pressure. The dotted line is the level predicted by Vanderkooy’s diffraction theory. (Figure borrowed from [5]). The interpolated levels in figure 10.8 and figure 10.9 are found by taking the logarithm to the interpolated sound pressure divided by the free-field sound pressure, and then scaling them so that the levels are comparable to the reference in figure 10.7. In figure 10.8 the levels are found using linear interpolation with far-field approximation. One interpolation was carried out in the frequency range 500 to 1000 Hertz, using one mesh, and another interpolation was carried out in the frequency range 1000 to 2000 Hertz, using another mesh. Below 500 Hertz the levels vary quite slowly (the spikes in the measured levels are due to vibrations according to [5]) so interpolation in this range is less interesting. Above 2000 Hertz the calculation time makes calculating very tedious and the demand for computer memory is very high. In figure 10.9 the levels are calculated by interpolation without applying the far-field approximation. With the far-field approximation the interpolated levels are quite similar to measured levels. At about 1600 Hz the interpolated level has a spike. This may be a result of the frequency range being to wide for the interpolation to work properly. Without applying the far-field approximation the plotted curve bears no resemblance with the measured levels.
10.4
Concluding Remarks
An interpolation scheme making BEM calculation faster has been described. Two programs that use this interpolation scheme has been developed. One of the programs has been tested, and it was shown that calculation time is dramatically decreases and the calculation results are acceptable.
10.4 Concluding Remarks
76
Scaled Level (pressure divided by free−field pressure)
15
10
5
0
−5 2 10
3
10 Frequency, [Hz]
4
10
Figure 10.8: The level is calculated using linear interpolation with far-field approximation. The interpolation frequencies are 500 and 1000 Hz in the range [500,1000], and 1000 and 2000 Hz in the range [1000,2000].
Scaled Level (pressure divided by free−field pressure)
15
10
5
0
−5 2 10
3
10 Frequency, [Hz]
4
10
Figure 10.9: The level is calculated using linear interpolation without far-field approximation. The interpolation frequencies are 500 and 1000 Hz in the range [500,1000], and 1000 and 2000 Hz in the range [1000,2000].
Chapter 11
Discussion In this chapter some of the programs developed in this work are discussed.
11.1
Discussion of Mesh Refinement
In chapter 5 the program refinemesh.m was described. The program refines triangular element meshes by dividing the larger triangles in the mesh into smaller ones; this is done to meet a demand for a certain number of nodes per wave length. If one were to make acoustic calculations for several distinct frequencies in a given range, refinemesh.m could advantagesly be combined with the calculation program TriQuadEquat. This combination could work as follows: The user inputs a start frequency, a finish frequency and a frequency increment along with information on the nodes and the topology. It would then be checked if the mesh complies with the start frequency; if it does, calculations are carried out and the system matrices are saved; otherwise the mesh is refined before the calculations are carried out. The program would then move on to the next frequency which would be the start frequency plus the frequency increment. Once again it would checked if the mesh is acceptable with the new frequency; if this is not the case, the mesh is refined before calculating. This way the mesh would automatically be refined succesively to meet the increasing demand for nodes. This proces can of course also be done manually, but it is rather tedious. One might be temped to instead make just one mesh, refine it for the highest frequency in the desired frequency range, and use this mesh at all frequencies. This, however, increases the calculation time considerably which is obviously unwanted.
11.2
Discussion of Incompatible Meshes
The program merge.m merges incompatible meshes. In its current state the program actually merges all meshes, but excess nodes in the resultant mesh are not removed from the nodes matrix. Once this is taken care the mesh is suited for acoustic calculations. 77
11.3 Discussion of Frequency Interpolation
78
It is no longer a problem that some CAD programs make meshes that represent one open edge using one node distibution and another open edge with the same geometry using another node distribution. The program could e.g. find use in the loudspeaker industry, where domes and cabinets are often meshed separately.
11.3
Discussion of Frequency Interpolation
One of the downsides of using the boundary element method is that calculation time increases considerably as the calculation frequency is increased. Using the interpolation programs developed in this work, calculation time can be reduced dramatically. As with the mesh refinement program, the interpolation programs could also be combined the calculation program. The user would input a frequency range and a frequency increment, explicit calculations would be carried out for two of the frequencies in the range using a mesh suitable for the highest frequency and the frequencies in between would be calculated by interpolation for each increment frequency. Finally, the refinement program and an interpolation program could both be used at the same time along with the calculation program. The mesh could be refined for the highest frequency in some range, two explicit calculations would be performed and interpolation would be used to find the rest of the values in the range. Then the refinement program could refine the mesh for a higher frequency range and the procedure could be repeated for this range.
Chapter 12
Conclusion In this work different aspects surrounding the import of geometries from CAD programs for use in acoustic calculation programs based on the Boundary Element Method has been examined. The theory of the Boundary Element Method has been described. It is described how calculations meshes are used in the calculation, and how the acoustical problem is represented in a matrix formulation. It has been examined what effect ill-shaped triangles in a calculation mesh have on the accuracy of the calculation. It was found that pointy triangles, i.e. triangles with two nodes located close together, in a mesh will result in a slight increase in calculation error. Such triangles are often found in meshes from CAD programs. These meshes can, based on the examination in this work, be considered as acceptable in acoustic calculation. The effect of another type of ill-shaped triangle was examined. Flat triangles, i.e. triangles with one node close to its subtending side, are highly unacceptable in meshes, when they have a certain proportion and three integration points per triangle are used. When instead four integration points are used, flat triangles do not decrease calculation accuracy. Meshes made by CAD programs often have very large geometric elements where the mesh geometry is simple, e.g. on planar surfaces. Such meshes are in general not suited for use in acoustic calculations. A program that successively divides large triangles into smaller triangles until a certain demand for nodes versus wave length is met was developed in this work. The program is described and test results are illustrated. A convergence analysis was carried out. The analysis validated the assumption that the acoustic variables vary linearly along the geometric elements. The effect of 79
80
the number of integration points was also examined. In general, increasing the number of integration points increases slightly without increasing calculation accuracy. Finally, two meshes with quadrilateral elements and triangular elements, respectively, with the exact same geometry and the exact same number of nodes were used in calculations and the results were compared. Using the quadrilateral element mesh reduces calculation time by about 30% compared to using the triangular element mesh. Calculation accuracy is approximately the same for the two. Incompatible meshes are meshes that are not easily merged. There can be different reasons for working with several open meshes that are to be joined into one closed mesh at a later point. To the knowledge of the author a program capable of merging meshes which have open edges with the same geometry but with different node distribution along these edges has never been developed. In this work such a program was made. It is capable of merging two meshes into one, but a little more work has to be done before the resultant mesh is acceptable for acoustic calculations. The program has been described, test results have been presented and possible improvements have been discussed. As mentioned calculation time decreases when quadrangles are used in the calculation mesh compared to triangles. A program that makes triangle pairs into quadrangles has been developed. The program strategy is decribed and test results are illustrated. Finally a method for speeding up calculations considerably has been described. The method involves interpolation of the elements in the system matrices. Two programs capable of performing this interpolation have been developed. The program strategy is discussed and test results are illustrated.
Bibliography [1] K. H. Huebner, E. A. Thornton and T. G. Byron. 1995 ”The Finite Element Method for Engineers” ISBN 0-471-54742-5 [2] G. Beer and J. O. Watson ”Introduction to Finite and Boundary Element Methods for Engineers” ISBN 0 471 92813 5 [3] Peter Møller Juhl. 1993 ”The Boundary Element Method for Sound Field Calculations” Ph.D. Thesis, The Acoustics Laboratory, Technical University of Denmark ISSN 0105-3027, Report No. 55 [4] John Vanderkooy. 1991 ”A Simple Theory of Cabinet Edge Diffraction” J. Audio Eng. Soc., Vol. 39, No. 12 [5] Søren Rasmussen and Karsten Bo Rasmussen. 1994 ”On Loudspeaker Cabinet Diffraction” J. Audio Eng. Soc., Vol. 42, No. 3 [6] Peter Møller Juhl et al. ”OpenBEM”, Acoustic Boundary Element Method Software Package [7] G. W. Benthien and H. A. Schenck ”Structural-Acoustic Coupling” Naval Ocean Systems Center, San Diego, CA 92152-5000, U.S.A. From: ”Boundary Element Methods in Acoustics”. 1991 C. A. Brebbia and R. D. Ciskowski ISBN 1851666796 [8] R. Cools and A. Haegemans. 1987 ”Construction of Minimal Cubature Formulae for the Square and the Triangle using Invariant Theory” Report TW 96 Dept. of Computer Science, Katholieke Universitet Leuven
81
BIBLIOGRAPHY
82
[9] M. Cristeu and G. Loubinac ”Gaussian Quadrature Formulas for Functions with Singularities in 1/R over Triangles and Quadrangles” From: ”Recent Advances in Boundary Element Methods” Edited by C. A. Brebbia ISBN 0-7273-01803-9
Appendix A
List of Programs The CD in the enclosure has two folders: Thesis and triquadbem. In Thesis this thesis is included in PDF format and with all LATEX source files. In triquadbem the MATLAB files developed in this work is included along with test cases. The files are distributed over several folders. In the folder testcases there are test cases used in this work; some in STL format, others in ANSYS format. Some are taken from the OpenBEM package, some are made by the author and some have been provided by Bang & Olufsen. The folder meshtools contains the programs developed by the author. In the following sections the ones of most interest are described.
A.1
Mesh Tools
The program degen.m makes some of the triangles in a triangular element mesh into degenerate quadrangles, i.e. quadrangles with three aligned nodes. It works by adressing the first triangle in a mesh, adding a node on the longest side of the triangle, removing the triangle and revising the topology so that the triangle becomes a quadrangle (or actually making the three node numbers of the triangle zero and adding the quadrangle to the topology). The triangle sharing the longest side with the first element is found and this triangle is also changed into a quadrangle. The two quadrangles are marked so that they cannot get any more new nodes. Input is the nodes matrix (nodes) and the topology matrix (topology) in STL format without body numbers, output is the nodes matrix (nodes) and the topology matrix (topology) in ANSYS format without body numbers. The program interplin.m interpolates matrix elements. It uses linear interpolation with scaling, i.e. a far-field quantity is removed while interpolating and put back afterwards. Input is two A matrices (A1 and A2) and two B matrices (B1 and B2) and their respective wave numbers (k1 and k2), the nodes matrix in STL format without body numbers (nodes), the wave number for which the interpolation is to be carried out (k) and one matrix holding distances between the nodes (rmn; is known only after 83
A.1 Mesh Tools
84
running interplin.m once, so for the first run it is input as an empty matrix). Output is the interpolated A and B matrices (A and B) for the chosen interpolation wave number, and the distance matrix (rmn). The program interpquad.m interpolates matrix elements. It uses quadratic interpolation. The input variables are similar to those in interplin.m only here three A matrices, three B matrices and three wave numbers are used. The output is the interpolated A matrix and the interpolated B matrix along with the node distance matrix. The program makediag makes quadrilateral element meshes into triangular element meshes. It adresses the first quadrangle (e.g. nodes 1, 2, 3 and 4) in the mesh and makes it into two triangles (nodes 1, 2, 2 and 3, and nodes 1, 3, 3 and 4). Input is the nodes matrix (nodes) and the topology matrix (topology) in ANSYS format without body numbers. Output is the nodes matrix (newnodes) and the topology matrix (newtopology) in ANSYS format without body numbers. The program merge.m merges incompatible meshes. Input is the nodes matrix (nodesb) and the topology matrix (topologyb) in STL format with body numbers, and information about the open segments (segmopen). Output is the nodes matrix (mergnodesb) and topology matrix (mergtopologyb) in STL format with body numbers. The program refinemesh.m refines triangular element meshes to meet a demand to the number of nodes per wave length. Triangles that are too large are refined by putting an extra node along their longer side length and making two new triangles. In its current state the mesh is refined until there are five nodes per wave length. Input is the nodes (nodes) and the topology (topology) in STL format without body numbers, and the wave number (k) for which the mesh is to be refined. Output is the nodes matrix (nodes) and the topology matrix (topology) in STL format without body numbers. The program tri2quad makes suited pairs of triangles in a triangular element mesh into quadrangles. The triangles must lie in the same plane to a certain degree specied by the user, and none of the internal angles in the resulting quadrangles must superseed π radians. Input is the nodes matrix (nodes) and the topology matrix (topology) in STL format without body numbers, and the maximum allowable angle between the triangle pairs (theta) in degrees. Output is the nodes matrix (nodes) and the topology matrix (topology) in ANSYS format without body numbers.
85
A.2
List of Programs
Additional Programs
Two additional programs of interest are found in the folder triquadbem. One is in the folder input, namely bodyfindII. It is a slighty changed version of a program from the OpenBEM package, bodyfind, with the only difference being an extra output variable, geometry. Both programs read meshes in ANSYS format to find open segments, find the normal vector of the elements, draw the mesh and several other things. The variable geometry is a vector with as many rows as there are elements in the mesh. A zero in column x in this vector indicates that the x’th element is a quadrangle, whereas a one indicates a triangle. The other program is found in the folder triquadbem, namely TriQuadEquat. It is a combination of existing programs from the OpenBEM package. It performs acoustic calculations using meshes with both triangular and quadrilateral elements, and one of its input variables is the vector geometry.
Appendix B
Mathematics In this chapter some mathematics is described. This is done primarily to assist students who are about to get familiar with the OpenBEM package.
B.1
Green’s Function, Singularity
Green’s free-field function, G(R) = can be parted in two:
e−jkR R ,
has a singularity in R = 0. This function
e−jkR − 1 1 e−jkR = + (B.1) R R R The first part is non-singular as it tends to −jk for R going towards zero. The second part is singular, but is more easily handled than Green’s function. G(R) =
B.2
The Jacobian and the Normal Vector
The Jacobian of a transformation from a planar surface in the xyz-coordinate system to a surface in the local ξ1 ξ2 -coordinate system, J(ξ1 , ξ2 ), is found as follows: ° ° ° ∂~r ∂~r ° ∂~r ∂x ~ ∂y ~ ∂z ~ ° ° where × = i+ j+ k J(ξ1 , ξ2 ) = ° ° ∂ξ1 ∂ξ2 2 ∂ξ1,2 ∂ξ1,2 ∂ξ1,2 ∂ξ1,2 °µ ¶ µ ¶ µ ¶ ° ° ∂y ∂z ° ∂z ∂y ∂z ∂x ∂x ∂z ∂x ∂y ∂y ∂x ~° ~ ~ = ° ° ∂ξ1 ∂ξ2 − ∂ξ1 ∂ξ2 i + ∂ξ1 ∂ξ2 − ∂ξ1 ∂ξ2 j + ∂ξ1 ∂ξ2 − ∂ξ1 ∂ξ2 k ° 2 ° ° ° ~ ° = °nx i + ny~j + nz~k ° 2
= k~nk2
(B.2) (B.3)
Notice that ξ1,2 means ”holds for either ξ1 or ξ2 ”. The derivatives are found by the use of shape functions. Since: 86
87
Mathematics
x=
n X
Nα (ξ1 , ξ2 )xα ,
α=1
then n X ∂x ∂Nα (ξ1 , ξ2 ) = xα , ∂ξ1,2 ∂ξ1,2
(B.4)
α=1
and similarly for y and z.
B.3
The Spatial Angle
The spatial angle C(P ) is found as Z C(P ) = 4π + S
∂ ∂n
µ ¶ 1 dS, R
for exterior problems. The function to be integrated can be expressed by use of the chain rule: ∂( R1 ) ∂R ∂( R1 ) = ∂n ∂n ∂R The distance R is found as: q R = |~r − ~r0 | = (xQ − xP )2 + (yQ − yP )2 + (zQ − zP )2 The first part is found as: ∂R ∂R ∂R ∂R = ∇R · ~n = nx + ny + nz ∂n ∂x ∂y ∂z The calculation of
∂R ∂x
= = =
So now
∂R ∂n
∂R ∂x
∂
is illustrated: ³p ´ (xQ − xP )2 + (yQ − yP )2 + (zQ − zP )2
∂x 2xQ − 2xP p 2 (xQ − xP )2 + (yQ − yP )2 + (zQ − zP )2 xQ − xP R
can be found as xQ − xP yQ − yP zQ − zP ∂R = nx + ny + nz ∂n R R R
B.4 Differentiating Green’s Function
The other part,
1 ) ∂( R ∂R
88
is found more easily: ∂( R1 ) −1 = 2 ∂R R
This means that ∂( R1 ) xQ − xP yQ − yP zQ − zP −1 =( nx + ny + nz )( 2 ) ∂n R R R R
B.4
(B.5)
Differentiating Green’s Function
The differentiation of Freen’s function can be done starting with the chain rule: ∂G(R) ∂R ∂G(R) = ∂R ∂n ∂R The first part,
∂R ∂n ,
has just been found. The other part is found: ³ −jkR ´ ∂ e R ∂G(R) e−jkR G(R) = =− (1 + jkR), (1 + jkR) = − ∂R ∂R R2 R
so that the total expression equals: xQ − xP yQ − yP zQ − zP ∂G(R) G(R) =( nx + ny + nz )(− (1 + jkR)) ∂R R R R R
(B.6)