p-multigrid: remove custom interpolation code - #5289
Open
pbrubeck wants to merge 2 commits into
Open
Conversation
pbrubeck
force-pushed
the
pbrubeck/remove-pmg-parloop
branch
from
July 29, 2026 10:25
a79a5c0 to
2c9e9a1
Compare
pbrubeck
marked this pull request as ready for review
July 29, 2026 10:31
pbrubeck
force-pushed
the
pbrubeck/remove-pmg-parloop
branch
from
July 29, 2026 10:33
2c9e9a1 to
8b84e62
Compare
This was referenced Jul 29, 2026
leo-collins
reviewed
Jul 29, 2026
| return Interpolate(expr, V, **kwargs) | ||
|
|
||
|
|
||
| def _bc_root(bc: DirichletBC) -> WithGeometry: |
Contributor
There was a problem hiding this comment.
interpolation seems like a strange place to have this. Maybe put it as a method on BCBase?
pbrubeck
commented
Jul 29, 2026
Comment on lines
+371
to
+374
| if is_dual(Vrow): | ||
| Vrow = Vrow.dual() | ||
| if is_dual(Vcol): | ||
| Vcol = Vcol.dual() |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| if is_dual(Vrow): | |
| Vrow = Vrow.dual() | |
| if is_dual(Vcol): | |
| Vcol = Vcol.dual() | |
| Vcol = Vcol.dual() |
pbrubeck
commented
Jul 29, 2026
pbrubeck
force-pushed
the
pbrubeck/remove-pmg-parloop
branch
from
July 29, 2026 18:30
8b84e62 to
41c33c8
Compare
Assembling a two-form Interpolate matrix-free passed the same bcs as both the row and the column bcs of the ImplicitMatrixContext, and left on_diag at its default of True. Neither holds for interpolation between two different spaces: applying the target space's bcs to the source side raised "Cofunction defined on incompatible FunctionSpace", and on_diag made multTranspose try to write the row values into the column vector. Split the bcs by the space they are defined on, as the assembled path already does, and set on_diag from whether the two spaces coincide. A bc on a component of a mixed space is defined on an IndexedProxyFunctionSpace rather than on the space itself, so compare against the top-level parent, which BCBase.function_space now returns on request. Coarsen the p-multigrid nullspace with a locally built interpolation matrix, rather than through getNestSubMatrix, which only the removed MixedInterpolationMatrix provided. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pbrubeck
force-pushed
the
pbrubeck/remove-pmg-parloop
branch
from
July 29, 2026 23:29
3d81cdf to
33be7ba
Compare
pbrubeck
changed the base branch from
pbrubeck/fix/dual-enriched
to
pbrubeck/hdivcurl-delta
July 29, 2026 23:33
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.
Removes ~1050 lines of hand-written interpolation machinery from
firedrake/preconditioners/pmg.py—StandaloneInterpolationMatrix,MixedInterpolationMatrix,kronmxv,get_permutation_to_nodal_elements,evaluate_dualand friends — and replaces the p-multigrid transfer operators withthe generic
assemble(interpolate(TrialFunction(cV), fV)). The helpers that are stillneeded move to
firedrake/preconditioners/fdm.py.Stacked on #5295, which fixes the matrix-free adjoint interpolation this now relies on.
Also needs firedrakeproject/fiat#268 — see the
DROP BEFORE MERGEcommit, whichapplies to both PRs in the stack.
Bugs this exposed
Routing the transfers through the generic interpolation path uncovered three defects
that the bespoke code had been bypassing. Two are fixed in the PRs below this one; the
Firedrake-side ones are in the second commit here:
Rectangular matrices got the wrong bcs. Assembling a two-form
Interpolatematrix-free passed the same bcs as both the row and the column bcs of the
ImplicitMatrixContext, and lefton_diagat its default ofTrue. Neither holdswhen interpolating between two different spaces: applying the target space's bcs to
the source side raised
Cofunction defined on incompatible FunctionSpace, andon_diagmademultTransposewrite the row values into the column vector. The bcsare now split by the space they are defined on, as the assembled path already does,
and
on_diagis set from whether the two spaces coincide. A bc on a component of amixed space is defined on an
IndexedProxyFunctionSpacerather than on the spaceitself, so the comparison walks up to the top-level parent — without that, bcs on a
mixed space were silently dropped from both lists and the preconditioner degraded
(
test_p_multigrid_mixedneeded 8 iterations instead of 7).Nullspace coarsening used a deleted API.
coarsen_nullspacecalledinterpolate.getNestSubMatrix(i, i), which onlyMixedInterpolationMatrixprovided.It now recurses over the sub-spaces and builds the interpolation matrix locally.
Testing
tests/firedrake/regression/test_fdm.pytests/firedrake/multigrid/test_p_multigrid.pytests/firedrake/multigridmake srclintMatrix-free
mult/multTransposewere also compared against the assembled matrixacross 47 element/mesh combinations, all agreeing to machine precision.
🤖 Generated with Claude Code