Skip to content

Consider replacing manual /viz topology assembly with PETSc HDF5_VIZ viewer #217

Description

@lmoresi

Tracking the cleaner alternative to the XDMF viz-topology fix landed in PR #205.

Background

PR #205 (tiannh7) added a Python+MPI helper _write_mesh_viz_groups that gathers vertex coordinates and cell-to-vertex connectivity across ranks, deduplicates global vertex ids, and writes /viz/geometry/vertices + /viz/topology/cells into the mesh HDF5. This fixes ParaView crashes reading the XDMF generated by write_timestep. ~115 lines of new code, including 3D simplex/quad cell reordering.

The alternative @gthyagi developed

Commit 22dd9ab2 (gthyagi, on a now-deleted branch feature/annulus-spherical-benchmark-debug) addressed the same bug with a much smaller change:

  • Add petsc_format: bool = False kwarg to Mesh.write()
  • write_timestep calls self.write(mesh_file, petsc_format=False) → uses PETSc.Viewer.Format.HDF5_VIZPETSc itself writes /viz/topology/cells natively, no Python-side MPI gather needed
  • write_checkpoint keeps HDF5_PETSC (DMPlex restart format)
  • Also hardens checkpoint_xdmf: uses integer topology precision from the HDF5 dtype rather than hardcoded Precision=\"8\", and removes the HyperSlab wrapper from variable DataItems (simpler/correct XDMF)

Roughly 10 lines of behavior change vs ~115 in PR #205.

Why we landed #205 anyway

  • It was already submitted by a first-time contributor with working tests
  • bknight1 confirmed it resolves his ParaView crashes
  • The 22dd9ab branch had already been deleted from upstream; reviving it required separate work

What's needed to close this issue

  1. Revive 22dd9ab2 as a fresh PR off current development (commit is still reachable via SHA on underworldcode/underworld3)
  2. Verify it generates the same XDMF behaviour PR Fix XDMF output to explicitly write cell-to-vertex topology and ensure strict ParaView compatibility #205's tests exercise (test_0005_xdmf_compat.py::test_xdmf_viz_topology_written_correctly and _3d)
  3. Run the parallel cases (PR Fix XDMF output to explicitly write cell-to-vertex topology and ensure strict ParaView compatibility #205 only had serial tests)
  4. Once landed, _write_mesh_viz_groups and the _local_viz_cell_connectivity / _petsc_numbering_to_global_ids helpers from PR Fix XDMF output to explicitly write cell-to-vertex topology and ensure strict ParaView compatibility #205 can be removed — leaving only PETSc-managed viz topology

If the HDF5_VIZ viewer turns out not to handle some cell topology that the manual Python helper does, this issue can be closed as "alternative not viable" instead.

cc @gthyagi @bknight1

Underworld development team with AI support from Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions