NiHu
2.0
|
In this example we compute the acoustic field radiated by a set of 2D acoustic monopoles. This problem involves the evaluation of the 2d Helmholtz kernel between source and receiver locations and adding the sources' contributions. We solve this matrix multiplication by means of the wideband fast multipole method for the 2D Helmholtz kernel.
The below sections present the full code needed to compute the MVP (matrix vector product).
A few types are defined first fo convenience, including the cluster type, cluster tree type and physical location type.
We define random source and receiver locations:
A cluster tree is built that contains all the source and receiver nodes. The clusters are divided until they contain less than 10 nodes.
We initialize further data structures needed to compute the fmm operators. This is done by initializing the fmm object, and initializing its level data vector using the cluster tree. The level data vector is attached to the tree by linking the appropriate level data structures to each cluster.
We get the fmm operators from the fmm object, and combine them into a collection for later convenience. Two functors are defined, first to assign the nodes and the cluster tree to the operators, and a second to assign the interaction lists to them.
Using the two functors, all the fmm operators are easily indexed and precomputed.
Finally, an fmm matrix is instantiated from the precomputed operators, a source vector is allocated, and the response is computed by simple matrix vector product.