Repository navigation
Conversation
contraction() split the whole product into ListTensor entries, which pulled the component Delta of a vector-valued Argument into every entry, so spectral mode raised FactorisationError for vector spaces of physically mapped elements. Fixes firedrakeproject/firedrake#5690 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI assistance used OpenAI Codex.
Partition factors after Delta cancellation and respect scope when locating free ListTensor indices. Preserve reductions over invariant factors and keep coupled argument axes visible to TSFC. AI assistance used OpenAI Codex.
Preserve free Delta selectors per contraction group so independent ListTensor entries still specialise. Restore the one-argument contraction interface. AI assistance used OpenAI Codex.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
added a commit
to firedrakeproject/firedrake
that referenced
this pull request
Nov 26, 2026
Install fiat 161738ac from firedrakeproject/fiat#317 and UFL 24a8b5dd from FEniCS/ufl#571 in the test and documentation jobs. Drop this commit, with the earlier DROP BEFORE MERGE commits, once both companions have merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
added a commit
to firedrakeproject/firedrake
that referenced
this pull request
Nov 26, 2026
Install fiat from pbrubeck/fix/listtensor-contraction (firedrakeproject/fiat#317) and UFL from pbrubeck/fix/interpolate-target-domain (FEniCS/ufl#571) in the test and documentation jobs. Drop this commit, with the earlier DROP BEFORE MERGE commits, once both companions have merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The derivatives of a vector-valued basis form a ListTensor over the derivative direction, and every entry carries the Delta that couples a basis function to its value component. contraction() refuses to split a ListTensor contraction whose factors carry a Delta index, so the buried Delta kept the basis transformation of a physically mapped element from absorbing the contraction with an interpolated basis. TSFC then contracted the interpolation matrix at every quadrature point, and a vector of zany elements cost more than twice the scalar form. Since [c x_0, ..., c x_n]_i = c [x_0, ..., x_n]_i, contraction() now pulls the factors shared by every entry of an indexed ListTensor out before cancelling Deltas. 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.
Summary
Fixes firedrakeproject/firedrake#5690
Bug
Spectral mode raises
FactorisationErrorforinterpolate(v, T)whenvis an Argument on aVectorFunctionSpaceof a physically mapped element (Hermite, Morley, Argyris, Bell). Vanilla mode works.The vector basis is a product of the transformed scalar basis and a component selector:
contraction()split the whole product along every free index of a ListTensor, so theDeltawas copied into each ListTensor entry:collect_monomialscannot see an argument factor inside a ListTensor, so it raisesFactorisationError.Fix
Split only the factors that depend on the ListTensor index, and leave the rest outside:
The
Deltanow stays a top-level factor, wherecollect_monomialsfinds it.Splitting a group substitutes fixed values for its ListTensor index. That exposed index bugs in GEM, which this PR also fixes:
replace_indices(IndexSum)renames a bound index when a substitution would capture it. When a specialised entry no longer depends on a summed index, it multiplies by that index's extent, so the sum keeps its value.traverse_productandMonomialSum.product/_collect_monomialsreserve the expression's free indices before renaming, so a renamed sum index cannot reuse a free index's name._collect_monomialssums out an index right away when only non-atomic factors use it, or when Delta cancellation has left no factor that depends on it._contracthandles a sum index that no factor depends on.associatefalls back to a linear pass for products with more than 32 operands. Before, it raisedNotImplementedError.This PR is stacked on the coordinate-mapping changes in #316.
Evidence
inner(interpolate(v, T), Constant((1, 0))) * dxwithvin vector Hermite, Morley, Argyris or Bell andTvector CG1 or DG1: all 8 cases raiseFactorisationErrorin spectral mode.After: all 8 compile and agree with
"mode": "vanilla"(max difference 1.4e-17).test_refactorise_contracted_list_tensorfails on both parameters, because theDeltais buried inside the ListTensor.After: it passes.
collect_monomials(contraction(expr))returns a single monomial withatomics == (Delta(source, target),), and evaluating it gives the original values.FactorisationError.After: the Bernardi–Raugel case and the vector Morley cases for RT, N1curl and gradient interpolation pass. They agree with vanilla mode to within 8.4e-17.
test/gemandtest/finatpass (685 passed, 8 skipped). The 400 TSFC tests pass, includingtest_sum_factorisationandtest_flop_countfor tensor-product H(div)/H(curl). The serial tests in Firedrake'stest_interpolate_zany.py,test_interpolation_operators.py,test_interp_dual.pyandtest_helmholtz_zany.pypass.make lintis clean.Merge Danger
Door: two-way
Reverting this PR restores the old splitting. No API or data-format change.
Blast Radius: kernels
Every kernel whose contraction has a ListTensor indexed by a free index now goes through the new grouping. This includes tensor-product H(div)/H(curl) elements. The flop-count tests pass, but exact kernel cost has not been benchmarked.
AI assistance used Claude Code (Claude Opus 5.5) and OpenAI Codex.
🤖 Generated with Claude Code