Compute_collisions incompatible function arguments

I’m in dolphin-x 0.3.0 and I’m trying to plot a solution over a line following this example.

After computing the solution U I have, the lines:


y = np.linspace(0,Ly,Ny)

points = np.zeros([Ny,3])
points[:,1] = y

bb_tree = geometry.BoundingBoxTree(mesh, mesh.topology.dim)
cells = []
points_on_proc = []
# Find cells whose bounding-box collide with the the points
#cell_candidates = geometry.compute_collisions(bb_tree, points)
cell_candidates = geometry.compute_collisions(bb_tree, [[0.,0.,0.]])

(It fails in the same way in the commented version). The error message I get is:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_30380/517046611.py in <module>
      9 # Find cells whose bounding-box collide with the the points
     10 #cell_candidates = geometry.compute_collisions(bb_tree, points)
---> 11 cell_candidates = geometry.compute_collisions(bb_tree, [[0.,0.,0.]])
     12 
     13 # Choose one of the cells that contains the point

TypeError: compute_collisions(): incompatible function arguments. The following argument types are supported:
    1. (arg0: dolfinx::geometry::BoundingBoxTree, arg1: dolfinx::geometry::BoundingBoxTree) -> List[List[int[2]]]
    2. (arg0: dolfinx::geometry::BoundingBoxTree, arg1: List[float[3]]) -> numpy.ndarray[numpy.int32]

Invoked with: [0 0 0 ]->[0.01 0.1 0 ]
{[0 0 0 ]->[0.01 0.05 0 ]
{[0 0 0 ]->[0.01 0.025 0 ]
{[0 0 0 ]->[0.01 0.015 0 ]
{[0 0 0 ]->[0.01 0.01 0 ]
{[0 0 0 ]->[0.005 0.01 0 ]
{[0 0 0 ]->[0.005 0.005 0 ]
leaf containing entity (4), 
[0 0.005 0 ]->[0.005 0.01 0 ]
leaf containing entity (8)}
, 
[0 0 0 ]->[0.01 0.005 0 ]
{[0 0 0 ]->[0.005 0.005 0 ]
leaf containing entity (2), 
[0.005 0 0 ]->[0.01 0.005 0 ]
{[0.005 0 0 ]->[0.01 0.005 0 ]
leaf containing entity (1), 
[0.005 0 0 ]->[0.01 0.005 0 ]
leaf containing entity (0)}
}
}
...
...
...
, 
[0 0.09 0 ]->[0.01 0.1 0 ]
{[0 0.09 0 ]->[0.01 0.1 0 ]
{[0 0.09 0 ]->[0.005 0.095 0 ]
leaf containing entity (76), 
[0.005 0.095 0 ]->[0.01 0.1 0 ]
leaf containing entity (77)}
, 
[0 0.095 0 ]->[0.01 0.1 0 ]
{[0 0.095 0 ]->[0.005 0.1 0 ]
leaf containing entity (79), 
[0 0.095 0 ]->[0.01 0.1 0 ]
{[0 0.095 0 ]->[0.005 0.1 0 ]
leaf containing entity (78), 
[0.005 0.095 0 ]->[0.01 0.1 0 ]
leaf containing entity (75)}
}
}
}
}
}
}
, [[0.0, 0.0, 0.0]]

I cuted the output representing the whole BoundingBoxTree that I passed for ease of reading.

The error message explains the proper arguments:

Usage 2 requires a BoundingBoxTree and a list of three floats, i.e. the coordinates of a single point. You have passed a list of lists, which is not a valid usage for v0.3.0. (See the definitions of the two valid call signatures for compute_collisions here.) The tutorial is for v0.4, where it is valid to pass a list of points.

1 Like

Thank you very much, I was suspecting something around that but looking the wrong documentation fooled me.

1 Like