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
16 changes: 11 additions & 5 deletions python/demo/demo_scattering-boundary-conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions python/test/unit/io/test_adios2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a good change. If we run test_adios2.py it should adios2, and fail if it can't.

We can have a situation where a change could cause in the CI DOLFINx to (silently) not build with ADIOS2. Changes like this one mean the issue is not picked up and we lose test coverage. In tests, skipping should be explicit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADIOS2 is an optional dependency. The test target pytest should give a suitable set of tests to allow for installation verification for any given configuration. If the we have not compiled with adios2 support a test failure due to a missing import or non-available functionality prohibits this.

Verification of having picked up the desired configuration in a CI run is not limited by this change https://github.com/FEniCS/dolfinx/blob/main/.github/workflows/ccpp.yml#L134.

import_adios2 might not have the right behaviour here, as this will skip a check if adios2 support is enabled and the adios2 python module is not available (skipping silently checks for supported functionality). But that was not altered in this PR.



def import_adios2():
adios2 = pytest.importorskip("adios2", minversion="2.10.0")
Expand Down Expand Up @@ -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")
Expand Down
Loading