From eab3c68306eb3fb2434540c9f4c71325bb47ebf4 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Tue, 18 Aug 2026 13:16:58 +0100 Subject: [PATCH 1/3] Test interpolation of products of coefficient evaluations A product of coefficient evaluations on a hexahedron contracts more indices than one sum factorisation can search, and raised NotImplementedError. Cover scalar powers, along with the vector and tensor expressions whose value indices contract the evaluations together. Companion to firedrakeproject/fiat#280. Co-Authored-By: Claude Opus 5 --- .../firedrake/regression/test_interpolate.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/firedrake/regression/test_interpolate.py b/tests/firedrake/regression/test_interpolate.py index 18abca9900..4539c20504 100644 --- a/tests/firedrake/regression/test_interpolate.py +++ b/tests/firedrake/regression/test_interpolate.py @@ -785,3 +785,46 @@ def test_interpolate_indexed(): I1 = assemble(interpolate(u2, U), mat_type="nest") I1_block = assemble(interpolate(TrialFunction(U), U)) assert np.allclose(I1.petscmat.getNestSubMatrix(0, 1)[:, :], I1_block.petscmat[:, :]) + + +@pytest.fixture +def hexmesh(): + return ExtrudedMesh(UnitSquareMesh(1, 1, quadrilateral=True), 1) + + +@pytest.mark.parametrize("source,target,expr,expected", [ + (FunctionSpace, FunctionSpace, + lambda f: f * f * f, + lambda f: f ** 3), + (FunctionSpace, FunctionSpace, + lambda f: f * f * f * f, + lambda f: f ** 4), + (VectorFunctionSpace, VectorFunctionSpace, + lambda f: dot(f, f) * f, + lambda f: np.einsum("...i,...i,...j->...j", f, f, f)), + (TensorFunctionSpace, TensorFunctionSpace, + lambda f: dot(f, f), + lambda f: np.einsum("...ij,...jk->...ik", f, f)), + (TensorFunctionSpace, FunctionSpace, + lambda f: inner(f, f), + lambda f: np.einsum("...ij,...ij->...", f, f)), +], ids=["cube", "quartic", "vector", "tensor", "inner"]) +def test_interpolate_too_many_indices(hexmesh, source, target, expr, expected): + """Test that products of several coefficient evaluations + do not exceed the sum-factorisation index limit. + + Internally, sum_factorise breaks the contraction into + independent subproblems to avoid a monolithic contraction + with too many indices. + + Evaluations that a value index contracts together do not split + into independent subproblems, and are instead kept whole. + """ + V = source(hexmesh, "CG", 1) + W = target(hexmesh, "CG", 1) + + w = Function(V) + w.dat.data[...] = np.arange(1, w.dat.data.size + 1).reshape(w.dat.data.shape) + u = Function(W).interpolate(expr(w)) + + assert np.allclose(u.dat.data_ro, expected(w.dat.data_ro)) From e97df7551d8f931aea6e73863c549bc7a6ecf18f Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Tue, 18 Aug 2026 13:17:14 +0100 Subject: [PATCH 2/3] DROP BEFORE MERGE: build against firedrakeproject/fiat#280 Reinstall FIAT from pbrubeck/atomic-contraction, which is pbrubeck/sum-factorise plus keeping factorised contractions whole. Interpolating a product of coefficient evaluations exceeds the sum factorisation index limit without it. Co-Authored-By: Claude Opus 5 --- .github/actions/install/action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index 54c1411d7f..4a7166e910 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -163,6 +163,14 @@ runs: firedrake-clean pip list + - name: "DROP BEFORE MERGE: install FIAT from firedrakeproject/fiat#280" + shell: bash + run: | + . venv/bin/activate + pip install --verbose --no-build-isolation --no-deps --force-reinstall \ + git+https://github.com/firedrakeproject/fiat.git@pbrubeck/atomic-contraction + pip list | grep -i fiat + - name: Run firedrake-check shell: bash run: | From 3af56fbb2be13d330e5bff27f305be8f33026bc1 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Wed, 19 Aug 2026 15:28:09 +0100 Subject: [PATCH 3/3] Apply suggestion from @pbrubeck --- .github/actions/install/action.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index 4a7166e910..54c1411d7f 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -163,14 +163,6 @@ runs: firedrake-clean pip list - - name: "DROP BEFORE MERGE: install FIAT from firedrakeproject/fiat#280" - shell: bash - run: | - . venv/bin/activate - pip install --verbose --no-build-isolation --no-deps --force-reinstall \ - git+https://github.com/firedrakeproject/fiat.git@pbrubeck/atomic-contraction - pip list | grep -i fiat - - name: Run firedrake-check shell: bash run: |