Submesh IO and storage of multiple meshes per checkpoint file - #78
Merged
Merged
Conversation
Member
Author
|
Thoughts while trying to sleep; use interpolate geometry and curve the mesh (square-> circle) to test read /write point data on submeshes |
for more information, see https://pre-commit.ci
jorgensd
marked this pull request as ready for review
September 22, 2026 21:20
finsberg
approved these changes
Sep 23, 2026
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.
Following the plan in #42.
Submesh checkpointing + named meshes
Checkpoint a
dolfinx.mesh.create_submeshsubmesh and functions on it, and re-derive itfrom a re-partitioned parent with
EntityMaps usable in mixed-dimensional forms.New public API
A submesh is never read onto a
create_submesh-derived mesh: it is stored as anordinary named mesh, read back as one, and the data is then transferred.
Writing
parentandcell_mapare the mesh the submesh was built from and the mapcreate_submeshreturned for it.Several submeshes of one parent can share a file, including several of the same dimension.
parent_filename=keeps the submesh in its own file; the post codes always go to theparent's, since they tag parent entities.
Reading
A separate run, typically at a different process count and therefore a different partition.
Nothing from the writing session is in scope: every mesh here comes out of the file.
Stop there if you only want the data. To assemble a mixed-dimensional form over the parent
and the submesh you need a submesh DOLFINx recognises as derived from that parent object,
which is what
read_submeshbuilds — so theparentit is given is the one read on theline above, not a mesh carried over from writing:
SubmeshCheckpointcarriessubmesh,cell_map,vertex_map,node_mapexactly ascreate_submeshreturns them — sochk.cell_mapgoes straight intodolfinx.fem.form(..., entity_maps=[...])againstparent— pluspost_code, the indexeach cell had in the stored submesh, which is how
transfer_submesh_functionroutes thedata from
storedontochk.submesh.Full signatures:
mesh_name=on every mesh-associated callwrite_mesh,read_mesh,write_function,read_function,write_meshtags,read_meshtags,write_point_data,read_point_data,write_cell_data,read_cell_data,read_timestamps,read_function_names. Several meshes per checkpoint.Omitting it selects the default mesh, stored exactly as before, so existing checkpoints
stay readable.
Backend support
read_submeshread_function→transfer_submesh_function, any spaceread_point_data/read_cell_data→transfer_submesh_functionadios2 and h5py are the full-feature backends. vtkhdf stores the mesh, the submesh and its
post codes, so
read_submeshworks; it cannot checkpoint a general function, but point andcell data can be read back and transferred. Point data follows the mesh's coordinate
element, so on a degree-4 mesh that transfers a degree-4 field, not a linear one.
Higher-order and curved geometry
Verified on a curved ball with degree-2 and degree-4 geometry (built with
dolfinx.fem.interpolate_geometry), whose boundary submesh is a genuinely curved manifold:parent degree, submesh degree and Lagrange variant all survive the round-trip, and the
transfer is exact to ~1e-14, at one and three processes.
Not supported
H(div)/H(curl) on a submesh with
tdim < gdimwrite and read exactly, buttransfer_submesh_functionraisesNotImplementedError: DOLFINx returns silently wrongvalues there (FEniCS/dolfinx#3619). Use
read_mesh/read_functionwith the submesh'smesh_nameand stop before re-deriving.Restrictions at an interface follow the facet-to-cell connectivity, so
jump()is notorientation-stable across a re-partition — that is a DOLFINx property, not an IO one, and
it is equally unstable without any IO. Use
abs(jump(...)), or pin the restrictions bycell marker (
scifem.compute_interface_data).Tests
tests/test_submesh.py, 110 tests, green at np=1 and np=3 on both writable backends.