Unify assign across Submesh, RestrictedFunctionSpace and RestrictedElement - #5287
Open
pbrubeck wants to merge 5 commits into
Open
Unify assign across Submesh, RestrictedFunctionSpace and RestrictedElement#5287pbrubeck wants to merge 5 commits into
pbrubeck wants to merge 5 commits into
Conversation
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
from
July 28, 2026 17:33
efc6a94 to
136fdbc
Compare
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
4 times, most recently
from
July 28, 2026 18:12
a5ef11e to
f03e5a4
Compare
pbrubeck
commented
Jul 28, 2026
pbrubeck
commented
Jul 29, 2026
pbrubeck
commented
Jul 29, 2026
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
from
July 30, 2026 16:40
b82e62b to
a8d8d84
Compare
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
from
July 31, 2026 13:35
a8d8d84 to
b86afbf
Compare
…ement Assigner special-cased Submesh, and RestrictedFunctionSpace went through a separate cell-node-map-based index computation in facet_split.get_restriction_indices. Both relate a source space's nodes to a subset of a target space's nodes, so route them through the same node-matching machinery: get_restriction_indices now walks node numbers through assign for the non-extruded case, and Assigner grows the general handling needed to cover RestrictedFunctionSpace, Submesh, and combinations of the two, including the redistributed Submesh case from the previous commit.
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
from
July 31, 2026 13:39
b86afbf to
70894ce
Compare
pbrubeck
commented
Jul 31, 2026
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
from
August 5, 2026 08:12
d8ba91f to
10e66bb
Compare
pbrubeck
force-pushed
the
pbrubeck/assign-submesh-restricted
branch
from
August 5, 2026 08:12
10e66bb to
ee9c744
Compare
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.
Stack
This is PR 3 of 3: #5288 (adaptive-multigrid) -> #5270 (mesh-redistribution) -> this PR (assign-submesh-restricted).
Summary
Unifies how
Function.assignmoves data between non-matching DOF layouts. ASubmesh, aRestrictedFunctionSpaceand aRestrictedElementall restrict the nodes of a space, and each was handled by its own machinery: entity maps, acell_node_mappermutation, and nothing at all respectively. They are now one mechanism — aPETSc.SFover the two spaces'PETSc.Sections.RestrictedElementcan be assigned to and from its parent element, which previously raised outright. Compatibility (_compatible_elements) is deduced from the UFL elements and their entity ids alone: the two must restrict a common element, and place the same number of nodes on every entity of the reference cell up to the entities one of them drops.cell_node_mappermutation is gone. Two distinct spaces on one mesh are related by an identity point SF and their sections, exactly as a submesh and its parent are related by the submesh point SF and theirs (_assign_via_sections, replacing_assign_redistributed).assignaccepts a subset of the cells, not just of the nodes (_node_subset), so a partial assignment can be expressed directly in terms of amesh.cell_subset(...).FacetSplitPCbuilds its restriction indices withassigninstead of a hand-written C kernel over aPermutedMap, keeping the kernel as a fallback for extruded meshes.g.assign(f_interior + f_facet)for complementary restrictions of one element): each function is related to the assignee by its own section SF and moved, unweighted, into the assignee's layout before the weighted combination happens there. Previously this raised a confusing tuple-unpackValueError.Requires firedrakeproject/fiat#267: a restricted element reported no entity permutations, so a restricted space could not be laid out consistently with the space it restricts, and the nodes on an edge carrying two or more of them came out transposed.
Not implemented
Extruded meshes. The classic
ExtrudedMeshhas only the flat baseDMPlex, so one base point carries a whole column of entities of which a restriction drops only some; aSectioncounts the nodes on a point without saying which they are._compatible_elementsraisesNotImplementedErrorthere, andFacetSplitPCfalls back to the kernel.Testing
tests/firedrake/submesh/test_submesh_assign.pygains tests for an element against its restriction (CG3, RT2 on triangles, Q3 on quadrilaterals), for the multi-space sum above (test_assign_multiple_source_spaces, nprocs=[1, 3]), for the remaining genuinely-incompatible pairs, and for the extruded case being refused. They compare against interpolation into the restricted space, which numbers its nodes without reference to the parent, so a permutation of the nodes within an entity cannot pass unnoticed.Also included are tests composing all three restrictions at once (a proper-subdomain
Submesh, redistributed or not, aRestrictedFunctionSpaceover part of the boundary, and a facet-onlyRestrictedElement), and a cell-subset assignment from a redistributedSubmesh.Ran
tests/firedrake/regression/test_assign.pyandtests/firedrake/submesh/test_submesh_assign.pyat nprocs 1, 2 and 3.Warning
test_submesh_assign_cell_subset_redistributed[nprocs=3]fails when run as part of the fulltest_submesh_assign.pyfile (though it passes in isolation): after several other tests in the file construct aSubmesh(..., redistribute=True), the section-SF coverage computed for a later redistributed submesh silently undercounts by exactlynprocsnodes on one rank. This reproduces identically against this PR's base (pbrubeck/mesh-redistribution, unmodified) with no code from this PR involved, so it is rooted inSubmesh(redistribute=True)'s point-SF construction infiredrake/mesh.py(from #5270), not in this PR's diff. Needs investigation in #5270 before this stack is CI-clean.🤖 Generated with Claude Code
Warning
Contains a DROP BEFORE MERGE commit pinning CI to the FIAT branch.