Repository navigation
Conversation
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>
|
Paired firedrake PR: firedrakeproject/firedrake#5323 — firedrakeproject/firedrake#5323 It carries the tsfc zero propagation this needs to reach codegen, the regression tests for quadrilaterals, and a DROP BEFORE MERGE commit pinning CI to this branch. |
| # Avoid circular import dependency | ||
| from finat.tensor_product import TensorProductElement | ||
|
|
||
| product = getattr(self.cell, "product", None) |
There was a problem hiding this comment.
Ugly getattr go away! Use isinstance(self.cell, FlattenedDimensions)
rckirby
left a comment
There was a problem hiding this comment.
Does this have top-level tests of correctness?
| """GEM expression describing the points, with free indices | ||
| ``self.indices`` and shape (point dimension,).""" | ||
|
|
||
| def almost_equal(self, other, tolerance=1e-12): |
There was a problem hiding this comment.
Do we want to read the default tolerance from some underlying data type to facilitate single precision in the future?
There was a problem hiding this comment.
yes, that would be good. Currently we put a dtype on ref_el.vertices precisely becuase we only use tolerances for point inclusions/comparisons
|
|
||
|
|
||
| @pytest.mark.parametrize("cellname", ["quadrilateral", "hexahedron"]) | ||
| @pytest.mark.parametrize("degree", [1, 2, 3, 5]) |
cf129c7 to
7eacfd1
Compare
47c5baf to
975634c
Compare
7eacfd1 to
20379ad
Compare
7167c73 to
a14c69c
Compare
a62a980 to
d630222
Compare
121951c to
a099322
Compare
215aa47 to
050579b
Compare
2e45b9e to
869959e
Compare
Assisted-by: OpenAI Codex
Concatenate the facet directions along the facet index and share the point indices across directions. The dual evaluation and tabulation then use the same basis shape. AI-assisted-by: OpenAI Codex
Use the same directional blocks for the facet selector and the dual evaluation so GEM can split their contraction. Keep flat tabulation for rules that do not factor by direction. AI-assisted-by: OpenAI Codex
Build directional facet point sets directly and preserve the facet basis axis. Cancel facet selectors before splitting concatenated contractions, and use EnrichedElement to evaluate cell quadrature unions. AI-assisted-by: OpenAI Codex
Index a Concatenate with a literal in Indexed, next to the ListTensor rule, and keep only the runtime index lowering to Piecewise in replace_indices. Use delta_elimination to cancel the concatenation index in split_contraction. Treat any UnionPointSet rule as a direct sum, so a single summand goes through EnrichedElement instead of a special case in dual evaluation. Derive the facet blocks of a hypercube from its unflattening map and entity transforms, and make them public as FacetPointSet.tensor_product_blocks. Test the runtime facet lookup that interpolation in a facet integral needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a FacetPointSet, tabulate on each facet and stack the tabulations with a Concatenate on the facet index, for every cell. Tensor product elements stack factor by factor, keeping the product structure on each facet. The points are stacked the same way, so the facet index enters only through Concatenate nodes. The dual evaluation of a facet QuadratureElement then identifies the facet index of the points with the facet index of the basis, and contracts only the points within a facet with the dual basis. unconcatenate splits the facet index off before argument factorisation, so no delta between the facet index and the basis is left to cancel. A runtime lookup of constant per-facet tables folds into a single Literal lookup in select_expression. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When unconcatenate splits a return variable along the facet index, a coefficient contraction that was sum factorised over the stacked Concatenate tables is contracted again for each block, so each facet gets its own contraction order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stack the tabulations of a union, of a facet point set, and of each tensor product factor on a facet with one stack_tabulations function, and tabulate the factors of a tensor product element on an entity in one place. Fold the runtime indexing of a Concatenate into the general branch of replace_indices, index its entries through Indexed, and merge the selection of tables on matching and on different indices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiE9EeMXhu6p14ShyaFE3o
FloorDiv and Remainder decode facet orientations into quadrature point indices. count_flops had no rule for them and returned 0 for the whole kernel, so every exterior facet kernel on a hexahedron reported 0 flops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiE9EeMXhu6p14ShyaFE3o
Literals with equal entries and different dtypes compared equal and had equal hashes. A memoized pass could then replace an integer table with a floating point table that has the same entries. An array index that uses such a table is not integral, and loopy rejects it. Negation multiplies by a -1 that has the dtype of the operand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep each facet's tensor product visible to contraction and eliminate indexed unit vectors as Kronecker deltas. Preserve real deltas under conjugation for adjoint interpolation. AI assistance: OpenAI Codex. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Enable FInAT to evaluate the dual basis of facet quadrature elements on quadrilaterals and hexahedra. A
FacetPointSetgathers points from every facet, and those points factor as a tensor product only when grouped by facet direction. For each direction, the normal factor contributes its two endpoints and the tangential factors contribute their quadrature rules.Dual evaluation concatenates the directional blocks along the facet index in cell facet order and shares the quadrature point indices across blocks. Basis tabulation uses the same blocks for its facet selector, so GEM can split contractions by direction while preserving the element's basis shape and degree-of-freedom ordering.
Each union of point sets is evaluated one constituent rule at a time. Vertex rules use
PointSingletonwith a scalar weight, and point-set comparisons derive their default tolerance from the coordinate dtype.count_flopsnow countsFloorDivandRemainderas integer index arithmetic. Hexahedral facet orientations emit them, and the counter had no rule for them, so it reported 0 flops for every exterior facet kernel on a hexahedron.flops_zeroplus # 0 + children LogicalNot, LogicalAnd, LogicalOr, ListTensor + FloorDiv, RemainderThe companion Firedrake PR exercises scalar, vector, and tensor
Boundary Quadratureinterpolation on quadrilaterals, and facet integrals ofBoundary Quadraturecoefficients on hexahedra. Firedrake #5323Evidence
test_facet_dual_evaluationfailed. The quadrilateral case raisedNotImplementedError: How to tabulate TensorProductElement on FacetPointSet?. On a hexahedron,u*dswithuin Q2 reported 0 flops.test/finat/test_quadrature_element.py. The regression checks that dual evaluation reproduces the reference coordinates in basis order at degrees 1–5 and retains tensor-product tabulation on quadrilaterals and hexahedra. On a hexahedron,f*u*dswithfinBoundary Quadratureof degree 2 anduin Q2 reports 772 flops, and thecount_flopscase forFloorDivandRemainderin Firedrake'stests/tsfc/test_flop_count.pypasses. Source and docstring lint passed.Merge Danger
Door — Two-way. After the companion Firedrake PR merges, coordinate any revert with that PR.
Blast radius — Quadrature. The change affects facet tabulation, dual evaluation of quadrature elements, point-rule handling in FInAT, and the flop counts TSFC reports for hexahedral facet kernels.
AI assistance from Claude Code and OpenAI Codex.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BiE9EeMXhu6p14ShyaFE3o