Bempp (formerly known as BEM++) is a computational boundary element platform to solve electrostatic, acoustic and electromagnetic problems. Features include:

  • Easy-to-use Python interface
  • Support for triangular surface meshes
  • Import and export in the Gmsh format
  • Easy formulation of acoustic and electromagnetic transmission problems
  • Built-in fast hierarchical matrix compression techniques
  • Shared memory and MPI parallelisation
  • FEM/BEM computations via interfaces to FEniCS
  • Docker images for easy installation on Windows, Mac and Linux

Getting started with Bempp

Before continuing, you need to download Bempp. Once you have done this launch an IPython session or notebook.

First, you need to import Bempp. Bempp is split into two parts: bempp.api and bempp.core. bempp.api contains the library’s Python functionality and bempp.core contains the interfaces to the fast C++ computational kernel. As you user you (almost certainly) want to begin by importing bempp.api:

import bempp.api

Next, you need to build a grid on which to solve your problem. In this example, we will use a sphere. The second line will launch a Gmsh window showing the grid, as shown below the code snippet (if you are using a notebook, this functionality is not yet available). More information about grids can be found in the grids tutorial.

grid = bempp.api.shapes.sphere(h=0.3)

Next, you need to build a function space on the grid. In this case, we use piecewise constant polynomials: ie order 0 discontinuous polynomials (DP). Details of other available spaces can be found in the spaces tutorial.

space = bempp.api.function_space(grid, “DP”, 0)

Next, you can build boundary operators using the spaces you have defined. Below, we construct a Laplace single layer boundary operator. Details of operator functionality can be found in the operator concepts and the available operators tutorials.

slp = bempp.api.operators.boundary.laplace.single_layer(space, space, space)

Next, you can construct a grid function containing your right-hand-side data. Here we use a Python function to construct our grid function. More details can be found in the grid functions tutorial.

def f(x, n, domain_index, result):
    result[0] = x[0] + 1

rhs = bempp.api.GridFunction(space, fun=f)

Now that you have constructed all the necessary objects, you are ready to solve the discretised problem. In this case, we use bempp.api.linalg.gmres to solve the problem. More details of available solvers can be found in the solving linear systems tutorial.

sol, info = bempp.api.linalg.gmres(slp, rhs)

Finally, you can launch a Gmsh window showing the solution:


A list of further documentation and tutorials can be found on the documentation page.