Hello everyone,
When using version Bempp3.3.4 to solve the scattering field of a cube, I encountered ‘nan’ values in the computed scattered electric field on the surface. However, when running the following code multiple times:
points_values = -ME*sol
num_nan = np.sum(np.isnan(points_values)) print(num_nan)
the number of ‘nan’ values varies each time, and I am unsure why this occurs. I hope someone can provide a solution to this issue. In the latest version, bempp-cl 0.4.2, this ‘nan’ problem does not occur, but it lacks the feature for local mesh refinement (I mainly need the local mesh refinement functionality. Can bempp-cl0.4.2 achieve this, or can it be implemented through other packages?). Therefore, I would greatly appreciate it if anyone knows how to resolve this problem. The specific code is as follows.
import bempp.api
import numpy as np
from bempp.api.operators.boundary import maxwell
from bempp.api.operators.boundary.sparse import identity as ident
polarization = np.array([1.0, 0, 0.0])
direction = np.array([0.0, 0, 1.0])
def incident_field(point):return polarization * np.exp(1j * k * np.dot(point, direction))
@bempp.api.complex_callable#(jit=False)
def tangential_trace(point, n, domain_index, result):
value = polarization * np.exp(1j * k * np.dot(point, direction))
result[:] = np.cross(value, n)
grid = bempp.api.shapes.cube(length=1, origin=(0, 0, 0), h=0.1)
grid.plot()
rwg_space = bempp.api.function_space(grid, “RWG”, 0)
snc_space = bempp.api.function_space(grid, “SNC”, 0)
Id = ident(rwg_space, rwg_space, snc_space)
tan_inc = bempp.api.GridFunction(rwg_space, fun = tangential_trace, dual_space = snc_space)
E = maxwell.electric_field(rwg_space, rwg_space, snc_space, k)
H = maxwell.magnetic_field(rwg_space, rwg_space, snc_space, k)
vertices = grid.leaf_view.vertices
elements = grid.leaf_view.elements
points = vertices[:, elements[ 1 , : ]]
points = ( vertices[:, elements[ 0 , : ]] + vertices[:, elements[ 1 , : ]] +
vertices[:, elements[ 2 , : ]] ) / 3
ME = bempp.api.operators.potential.maxwell.electric_field(rwg_space, points, k)
points_values = -ME*sol
num_nan = np.sum(np.isnan(points_values))
print(num_nan)
The number of NaN is different each time.

