Repository navigation
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>
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>
compile_expression_dual_evaluation carried a TODO to apply the GEM optimisations that assembly applies. Apply one of them: contract each assignment once unconcatenate has split the Concatenate nodes. This matters for H(div) and H(curl). Those elements are a sum of blocks, each mapping into one vector component, and with firedrakeproject/fiat#270 each block selects its component with a Delta. Before unconcatenation the blocks are branches of a Concatenate, so the Deltas never meet; afterwards each pair of blocks is its own assignment, the Deltas multiply, and delta elimination cancels every pair mapping to different components. Coarse to fine interpolation, kernel temporaries and wall clock: NCF 1->4 832K -> 68K 3.07x faster NCE 1->4 307K -> 110K 2.23x faster NCE 1->3 131K -> 61K 2.23x faster Form assembly does not go through this function and is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Apply to dual evaluation the zero handling assembly already does. Fold zero-valued Literals into symbolic Zero before anything else, so the algebraic identities built into gem (Product(_, Zero) -> Zero, and so on) can propagate them and the later steps can prune what they reach. Then drop any pair whose expression has collapsed to Zero once the blocks are contracted: a cross-component block that a Delta has just cancelled is a real zero contribution rather than one merely absent from the sum, and it must not reach codegen as a temporary. Emit a Zero temporary as a zero-filled read-only array when one does reach loopy, as gem.Zero carries no .array for the Constant branch to use.
Run the quadrature element tests on a quadrilateral mesh as well as a triangular one, and check that interpolation into a facet quadrature space reproduces the expression at the points and gives both cells sharing a facet the same values there. Scalar, vector and tensor valued spaces each take a different path through dual evaluation, so cover all three. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Point the existing FIAT install step at pbrubeck/tensor-facet-quadrature, which is pbrubeck/fix/dual-enriched plus the facet quadrature work. A Boundary Quadrature space on a quadrilateral cannot be interpolated into without it: the dual basis names the points of every facet at once, and a TensorProductElement cannot tabulate on those. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pbrubeck
commented
Aug 4, 2026
pbrubeck
commented
Aug 4, 2026
pbrubeck
commented
Aug 4, 2026
Co-authored-by: Pablo Brubeck <brubeck@protonmail.com>
pbrubeck
commented
Aug 4, 2026
pbrubeck
force-pushed
the
pbrubeck/hdivcurl-delta
branch
from
August 18, 2026 22:22
a992610 to
537d1b5
Compare
pbrubeck
force-pushed
the
pbrubeck/tensor-facet-quadrature
branch
from
September 23, 2026 00:49
61233e4 to
b4efefe
Compare
Keep the shared TSFC interpolation path. FIAT now returns the facet quadrature basis in the layout used by tabulation. Exercise the quadrature interpolation regressions on one and two MPI ranks. AI-assisted-by: OpenAI Codex
Use the operators in each integrand when choosing the quadrature rule. Test Boundary Quadrature interpolation in exterior and interior facet integrals. AI-assisted-by: OpenAI Codex
On a hexahedron the quadrature points of a facet integral are replaced by orientation-permuted runtime indices. With one point on an axis, a facet quadrature coefficient leaves Delta(q, 0) after its singleton sum is unrolled, and the permuted q stops it from folding, so a Delta reached code generation. The only permutation of a single point is the identity, so such an axis takes the fixed index 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiE9EeMXhu6p14ShyaFE3o
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiE9EeMXhu6p14ShyaFE3o
Apply the facet orientation permutation to the basis tables instead of to the contracted result. The argument tables are already permuted in the same way. Interpolated values on Boundary Quadrature elements then need no separate treatment. AI assistance: OpenAI Codex. 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
Support interpolation into
Boundary Quadraturespaces on quadrilaterals. FIAT supplies the dual evaluation for each facet direction of the tensor-product cell. FIAT #274When an interpolation appears inside a form, TSFC now includes its target element when inferring the quadrature rule.
Infer the quadrature rule from: arguments, coordinates, coefficients + elements of base form operators in the integrandOn a hexahedron, TSFC replaces the quadrature point indices of a facet integral with indices permuted by the facet orientation. An axis with a single point now keeps the fixed index 0, because the only permutation of one point is the identity. Before this change, a
Boundary Quadraturecoefficient with one point per axis leftDelta(q, 0)after its singleton sum was unrolled, and the permutedqkept thatDeltafrom folding before code generation.The regression tests check scalar, vector, and tensor interpolation on triangles and quadrilaterals. They verify that both
Function.interpolateandinterpolateinside a form reproduce the expression at the exterior and interior facet quadrature points. A TSFC test compilesf*u*dsandInterpolate(u, V)*u*dson quadrilaterals and hexahedra, withVaBoundary Quadraturespace of degree 1 or 2.Evidence
NotImplementedError: How to tabulate TensorProductElement on FacetPointSet?with the base FIAT revision. With both repositories at their base revisions,f*u*dson a hexahedron raisedAssertionError: cannot generate expression from <class 'gem.gem.Delta'>at degree 1 and reported 0 flops at degree 2.db5a42ae, all 405 TSFC tests passed. The new hexahedron cases intest_boundary_quadrature_in_facet_integralfail without the fix.test_quadrature.pyand the eight test files with hexahedral facet integrals passed at 1 to 8 MPI ranks. Quadrilateral flop counts did not change. On a perturbed hexahedral mesh,f*u*ds,Interpolate(g, Q)*u*ds, and theirdScounterparts matchedg*u*ds(degree=deg)to 1e-14 at degrees 1–3. Firedrake still rejectsBoundary Quadraturespaces on hexahedral meshes, so this check bypassedcheck_elementin a script.flake8passed on the changed files. FIAT #274Merge Danger
Door — Two-way. The Firedrake changes can be reverted independently.
Blast radius — Assembly. The change affects quadrature inference for integrands that contain base form operators, and the point indices of every facet integral on a hexahedron whose rule has an axis with a single point.
Merge FIAT #274 first, then drop the temporary CI install step for its branch.
AI assistance from Claude Code and OpenAI Codex.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BiE9EeMXhu6p14ShyaFE3o