-
Notifications
You must be signed in to change notification settings - Fork 189
Fix Submesh to propagate "Edge Sets" / "Vertex Sets" to codimension-1 submesh exterior facet markers
#4950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lorenzoCorintis
wants to merge
17
commits into
firedrakeproject:main
Choose a base branch
from
lorenzoCorintis:fix-submesh-labels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix Submesh to propagate "Edge Sets" / "Vertex Sets" to codimension-1 submesh exterior facet markers
#4950
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
afde9fa
fix submesh labels
lorenzoCorintis 19d97e8
add tests
lorenzoCorintis 1ac8e61
make an else condition explicit
lorenzoCorintis 19b188f
add some tests
lorenzoCorintis fcbca35
fix tests
lorenzoCorintis 88446cd
small refactoring
lorenzoCorintis eec6bed
Update tests/firedrake/submesh/test_submesh_codim1_labels.py
lorenzoCorintis 2cfffed
Update tests/firedrake/submesh/test_submesh_codim1_labels.py
lorenzoCorintis 7507425
Apply suggestions from code review
lorenzoCorintis 307c688
lint fixes
lorenzoCorintis 6f9c0a8
Merge branch 'fix-submesh-labels' of github.com:lorenzoCorintis/fired…
lorenzoCorintis b2bdc65
Update firedrake/cython/dmcommon.pyx
lorenzoCorintis 5629346
improve a docstring
lorenzoCorintis b4bd689
Merge branch 'fix-submesh-labels' of github.com:lorenzoCorintis/fired…
lorenzoCorintis e3f0b85
refactor tests
lorenzoCorintis 5f30402
connor's suggestion
lorenzoCorintis 055e577
Rebuild submesh "Face Sets" from lower-dimensional labels
lorenzoCorintis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this. Can you explain? I would expect that the given "Face Sets" is now just wrong and it seems a bit dodgy to be partially editing the "Face Sets" label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DMPlexFiltercopies every label from the parent into thesubdm, including "Face Sets" values thatDMPlexLabelCompletepropagated to closure entities (edges, vertices). For a codim-1 submesh these inherited edge-level values carry useful boundary information.I tried discarding the inherited "Face Sets" and rebuilding from scratch, but this breaks
test_submesh_solve_2d_1d_poisson_hermite(which chains 3D→2D→1D submesh extractions): removing and recreating the label loses PETSc's internal parallel migration state, so the rebuilt label doesn't survive redistribution correctly.I therefore preserve inherited values and only fill in exterior facets that don't already have one, using the parent's lower-dimensional label or a fresh default. The docstring now explains this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems quite counter intuitive and might cause some confusion down the line. I wonder if there's a simpler solution:
When we propagate "Face Sets" to the rest of the facet closure could we at the same time set "Edge Sets" and "Vertex Sets" for the extra entities.
Consider one of our 3D utility meshes with some marked boundary. "Face Sets" for this boundary would contain all facets, edges and vertices on the boundary, "Edge Sets" would contain all edges and vertices, and "Vertex Sets" just the vertices.
This way when we lose a dimension via submesh all the necessary boundary information is already encoded in "Edge Sets" and so "Face Sets" is safe to discard (or push to "Cell Sets"?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented part 1 of your suggestion:
complete_facet_labelsnow populates "Edge Sets" and "Vertex Sets" from the "Face Sets" closure (entities that already carry a value, e.g. from Gmsh, are not overwritten). So after mesh setup a 3D utility mesh with a marked boundary will have:For part 2 I also switched
_propagate_parent_facet_labelsto read from the subdm's own inherited "Edge Sets" / "Vertex Sets" instead of doing cross-DM queries against the parent viasubpoint_indices. This simplifies the function signature and removes the parent-DM dependency entirely.However, I was not able to fully discard inherited "Face Sets" on the subdm (the
removeLabel/createLabelapproach). Even when reading exclusively from subdm-local labels, removing and recreating "Face Sets" still breakstest_submesh_solve_2d_1d_poisson_hermite(which chains 3D→2D→1D). The issue is thatremoveLabel/createLabelloses PETSc's internal parallel label-migration state regardless of where the replacement values come from.So the current implementation preserves inherited "Face Sets" and only fills in exterior facets that don't already have a value. I think fully discarding inherited "Face Sets" would require PETSc-level changes (e.g. a way to reset label values without destroying the migration SF), which is out of scope here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue that I am having is that there is some quite complicated implicit union behaviour going on between the closure-propagated "Face Sets" and any new "Edge Sets" entries. For instance consider having a cube:
where the left-most edges are labelled 1 in "Edge Sets" and the right-most face is labelled 1 in "Face Sets". If you take some sort of codim-1 submesh it is not obvious which edges (now faces) should be labelled 1.
I think my preferred approach is:
Sorry for making this such a big deal, but I think we have to be careful about this.
What about something like DMLabelClearStratum?
This is weird. I wonder what is happening there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@connorjward
Thanks for the suggestion — we've now implemented the approach you described:
1. Populate "Edge Sets" and "Vertex Sets" from "Face Sets" on the parent
Before
DMPlexFilter, a new helper_populate_lower_dim_labelsiterates each positive "Face Sets" stratum on the parent mesh and copies the value to "Edge Sets" (depth-1 entities) and "Vertex Sets" (depth-0 entities). Entities that already carry a positive value (e.g. user-defined labels from Gmsh) are preserved.2. Clear inherited "Face Sets" on the subdm and rebuild from "Edge Sets"
_propagate_parent_facet_labelsnow usesDMLabelClearStratumto clear every stratum of the inherited "Face Sets" on the subdm, then rebuilds it purely from the subdm's own "Edge Sets" (3D→2D) or "Vertex Sets" (2D→1D).DMPlexLabelCompleteis called afterwards to propagate to closure entities and synchronise ghost points via the point SF. When no source label exists, a fallback path preserves inherited values.3. Handling mesh-generator artifacts (value 0)
The main difficulty we hit was that mesh files (and
RelabeledMesh) can leave "Face Sets" value 0 on many boundary entities. SinceDMLabelGetValuereturns the minimum value for a point, edges at face intersections appeared to have value 0 rather than their meaningful positive value. The fix was to:DMLabelGetStratumIS) rather than relying onDMLabelGetValueDMLabelClearValuebefore setting the correct positive valueAll existing submesh tests pass, including
test_submesh_solve_2d_1d_poisson_hermite(nprocs=7) which chains 3D→2D→1D submesh extractions viaRelabeledMesh.