Fix matrix-free adjoint interpolation into Restricted/EnrichedElement - #5295
Open
pbrubeck wants to merge 2 commits into
Open
Fix matrix-free adjoint interpolation into Restricted/EnrichedElement#5295pbrubeck wants to merge 2 commits into
pbrubeck wants to merge 2 commits into
Conversation
…ient compile_expression_dual_evaluation contracts the dual evaluation against the dual coefficient with an IndexSum over the basis indices when the dual argument is a Cofunction. When the target element has a block-structured dual basis (e.g. a RestrictedElement, whose dual evaluation is a gem.Concatenate), this hid the concatenation index from the subsequent unconcatenate() call, which can only split along indices that are still free in the assignment. Resolve the concatenation of the dual basis before the basis indices are summed over, following the same pattern already used for coefficient evaluation in tsfc.fem. This makes matrix-free adjoint interpolation (MatMultTranspose of a two-form Interpolate) work for restricted elements. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pbrubeck
force-pushed
the
pbrubeck/fix/dual-enriched
branch
from
July 29, 2026 10:33
cf08365 to
a9ee8fa
Compare
This was referenced Jul 29, 2026
pbrubeck
force-pushed
the
pbrubeck/fix/dual-enriched
branch
from
July 29, 2026 18:30
a9ee8fa to
168ee7b
Compare
EnrichedElement has no dual basis without it, so interpolating into the facet space of a hexahedron raises NotImplementedError, and gem cannot unconcatenate a dual basis whose blocks have already been contracted with a Cofunction. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pbrubeck
force-pushed
the
pbrubeck/fix/dual-enriched
branch
from
July 29, 2026 23:29
168ee7b to
6072eee
Compare
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.
Assembling a two-form
Interpolateagainst aCofunction— the adjoint of amatrix-free interpolation matrix, i.e.
MatMultTranspose— failed for any targetelement with a block-structured dual basis, such as a
RestrictedElement:compile_expression_dual_evaluationcontracts the dual evaluation against the dualcoefficient with an
IndexSumover the basis indices when the dual argument is aCofunction. When the target element's dual evaluation is agem.Concatenate, thatcontraction hides the concatenation index from the subsequent
unconcatenatecall,which can only split along indices that are still free in the assignment.
Resolve the concatenation of the dual basis before the basis indices are summed
over, following the same pattern already used for coefficient evaluation in
tsfc.fem. The twounconcatenatecalls share an index splitting cache so a givenConcatenateindex is always split the same way.Interpolation points come from the dual point set
firedrakeproject/fiat#268 makes an element whose functionals do not all evaluate on
the same points a direct sum, with a dual basis on each of its sub-elements rather
than one weight tensor on one point set. Reconstructing such a space as a runtime
Quadraturespace only ever wanted the points, so it asks fordual_point_setdirectly instead of unpacking
dual_basis.Depends on firedrakeproject/fiat#268, which supplies the corresponding
gemfix:find_groupmust intersect against the assignment variables' free indices, not theexpressions'. Without it the extra
unconcatenatecall here can recurse on a pair itcannot split.
Testing
Matrix-free
mult/multTransposewere compared against the assembled matrix overquadrilateral, triangle, hexahedron and prism meshes, CG/RTCE/RTCF, full/facet/interior
restrictions, spectral and fdm variants: 47 cases, all agreeing to machine precision.
The p-multigrid and FDM PR is stacked on top of this one.
🤖 Generated with Claude Code