def test_distance_interval(): mesh = UnitIntervalMesh(MPI.comm_self, 1) cell = Cell(mesh, 0) assert round(cell.distance(Point(-1.0)) - 1.0, 7) == 0 assert round(cell.distance(Point(0.5)) - 0.0, 7) == 0
def test_distance_interval(): mesh = UnitIntervalMesh(MPI.comm_self, 1) cell = Cell(mesh, 0) assert round(cell.distance(numpy.array([-1.0, 0, 0])) - 1.0, 7) == 0 assert round(cell.distance(numpy.array([0.5, 0, 0])) - 0.0, 7) == 0
def test_distance_triangle(): mesh = UnitSquareMesh(MPI.comm_self, 1, 1) cell = Cell(mesh, 1) assert round(cell.distance(Point(-1.0, -1.0)) - numpy.sqrt(2), 7) == 0 assert round(cell.distance(Point(-1.0, 0.5)) - 1, 7) == 0 assert round(cell.distance(Point(0.5, 0.5)) - 0.0, 7) == 0
def test_distance_tetrahedron(): mesh = UnitCubeMesh(MPI.comm_self, 1, 1, 1) cell = Cell(mesh, 5) assert round(cell.distance(Point(-1.0, -1.0, -1.0)) - numpy.sqrt(3), 7) == 0 assert round(cell.distance(Point(-1.0, 0.5, 0.5)) - 1, 7) == 0 assert round(cell.distance(Point(0.5, 0.5, 0.5)) - 0.0, 7) == 0