Skip to content

Keep DirichletBCs when a matrix-free submatrix spans a whole non-mixed space - #5556

Draft
bueler wants to merge 1 commit into
firedrakeproject:releasefrom
bueler:bueler/matfree-submatrix-bcs
Draft

bueler wants to merge 1 commit into
firedrakeproject:releasefrom
bueler:bueler/matfree-submatrix-bcs

Conversation

@bueler

@bueler bueler commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Description

ImplicitMatrixContext.createSubMatrix rebuilds each DirichletBC with bc.reconstruct(field=row_inds, ...). For a space that is not a subspace of a mixed space, fs.index is None, so BCBase.as_subspace returns None for field=[0], and the BC is silently dropped. The submatrix then has ordinary operator rows on the boundary, where the original matrix has identity rows.

This happens whenever a general (non-stride) IS covers the whole space; PETSc's identity-stride shortcut in MatCreateSubMatrix avoids it. For example, SNESVINEWTONRSLS with mat_type: matfree and an empty active set does this: CG on the reduced system stagnates or diverges. That is how it showed up, in a FAS multigrid solver for an unconstrained problem.

The fix treats a space with no index as field 0 of itself. BCs on whole mixed spaces are already rejected, so this does not change any mixed-space behaviour. A regression test compares matrix-free and AIJ submatrices over a whole-space general IS, for scalar, vector and vector-component BCs.

AI assistance: diagnosis, fix and test were developed with Claude Code (Claude Opus 5.5) and reviewed by the author.

@bueler

bueler commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer please add the "LLM used" label? I apparently don't have permission to set labels.

This branch has not been deployed

No deployments
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