Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility fix for Firedrake 2024-12 Docker image #24

Conversation

vojtamolda
Copy link
Contributor

@vojtamolda vojtamolda commented Dec 5, 2024

This PR removes the (actually unused) import of firedrake_configuration package that is no longer present in recent (2 weeks or so) versions of Firedrake Docker Hub image.

Root cause of the issue is the migration of Firedrake to be pip-installable. There's details about the topic here. Specifically, the problem started with the PR that migrates PyOP2 into the main Firedrake repo.


It seems like the obvious fix, i.e. just remove the import, worked. The firedrake_configuration module wasn't used for anything directly within the firedrake_ts package. Besides this, the PR contains a few small fixes to make the unit tests and examples work.

It seems like PETSc 3.22 upgrage that's bundled in the Firedrake 2024-12 image doesn't set the ts_max_snes_failures option anymore. Somehow the default value causes the inner SNES solver never to retry any linear solves. So the TS solver has no other option but to fail whenever it happens instead of retrying.

I also migrated the example applications to use the newer interpolate and VTK output Firedrake API.

- Monkey-patch u_restrict property required by newer PETSc TS
- Package is no longer available due to pip install migration
- Migrate adjoint.py to newer interpolate API
- Set max SNES failures to make TS retry steps
@vojtamolda
Copy link
Contributor Author

vojtamolda commented Dec 6, 2024

Fixes #23. I also tested the firedrakeproject/firedrake:2024-11 image and everything works there as well.

- Silences deprecation warning emitted from Firedrake
- Duck typing compatible with VariationalProblem class
- Use the new member everywhere
@vojtamolda
Copy link
Contributor Author

vojtamolda commented Dec 23, 2024

I figured out why the tests were failing and fixed. So all tests now pass for me locally. I'm still not sure what's wrong with the CI here though...

Besides that I also polished the changes in this PR to make them more consistent with recent Firedrake changes. The DAEProblem is duck-type compatible with VariationalProblem. Due to the changes in Firedrake PR 3215 the use self.u_restrict is preferable to self.u.

@IvanYashchuk
Copy link
Owner

Hi Vojta! Thank you for submitting the pull request! I'll take a look at what's wrong with the CI this week. Let's merge when we get a green signal in the CI.

Copy link
Owner

@IvanYashchuk IvanYashchuk left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for keeping this project alive and working!

@@ -81,15 +81,16 @@ def __init__(
is_form_consistent(self.is_linear, self.bcs)
self.Jp_eq_J = Jp is None

self.u = u
self.u_restrict = u
Copy link
Owner

Choose a reason for hiding this comment

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

Why do you like the "_restrict" suffix over the original naming?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally don't like u_restrict at all. But I think it is the most seamless way to make Firedrake TS compatible with the upstream changes done in Firedrake. The alternative would be to keep both u and u_restrict around which I think would confuse people and cause some unnecessary head scratching for the readers.

Here's the exact line that adds the u_restrict property to NonlinearVariationalProblem class: https://github.com/firedrakeproject/firedrake/blob/8e937ed13c6b62a02c09a98e81eb7fe877180950/firedrake/variational_solver.py#L92

This is the PR merged about 8 months ago that adds u_restrict to Firedrake:
firedrakeproject/firedrake#3215

The DAEProblem class from here needs to be duck-type compatible with NonlinearVariationalProblem from Firedrake to make the solve(...) call work. The missing u_restrict property error is actually a follow up problem that I got when I fixed the package import problem described in #23.

@IvanYashchuk IvanYashchuk merged commit ed997a9 into IvanYashchuk:master Dec 27, 2024
2 checks passed
@vojtamolda
Copy link
Contributor Author

Thanks a lot for maintaining this repo and fixing the CI. It's a nice little package!

@vojtamolda vojtamolda deleted the firedrake-2024-12-compatibility-fix branch December 27, 2024 15: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.

2 participants