Skip to content

Submesh + MeshHierarchy#5084

Closed
pbrubeck wants to merge 1 commit into
mainfrom
pbrubeck/mg-submesh
Closed

Submesh + MeshHierarchy#5084
pbrubeck wants to merge 1 commit into
mainfrom
pbrubeck/mg-submesh

Conversation

@pbrubeck
Copy link
Copy Markdown
Contributor

@pbrubeck pbrubeck commented May 7, 2026

Description

Comment thread firedrake/mg/mesh.py

if isinstance(mesh, firedrake.MeshSequence):
result = []
for m in mesh:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to sort the meshes in the MeshSequence by ancenstry. The parent hierarchy must be constructed before that of the children.

@pbrubeck pbrubeck force-pushed the pbrubeck/mg-submesh branch from 003f924 to a886c07 Compare May 7, 2026 13:08
pefarrell added a commit that referenced this pull request May 7, 2026
Replace the implicit Submesh(mh[-1], ...) approach with Pablo's explicit
MeshHierarchy(submesh, nref) API.  Three architectural changes:

* mesh.py: Drop _create_submesh_raw; inline the body back into Submesh and
  store _submesh_label_name / _submesh_label_value / _submesh_ignore_halo so
  that MeshHierarchy can replay the same filter on each parent level.

* mg/mesh.py: Add MeshSequence support at the top of MeshHierarchy (builds
  independent hierarchies for each component, wraps fine meshes in
  MeshSequenceGeometry).  Add submesh_parent branch: for a Submesh, re-apply
  dmcommon.submesh_create to each level of the pre-existing parent hierarchy
  rather than refining the submesh DM directly.  Remove the now-superseded
  _build_submesh_hierarchy_for_level and _submesh_coarse_to_fine_cells helpers.
  The coarse_to_fine_cells computation for submesh pairs is delegated to the
  same impl.coarse_to_fine_cells call as for volume meshes, which works
  because submesh_create preserves the consecutive child-numbering property.

* test: Update test_submesh_mg.py to use the new explicit API (build parent
  hierarchy first, then call MeshHierarchy(submesh, nref)).

The dmhooks.py / mg/embedded.py / mg/ufl_utils.py fixes from the previous
commit are kept unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pefarrell pefarrell mentioned this pull request May 7, 2026
@pbrubeck
Copy link
Copy Markdown
Contributor Author

pbrubeck commented May 8, 2026

Closing in favour of #5083

@pbrubeck pbrubeck closed this May 8, 2026
pbrubeck pushed a commit that referenced this pull request May 12, 2026
Replace the implicit Submesh(mh[-1], ...) approach with Pablo's explicit
MeshHierarchy(submesh, nref) API.  Three architectural changes:

* mesh.py: Drop _create_submesh_raw; inline the body back into Submesh and
  store _submesh_label_name / _submesh_label_value / _submesh_ignore_halo so
  that MeshHierarchy can replay the same filter on each parent level.

* mg/mesh.py: Add MeshSequence support at the top of MeshHierarchy (builds
  independent hierarchies for each component, wraps fine meshes in
  MeshSequenceGeometry).  Add submesh_parent branch: for a Submesh, re-apply
  dmcommon.submesh_create to each level of the pre-existing parent hierarchy
  rather than refining the submesh DM directly.  Remove the now-superseded
  _build_submesh_hierarchy_for_level and _submesh_coarse_to_fine_cells helpers.
  The coarse_to_fine_cells computation for submesh pairs is delegated to the
  same impl.coarse_to_fine_cells call as for volume meshes, which works
  because submesh_create preserves the consecutive child-numbering property.

* test: Update test_submesh_mg.py to use the new explicit API (build parent
  hierarchy first, then call MeshHierarchy(submesh, nref)).

The dmhooks.py / mg/embedded.py / mg/ufl_utils.py fixes from the previous
commit are kept unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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