Skip to content

Commit 087d12b

Browse files
committed
add changing tolerance test
1 parent be2d898 commit 087d12b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/firedrake/regression/test_point_eval_api.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,24 @@ def test_point_evaluator_moving_mesh(mesh_and_points):
261261
mesh.coordinates.dat.data[:, 0] -= 1.0
262262
f_at_points = evaluator.evaluate(f)
263263
assert np.allclose(f_at_points, [0.2, 0.4, 0.6])
264+
265+
266+
def test_point_evaluator_tolerance():
267+
mesh = UnitSquareMesh(1, 1)
268+
old_tol = mesh.tolerance
269+
f = Function(VectorFunctionSpace(mesh, "CG", 1)).interpolate(SpatialCoordinate(mesh))
270+
ev = PointEvaluator(mesh, [[0.2, 0.4]])
271+
assert np.allclose([0.2, 0.4], ev.evaluate(f))
272+
# tolerance of mesh is not changed
273+
assert mesh.tolerance == old_tol
274+
# Outside mesh, but within tolerance
275+
ev = PointEvaluator(mesh, [[-0.1, 0.4]], tolerance=0.2)
276+
assert np.allclose([-0.1, 0.4], ev.evaluate(f))
277+
# tolerance of mesh is changed
278+
assert mesh.tolerance == 0.2
279+
# works if mesh tolerance is changed
280+
mesh.tolerance = 1e-11
281+
with pytest.raises(VertexOnlyMeshMissingPointsError):
282+
ev.evaluate(f)
283+
ev = PointEvaluator(mesh, [[-1e-12, 0.4]])
284+
assert np.allclose([-1e-12, 0.4], ev.evaluate(f))

0 commit comments

Comments
 (0)