Skip to content

Replace io4dolfinx.compat with fenicsx-compat - #87

Merged
jorgensd merged 2 commits into
mainfrom
finsberg/fenicsx-compat
Oct 21, 2026
Merged

jorgensd merged 2 commits into
mainfrom
finsberg/fenicsx-compat

Conversation

@finsberg

@finsberg finsberg commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Moves io4dolfinx's DOLFINx cross-version workarounds to fenicsx-compat, as was done for scifem. It also fixes the 10 tests that fail on DOLFINx nightly on main.

Important

Depends on fenicsx-compat>=0.3.0.

Migration

  • io4dolfinx.compat removed. The following now come from fenicsx_compat:
    • cmap, dofmap
    • cell permutation info
    • index map creation and unwrapping
    • index_to_dest_ranks, which always returns (ranks, offsets), so the AdjacencyList/tuple branching in writers.py is gone.
  • Inline duplicates replaced:
    • mesh creation with a ghost mode in read_mesh
    • the C++ finite element constructor
    • reconstruct_mesh (still deprecated)
    • the PyVista snake_case setting (4 places)
    • the ADIOS2 scope
  • Dead pre-0.10 branches removed, each checked against the DOLFINx v0.10.0 sources:
    • the block_size element constructor
    • the value_shape FunctionSpace constructor
    • create_mesh without max_facet_to_cell_links
    • element.signature() as a method
    • the petsc_options_prefix probe in the legacy reader tests
  • Closure dofs per entity are now len(layout.entity_closure_dofs(dim, 0)). That is the value num_entity_closure_dofs gave on 0.10/0.11, and it exists on every version. DOLFINx main removed num_entity_closure_dofs.
  • Dependencies: fenicsx-compat>=0.3.0 is added and packaging moves to the test group, since only the tests still use it.
  • README: the claim of v0.9.0 support (already ruled out by the >=0.10.0 floor) is gone, and the README now points to fenicsx-compat.

Nightly fixes

Failing tests on main Cause Fix
6 × test_vtkhdf.py: "VTK hexahedra need at least 8 nodes" FEniCS/dolfinx#4621: get_vtk_cell_type takes the node count, not the dimension fenicsx_compat.vtk_cell_type(cell_type, num_dofs_per_cell)
2 × test_manifold_hcurl_roundtrips_but_transfer_raises[*-RT] FEniCS/dolfinx#4625: RT on a manifold needs facet orientations the test calls fenicsx_compat.create_facet_orientations before creating the spaces
2 × test_submesh_roundtrip_codim0_vector[*-2-RT]: error 9.4e-7 vs 1e-13 The test reference field contained sin, which isn't in RT2. On nightly, interpolating it into RT2 gives dofs that differ by about 1e-6 between mesh numberings. The reference vector field is now linear, so it lies in RT2

The last one is a test bug, not an I/O bug. Outside the suite, the RT2 function read back from file has the same norm (to 15 digits) and the same L2 error against the exact field as the one written. With a field that lies in the space, the re-interpolated DOFs match to 1e-16.

Testing

Run locally against DOLFINx 0.12.0.dev0:

main this branch
serial 2466 passed, 10 failed 2476 passed, 24 skipped
mpirun -n 2 2090 passed, 10 failed 2100 passed, 400 skipped
mpirun -n 3 — 2100 passed, 400 skipped
  • pre-commit run --all-files and mypy (in the DOLFINx environment, as CI runs it) are clean.
  • Not run locally: the stable leg, and the legacy-data tests, which need data generated with legacy DOLFIN.

🤖 Generated with Claude Code

Cross-version DOLFINx workarounds now come from fenicsx-compat
(>=0.3.0), which centralises them for io4dolfinx, scifem and
dolfinx-adjoint.

- io4dolfinx.compat is removed. cmap, dofmap, cell permutations, index
  map creation and unwrapping, and index_to_dest_ranks come from
  fenicsx_compat. index_to_dest_ranks always returns (ranks, offsets)
  there, so the AdjacencyList/tuple branching in writers.py goes.
- Inline duplicates are replaced too: mesh creation with a ghost mode
  in read_mesh, the C++ finite element constructor, reconstruct_mesh
  (still deprecated), the PyVista snake_case setting and the ADIOS2
  scope.
- Branches that cannot run on DOLFINx >= 0.10 become plain DOLFINx
  calls, checked against the v0.10.0 sources: the block_size element
  constructor, the value_shape FunctionSpace constructor, the
  create_mesh call without max_facet_to_cell_links, the
  element.signature() call and the petsc_options_prefix probe in the
  legacy reader tests.
- The number of closure dofs of an entity is taken as
  len(entity_closure_dofs(dim, 0)), which is what
  num_entity_closure_dofs returned on 0.10 and 0.11, and which exists on
  every version. DOLFINx main removed num_entity_closure_dofs.

Fixes for the 10 tests that fail on DOLFINx nightly on main:

- The VTKHDF backend gets its cell type from
  fenicsx_compat.vtk_cell_type, as dolfinx#4621 changed
  get_vtk_cell_type to take the number of nodes rather than the
  dimension.
- The manifold H(div)/H(curl) submesh test calls
  fenicsx_compat.create_facet_orientations before creating the spaces,
  which dolfinx#4625 requires for Raviart-Thomas on a manifold.
- The vector reference field in test_submesh.py is linear rather than
  containing a sine, so it lies in RT2. Interpolating a field outside
  RT2 on DOLFINx nightly gives dofs that differ by about 1e-6 between
  mesh numberings, which broke the comparison with the field
  interpolated again on the mesh read back from file. The round trip
  itself was exact.

`packaging` moves from the runtime dependencies to the test group, as
only the tests still use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@finsberg
finsberg marked this pull request as draft October 20, 2026 19:20
@finsberg
finsberg requested a review from jorgensd October 21, 2026 06:46
@finsberg
finsberg marked this pull request as ready for review October 21, 2026 06:48
@jorgensd
jorgensd merged commit 309e6ea into main Oct 21, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants