MeshSequenceHierarchy - #5309
Open
pbrubeck wants to merge 1 commit into
Open
Conversation
…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>
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.
Summary
MeshHierarchy()andMeshGeometry.refine_marked_elementsonly ever accepted a plainMeshGeometry. Neither dispatched across the distinct component meshes of a genuinely multi-subdomainMeshSequenceGeometry(the mesh behind aMixedFunctionSpacebuilt from distinct meshes, e.g. aSubmesh-coupled volume+surface problem).MeshSequenceGeometry.set_hierarchy()worked around this by hand-building a plain Pythontupleof per-levelMeshSequenceGeometrys, tagged viaset_level. That's not aHierarchyBaseand has no.add_mesh(), so any adaptive-refinement caller crashed withAttributeError: 'tuple' object has no attribute 'add_mesh'.MeshSequenceHierarchy(aHierarchyBasesubclass,firedrake/mg/mesh.py) that dispatches per distinct component mesh: components that already have a hierarchy (e.g. built withSubmeshHierarchy) are reused as-is; standalone components are refined fresh viaMeshHierarchy. 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, soSubmeshHierarchymust be called explicitly first.MeshHierarchy()now dispatches toMeshSequenceHierarchy.from_componentswhen given aMeshSequenceGeometry, andMeshSequenceGeometry.set_hierarchy()(triggered automatically byMixedFunctionSpace) now builds the same real hierarchy instead of the tuple.SubmeshHierarchy()now returns aSubmeshHierarchyBase, which remembers itsSubmeshconstruction 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 usingmark, 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_componentsrejects aMeshSequenceGeometrythat 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