Error in tutorial related to fenicsx

Hi everyone,

I want to use Fenicsx together with Bempp to calculate a double-layer potential. When running the tutorial “Simple FEM-BEM coupling for the Helmholtz equation with FEniCSx” I get an error. How I can fix that?

Thanks

import dolfinx
from dolfinx.fem import FunctionSpace, Function
from dolfinx.mesh import create_unit_cube
import dolfinx.geometry
import ufl
from mpi4py import MPI
import bempp.api
import numpy as np

mesh = create_unit_cube(MPI.COMM_WORLD, 10, 10, 10)

from bempp.api.external import fenicsx

fenics_space = FunctionSpace(mesh, ("CG", 1))
trace_space, trace_matrix = \
    fenicsx.fenics_to_bempp_trace_data(fenics_space)
bempp_space = bempp.api.function_space(trace_space.grid, "DP", 0)

fem_size = fenics_space.dofmap.index_map.size_global
bem_size = bempp_space.global_dof_count

print("FEM dofs: {0}".format(fem_size))
print("BEM dofs: {0}".format(bem_size))

The error is:

TypeError                                 Traceback (most recent call last)
Input In [6], in <cell line: 16>()
     12 from bempp.api.external import fenicsx
     14 fenics_space = FunctionSpace(mesh, ("CG", 1))
     15 trace_space, trace_matrix = \
---> 16     fenicsx.fenics_to_bempp_trace_data(fenics_space)
     17 bempp_space = bempp.api.function_space(trace_space.grid, "DP", 0)
     19 fem_size = fenics_space.dofmap.index_map.size_global

File ~/miniconda3/envs/fenics/lib/python3.8/site-packages/bempp/api/external/fenicsx.py:61, in fenics_to_bempp_trace_data(fenics_space)
     59 if family in ["Lagrange", "P"]:
     60     if degree == 1:
---> 61         return p1_trace(fenics_space)
     62 else:
     63     raise NotImplementedError()

File ~/miniconda3/envs/fenics/lib/python3.8/site-packages/bempp/api/external/fenicsx.py:117, in p1_trace(fenics_space)
    114 except AttributeError:
    115     pass
--> 117 for tet, cell_verts in enumerate(tets):
    118     cell_dofs = fenics_space.dofmap.cell_dofs(tet)
    119     for v in range(4):

TypeError: 'dolfinx.cpp.graph.AdjacencyList_int32' object is not iterable

I’ll look into this. Which version of FEniCSx and Bempp are you using?

Hi, I have installed Bempp CL with anaconda (conda install -c conda-forge bempp-cl), The version is v0.3.0. The version of FEniCSx that I use is 0.6.

I think this error should be fixed in Update to work with latest FEniCSx by mscroggs · Pull Request #200 · bempp/bempp-cl · GitHub. I’ll make a new release in the next fews days once I’ve merged this fix.