Repository navigation
Conversation
This was referenced Dec 3, 2026
The aij matrix eliminated the columns of a DirichletBC that is nested in an EquationBC only from the rows of that EquationBC, while the matrix-free operator eliminated them only from the domain rows. So mult and multTranspose of the two operators differed. Eliminate the columns of every DirichletBC in the bcs tree from the domain rows and from every EquationBC row. The matrix stores the bcs of its top-level assembly, and the EquationBC assemblers read the Dirichlet columns from it. The matrix-free EquationBC actions use the input with zeroed Dirichlet entries, as the domain action does. Because the EquationBC rows now eliminate the Dirichlet columns, the solver lifts the residual of each EquationBC with its own Jacobian when pre_apply_bcs=False, as it does for the domain residual. Add the form and bcs arguments to EquationBCSplit.reconstruct, so that the lifted EquationBC is a new object and the problem does not change. Co-authored-by: Sia Ghelichkhan <6863057+sghelichkhani@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EquationBCSplit.reconstruct rebuilt a nested DirichletBC on the function space of the EquationBC. A DirichletBC on one component of a vector field was then applied to every component, so the matrix-free operator had identity rows where the aij matrix has EquationBC rows. Rebuild the nested DirichletBC on its own field and component, as for a nested EquationBC. Co-authored-by: Sia Ghelichkhan <6863057+sghelichkhani@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
force-pushed
the
pbrubeck/equationbc-matfree-aij
branch
from
December 3, 2026 10:34
2bb7857 to
e13994e
Compare
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.
AI assistance: Claude Code (Claude Opus 5.5) helped to write these changes and this description. The fix for the component of a nested DirichletBC and the two test cases come from #5620 by @sghelichkhani.
Summary
Fixes the second case of #5609 and supersedes #5620.
For a DirichletBC nested in an EquationBC, the aij matrix and the matrix-free operator eliminated different columns, so their
multandmultTransposediffered by about 30%. Now both eliminate the columns of every DirichletBC in the bcs tree, in the domain rows and in every EquationBC row:Because the EquationBC rows now eliminate the Dirichlet columns, the solver with
pre_apply_bcs=Falselifts the residual of each EquationBC with its own Jacobian, as it already does for the domain residual:A second commit fixes
EquationBCSplit.reconstruct, which rebuilt a nested DirichletBC on the whole space of the EquationBC. A DirichletBC on one velocity component was then applied to every component, so the matrix-free operator had identity rows where the aij matrix has EquationBC rows.Changes for users
multandmultTransposewith nested DirichletBCsassemble(a, tensor=A, bcs=bcs)A.bcsA.bcstobcsImplementation details
matrix.bcs.multTranspose.EquationBCSplit.reconstructtakes newformandbcsarguments, so that_SNESContextbuilds each lifted EquationBC as a new object and the problem does not change.Limitations
multof the matrix-free operator differs from aij in that row.Evidence
test_matrixfree_action_transpose_blockscomparesmultandmultTransposeof the matrix-free operator, and of each field block fromcreateSubMatrix, with the aij matrix. Two new cases:equationbc_nestedfails onmain. With only the first commit,mixed_equationbc_nestedfails, with a relative difference of 1.7% inmult.After: both pass.
test_matrix_free.pypasses on 1, 2 and 3 processes, andtest_equation_bcs.pypasses on 1 and 3 processes.Merge Danger
Door: two-way
Blast Radius: assembly
Every aij matrix with a DirichletBC nested in an EquationBC changes. Solutions with
pre_apply_bcs=Truedo not change. Code that readsA.bcsafterassemble(a, tensor=A, bcs=...)now sees the new boundary conditions.🤖 Generated with Claude Code