Skip to content

Retire XDMF from the archive: the writers build ymf grid dicts, no module imports xml (C2) - #97

Merged
cekees merged 2 commits into
mainfrom
retire-xdmf
Oct 24, 2026
Merged

cekees merged 2 commits into
mainfrom
retire-xdmf

Conversation

@cekees

@cekees cekees commented Oct 23, 2026

Copy link
Copy Markdown
Owner

C2: retire XDMF/XML from proteus

Only ymf2xmf needs XDMF now. The archive's writers build ymf grid dicts directly; nothing in the proteus package imports an XML library.

Needs cekees/ymf#20 merged first (CI installs ymf from @main): the two XDMF reads a version 1 archive still needs moved there.

What changed

  • The running archive is dicts, not a tree. Archiver.ArchiveDomain holds named ArchiveCollections, each with only the current step's ymf grid dict (the tree used to be emptied at every sync too). write_grid starts a step's grid and records its time on the collection; write_topology, write_geometry and write_field fill it with ymf's own builders and return the data item. allGatherIncremental stores the dicts as they are, so the parse_grid_element bridge is gone, and the stored step time is the float, not a %e string.
  • Every writer converted: the 14 writeMeshXdmf_* and the hand-built function writers in Archiver.XdmfWriter; Mesh, Mesh2DM and Mesh3DM.writeMeshXdmf in MeshTools (the base mesh, its element-boundary mesh, the local-to-global maps and the material types); AuxiliaryVariables.writeScalarXdmf (the value is inlined in the document). Dataset names and sidecar names are unchanged, so existing archives read as before. The "does this time already have a grid?" test every writer made against its grid's <Time> is now collection.is_current(t).
  • Gone: self.tree, indentXML, from xml.etree.ElementTree import * in Archiver, AuxiliaryVariables and MeshTools, and the two lines in NumericalSolution that created the <Domain>.
  • The mesh readers work on the domain dict: MeshTools.readMeshFromArchive reads a proteus archive from its .h5 metadata through readArchiveDomain (version 1 and 2 alike, no .xmf needed), and readMeshXdmf reads XDMF written by other tools (the OpenFOAM hex_cube_3x3 fixture) through ymf.xdmf.read_xdmf; findXMLgridElement became findArchiveGrid. The v1 fragments and the v1 collection order are parsed by ymf.xdmf.read_grid_fragment and ymf.xdmf.collection_names.
  • Tests: test_archiver_write_field.py pins the dicts instead of the XML (and the builders); test_archive_no_xml.py checks by AST that no module on the archive path imports xml and that no SubElement is left in the package; the read-path, dtype, parallel-metadata and bathymetry tests lost their tree fixtures.

Fixed along the way

Four writers only ever worked on one rank under global_sync and now contribute the owned slice with offsets like the rest: writeVectorFunctionXdmf_MonomialDGPK, writeVectorFunctionXdmf_LowestOrderMixed (wrote the whole local array under the global name with a non-collective create), writeVectorFunctionXdmf_P1Bubble (zero components sized by the global count against owned slices), writeFunctionXdmf_P1Bubble (offsets read off the subdomain mesh). writeMeshXdmf_DGP0 declared a mixed topology's size from self.xdmf_topology, which does not exist on the writer; readMixedElementTopologyFromXdmf had the same self. in a module function. writeMeshXdmf_MonomialDGPK and _LowestOrderMixed now set self.mesh, which their vector writers read.

Left as it was

mbd/CouplingFSI.pyx still writes its own per-body .xmf (version 1 style fragments in its own .h5) and keeps a local copy of indentXML; converting it to the archive is a follow-up. scripts/waves2xmf and velocity2xmf are Python 2 and were already dead; scripts/gatherArchives.py composes .xmf files and stays an XDMF tool.

🤖 Generated with Claude Code

cekees and others added 2 commits October 23, 2026 21:54
…dule imports xml (C2)

The running archive is Archiver.ArchiveDomain, named collections each
holding the current step's ymf grid dict, in place of the ElementTree
whose last child was that step. write_grid starts a step's grid and
records its time on the collection; write_topology, write_geometry and
write_field fill it with ymf's own builders. allGatherIncremental stores
the dicts as they are: the parse_grid_element bridge is gone.

Every writer is converted: the fourteen writeMeshXdmf_* methods and the
hand-built function writers in XdmfWriter, Mesh/Mesh2DM/Mesh3DM in
MeshTools (base mesh, element-boundary mesh, local-to-global maps,
material types), AuxiliaryVariables.writeScalarXdmf. Dataset and sidecar
names are unchanged. self.tree, indentXML and the xml imports are gone;
NumericalSolution no longer creates a <Domain>.

The legacy readers in MeshTools read the archive's .h5 metadata through
readArchiveDomain (version 1 and 2 alike), so no .xmf is needed;
findXMLgridElement became findArchiveGrid on the domain dict. The two
XDMF reads a version 1 archive still needs live in ymf.xdmf (ymf#20):
read_grid_fragment for the stored <Grid> fragments and collection_names
for the order of the collections.

Four global_sync writers that only worked on one rank now contribute the
owned slice with offsets like the rest (MonomialDGPK and LowestOrderMixed
vectors, P1Bubble scalar and vector); writeMeshXdmf_DGP0's mixed topology
and readMixedElementTopologyFromXdmf read a self.xdmf_topology that did
not exist. CouplingFSI.pyx, which writes its own per-body .xmf, keeps a
local copy of indentXML.

test_archive_no_xml.py pins by AST that no module on the archive path
imports an XML library and that no SubElement is left in the package;
test_archiver_write_field.py pins the dicts and the builders.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…FromArchive reads a proteus archive

The OpenFOAM-converted fixture hex_cube_3x3 is an .xmf whose .h5 holds
the arrays and no proteus metadata, so it cannot be read from the .h5
alone. readMeshXdmf keeps reading such files, parsed by ymf.xdmf rather
than by proteus; readMeshFromArchive is the reader for a proteus archive.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@cekees
cekees merged commit c22f6d3 into main Oct 24, 2026
24 of 30 checks passed
@cekees
cekees deleted the retire-xdmf branch October 24, 2026 04:08
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.

1 participant