Usage of compute_closest_entity

Hello,

within my code is used the compute_closest_entity() function. When I yesterday updated my dolfinx docker container, I get an error as the function now requires the midpoint_tree of the entities of my mesh. I figured out, that there is the function create_midpoint_tree() but I couldn’t get it to work. Any suggestions how to create the midpoint_tree of a given mesh?

Best wishes,
Maximilian

It looks like the API for this function was changed with this PR.
You can take a look at, e.g., this code to see how to create the midpoint tree.

tree = BoundingBoxTree(mesh, dim)
num_entities_local = mesh.topology.index_map(dim).size_local + mesh.topology.index_map(dim).num_ghosts
entities = numpy.arange(num_entities_local, dtype=numpy.int32)
midpoint_tree = create_midpoint_tree(mesh, dim, entities)

It looks like you just need to pass in the indices of the mesh entities.

2 Likes