You are on page 1of 57

The Boundary Element Method in Acoustics

Basic Theory and Practical Exercises with


OpenBEM

Manuel A. Sobreira Seoane

Signal Theory and Communications Department


University of Vigo

OpenBEM

Year: 2014 / 2015

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 1 / 44


Index

1 The Boundary Element Method in Acoustics – BEM.


Basic Theory
Geometry Discretization: Mesh Generation
2 Mesh generation in 3D
CAD design: FreeCad
Mesh generation in 3D with Gmsh
Importing 3D Meshes into Matlab
Tasks
3 Resonances in Cavities
Theoretical background
An Example of 2D Cavity: Resonances
Mapping the sound pressure in a 2D cavity
Tasks:
Resonances and modes in 3D

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 2 / 44


Theory– BEM

1 The Boundary Element Method in Acoustics – BEM.


Basic Theory
Geometry Discretization: Mesh Generation

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 3 / 44


Theory– BEM Integral Equation

The Kirchhoff-Helmlhotz Integral Equation

BEM Notation Helmholtz Equation and Boundary


Conditions:
∇2 p + k 2 p = 0, (1)
jωρ0 u + ∇p = 0, (2)
Boundary Conditions:

αp + βvn = γ. (3)

Figure : BEM Notation: Q: Equation (1) is the Helmholtz Equation


points on the surface of the Equation (2) is the Euler Equation for
body, P: field points. harmonic sound waves.
For a rigid body, in eq. (3) vn = 0, a
vibrating body, vn = vo (known).

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 4 / 44


Theory– BEM Integral Equation

The Kirchhoff-Helmlhotz Integral Equation


After some transformations, Helmholtz equation can be expressed as
a integral equation:
Z  
∂G(P, Q)
C(P)p(P) = p(Q) + jkz0 v (Q)G dS + 4πpI (P), (4)
S ∂n

G is the free space Green’s function which relates the sound pressure between two points.
For 3-D problems:
e−jkR
G(R) = , R = |P − Q| (5)
R
For 2D-problems:
1 (1)
G(R) = H (kR), R = |P − Q| (6)
4i 0
C(P) are constants that depend on the geometry of the body and where the point P is
placed [?, ?]
S is the surface of the body
Q, as the figure 10 shows, a point on the surface
P is any interior or exterior point.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 5 / 44


Theory– BEM Integral Equation

The Kirchhoff-Helmlhotz Integral Equation

Discretisation of the equation: example


In scattering problems on a rigid body, there is an incident wave and vn = 0. Eq (4) becomes:

∂G(P, Q)
Z
C(P)p(P) = p(Q)dS + 4πpI (P), ⇒ (7)
S ∂n

N Z
X ∂G(P, Q)
C(P)p(P) ≈ p(Q)dSj + 4πpI (P) (8)
Sj ∂n
j=1

If it is assumed the pressure is constant in each element:

N
∂G(P, Q)
X Z
C(P)p(P) ≈ pj dSj + 4πpI (P) = (9)
Sj ∂n
j=1

= p1 · hP,1 + p2 · hP,2 + · · · + pN · hP,N + 4πpI (P),

In matrix form:
C(Q) · p(Q) = H · p(Q) + 4πpI (Q). (10)

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 6 / 44


Theory– BEM Integral Equation

The Kirchhoff-Helmlhotz Integral Equation

Discretisation of the equation: example (cont.)


Rearranging the equation (10):

0 = [H − C(Q)] · p(Q) + 4πpI (Q). (11)

If the matrix A can be inverted, the matrix equation can be multiplied on the left by A−1 , to get
the vector containing the sound pressure at the points Q placed on the surface of the body:

p(Q) = A−1 (−4πpI (Q)) (12)

Once the sound pressure is known on the surface, the sound pressure can be solved to any Field
Point:
C(P) · p(P) = H · p(Q) + 4πpI (P), (13)

Note: The BEM is solved in two steps: first, for the boundary and
second for the domain.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 7 / 44


Theory– BEM Mesh Generation

The Kirchhoff-Helmlhotz Integral Equation


The rough solution for scattering problems, can be repeated for
radiation problems, and the general BEM equation in matrix form can
be obtained:
BEM matrix equation

C(P) · p(P) = H · p(Q) + jkZ0 B · v(Q) + 4πpI (P) (14)

v(Q) contains the known velocity on the surface of the body and the
elements of the matrix
B are the surface integrals of the Green function – see eq (4).
The equation (14) must be solved in two steps:
1 Making P → Q and solving for the nodal values, p(Q).
2 Once the nodal values are known, the sound pressure in the field points,
p(P), can be obtained.
OpenBEM (U.Vigo) Boundary Element Method 2014/2015 8 / 44
Mesh generation in 3D

2 Mesh generation in 3D
CAD design: FreeCad
Mesh generation in 3D with Gmsh
Importing 3D Meshes into Matlab
Tasks

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 9 / 44


Mesh generation in 3D FreeCad

Discretisation of the geometry: mesh generation


Mesh Generation
Mesh generation: Discretization of a geometry into a set of nodes and
elements connecting the nodes.
Process: Geometry definition in a CAD software −→ Mesh generation
with a mesh software
Software: FreeCad −→ Gmsh

Mesh  genera*on  
(Meshing)  

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 10 / 44


Mesh generation in 3D FreeCad

FreeCad: Example
Example:
Rectangular room with dimensions Length=4 m, Width=3 m and Heigh= 2,7 m

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 11 / 44


Mesh generation in 3D FreeCad

FreeCad: Example

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 12 / 44


Mesh generation in 3D FreeCad

FreeCad: Example

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 13 / 44


Mesh generation in 3D FreeCad

FreeCad: Example

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 14 / 44


Mesh generation in 3D FreeCad

FreeCad: Example
We need to export the file to exchange format to be imported in the
meshing software. In our case, ”step”.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 15 / 44


Mesh generation in 3D Gmsh

Gmsh: Example
Import the geometry into Gmsh and under the ”mesh” menu, press the
2D option:

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 16 / 44


Mesh generation in 3D Gmsh

Gmsh: Example
Now the mesh is done and ready to save in ”msh” format that can be
imported into Matlab. Save it as box tutorial.msh.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 17 / 44


Mesh generation in 3D Importing into Matlab

Importing a mesh into Matlab

Function geometry=loadgeom(file,n)
The function loadgeom, imports a 3D mesh in ”.msh” format into matlab
Input: The file name: ’filename.msh’ and the direction of the normal vectors desired +1 for
exterior problems and -1 in the case of interior problems.

Output: The structure geometry, with the fields geometry.nodesb and geometry.topologyb

Example: load the box into matlab


Be sure you are under the 3DBEM folder in OpenBEM.

>> run_me % Set the path


>> geometry=loadgeom(’box_tutorial.msh’,-1);

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 18 / 44


Mesh generation in 3D Importing into Matlab

Importing a mesh into Matlab:


The meshed box, imported in Matlab

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 19 / 44


Mesh generation in 3D Importing into Matlab

Data structure in Matlab

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 20 / 44


Mesh generation in 3D Tasks

Tasks
Practice to
1 Create, mesh and import into Matlab a cylindrical room with a
dome on the top. Radius of the cylinder and the dome, r= 7 m.
Heigth=3 m. Total Heigh including the dome: 10 m
2 Create, mesh and import into Matlab a room with two non parallel
walls (any dimensions).

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 21 / 44


Interior problems in BEM

3 Resonances in Cavities
Theoretical background
An Example of 2D Cavity: Resonances
Mapping the sound pressure in a 2D cavity
Tasks:
Resonances and modes in 3D

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 22 / 44


Interior problems in BEM Background

Introduction

Aims:
Know how to generate geometries in 2D-BEM
Understand the use of the kernel functions in OpenBEM (2D and
3D)
Calculate resonances, 2D and 3D, in cavities using BEM.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 23 / 44


Interior problems in BEM Background

Theoretical background

1-Resonances in rectangular cavities


As it is well known, the resonance frequencies of a rectangular
cavity, with dimensions Lx , Ly and Lz , can be calculated using the
following expression, ∀ nx , ny , nz = 0 · · · ∞
s 
nx 2
 2  2
c ny nz
fnx ,ny ,nz = + + , (15)
2 Lx Ly Lz
or plane 2D cavities, it can be assumed there is no resonance in
the z-axis direction.
s 
nx 2
 2
c ny
fnx ,ny ,nz = + , ∀nx , ny = 0 · · · ∞ (16)
2 Lx Ly

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 24 / 44


Interior problems in BEM Background

Theoretical background

1-Resonances in rectangular cavities


