Restrict : incompatible function arguments

Hi,

I’m trying to create virtual probes to get the value of the solution at a given coordinate (not necesseraly on a node).

So far I was just looking at the value of the closest node but I want to be more precise by using the restrict function. But I get this error and can’t figure out how to solve it:

TypeError: restrict(): incompatible function arguments. The following argument types are supported:

  1. (self: dolfin.cpp.function.Function, arg0: float, arg1: dolfin::FiniteElement, arg2: dolfin::Cell, arg3: float, arg4: dolfin.cpp.function.ufc_cell) → None

Invoked with: <dolfin.cpp.function.Function object at 0x7fcd0fd372d0>, array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]), <dolfin.cpp.fem.FiniteElement object at 0x7fcd0fd37228>, <dolfin.cpp.mesh.Cell object at 0x7fcd0fd375e0>, [0.625000000001214, -1.0, 0.5833333333348364, -1.0, 0.6032837911524445, -0.9588620043877216], <dolfin.cpp.mesh.Cell object at 0x7fcd0fd375e0>

Here is my function call:

w.restrict(coefficients, element, cell, vertex_coords, cell)

With:

element = w.function_space().dolfin_element()
coefficients = np.zeros(element.space_dimension())
cell = Cell(mesh, cell_id)
vertex_coords = cell.get_vertex_coordinates()

Here is the full code of the class init:

def __init__(self, w, locations):
   mesh = w.function_space().mesh()
   limit = mesh.num_entities(mesh.topology().dim())
   bbox_tree = mesh.bounding_box_tree()

   cells_for_x = [None]*len(locations)
   for i, x in enumerate(locations):
       cell = bbox_tree.compute_first_entity_collision(Point(*x))
       if -1 < cell < limit:
           cells_for_x[i] = cell

   V = w.function_space()
   element = V.dolfin_element()

   size = V.ufl_element().value_size()
   evals = []
   for x, cell in zip(locations, cells_for_x):
       if cell is not None:
           basis_matrix = np.zeros(size*element.space_dimension())
           coefficients = np.zeros(element.space_dimension())

           cell = Cell(mesh, cell)

           vertex_coords, orientation = cell.get_vertex_coordinates(), cell.orientation()
           basis_matrix = element.evaluate_basis_all(x, vertex_coords, orientation)

           basis_matrix = basis_matrix.reshape((element.space_dimension(), size)).T

           def val(w, c = coefficients, ele = element, A = basis_matrix, cell = cell, vc = vertex_coords):
               w.restrict(c, ele, cell, vc, cell)
               return np.dot(A, c)
       else:
           val = lambda w, size=size: (np.finfo(float).max)*np.ones(size)

       evals.append(val)