def test_compute_closest_entity_3d(): reference = (0, 0.1) p = numpy.array([0.1, 0.05, -0.1]) mesh = UnitCubeMesh(MPI.comm_world, 8, 8, 8) tree = BoundingBoxTree(mesh, mesh.topology.dim) entity, distance = tree.compute_closest_entity(p, mesh) assert entity == reference[0] assert round(distance - reference[1], 7) == 0
def test_compute_closest_entity_2d(): reference = (1, 1.0) p = numpy.array([-1.0, 0.01, 0.0]) mesh = UnitSquareMesh(MPI.comm_world, 16, 16) tree = BoundingBoxTree(mesh, mesh.topology.dim) entity, distance = tree.compute_closest_entity(p, mesh) assert entity == reference[0] assert round(distance - reference[1], 7) == 0