Skip to content

Fix DG1 XDMF export with element-local simplex topology - #736

Merged
lmoresi merged 1 commit into
underworldcode:developmentfrom
gthyagi:bugfix/dg1-xdmf-export
Oct 6, 2026
Merged

lmoresi merged 1 commit into
underworldcode:developmentfrom
gthyagi:bugfix/dg1-xdmf-export

Conversation

@gthyagi

@gthyagi gthyagi commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Problem

DG1 fields were treated as one-value-per-cell XDMF attributes even though triangles have three and tetrahedra four local coefficients. This creates invalid visualization metadata and cannot preserve the discontinuous linear field correctly.

Changes

  • Add a disconnected DG1 grid alongside the standard mesh grid in one XDMF file.
  • Evaluate each cell polynomial at its own physical vertices using native cell maps; no coordinate matching or averaging across cells.
  • Write only owned cells through PETSc collective output, including ranks with no owned cells.
  • Support scalar, vector, full tensor and symmetric tensor fields on full-dimensional triangles and tetrahedra.
  • Preserve native HDF5 checkpoint/reload data. Unsupported DG visualization fails explicitly; native-only output remains available.
  • Document the layout and ParaView usage.

Verification

  • Rebuilt UW3 in amr-dev.
  • 24 focused serial tests passed (DG1, existing XDMF compatibility and save/load).
  • All four DG1 regression tests passed on eight MPI ranks.
  • ParaView 6.0 read both 2D and 3D outputs and rendered the 2D field; maximum scalar errors were 1.78e-15 and 3.55e-15 respectively.
  • Regression tests cover preserved jumps, physical vertex values, positive cell orientation, ownership, tensor packing, native checkpoint reload and unsupported layouts.
  • Deprecated-pattern check and git diff --check passed.

This changes visualization output only; it does not change the Stokes solver or smooth stress/strain-rate fields.

Write independent physical vertices and cell-local linear field traces for DG1 triangles and tetrahedra. Use native cell maps and owned-cell PETSc output to preserve discontinuities without coordinate matching or inter-element averaging.

Expose continuous and DG1 fields as separate grids in one XDMF file, support scalar/vector/tensor layouts, and retain native checkpoint data unchanged. Reject unsupported DG visualization explicitly while preserving native-only output.

Add serial and MPI regression coverage for affine fields, jumps, orientation, ownership, tensor packing, and checkpoint reload. Document supported layouts and ParaView usage. Validated 24 focused serial tests, four DG tests on eight ranks, and actual ParaView 2D/3D reads.
@lmoresi

lmoresi commented Oct 6, 2026

Copy link
Copy Markdown
Member

Issues in this branch's territory

Territory is discretisation_mesh.py, function/field_projection.py, test_0005_xdmf_dg1, and the checkpointing-system doc.

issue verdict
#690 reloading a refinement>=1 checkpoint gives a corrupt DM (integral of 1 is 0.07) still live — a DM/section reload defect, not an export-topology one
#809 a refined mesh reloaded from its checkpoint has cells joined to the wrong vertices still live — same family as #690; nothing here touches the reload path
#645 long HDF5 paths segfault in parallel PETSc output still live as a docs item
#562 FreeSurface records hscale but not tscale still live — unrelated to XDMF topology

This PR is the export side only: DG1 fields were written with the wrong topology, and element-local simplex topology is what XDMF needs for a discontinuous space. No open issue was filed against it.

@lmoresi lmoresi left a comment

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.

Approved. Element-local topology is the right representation for a discontinuous space in XDMF, and test_0005_xdmf_dg1.py covers the export. Confined to the writer; the reload defects (#690, #809) are a different path and stay open.

@lmoresi
lmoresi merged commit 4a4f18d into underworldcode:development Oct 6, 2026
2 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