Skip to content

Propagate coordinate mapping through FInAT wrappers - #316

Open
pbrubeck wants to merge 3 commits into
mainfrom
pbrubeck/zany-vector
Open

pbrubeck wants to merge 3 commits into
mainfrom
pbrubeck/zany-vector

Conversation

@pbrubeck

Copy link
Copy Markdown

Summary

Wrapped element needs a coordinate mapping
  → wrapper reports that requirement
  → wrapper passes the supplied mapping to its evaluation calls

This provides the FInAT side of the fix for firedrakeproject/firedrake#5687.

Evidence

  • Before the paired fix, the Bernardi-Raugel and Rotated-Bernardi-Raugel vector interpolation cases failed with AssertionError when the base element received no coordinate mapping.
  • With the paired TSFC patch, both cases match componentwise interpolation on one and two MPI ranks. All 625 FInAT tests and make lint passed locally.

Merge Danger

Two-way. This adds a property to FInAT elements and forwards geometry in wrapper evaluation. Merge this PR before the Firedrake companion that reads the property.

AI assistance used OpenAI Codex.

@pbrubeck pbrubeck added the LLM used An LLM was used in the production of this PR label Nov 20, 2026
pbrubeck added a commit to firedrakeproject/firedrake that referenced this pull request Nov 20, 2026
Run test and documentation jobs against the coordinate mapping API from firedrakeproject/fiat#316. Drop this commit after that PR merges into FIAT main.

AI assistance used OpenAI Codex.
@pbrubeck
pbrubeck added this pull request to stack #318 November 22, 2026 12:37
Comment thread finat/finiteelementbase.py Resolved
@pbrubeck
pbrubeck force-pushed the pbrubeck/zany-vector branch from 05c90be to 521b035 Compare November 25, 2026 11:02
@pbrubeck
pbrubeck requested a review from connorjward November 25, 2026 11:07

@connorjward connorjward left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still reads like a code smell to me. Now that needs_coordinate_mapping is a property to me it makes far more sense to avoid having a mixin class at all. In particular you now have

elem.needs_coordinate_mapping and not isinstance(elem, NeedsCoordinateMapping)

which is deeply unintuitive.

Just have things like:

def dual_transformation(self, ...):
  if self.needs_coordinate_mapping:
    # do what the mixin currently does
  else:
    # do what FiniteElementBase does

@pbrubeck

pbrubeck commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

This still reads like a code smell to me. Now that needs_coordinate_mapping is a property to me it makes far more sense to avoid having a mixin class at all. In particular you now have

elem.needs_coordinate_mapping and not isinstance(elem, NeedsCoordinateMapping)
which is deeply unintuitive.

Where did you find this?

Just have things like:

def dual_transformation(self, ...):
if self.needs_coordinate_mapping:
# do what the mixin currently does
else:
# do what FiniteElementBase does

NeedsCoordinateMapping is quite abstract and should only serve the role of telling the form compiler to pass the coordinate mapping to basis_evaluation and dual_transformation, which is what we expose with needs_coordinate_mapping property.

But keeping the mixin is still worth it because there are two further mixins: PhysicallyMappedElement and DirectlyDefinedElement, the latter being inherently ungeneralizable.

PhysicallyMappedElement and DirectlyDefinedElement now declare
needs_coordinate_mapping themselves, so the property is the single
marker for elements that require a coordinate mapping.

AI assistance: Claude Code (Claude Opus 5.5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbrubeck

Copy link
Copy Markdown
Author

I deleted NeedsCoordinateMapping, but kept PhysicallyMappedElement and DirectlyDefinedElement

@connorjward connorjward left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice thanks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM used An LLM was used in the production of this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants