Repository navigation
Give ZeroBaseForm terminal_numbering() and a _cache - #556
Merged
Merged
Conversation
Add terminal_numbering(), which returns an empty numbering, and a _cache dict like the one on Form. Together with integrals() and constants(), form compilers and Firedrake can then process a ZeroBaseForm like a Form without integrals. Needed for firedrakeproject/firedrake#5571. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 11, 2026
pbrubeck
added a commit
to firedrakeproject/firedrake
that referenced
this pull request
Nov 17, 2026
Install UFL from the branch pbrubeck/zero-base-form-cache over the UFL main pin, in the composite install action and in the docs job. The branch adds ZeroBaseForm.terminal_numbering() and _cache, which the assembly of a ZeroBaseForm needs. Install it after Firedrake, since the direct URL pin on UFL main would otherwise reinstall main over it. Drop this commit once FEniCS/ufl#556 merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jorgensd
approved these changes
Nov 25, 2026
pbrubeck
added a commit
to firedrakeproject/firedrake
that referenced
this pull request
Nov 25, 2026
Use UFL main now that FEniCS/ufl#556 has merged. Assisted-by: OpenAI Codex
pbrubeck
added a commit
to firedrakeproject/firedrake
that referenced
this pull request
Nov 27, 2026
* Assemble a ZeroBaseForm like any other form Dispatch a ZeroBaseForm to the 0-, 1- and 2-form assemblers, so that assemble() returns a zero float, Cofunction or Matrix instead of the symbolic ZeroBaseForm. TSFC generates no kernels for a form without integrals, so the assemblers only allocate the output, zero it, and apply the boundary conditions. A zero 2-form with Dirichlet boundary conditions therefore gets the identity on the boundary rows, as any other assembled matrix does. Use COMM_SELF for the compilation cache and the scalar output of a form without a mesh, since such a form has no integrals and nothing is compiled or reduced. This fixes the adjoint of a solve whose residual depends on a control only through a conditional predicate (#5571), where dF/dm is a ZeroBaseForm. Requires a UFL in which ZeroBaseForm provides integrals(), constants(), terminal_numbering() and _cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Test the assembly of a vanishing 0-form Assemble 0*dx and 0*ds, which raised an IndexError on the release branch (#3598). Main already returns 0, since #5551 left the preprocessing of a plain form to TSFC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * DROP BEFORE MERGE: Install the UFL branch for ZeroBaseForm Install UFL from the branch pbrubeck/zero-base-form-cache over the UFL main pin, in the composite install action and in the docs job. The branch adds ZeroBaseForm.terminal_numbering() and _cache, which the assembly of a ZeroBaseForm needs. Install it after Firedrake, since the direct URL pin on UFL main would otherwise reinstall main over it. Drop this commit once FEniCS/ufl#556 merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Remove temporary UFL branch override Use UFL main now that FEniCS/ufl#556 has merged. Assisted-by: OpenAI Codex --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
Firedrake assembles a
ZeroBaseFormthrough the same path as aFormwithout integrals, so it needs the rest of the form-compiler interface onZeroBaseForm:class ZeroBaseForm(BaseForm): __slots__ = ( "_arguments", + "_cache", ... ) def integrals(self): # from #451 return () + def terminal_numbering(self): + return {} def constants(self): # from #451 return ()_cachestays onZeroBaseForm, becauseBaseForm.__slots__is kept empty for multiple inheritance.Needed for firedrakeproject/firedrake#5571. The 2026.2 backport is #557.
Evidence
assemble(ZeroBaseForm((v,)))in Firedrake, routed to its 1-form assembler:Cofunction. The newtest_zero_base_form_compiler_interfacepasses, and so does the full UFL suite (1259 passed). ruff 0.17.4 and mypy 2.4.1 (.[ci]) are clean.Merge Danger
Door: two-way
Blast Radius: small
The change only adds methods and a slot. Code that tests
hasattr(form, "_cache")to tell aFormfrom aZeroBaseFormwould now see both alike.🤖 Drafted with Claude Code (Claude Opus 5.5).