# Calculate the double-layer potential using a function obtained from fenicsx

**URL:** https://bempp.discourse.group/t/calculate-the-double-layer-potential-using-a-function-obtained-from-fenicsx/268
**Category:** Uncategorized
**Created:** [5 June 2024 00:49 UTC](https://bempp.discourse.group/t/calculate-the-double-layer-potential-using-a-function-obtained-from-fenicsx/268 "2024-06-05T00:49:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mk2020](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@Mk2020](https://bempp.discourse.group/u/Mk2020)
#### Post date: [5 June 2024 00:49 UTC](https://bempp.discourse.group/t/calculate-the-double-layer-potential-using-a-function-obtained-from-fenicsx/268/1 "2024-06-05T00:49:03Z")

</div>

Hi,

I have computed a flow using fenicsx and would like to utilize Bempp to calculate the BEM component. Although I have reviewed the example, I still find the process unclear.

Basically, I would like to calculate the integral

I = \int\_{\partial S} \Phi \frac{\partial}{\partial n} \frac{1}{|r-r'|}dr,

where this integral is evaluated at the boundary of the body and \Phi is a scalar field calculated with fenicsx.

In fenicsx I defined:

mesh = dolfinx.mesh.create\_box(MPI.COMM\_WORLD, [np.array([0,0,0]), np.array([20, 20, 2])], [10,10,2])  
V = functionspace(mesh, (“Lagrange”, 1, (mesh.geometry.dim,)))

problem = fem.petsc.LinearProblem(a, L, petsc\_options={“ksp\_type”: “preonly”})  
PHI = problem.solve()

In Bempp:

trace\_space, trace\_matrix = fenicsx.fenics\_to\_bempp\_trace\_data(V)  
bempp\_space = bempp.api.function\_space(trace\_space.grid, “DP”, 0)

dlp = bempp.api.operators.boundary.laplace.double\_layer(trace\_space, bempp\_space,bempp\_space)

How should I continue?

thanks.

---

<div class="post-metadata">

### Author: ![Elwin](https://yyz2.discourse-cdn.com/free1/user_avatar/bempp.discourse.group/elwin/32/38_2.png) [@Elwin](https://bempp.discourse.group/u/Elwin)
#### Post date: [12 June 2024 20:44 UTC](https://bempp.discourse.group/t/calculate-the-double-layer-potential-using-a-function-obtained-from-fenicsx/268/2 "2024-06-12T20:44:58Z")

</div>

The integral I you like to evaluate is called the double-layer operator. You need to be careful and distinguish between the double-layer _boundary_ operator and the double-layer _potential_ operator.

If, in your notation, the location r' is outside the surface \partial S and \Phi is a known Dirichlet potential on \partial S, you can use the function `bempp.api.operators.potential.laplace.double_layer()`. See, for example, the variable `dlp_pot` in the FEM-BEM tutorial.

If the location r' is really on the surface \partial S, you need to handle the singularity in the Green’s function. This is usually dealt with by singular integration for the weak form of the operator, and provided in the function `bempp.api.operators.boundary.laplace.double_layer()`. However, this is a matrix with elements that correspond to cross-interactions between dofs on the surface. The variable \Phi is an unknown here and needs to be included in your model. See the variable `dlp` in the FEM-BEM tutorial, representing the operator K in the system matrix.

I hope this helps you forward.
