Skip to content

MeshSequenceHierarchy - #5309

Open
pbrubeck wants to merge 1 commit into
mainfrom
pbrubeck/meshsequence-hierarchy
Open

MeshSequenceHierarchy#5309
pbrubeck wants to merge 1 commit into
mainfrom
pbrubeck/meshsequence-hierarchy

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

MeshHierarchy() and MeshGeometry.refine_marked_elements only ever accepted a plain MeshGeometry. Neither dispatched across the distinct component meshes of a genuinely multi-subdomain MeshSequenceGeometry (the mesh behind a MixedFunctionSpace built from distinct meshes, e.g. a Submesh-coupled volume+surface problem).

MeshSequenceGeometry.set_hierarchy() worked around this by hand-building a plain Python tuple of per-level MeshSequenceGeometrys, tagged via set_level. That's not a HierarchyBase and has no .add_mesh(), so any adaptive-refinement caller crashed with AttributeError: 'tuple' object has no attribute 'add_mesh'.

  • Add MeshSequenceHierarchy (a HierarchyBase subclass, firedrake/mg/mesh.py) that dispatches per distinct component mesh: components that already have a hierarchy (e.g. built with SubmeshHierarchy) are reused as-is; standalone components are refined fresh via MeshHierarchy. A submesh with no existing hierarchy raises a clear error — its construction parameters (subdomain_id, label_name, ...) can't be recovered from the mesh object, so SubmeshHierarchy must be called explicitly first.
  • MeshHierarchy() now dispatches to MeshSequenceHierarchy.from_components when given a MeshSequenceGeometry, and MeshSequenceGeometry.set_hierarchy() (triggered automatically by MixedFunctionSpace) now builds the same real hierarchy instead of the tuple.
  • SubmeshHierarchy() now returns a SubmeshHierarchyBase, which remembers its Submesh construction kwargs and parent hierarchy, so a submesh can be rebuilt from a adaptively-refined parent level.
  • MeshSequenceGeometry.refine_marked_elements(mark) refines only the "root" (non-submesh) components using mark, and rebuilds every submesh component from its refined ancestor — keeping submesh and parent geometrically consistent under adaptive growth, rather than refining them independently.
  • MeshSequenceHierarchy.from_components rejects a MeshSequenceGeometry that combines a submesh and one of its ancestors as separate components when their hierarchies aren't actually related (walks the full ancestor chain, not just the direct parent).

🤖 Generated with Claude Code

…uenceGeometry

MeshHierarchy() and MeshGeometry.refine_marked_elements only ever accepted a
plain MeshGeometry, so a genuinely multi-subdomain MeshSequenceGeometry (the
mesh behind a MixedFunctionSpace built from distinct meshes, e.g. a Submesh
coupled volume+surface problem) had no way to build or adaptively grow a real
hierarchy: MeshSequenceGeometry.set_hierarchy() worked around this with a bare
Python tuple that has no add_mesh, crashing any adaptive-refinement caller
with AttributeError: 'tuple' object has no attribute 'add_mesh'.

Add MeshSequenceHierarchy (a HierarchyBase subclass) that dispatches per
distinct component mesh, reusing any component's existing hierarchy (e.g. one
built with SubmeshHierarchy) and building fresh ones for standalone
components. SubmeshHierarchy now returns a SubmeshHierarchyBase that
remembers its Submesh construction parameters and parent hierarchy, so
MeshSequenceGeometry.refine_marked_elements() can refine only the root
(non-submesh) components and rebuild each submesh from its newly refined
parent, keeping submesh and parent geometrically consistent under adaptive
growth.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@pbrubeck pbrubeck changed the title Dispatch MeshHierarchy/refine_marked_elements across MeshSequenceGeometry MeshSequenceHierarchy Jul 31, 2026
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