Skip to content

Gradient recovery by L2-projection#13

Merged
joewallwork merged 12 commits intomainfrom
5_recovery
Feb 10, 2026
Merged

Gradient recovery by L2-projection#13
joewallwork merged 12 commits intomainfrom
5_recovery

Conversation

@joewallwork
Copy link
Copy Markdown
Member

Towards #11.
Towards #5.

This PR adds a recovery module and ports the recover_gradient_l2 function over from Animate. Once this is merged, we will just need to port the Clement interpolant (see #12) and recover_hessian_clement (which uses both clement_interpolant and recover_gradient_l2) and then Movement will be independent of Animate.

@joewallwork joewallwork self-assigned this Jan 30, 2026
@joewallwork joewallwork added the enhancement New feature or request label Jan 30, 2026
@joewallwork joewallwork changed the title 5 recovery Gradient recovery by L2-projection Jan 30, 2026
@joewallwork joewallwork marked this pull request as ready for review February 4, 2026 08:26
Copy link
Copy Markdown
Member

@stephankramer stephankramer left a comment

Choose a reason for hiding this comment

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

Minor suggestions

Comment thread adapt_common/recovery.py Outdated
Comment on lines +32 to +33
"Input Function must be at least degree 2 to recover gradient"
" in CG space."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to clarify: it's perfectly valid to L2 project the gradient of a CG1 Function to CG1 or DG0, right? Which seems to be allowed indeed if you provide your own target space. Here, the automatic choice of CG(k-1) of course doesn't work, but the error message seems to imply something more - which might be confusing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. I extended to allow CG1 input (implying DG0 output) in f1d4c92, providing a test in 070264f.

Comment thread adapt_common/recovery.py Outdated
" in CG space."
)
raise ValueError(val_err)
target_degree = max(1, source_degree - 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick, but we've already assured source_degree-1>1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good spot. Fixed in f1d4c92.

Comment thread adapt_common/recovery.py Outdated
@joewallwork joewallwork merged commit 4a593ff into main Feb 10, 2026
1 check passed
@joewallwork joewallwork deleted the 5_recovery branch February 10, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants