NiHu
2.0
|
This tutorial demonstrates the usage of NiHu for solving an exterior acoustic scattering problem in 2D by means of a collocational type boundary element method (BEM). The modeled problem is scattering of an incident plane wave from a rigid cylinder of radius \(R_0\), centered at the origin of the 2D coordinate system.
The incident wave field is given as
\( \displaystyle p_{\mathrm{inc}}({\bf x}) = \exp(-\mathrm{i}k {\bf x} \cdot {\bf d}) \)
where \( {\bf d} \) denotes the unit direction vector of propagation. The scattering is considered as superposing a reflected field to the incident pressure field so that the sum of the two fields results a zero velocity on the scatterer surface:
\( \displaystyle p_{\mathrm{tot}}({\bf x}) = p_{\mathrm{inc}}({\bf x}) + p_{\mathrm{ref}}({\bf x}) \\ p'_{\mathrm{tot}}({\bf x}) = 0 \quad {\bf x} \in S \)
This consideration results in the Neumann boundary condition to the reflected wave field:
\( \displaystyle p'_{\mathrm{ref}}({\bf x}) = -p'_{\mathrm{inc}}({\bf x}) \quad {\bf x} \in S \)
The problem is easily formulated with conventional BEM operator notations:
\( \displaystyle q_{\mathrm{ref}} = -p'_{\mathrm{inc}}, \quad {\bf x} \in S, \\ \frac{1}{2} p_{\mathrm{ref}}({\bf x}) = \left(\mathcal{M}p_{\mathrm{ref}}\right)_S({\bf x}) - \left(\mathcal{L}q_{\mathrm{ref}}\right)_S({\bf x}), \quad {\bf x} \in S, \\ p_{\mathrm{ref}}({\bf x}) = \left(\mathcal{M}p_{\mathrm{ref}}\right)_S({\bf x}) - \left(\mathcal{L}q_{\mathrm{ref}}\right)_S({\bf x}), \quad {\bf x} \in F \)
and can be discretised using either collocation or Galerkin formalisms.
We are going to implement a Matlab-C++ NiHu application, where
The C++ code is going to be called from Matlab as
[Ls, Ms, Lf, Mf] = helmholtz_bem_2d_cyl(... surf_nodes, surf_elements, field_nodes, field_elements, wave_number);
Ms
will contain the discretised identity operator too, as required by the conventional BEM formalisms.The header of our C++ source file includes the necessary header files and defines some basic types for convenience. We further include library/helmholtz_singular_integrals.hpp that defines the specialised singular integrals of the Helmholtz kernel for constant lines.
Two meshes will be created, both meshes contain line elements only:
surf_mesh
)field_mesh
)Next, we create the discretised function spaces of our mesh. The definitions are straightforward, as only constant line boundary elements are dealt with. For the definition of the field point function space, we immediately apply the dirac view.
The number of degrees of freedom on the radiating cylinder \( S \) and in the field mesh \( F \) are denoted by \( n \) and \( m \), respectively. After the function spaces are built, the number of DOFs are known, and the memory for the system matrices can be preallocated. The surface system matrices \( \mathbf{L}_s \), \( \mathbf{M}_s \) are of size \( n \times n \), whereas the matrices describing the field point radiation \( \mathbf{L}_f \) and \( \mathbf{M}_f \) are of size \( m \times n \). The four system matrices are preallocated by means of the following lines of code.
In the next steps, the three integral operators \( \mathcal{L} \), \( \mathcal{M} \), and \( \mathcal{I} \) are defined. Since the kernel functions depend on the wave number \( k \), which is passed as the fifth right hand side parameter of the mex function, the integral operators are created as follows.
Finally, the system matrices are obtained by the evaluation of the integral operators on the function spaces defined above. Note that as a collocational formalism is applied, the Dirac-view of the test function spaces is taken for the boundary integrals.
The example creates a sphere surface of radius \( R = 1\,\mathrm{m} \) centred at the origin, consisting of triangular elements only. The CHIEF points are located on the surface of a cube, shifted from the origin.
The Neumann boundary conditions are defined by a point source located at the point \( \mathbf{x}_0 \). By this definition the geometry is considered transparent, and the resulting acoustic fields on \( S \) are obtained as the acoustic field of the point source.
The compiled mex file can be called from Matlab, as demonstrated in the example below:
The generated plot looks like
And the resulting errors read as
Log10 mean error: -2.484395
The full codes of this tutorial are available here: