Evaluate function at point in dolfinx

How to compute value of function u at a specific point (other than the finite element node)

I tried the following:

# set up mesh, space and weak form etc before this...
u = Function(V)
solve(a==L,u,[] )
bbtree = BoundingBoxTree(mesh, 3)
#let us say, i want to evaluate u at point (0,0,0)
point = np.array([0.,0.,0.])
# and then store the output in 'result':
result = np.array([0.])
u.eval(result,point,bbtree)

But dolfinx does not like this and ends up in:

u.eval(result,point,bbtree)
*** TypeError: eval(): incompatible function arguments. The following argument types are supported:
1. (self: dolfin.cpp.function.Function, arg0: numpy.ndarray[complex128[m, n], flags.writeable, flags.c_contiguous], arg1: numpy.ndarray[float64[m, n], flags.c_contiguous], arg2: dolfin::mesh::Cell) -> None
2. (self: dolfin.cpp.function.Function, values: numpy.ndarray[complex128[m, n], flags.writeable, flags.c_contiguous], x: numpy.ndarray[float64[m, n], flags.c_contiguous], bb_tree: dolfin::geometry::BoundingBoxTree) -> None

Invoked with: <dolfin.cpp.function.Function object at 0x7efdaf962538>, array([ 0.]), array([ 0., 0., 0.]), <dolfin.geometry.BoundingBoxTree object at 0x7efda7a1ce80>

I don’t understand how both the first and second arguments are mxn arrays. If I want to compute value of u at a single point, shouldn’t the size of values be 1x1 and that for x be 3x1 in 3D and 2x1 in 2D. What am i doing wrong here? I am using the complex dolfinx from image: quay.io/fenicsproject/dolfinx:complex. Thanks in advance.

Perhaps you need to change the dtype of the np.array to be complex128? Usually when this type of error message comes up, it is due to a type mismatch. I am not sure about the mxn array, but again, you could try point = np.array([[0.,0.,0.]]) if it really wants a 2D array.