No attribute 'assemble' when using fmm in gmres solver

48 views
Skip to first unread message

xavier vuylsteke

unread,
Sep 1, 2020, 2:36:01 PM9/1/20
to bempp
Hi Bempp team,

I have been following the updates regarding this library for few years now, and first of all thank you very much for the amazing job you have done so far.

I am really excited to see that the FMM is currently implementing into the library, but I encounter an error when trying to use this latter on helmholtz problems (I do not really know if this is the case on other formalisms).

Using the problem provided by the scattering sphere example and trying to assemble the matrices with the FMM formalism as follow:

###############################################
import bempp.api
import numpy as np
from bempp.api.linalg.iterative_solvers import gmres

k = 5.

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

print (grid.number_of_elements)

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

@bempp.api.complex_callable
def combined_data(x, n, domain_index, result):
    result[0] = 1j * k * np.exp(1j * k * x[0]) * (n[0]-1)
    
grid_fun = bempp.api.GridFunction(space, fun=combined_data)

identity = bempp.api.operators.boundary.sparse.identity(space, space, space)
adlp = bempp.api.operators.boundary.helmholtz.adjoint_double_layer(space, space, space, k, assembler='fmm')
slp = bempp.api.operators.boundary.helmholtz.single_layer(space, space, space, k, assembler='fmm')
lhs = 0.5 * identity + adlp - 1j * k * slp

neumann_fun, info = gmres(lhs, grid_fun, tol=1E-5)
#############################################

i get the following error:

AttributeError                            Traceback (most recent call last)
~/scattering.py in <module>
     22 lhs = 0.5 * identity + adlp - 1j * k * slp
     23
---> 24 neumann_fun, info = gmres(lhs, grid_fun, tol=1E-5)
     25
     26

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/linalg/iterative_solvers.py in gmres(A, b, tol, restart, maxiter, use_strong_form, return_residuals, return_iteration_count)
     74             use_strong_form,
     75             return_residuals,
---> 76             return_iteration_count,
     77         )
     78

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/linalg/iterative_solvers.py in _gmres_single_op_imp(A, b, tol, restart, maxiter, use_strong_form, return_residuals, return_iteration_count)
    193         b_vec = b.coefficients
    194     else:
--> 195         A_op = A.weak_form()
    196         b_vec = b.projections(A.dual_to_range)
    197

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/boundary_operator.py in weak_form(self)
     40
     41         if not self._cached:
---> 42             self._cached = self._assemble()
     43
     44         return self._cached

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/boundary_operator.py in _assemble(self)
    160     def _assemble(self):
    161         """Implement the weak form."""
--> 162         return self._op1.weak_form() + self._op2.weak_form()
    163
    164

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/boundary_operator.py in weak_form(self)
     40
     41         if not self._cached:
---> 42             self._cached = self._assemble()
     43
     44         return self._cached

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/boundary_operator.py in _assemble(self)
    160     def _assemble(self):
    161         """Implement the weak form."""
--> 162         return self._op1.weak_form() + self._op2.weak_form()
    163
    164

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/boundary_operator.py in weak_form(self)
     40
     41         if not self._cached:
---> 42             self._cached = self._assemble()
     43
     44         return self._cached

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/boundary_operator.py in _assemble(self)
    136     def _assemble(self):
    137         """Assemble the operator."""
--> 138         return self.assembler.assemble(self.descriptor)
    139
    140

~/anaconda3/envs/bempp/lib/python3.7/site-packages/bempp/api/assembly/assembler.py in assemble(self, operator_descriptor, *args, **kwargs)
     72     def assemble(self, operator_descriptor, *args, **kwargs):
     73         """Assemble the operator."""
---> 74         return self._implementation.assemble(
     75             operator_descriptor,
     76             self._device_interface,

AttributeError: 'NoneType' object has no attribute 'assemble'


I do not know if you (or someone else) have a working example using the exafmm library or if this feature is not fully integrated, but it would be much appreciated if you could help me with it.

For information, I work on the subsystem Linux on W10.

Thanks a lot again and best regards.

Xavier Vuylsteke.

Timo Betcke

unread,
Sep 10, 2020, 2:12:24 PM9/10/20
to bempp
Dear Xavier, 

this error appears if the Python interface of exafmm-t is not installed. We should have created a proper error message for that case. I will include it in the next patch. You can get exafmm-t from github.com/exafmm/exafmm-t. Installation is simple. Just say 'python setup.py install'. We test against the 0.1 release tag. The master branch of exafmm may be further along. Alternatively, we have Docker images that integrate exafmm-t already.

Thanks for your encouragement!

Best wishes

Timo

Timo Betcke

unread,
Sep 14, 2020, 7:22:41 AM9/14/20
to bempp
Dear Xavier,

just to let you know. Based on your report we have patched the error mesage if Exafmm is not present. It is included in Bempp-cl 0.2.1, which we have just pushed to conda-forge.
Thanks again and best wishes

Timo

Reply all
Reply to author
Forward
0 new messages