From a787bd2afeb40d73da4e167f606607e3d16dfed9 Mon Sep 17 00:00:00 2001 From: cekees <613654+cekees@users.noreply.github.com> Date: Fri, 23 Oct 2026 21:54:01 +0200 Subject: [PATCH 1/2] Retire XDMF from the archive: the writers build ymf grid dicts, no module 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 . 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 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 --- proteus/Archiver.py | 1946 ++++++++------------- proteus/AuxiliaryVariables.py | 29 +- proteus/FemTools.py | 2 - proteus/MeshTools.py | 746 +++----- proteus/NumericalSolution.py | 9 +- proteus/mbd/CouplingFSI.pyx | 25 +- test/mesh_tests/test_interpolatedbathy.py | 13 - test/test_archive_dtypes.py | 10 +- test/test_archive_no_xml.py | 88 + test/test_archive_parallel_metadata.py | 18 +- test/test_archive_read_paths.py | 168 +- test/test_archiver_write_field.py | 258 ++- 12 files changed, 1399 insertions(+), 1913 deletions(-) create mode 100644 test/test_archive_no_xml.py diff --git a/proteus/Archiver.py b/proteus/Archiver.py index 697256b6d9..74509a4c4a 100644 --- a/proteus/Archiver.py +++ b/proteus/Archiver.py @@ -10,25 +10,9 @@ import numpy import os import h5py -from xml.etree.ElementTree import * memory = Profiling.memory -def indentXML(elem, level=0): - i = "\n" + level*" " - if len(elem): - if not elem.text or not elem.text.strip(): - elem.text = i + " " - for e in elem: - indentXML(e, level+1) - if not e.tail or not e.tail.strip(): - e.tail = i + " " - if not e.tail or not e.tail.strip(): - e.tail = i - else: - if level and (not elem.tail or not elem.tail.strip()): - elem.tail = i - #: The dtype of the index arrays the XDMF writers number themselves -- the #: point numbering of quadrature, DG and particle meshes -- as opposed to a #: mesh's own connectivity, whose dtype comes from the mesh. The writers @@ -55,6 +39,104 @@ def xdmf_number_type(*arrays): item = data_item_for(numpy.empty(0, numpy.result_type(*arrays)), inline=True) return {"DataType": item["data_type"], "Precision": str(item["precision"])} + +class ArchiveCollection(object): + """One temporal collection of the running archive. + + A collection is one finite-element space's sequence of grids, one per + archived instant, and it holds only the *current* step's grid: the + writers build it, :meth:`AR_base.sync` stores it in the HDF5 file and + clears it, so the running document is never more than one step deep. + The grid is a ymf grid dict (``topology``, ``geometry``, ``attributes`` + and an optional ``name``), built by :meth:`AR_base.write_grid`, + :meth:`AR_base.write_topology`, :meth:`AR_base.write_geometry` and + :meth:`AR_base.write_field`, and stored as it is. + + Before the XDMF retirement this was a ```` element whose last child was the current + step; the writers compared that child's ``