diff --git a/tests/conftest.py b/tests/conftest.py index 15ede33..c3d6a82 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -41,6 +41,7 @@ def backend(request): def cluster(): cluster = ipp.Cluster(engines="mpi", n=2) rc = cluster.start_and_connect_sync() + rc.wait_for_engines(n=2) yield rc cluster.stop_cluster_sync() diff --git a/tests/test_legacy_readers.py b/tests/test_legacy_readers.py index 37f083f..f8adf92 100644 --- a/tests/test_legacy_readers.py +++ b/tests/test_legacy_readers.py @@ -14,7 +14,6 @@ import numpy as np import pytest import ufl -from dolfinx.fem.petsc import LinearProblem from io4dolfinx import ( read_cell_data, @@ -110,6 +109,11 @@ def test_legacy_function(backend): f = ufl.conditional(ufl.gt(x[0], 0.5), x[1], 2 * x[0]) L = ufl.inner(f, v) * ufl.dx + if not dolfinx.has_petsc4py: + pytest.skip("dolfinx not configured with PETSc4py") + + from dolfinx.fem.petsc import LinearProblem + uh = dolfinx.fem.Function(V) if "petsc_options_prefix" in inspect.signature(LinearProblem.__init__).parameters.keys(): extra_options = {"petsc_options_prefix": "legacy_test"} @@ -139,6 +143,8 @@ def test_read_legacy_function_from_checkpoint(backend): if not path.exists(): pytest.skip(f"{path} does not exist") + from dolfinx.fem.petsc import LinearProblem + mesh = read_mesh_from_legacy_h5(path, comm, "/Mesh/mesh", backend=backend) V = dolfinx.fem.functionspace(mesh, ("DG", 2)) @@ -149,6 +155,9 @@ def test_read_legacy_function_from_checkpoint(backend): f = ufl.conditional(ufl.gt(x[0], 0.5), x[1], 2 * x[0]) L = ufl.inner(f, v) * ufl.dx + if not dolfinx.has_petsc4py: + pytest.skip("dolfinx not configured with PETSc4py") + uh = dolfinx.fem.Function(V) if "petsc_options_prefix" in inspect.signature(LinearProblem.__init__).parameters.keys(): extra_options = {"petsc_options_prefix": "legacy_checkpoint_test"} diff --git a/tests/test_vtkhdf.py b/tests/test_vtkhdf.py index 566d5bb..968288c 100644 --- a/tests/test_vtkhdf.py +++ b/tests/test_vtkhdf.py @@ -105,7 +105,7 @@ def test_write_point_data(dtype, tmp_path, cell_type): filename=filename, name="u", mesh=grid, time=tj, backend="vtkhdf" ) v_ref = Function(u.function_space, dtype=u.x.array.dtype) - atol = 10 * np.finfo(u.x.array.dtype).eps + atol = 15 * np.finfo(u.x.array.dtype).eps v_ref.interpolate(lambda x: f(x, tj)) np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol) @@ -124,7 +124,7 @@ def test_write_point_data(dtype, tmp_path, cell_type): filename=blocked_file, name="u", mesh=grid, time=tk, backend="vtkhdf" ) v_ref = Function(u.function_space, dtype=u.x.array.dtype) - atol = 10 * np.finfo(u.x.array.dtype).eps + atol = 15 * np.finfo(u.x.array.dtype).eps v_ref.interpolate(lambda x: g(x, tk)) np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol) @@ -160,7 +160,7 @@ def test_write_cell_data(dtype, tmp_path, cell_type): filename=filename, name="u", mesh=grid, time=tj, backend="vtkhdf" ) v_ref = Function(u.function_space, dtype=u.x.array.dtype) - atol = 10 * np.finfo(u.x.array.dtype).eps + atol = 15 * np.finfo(u.x.array.dtype).eps v_ref.interpolate(lambda x: f(x, tj)) np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol) @@ -179,7 +179,7 @@ def test_write_cell_data(dtype, tmp_path, cell_type): filename=blocked_file, name="u", mesh=grid, time=tk, backend="vtkhdf" ) v_ref = Function(u.function_space, dtype=u.x.array.dtype) - atol = 10 * np.finfo(u.x.array.dtype).eps + atol = 15 * np.finfo(u.x.array.dtype).eps v_ref.interpolate(lambda x: g(x, tk)) np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol) @@ -254,7 +254,7 @@ def test_write_meshtags(dtype, tmp_path, generate_reference_map): ) org_maps[dim] = generate_reference_map(mesh, et, comm, root) - tol = 10 * np.finfo(dtype).eps + tol = 15 * np.finfo(dtype).eps # Read in hex grid from second time step hex_mesh = io4dolfinx.read_mesh( filename, comm, time=1.0, backend_args={"name": "hex"}, backend="vtkhdf" @@ -288,7 +288,7 @@ def test_write_meshtags(dtype, tmp_path, generate_reference_map): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) def test_read_write_pointdata(dtype, tmp_path): - tol = 10 * np.finfo(dtype).eps + tol = 15 * np.finfo(dtype).eps comm = MPI.COMM_WORLD tmp_path = comm.bcast(tmp_path, root=0) @@ -360,7 +360,7 @@ def f(x, t): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) def test_read_write_celldata(dtype, tmp_path): - tol = 10 * np.finfo(dtype).eps + tol = 15 * np.finfo(dtype).eps comm = MPI.COMM_WORLD tmp_path = comm.bcast(tmp_path, root=0) @@ -436,7 +436,7 @@ def f(x, t): @pytest.mark.parametrize("dtype", [np.float32, np.float64]) def test_read_write_mix_data(dtype, tmp_path): - tol = 10 * np.finfo(dtype).eps + tol = 15 * np.finfo(dtype).eps mesh = create_unit_square(MPI.COMM_WORLD, 5, 7, dtype=dtype)