Plotting grids and grid functions

Within Bempp, grids and grid functions be visualised using Gmsh, ParaView or three.js.

By default, Gmsh is used for visualisations. If you want to use ParaView, you can set

bempp.api.PLOT_BACKEND = "paraview"

In order to plot using Gmsh or ParaView, you must have Gmsh or ParaView installed on your system. Installation instructions can be found here and here.

If you are running an IPython notebook, you should set

bempp.api.PLOT_BACKEND = "ipython_notebook"

This will allow you to plot grids and functions within an IPython notebook using three.js.


Once you have set Bempp to use the correct plotting backend, you may plot a grid or grid function as in the following examples.

grid = bempp.api.shapes.regular_sphere(3)

grid = bempp.api.shapes.regular_sphere(5)
space = bempp.api.function_space(grid, "DP", 1)
def fun(x, normal, domain_index, result):    
    result[0] = np.exp(1j * x[0])
grid_fun = bempp.api.GridFunction(space, fun=fun)