As it is well known, the resonance frequencies of a rectangular
cavity, with dimensions Lx , Ly and Lz , can be calculated using the
following expression, ∀ nx , ny , nz = 0 · · · ∞
s 
nx 2
 2  2
c ny nz
fnx ,ny ,nz = + + , (15)
2 Lx Ly Lz
For plane 2D cavities, it can be assumed there is no resonance in
the z-axis direction.
s 
nx 2
 2
c ny
fnx ,ny ,nz = + , ∀nx , ny = 0 · · · ∞ (16)
2 Lx Ly

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 24 / 44


Interior problems in BEM Tutorial Resonances 2D

Theoretical Task
1-Data:
We want to calculate the resonance frequencies of a 2D cavity when a
sound source is placed at P = (xs , ys ) = (0.1, 0.1). The cavity
dimensions are: Lx = 4 m, Ly = 3 m. It is desired to calculate the
frequency response from f1 = 40 to f2 = 145Hz:
1 At a field point, P1 , placed at P1 = (0.9, 1.1)
2 At a field point, P2 , placed at P1 = ( L2x , Ly
2 )

Lz  

Ly  

Lx  

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 25 / 44


Interior problems in BEM Tutorial Resonances 2D

Theoretical Task

Calculate and fill:


Find all the resonance frequencies up to nx = ny = 2 and write the
results in the table 1. Mark those resonance frequencies whose peaks
should not appear in the frequency response evaluated at P2 .
Consider:

The temperature is t = 20 o C
The static pressure: po = 101325 Pa.
Relative Humidity: Hr = 50
With this atmospheric conditions, the speed of sound,
c = 343.9862 m/s.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 26 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Geometry definition:
Function: [xyb,topology, admitt]=nodegen(segments,see);

Builds geometry arrays from a description of the geometry as


segments of constant curvature and mesh density.
segments: array with a segment description per row. Clockwise
direction. The columns are: x and y of the starting point, x and y
of the end point, number of elements in the segment, curvature
radius and segment admittance.
see: if it is set to ’y’ or ’Y’, a plot is made with the geometry.
Output: Nodes coordinates, xyb, segments, and vector admitance
for each node, admitt.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 27 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Geometry definition:
Function: [xyb,topology, admitt]=nodegen(segments,see);

Builds geometry arrays from a description of the geometry as


segments of constant curvature and mesh density.
segments: array with a segment description per row. Clockwise
direction. The columns are: x and y of the starting point, x and y
of the end point, number of elements in the segment, curvature
radius and segment admittance.
see: if it is set to ’y’ or ’Y’, a plot is made with the geometry.
Output: Nodes coordinates, xyb, segments, and vector admitance
for each node, admitt.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 27 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Geometry definition:
Function: [xyb,topology, admitt]=nodegen(segments,see);

Builds geometry arrays from a description of the geometry as


segments of constant curvature and mesh density.
segments: array with a segment description per row. Clockwise
direction. The columns are: x and y of the starting point, x and y
of the end point, number of elements in the segment, curvature
radius and segment admittance.
see: if it is set to ’y’ or ’Y’, a plot is made with the geometry.
Output: Nodes coordinates, xyb, segments, and vector admitance
for each node, admitt.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 27 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Geometry definition: Example Output


% Dimensions of the rectangular cavity:
lx=4; ly=3;

% Impedance rigid surface


sigmaS=Inf;

% De-normalized admittance
betaS=betag(sigmaS,fr)/(rho*c);

% Resolution of the mesh (6 nodes per wavelength)


el_wl=6*max(f)/c;

% Define segments:
segments=[0 0 0 ly ceil(ly*el_wl) 0 betaS;...
0 ly lx ly ceil(lx*el_wl) 0 betaS;...
lx ly lx 0 ceil(ly*el_wl) 0 betaS;...
lx 0 0 0 ceil(lx*el_wl) 0 betaS];

% Call nodegen:
[xyb,topology,Ynodes]=nodegen(segments,’y’);

% Interior problem:
xyb(:,end)=-xyb(:,end);
topology(:,end)=-topology(:,end);

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 28 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Calculations: Kernel Functions (I)


Function:
[G0dir,G0ref,dG0dirdR1,dG0refdR2,Pbeta,dPbetadx,dPbetady]=greendef(k,pxyb,betaP,xq,yq);

Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 29 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Calculations: Kernel Functions (I)


Function:
[G0dir,G0ref,dG0dirdR1,dG0refdR2,Pbeta,dPbetadx,dPbetady]=greendef(k,pxyb,betaP,xq,yq);

Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 29 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Calculations: Kernel Functions (I)


Function:
[G0dir,G0ref,dG0dirdR1,dG0refdR2,Pbeta,dPbetadx,dPbetady]=greendef(k,pxyb,betaP,xq,yq);

Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 29 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Calculations: Kernel Functions (I)


Function:
[G0dir,G0ref,dG0dirdR1,dG0refdR2,Pbeta,dPbetadx,dPbetady]=greendef(k,pxyb,betaP,xq,yq);

Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 29 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Calculations: Kernel Functions (I)


Function:
[G0dir,G0ref,dG0dirdR1,dG0refdR2,Pbeta,dPbetadx,dPbetady]=greendef(k,pxyb,betaP,xq,yq);

Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 29 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });

Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 30 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });

Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 30 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });

Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 30 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });

Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 30 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });

Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 30 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });

Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 30 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Calculations: Kernel Functions (III)


Function: [Ap,Bp,CConst]=fieldpoints(xyb,topology,k,betaP,xy);

Calculates rows of coefficients for a set of field points. It admits a plane with finite or infinite
impedance.

Input variables
xyb:node positions, first column is the x-coordinate, second column is y-coordinate,
and third column is the body number to which the node belongs to.
topology:each row contains the node numbers (row number in xyb) of the nodes in
one element. The last column is the body number the element belongs to.
k: wavenumber
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is
considered (infinite impedance); if its value is NaN (not-a-number), free-field is
assumed.
xy:field points to calculate. Two columns [xi yi], with N rows (N: number of field
points).
Output: Ap,Bp and Cp: The rows of coefficients for the A, B and C constants matrixes.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 31 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations

Atmospheric conditions and propagation constants


Function: function [rho,c0,cf,CpCv,eta,alfa,Cp,Cv,landa,beta]=amb2prop(ps,t,H,f);

Calculation of the physical properties of air ambient conditions.

Input variables
t: temperature in Celsius. Standard: 20 Celsius
H: humidity in %. Standard: 50 %
f: frequency in Hz.
ps: static pressure in Pa. Standard: 101325 Pa
Output: c0: This is the variable we are interested in: the speed of sound at f=0.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 32 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
The resonances in BEM are calculated detecting the maximums of the Condition Number of the
matrix A. For the example given, the next code allows to calculate the resonances and the
pressure at the field points

Calculating the resonances (I)


% Frequency range
f=(40:0.2:145);
k=2*pi*f/c; %Obtain c =c0 using the amb2prop function.
L=length(f);

% Field Points position


xy=[0.9 1.1;lx/2 ly/2];
% Source position
position=[0.1 0.1];
% Loop for different frequencies calculations.
for ff=1:L
% Obtain incident pressure
[Gd,Gr,dG0dirdR1,dG0refdR2,Pbeta,dPbdx,dPby]=greendef(k(ff),position,betaP,xyb(:,1),xyb(:,2));
inc_pressure=i/4*(Gd+Gr)+Pbeta;
% calculate coefficient matrix
[A,B]=bem2d(xyb,topology,k(ff),betaP);
% Condition number, loop ends here if only the value of resonance freqs. are desired
condA(ff)=cond(A);
% Solve System: pressure at the nodes:
ps=(A+j*k(ff)*rho*c*B*diag(Ynodes))\(-2*pi*inc_pressure);

(cont. next page)

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 33 / 44


Interior problems in BEM Tutorial Resonances 2D

2D BEM calculations
... from prev. page

Calculating the resonances (II)


% Calculation of the pressure on field points:
[Ap,Bp,CConst]=fieldpoints(xyb,topology,k(ff),betaP,xy);
[Gd,Gr,dG0dirdR1,dG0refdR2,Pbeta,dPbdx,dPbdy]=greendef(k(ff),position,betaP,xy(:,1),xy(:,2));
% Incident pressure on the field points
pIfield=i/4*(Gd+Gr)+Pbeta;
% Solve for the sound pressure on the field points
pfield=((Ap+j*k(ff)*rho*c*Bp*diag(Ynodes))*ps./CConst+pIfield).’;
% Store the results for all the points in p
p(:,ff)=pfield;
end

Post-processing and plotting


Now let’s find the peaks of the condition number and plot the results:
% Find peaks in condA
[pks,loc]=findpeaks(condA);
% Get the resonance frequencies from the position index given in loc
fresonance=f(loc);
% plot
semilogy(f,condo,f(loc),pks,’or’); % condition number
pref=2*e-5; %reference sound pressure
SPL=10*log10(0.5*p.*conj(p)/prefˆ2); % sound pressure level
plot(f,SPL); % SPL at P1 and P2

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 34 / 44


Interior problems in BEM Tutorial Resonances 2D

Output: SPL at P1 and P2 and condition number of matrix A

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 35 / 44


Interior problems in BEM Tutorial Resonances 2D

Results

Table : Resonance Frequencies in 2D, Lx = 4 m and Ly = 3 m

nx ny fnx ,ny fBEM at P1 fBEM at P2

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 36 / 44


Interior problems in BEM SPL maps

Mapping the sound pressure in a cavity

The Sound Field:


To map the sound field, a grid of field points should be defined:
% generate mesh of field points
[XX,YY]=meshgrid(espac:espac:lx,espac:espac:ly);
xy=[XX(1:end)’ YY(1:end)’];
% calculate corresponding rows of coefficients
[Ap,Bp,CConst]=fieldpoints(xyb,topology,k,betaP,xy);
% Direct pressure (incident field)
[G0dir,G0ref,dG0dR1,dG0dR2,Pb,Pbdx,dPbdy]=greendef(k,position,betaP,xy(:,1),xy(:,2));
pIfield=i/4*(G0dir+G0ref)+Pbeta;
% solve for the field points
pfield=((Ap+j*k*rho*c*Bp*diag(Ynodes))*ps./CConst+pIfield).’;
p(:,ff)=pfield;

Plot the sound field


OpenBEM includes the function plotfpoints to map the vector resulting
from the calculations on the grid of Field Points:
plotfpoints(XX,YY,abs(pfield));

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 37 / 44


Interior problems in BEM SPL maps

Mapping the sound pressure in a 2D cavity

The result for two resonance frequencies (f=122.5 and f=129 Hz).

Mode (2,1) Mode(3,0)

SPL  (dB)  
y  (m)  

y  (m)  

x  (m)  

x  (m)  

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 38 / 44


Interior problems in BEM Tasks

Tasks: 2D BEM Calculations

Using the tutorial and the theoretical background given, complete the
tasks:
1 Obtain the Frequency response of the cavity of the example for the data (dimensions,
source position and field points) and frequency range given, using the 2D BEM formulation.
2 Obtain the value of the resonance frequencies. Compare with the theoretical results.
3 Choose two resonances and plot the sound field in the cavity.
4 Identify in the Graphic of the frequency response, the mode shapes for each peak using
the notation mode (nx ,ny ).
5 Modify the geometry and recalculate the frequency response:
1 Keep the dimensions, but change the curvature of one of the segments. Choose two
of the resonances and map the sound pressure inside the cavity.
2 Build and arbitrary polygon with non-parallel sides, recalculate the frequency

response, and compare the mode shapes of the two first resonances with the
resonances of the parallelepiped.

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 39 / 44


Interior problems in BEM Tutorial Resonances 3D

3DBEM

Introduction
Once a geometry has been generated and meshed, it must be imported into Matlab to proceed
with the calculations. In this section the functions related to the post-processing of the mesh, the
calculations (kernel) and the post-processing of the calculations (plotting) are described.

Functions: Preprocessing geometry


We need:
A mesh with all the normal vectors pointing to the same direction.
A compact mesh without holes (missing elements) or meshing errors.
Functions: (type ’help’ in Matlab to learn how to use them)
loadgeom: Import and check files with ’.msh’ format.
read nodes and read elements. Import nodes and elements files from meshes performed
in ANSYS.
meshchech: Processes a geometry, and detects missing elements (holes), detects
different bodies and assign a body number and a normal vector pointing inwards or
outwards the surface of the body (+n exterior problems; −n interior problems; n is the
body number)

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 40 / 44


Interior problems in BEM Tutorial Resonances 3D

3DBEM
Kernel functions
TriQuadEquat . Provides the matrixes A, B and C, to solve the pressure at the nodes (see
eq(14)
points. Provides the matrixes for the calculation of the sound pressure at the field point
calculations.

Example: Calculation of the sound pressure for the mode (1,0,0) of a rectangular cavity, when a
velocity point source placed in a corner of the room.
Lx=4;
fr=c/(2*Lx);
u0=1 % Velocicy of the source
geometry=loadgeom(’box_tutorial.msh’,-1); % Load the box_tutorial file
% Extract the nodes and topology matrix from the structure
topologyb=geometry.topologyb;
nodesb=geometry.nodesb;

M=size(nodesb,1); N=size(topologyb,1);

%---Find the node in the corner:


Dist=sqrt((nodesb(:,1).ˆ2+nodesb(:,2).ˆ2+nodesb(:,3).ˆ2)) % distance to (0,0,0)
[minimum,pos]=min(Dist);
vp=zeros(M,1); vp(pos)=u0; % Place the velocity at the position of the corner.
[A,B,CConst]=TriQuadEquat(nodesb,topologyb,k(ff),nsingON); % Get Matrixes
pp=A\(-j*k*rho*c*B*vp); % Solve the system to get the complex pressure

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 41 / 44


Interior problems in BEM Tutorial Resonances 3D

3DBEM
Kernel functions
TriQuadEquat . Provides the matrixes A, B and C, to solve the pressure at the nodes (see
eq(14)
points. Provides the matrixes for the calculation of the sound pressure at the field point
calculations.

Example: Calculation of the sound pressure for the mode (1,0,0) of a rectangular cavity, when a
velocity point source placed in a corner of the room.
Lx=4;
fr=c/(2*Lx);
u0=1 % Velocicy of the source
geometry=loadgeom(’box_tutorial.msh’,-1); % Load the box_tutorial file
% Extract the nodes and topology matrix from the structure
topologyb=geometry.topologyb;
nodesb=geometry.nodesb;

M=size(nodesb,1); N=size(topologyb,1);

%---Find the node in the corner:


Dist=sqrt((nodesb(:,1).ˆ2+nodesb(:,2).ˆ2+nodesb(:,3).ˆ2)) % distance to (0,0,0)
[minimum,pos]=min(Dist);
vp=zeros(M,1); vp(pos)=u0; % Place the velocity at the position of the corner.
[A,B,CConst]=TriQuadEquat(nodesb,topologyb,k(ff),nsingON); % Get Matrixes
pp=A\(-j*k*rho*c*B*vp); % Solve the system to get the complex pressure

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 41 / 44


Interior problems in BEM Tutorial Resonances 3D

3DBEM
Graphic Functions to plot the geometry and sound pressure
plotgeometry. Plot a geometry with the format ”nodes” and ”elements” matrixes. It allows
to plot as *, the nodes listed in a set of index.
plotresults. Maps the result of the calculation on the surface of the body.
playresults. Shows an animation of the result.

Example: plotgeometry Example plotresults:


>>h=plotgeometry(nodesb,topologyb,index); >>h=plotresults(nodesb,topologyb,real(p));
% Notice the red * on the vertex % Instantaneous sound pressure

x   y  

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 42 / 44


Interior problems in BEM Tutorial Resonances 3D

Theoretical Task: Cavities in 3DBEM


Calculate and fill:
Let us transform the 2D cavity described in the previous task – data 25– into a 3D space with a
height Lz = 2, 7m. Consider the same atmospheric conditions as the example in 2DBEM.
1 Find all the resonance frequencies up to nx = ny = nz = 2 and write the results in the
table 2.
2 Generate a coarse mesh of the body (click once in Gmsh on the 2D mesh button). Import
the mesh into Matlab. Calculate and plot the sound pressure on the boundary for the mode
(2,1,2). Comment the results.
Check how many nodes there are in each edge.
Which is the resolution of the mesh?
Which is the highest frequency which could be calculated with this mesh resolution?
3 Recalculate the results of the previous question, refining the mesh.
4 Mesh and import a cylindrical room with a dome on the top.
Radius of the cylinder and the dome, r= 7 m. Heigth = 3 m. Total
Heigth= 10m. Calculate the resonance frequencies up to the
highest possible frequency (check the resolution of the mesh) and
plot
OpenBEM (U.Vigo) Boundary Element Method 2014/2015 43 / 44
Interior problems in BEM Tutorial Resonances 3D

Results

Table : Resonance Frequencies in 3D, Lx = 4, Ly = 3 Lz = 2, 7 m

nx ny nz fnx ,ny fBEM

OpenBEM (U.Vigo) Boundary Element Method 2014/2015 44 / 44

You might also like