From c560eb5c818b399a2baea82736acc6a571526beb Mon Sep 17 00:00:00 2001 From: Musawer Ahmad Saqif Date: Tue, 30 Jun 2026 14:28:04 -0600 Subject: [PATCH] Skip ADIOS2 test before importing VTXWriter --- .../demo/demo_scattering-boundary-conditions.py | 16 +++++++++++----- python/test/unit/io/test_adios2.py | 6 ++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/python/demo/demo_scattering-boundary-conditions.py b/python/demo/demo_scattering-boundary-conditions.py index dff94e4b460..a29db12f16e 100644 --- a/python/demo/demo_scattering-boundary-conditions.py +++ b/python/demo/demo_scattering-boundary-conditions.py @@ -47,7 +47,7 @@ import ufl from basix.ufl import element -from dolfinx import default_real_type, default_scalar_type, fem, io, plot +from dolfinx import default_real_type, default_scalar_type, fem, has_adios2, io, plot from dolfinx.fem.petsc import LinearProblem try: @@ -655,8 +655,11 @@ def curl_2d(f: fem.Function): assert isinstance(Esh, fem.Function) Esh_dg.interpolate(Esh) -with io.VTXWriter(mesh_data.mesh.comm, out_folder / "Esh.bp", Esh_dg) as vtx: - vtx.write(0.0) +if has_adios2: + with io.VTXWriter(mesh_data.mesh.comm, out_folder / "Esh.bp", Esh_dg) as vtx: + vtx.write(0.0) +else: + print("VTXWriter is unavailable, Esh.bp will not be saved.") # - # We visualize the solution using PyVista. For more information about @@ -694,8 +697,11 @@ def curl_2d(f: fem.Function): E.x.array[:] = Eb.x.array[:] + Esh.x.array[:] E_dg = fem.Function(V_dg) E_dg.interpolate(E) -with io.VTXWriter(mesh_data.mesh.comm, "E.bp", E_dg) as vtx: - vtx.write(0.0) +if has_adios2: + with io.VTXWriter(mesh_data.mesh.comm, "E.bp", E_dg) as vtx: + vtx.write(0.0) +else: + print("VTXWriter is unavailable, E.bp will not be saved.") # - # We validate our numerical solution by computing the absorption, diff --git a/python/test/unit/io/test_adios2.py b/python/test/unit/io/test_adios2.py index aeeb526a0c6..1387c311096 100644 --- a/python/test/unit/io/test_adios2.py +++ b/python/test/unit/io/test_adios2.py @@ -14,11 +14,13 @@ import ufl from basix.ufl import element -from dolfinx import default_real_type +from dolfinx import default_real_type, has_adios2 from dolfinx.fem import Function, functionspace from dolfinx.graph import adjacencylist from dolfinx.mesh import CellType, create_mesh, create_unit_cube, create_unit_square +pytestmark = pytest.mark.skipif(not has_adios2, reason="DOLFINx has been built without ADIOS2") + def import_adios2(): adios2 = pytest.importorskip("adios2", minversion="2.10.0") @@ -251,9 +253,9 @@ def test_vtx_reuse_mesh(self, tempdir, dim, simplex, reuse): def test_dg_0_data(self, tempdir): """Test that we can mix DG-0 and other Lagrange functions.""" + adios2 = import_adios2() from dolfinx.io import VTXWriter - adios2 = import_adios2() mesh = generate_mesh(2, False) v = Function(functionspace(mesh, ("Lagrange", 2, (2,)))) filename = Path(tempdir, "v.bp")