Drop the MatIS special case in FunctionSpace.local_to_global_map - #5437
Draft
pbrubeck wants to merge 1 commit into
Draft
Drop the MatIS special case in FunctionSpace.local_to_global_map#5437pbrubeck wants to merge 1 commit into
pbrubeck wants to merge 1 commit into
Conversation
A local submatrix of a MATIS used to report its local-to-global map in a different layout from one of a MATLOCALREF, so masking the boundary condition nodes had to pick a different array for each. PETSc MR !9575 puts MATIS on the same layout as MATLOCALREF, so the scalar indices are now in block_indices for both, and the mat_type argument that told the two apart is no longer needed. That PETSc branch also fixes the mixed MatIS assembly the branch was guarding: extend test_assemble_matis to a mixed space whose blocked subspace comes second, so that it starts at a degree of freedom of the mixed space that is not a multiple of its own block size. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YCEk6eomrH6igbUrxhuyYh
Comment on lines
+902
to
+903
| indices = lgmap.block_indices.copy() | ||
| unblocked = True |
Contributor
There was a problem hiding this comment.
I find this confusing: you have blocked indices (one per block), but the flag is unblocked
stefanozampini
approved these changes
Sep 8, 2026
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.
Description
FunctionSpace.local_to_global_map()carried amat_typeargument for one reason: a local submatrix of aMATISreported its local-to-global map in a different layout from one of aMATLOCALREF, so masking the boundary condition nodes had to read a different array for each.PETSc !9575 puts
MATISon the same layout asMATLOCALREF, so the scalar indices are inblock_indicesfor both and the branch has nothing left to distinguish. This PR drops it, along with themat_typeargument threaded throughParloopBuilderto supply it.The
MATISarm was never correct anyway: it readlgmap.indices, which is only the scalar map when the subspace starts on a block boundary of the mixed space. It also never reached the assembled matrix, becauseParloopBuilder.replace_lgmaps()skips installing the masked map whenm.handle.type == "is". What it did do was keepindices[nodes] = -1from going out of bounds, which is why it cannot simply be deleted against the currently pinned PETSc.Testing
test_assemble_matisgains a mixed space whose blocked subspace comes second, so that it starts at a degree of freedom of the mixed space that is not a multiple of its own block size — the case PETSc got wrong. The existing parametrizations put the blocked subspace first, where the offset is zero and the bug does not show.Against a PETSc that carries !9575, all 10 parametrizations pass on 3 processes. Against the pinned PETSc, 5 of them fail:
mixed-iswith boundary conditions raisesIndexErrorfromindices[nodes] = -1, and bothmixed_blocks-iscases raise PETSc error 75 fromMatGetLocalSubMatrix().I also checked, outside the test suite, that every combination of scalar, vector and tensor subspaces in a two-field mixed space assembles identically under
mat_type="is"andmat_type="aij", with and without Dirichlet conditions, in serial and on 3 processes. Before !9575, 10 of those 25 combinations either raised or assembled the wrong matrix.make srclintis clean. It stops atcython-lint, which is not installed in my environment; no.pyxfile is touched.Blocked on PETSc
CI cannot go green until PETSc !9575 reaches a release that
SUPPORTED_PETSC_VERSION(currentlyv3.25.0) points at. !9575 is stacked on !9511, and both need to land inreleasefirst.To build against it before then, the
petsc/petscbranchpbrubeck/matis-localref-block-sizesis currentreleaseplus the whole stack.Opened as a draft for that reason.
Assisted by Claude Code (Claude Opus 5).