def test_poly_lookup(): # A simple quad grid nodes = np.array([[0.0,0.0], [0.0,2.0], [2.0,0.0], [2.0,2.0], [4.0,0.0], [4.0,2.0], [6.0,0.0], [6.0,2.0] ]) faces = np.array([[0, 2, 3, 1], [4, 6, 7, 5], ], dtype = np.intc) print(faces) print(faces.dtype) tree = CellTree(nodes, faces, 2, 1) point = np.array([1.,1.]) #in triangle 1 result = tree.find_poly(point) assert result == 0 point[0] = 5.0 # tri 2 result = tree.find_poly(point) assert result == 1 point[0] = -1.0 # out of grid result = tree.find_poly(point) assert result == -1
def test_triangle_lookup(): tree = CellTree(nodes, faces, 2, 1) point = np.array([1.,1.]) #in triangle 1 result = tree.find_poly(point) assert result == 0 point[0] = 2.0 # tri 2 result = tree.find_poly(point) assert result == 1 point[0] = -1.0 # out of grid result = tree.find_poly(point) assert result == -1