def test_compute_collisions_point_1d():

    reference = {1: set([4])}

    p = numpy.array([0.3, 0, 0])
    mesh = UnitIntervalMesh(MPI.comm_world, 16)
    for dim in range(1, 2):
        tree = BoundingBoxTree(mesh, mesh.topology.dim)
        entities = tree.compute_collisions_point(p)
        assert set(entities) == reference[dim]
def test_compute_collisions_point_2d():

    #    reference = {1: set([226]),
    #                 2: set([136, 137])}

    p = numpy.array([0.3, 0.3, 0.0])
    mesh = UnitSquareMesh(MPI.comm_world, 16, 16)
    for dim in range(1, 3):
        tree = BoundingBoxTree(mesh, mesh.topology.dim)
        entities = tree.compute_collisions_point(p)
        for e in entities:
            ent = MeshEntity(mesh, dim, e)
            mp = ent.midpoint()
            x = (mp[0], mp[1])
            print("test: {}".format(x))
def test_compute_collisions_point_3d():

    reference = {
        1: set([1364]),
        2: set([1967, 1968, 1970, 1972, 1974, 1976]),
        3: set([876, 877, 878, 879, 880, 881])
    }

    p = numpy.array([0.3, 0.3, 0.3])
    mesh = UnitCubeMesh(MPI.comm_world, 8, 8, 8)
    tree = BoundingBoxTree(mesh, mesh.topology.dim)
    for dim in range(1, 4):
        entities = tree.compute_collisions_point(p)

        # FIXME: Face and edges tests are excluded because test
        # mistakingly relies on the face and edge indices
        tdim = mesh.topology.dim
        if dim != tdim - 1 and dim != tdim - 2:
            assert set(entities) == reference[dim]