Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 10 additions & 1 deletion tests/test_legacy_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import numpy as np
import pytest
import ufl
from dolfinx.fem.petsc import LinearProblem

from io4dolfinx import (
read_cell_data,
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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))
Expand All @@ -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"}
Expand Down
16 changes: 8 additions & 8 deletions tests/test_vtkhdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down