Repository navigation
Conversation
DiagonalInverseMatrix(form, bcs, lumped) is the pseudoinverse of the diagonal of a bilinear form (point Jacobi), of its row sums (lumped), or of a linear form. It is zero on the nodes of its boundary conditions, so that the product C D B does not couple through them. It can be assembled, split by fieldsplit, and coarsened by multigrid, and multigrid also coarsens Action. A preconditioner such as J - C D B is then rediscretized on every level, for example to precondition a Schur complement with geometric multigrid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
marked this pull request as draft
December 4, 2026 23:44
DiagonalInverseMatrix now takes and stores its form as `a`, like MatrixBase. Its hash now includes the boundary conditions, as its equality test does, and its repr and str use the MatrixBase format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The diagonal inverse assembled its form with separate assemblers and options. The operand is now assembled by the post-order traversal, as the operands of Adjoint and Action are, with the options of the enclosing assembly. The diagonal, the row sums or the entries are then taken from the assembled operand through PETSc, so that a matrix-free operand gives its diagonal through ImplicitMatrixContext.getDiagonal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Stacked on #5775 (ASMLinesmoothPC on mixed spaces). Review only the top commit; retarget to
mainonce #5775 merges.Summary
Geometric multigrid can now rediscretize a preconditioner built from
FormSum,Actionand a newDiagonalInverseMatrix. This is the BaseForm counterpart of the Slate static-condensation path: an approximate Schur complementS = E - C D Bwith a diagonal or lumpedDcan be passed asJp. Fieldsplit picks up its block, and multigrid coarsens it, with no PythonPC.DiagonalInverseMatrix(form, bcs=(), lumped=False), D: V* → V, with arguments(Coargument(V*, 0), Coargument(V*, 1)):aA_ii(point Jacobi)a,lumped=TrueΣ_j A_ijover columns that are not BC nodesℓℓ(φ_i)D_ii = 1/d_i, or 0 whered_i = 0or i is a node ofbcs(the pseudoinverse). So D of a one-block form is zero outside that block, andC D Bnever couples through BC nodes, even in a fieldsplit context whose solver BCs do not include them.Lumped row sums are a property of the matrix, so they need
lumped=True. Writing them as the action ofaon a function whose DoFs are all one is wrong after coarsening for H(div): injection makes the coarse DoFs about 2 or 4.Limitations: assembly needs
aijoperands (MatMatMult); D can only be split into diagonal or disjoint blocks.Related: FEniCS/ufl#578 lets
replacereach the operand of aDiagonalInverseMatrixand addsC @ D @ B. This PR does not depend on it.Evidence
New tests, on 1 and 3 processes (all fail or raise without this change):
test_diagonal_inverse_matrix_of_bilinear_form_inverts_diagonal,..._of_linear_form_inverts_lumped_diagonal,test_lumped_diagonal_inverse_matrix_inverts_row_sums_without_bc_nodes,..._is_zero_outside_block: compared withgetDiagonal/A·1computed in PETSc.test_action_of_diagonal_inverse_matrix_is_approximate_schur_complement:assemble(action(C, action(D, B)))equalsC · diag(A)⁻¹ · BfromMatMatMult, with BCs.test_split_diagonal_inverse_matrix: each split block equalscreateSubMatrixof the assembled D.test_coarse_schur_complement_is_rediscretized[lumped=False|True]: the MG coarse operator of the Schur field equalsE - C D Bassembled directly on the coarse mesh. Before: coarsening raises. After: equal to 1e-12.Mixed Darcy (RTCF × DQ0) on a
MeshHierarchy, outer GMRES iterations with one V-cycle on S:The changed modules' test files (
test_assemble_baseform,test_split,test_linesmoother*, multigridtest_schur_complement_gmg,test_transfer_manager,test_stokes_gmg,test_poisson_gmg_extruded,test_nested_split) pass at 1, 2 and 3 processes.Merge Danger
Door: two-way
Blast Radius: small
New class and new dispatch entries. The only change to existing behaviour: multigrid now coarsens
Actionexplicitly, where it used to fall back to a reconstruction that could not rebuild it.AI tool used: Claude Code (Claude Opus 5.5).
🤖 Generated with Claude Code