Skip to content

Give each pull back an inverse - #70

Closed
pbrubeck wants to merge 1 commit into
pbrubeck/interpolate-holesfrom
pbrubeck/pullback-apply-inverse-holes
Closed

Give each pull back an inverse#70
pbrubeck wants to merge 1 commit into
pbrubeck/interpolate-holesfrom
pbrubeck/pullback-apply-inverse-holes

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Sep 8, 2026

Copy link
Copy Markdown

Description

A pull back maps a function on the reference cell to the physical cell. UFL had no map in the other direction, so a form compiler that has to evaluate a physical expression on the reference cell — to dual-evaluate an Interpolate, for instance — carried its own copy of the Piola maps. TSFC has one.

This adds apply_inverse to AbstractPullback and implements it for every pull back that has an inverse:

pull back apply apply_inverse
IdentityPullback g g
ContravariantPiola (1/detJ) J g detJ K g
CovariantPiola Kᵀ g Jᵀ g
L2Piola g / detJ g detJ
DoubleContravariantPiola (1/detJ)² J g Jᵀ detJ² K g Kᵀ
DoubleCovariantPiola Kᵀ g K Jᵀ g J
CovariantContravariantPiola (1/detJ) Kᵀ g Jᵀ detJ Jᵀ g Kᵀ
MixedPullback per sub-element per sub-element
SymmetricPullback per unique block per unique block

PhysicalPullback and CustomPullback are their own inverse. UndefinedPullback inherits the NonStandardPullbackException from AbstractPullback, as it does for apply.

The test asserts the property that matters rather than the formulas: pushing a reference function forward and mapping it back returns the original, once remove_component_tensors and cancel_jacobian_products have cancelled the Jacobian products the round trip leaves behind. That closes exactly for eight of the nine, mixed and symmetric elements included. The L2Piola round trip leaves detJ / detJ standing, because cancelling a scalar factor is not something cancel_jacobian_products does, so that one is asserted directly instead.

Stacking

Based on pbrubeck/interpolate-holes (FEniCS#497), so that the branch pairs with pbrubeck/form-interp-tsfc in Firedrake. The pull back work itself is independent of FEniCS#497, and the same commit is proposed upstream against main as FEniCS#511.

Nothing calls apply_inverse yet. #69 uses it to lower interpolation in compute_form_data, which lets TSFC delete its copy of the maps.

🤖 Generated with Claude Code

https://claude.ai/code/session_0155wQMTMSGiF9a6TbyTVK5P

A pull back maps a function on the reference cell to the physical cell.
Nothing in UFL went the other way, so a form compiler that has to evaluate a
physical expression on the reference cell had to carry its own copy of the
maps.

apply_inverse is the inverse of apply, for every pull back that has one.
PhysicalPullback and CustomPullback are their own inverse, and
UndefinedPullback inherits the refusal from AbstractPullback.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0155wQMTMSGiF9a6TbyTVK5P
@pbrubeck

pbrubeck commented Sep 8, 2026

Copy link
Copy Markdown
Author

Superseded by #71, which uses the same branch as FEniCS#511 instead of a duplicate of it.


Written by Claude (Claude Code), posted from @pbrubeck's account.

@pbrubeck pbrubeck closed this Sep 8, 2026
@pbrubeck
pbrubeck deleted the pbrubeck/pullback-apply-inverse-holes branch September 8, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant