Use PETSc-native XDMF visualization topology - #218
Merged
lmoresi merged 7 commits intoJun 18, 2026
Conversation
Write visualization timesteps with PETSc HDF5_VIZ so generated XDMF references /viz/topology/cells rather than checkpoint-style DMPlex topology. Keep write_checkpoint on HDF5_PETSC for restart files. Harden checkpoint_xdmf against invalid topology datasets, use integer topology precision from the HDF5 dataset, and write mesh variable DataItems with their direct dataset dimensions instead of HyperSlab wrappers. Add regression tests covering write_timestep visualization topology, write_checkpoint restart topology, and 3D XDMF references.
Restore write_timestep mesh files to PETSc's default HDF5 layout instead of forcing HDF5_VIZ. This preserves labels and internal DMPlex restart datasets such as /topology/cells, /topology/cones, /topology/order, and /topology/orientation in output.mesh.00000.h5. Keep the XDMF writer guarded so visualization still references /viz/topology/cells and never the internal PETSc /topology/cells connectivity. This keeps ParaView-compatible direct cell connectivity while retaining restart-like mesh contents. Update the XDMF compatibility regression test to require both restart-style topology datasets and the /viz/topology/cells dataset from write_timestep output.
Contributor
Author
|
Additional validation after opening the PR:
|
Add a petsc_reload option to Mesh.write_timestep so timestep variable files can include PETSc DMPlex section/vector metadata alongside the existing XDMF, /fields, and vertex/cell compatibility payloads. This lets the same per-variable HDF5 files support both read_timestep remapping and read_checkpoint reloads. Refactor PETSc reload writing into shared helpers and add create_xdmf support to write_checkpoint by routing through the unified timestep writer. Invalid option combinations for the timestep layout now fail explicitly. Update checkpoint/reload developer documentation and add roundtrip tests covering unified write_timestep output and write_checkpoint(create_xdmf=True).
Emit a visible FutureWarning from Mesh.write_checkpoint() so new code is directed to the unified write_timestep(..., petsc_reload=True) API. Update checkpoint/reload documentation to present write_timestep() as the standard output method and write_checkpoint() as a legacy compatibility wrapper. Adjust tests to assert the warning on compatibility calls.
Contributor
Author
|
Follow-up pushed in
Validation after the change:
|
gthyagi
marked this pull request as ready for review
May 30, 2026 10:59
Member
Review — approved ✅ (implements & closes #217)Reviewed the full write/reload/XDMF path closely since this touches restart data integrity. Restart integrity is preserved, the default-format change is safe, and this satisfies #217's closure criteria.
Follow-ups (non-blocking — tracked separately, not gating this merge)
Merging for the release; closing #217. Underworld development team with AI support from Claude Code |
This was referenced Jun 18, 2026
Open
lmoresi
added a commit
that referenced
this pull request
Jun 19, 2026
…ng + drop dead cell_dim read (#252) (#256) Follow-ups from the #218 review: - disk_snapshot._write_disk_snapshot is a legitimate internal user of the user-deprecated write_checkpoint (it depends on the .mesh.00000.h5 / .<var>.00000.h5 filename convention its reload path reads). Wrap the call in warnings.catch_warnings()+ignore FutureWarning so persistent snapshots don't spam the deprecation warning. (Full migration to write_timestep tracked in #252.) - checkpoint_xdmf read topo["cells"].attrs["cell_dim"] into cellDim but never used it (topology_precision now derives from cells.dtype.itemsize). Removed — it was a needless dependency on a PETSc-internal attr that could KeyError. Verified: test_0007/0008 (snapshot) pass with -W error::FutureWarning (26/26); test_0003/0005 (save_load/xdmf) green (39/39 total). Item 3 (unify swarmVar HyperSlab XDMF block with the flattened meshVar form) deferred: cosmetic, ParaView-sensitive, no easy local validation — left in #252. Underworld development team with AI support from Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR revives the PETSc-native XDMF topology path from
feature/annulus-spherical-benchmark-debugon top of currentdevelopment, then extends the output API so timestep files can optionally carry PETSc reload metadata as well.The branch currently contains:
22dd9ab2/90774778: addpetsc_formatcontrol toMesh.write()and make XDMF use PETSc's direct/viz/topology/cellsconnectivity rather than internal DMPlex/topology/cells.9f41035e/47719277: keep restart-style topology inwrite_timestepmesh files while still pointing XDMF to direct visualization topology.5cd8a1f8: remove the manual_write_mesh_viz_groups()path added in PR Fix XDMF output to explicitly write cell-to-vertex topology and ensure strict ParaView compatibility #205 and rely on PETSc-native visualization topology.4bd05789: add unified timestep/reload output support withwrite_timestep(..., petsc_reload=True)andwrite_checkpoint(..., create_xdmf=True).Closes #217.
XDMF / visualization topology change
On current
development, PR #205 added a manual Python_write_mesh_viz_groups()path to assemble/viz/geometryand/viz/topology. This PR removes that manual gather/deduplication path and lets PETSc write the visualization topology natively.The resulting mesh output keeps the restart/topology information needed by UW3 while writing direct visualization connectivity at:
and geometry at:
The XDMF writer validates and references the PETSc-written
/viz/topology/cellsdataset rather than raw DMPlex/topology/cells.Unified timestep / PETSc reload output
This PR also adds an explicit output-payload switch:
With
create_xdmf=True, timestep variable files contain the existing XDMF/remap payloads:With
petsc_reload=True, the same per-variable HDF5 files also contain PETSc DMPlex reload payloads:That means a single
output.mesh.<variable>.00000.h5file can be used by both:write_checkpoint(..., create_xdmf=True)now routes through the same unified writer. The defaultwrite_checkpoint()path remains restart-only and backward-compatible.Why this is needed
The PETSc-native topology path avoids maintaining UW3-side MPI topology assembly, vertex deduplication, and cell reordering code. The unified output option also addresses the earlier architectural concern that visualization/remap output and PETSc-native reload output were locked into separate file families.
Users can now choose explicitly:
Scope note
This PR addresses the PETSc-native
/viz/topology/cellsreplacement requested in #217 for the current linear visualization topology workflow. It does not attempt to implement curved/isoparametric geometry support; that is a larger infrastructure change and should be tracked separately if needed.Tests
Core UW3 tests run locally in
amr-dev:./uw build.pixi/envs/amr-dev/bin/python -m pytest -q tests/test_0003_save_load.py tests/test_0005_xdmf_compat.py16 passed.pixi/envs/amr-dev/bin/mpirun -n 2 .pixi/envs/amr-dev/bin/python -m pytest -q --with-mpi tests/test_0003_save_load.py::test_timestep_with_petsc_reload_roundtrip.pixi/envs/amr-dev/bin/mpirun -n 2 .pixi/envs/amr-dev/bin/python -m pytest -q --with-mpi tests/parallel/test_0005_xdmf_viz_topology_mpi.pyBenchmark validation:
cellsize=1/8,P2/P1,m=-1,8MPI ranks using the unified writer path.read_checkpoint().