Fix essential BCs on wrapped imported DMPlex meshes#86
Merged
lmoresi merged 1 commit intoMar 20, 2026
Merged
Conversation
lmoresi
added a commit
that referenced
this pull request
Mar 20, 2026
Convert PR #86 reproducer script into a proper pytest (test_1012_stokesImportedDMPlex.py) and delete the root examples/ directory which contained only ad-hoc diagnostic scripts. Underworld development team with AI support from Claude Code
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
Fix essential BC handling for wrapped imported
PETSc.DMPlexmeshes by rebuilding named boundary labels from generic imported Gmsh boundary sets.This bug does not affect the usual:
path, because
_from_gmsh(...)already reconstructs named labels such asBottom,Top,Left, andRight.It does affect the lower-level path:
where the wrapped mesh may only expose generic labels such as
Face Sets/Cell Sets.Problem
The Stokes essential BC path expects named boundary labels like
Bottomto exist on the working DM. For wrapped importedDMPlexmeshes, that assumption is false on cleandevelopment.On exact upstream
development, the reproducer prints:and then dies in
stokes.solve().So the issue is specifically:
DMPlexretains generic Gmsh labelsMesh(plex, ...)Fix
When
uw.discretisation.Mesh(...)is constructed from an already-createdPETSc.DMPlex, and named boundary labels are missing, unstack the imported generic boundary-set labels into named UW labels beforeUW_Boundariesis stacked.In practice this means rebuilding labels such as:
BottomTopLeftRightfrom imported labels such as:
Face SetsEdge SetsVertex SetsThis keeps the wrapped-
DMPlexpath consistent with the standard file-import path instead of changing solver-side boundary semantics.Reproducer
Added:
examples/stokes_imported_box_essential_bc.pyIt is self-contained:
PETSc.DMPlex().createFromFile(...)DMPlexwithuw.discretisation.Mesh(plex, ...)u = (y, 0)on all four sidesResults
Before this fix
Run the reproducer against clean
development:Observed output:
The process then crashes in
stokes.solve().After this fix
Run the same script against this branch:
Observed output:
So the direct imported-
DMPlexpath now behaves correctly and matches the expected machine-precision solution for this simple imposed-velocity Stokes case.Scope
This PR only changes the wrapped imported-
DMPlexmesh path and adds the reproducer.