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

Add P argument to solve function #3555

Closed
wants to merge 7 commits into from

Conversation

juliusgh
Copy link
Contributor

@juliusgh juliusgh commented May 7, 2024

The class LinearSolver already supports passing a custom preconditioner matrix P to the PETSc solver.
However, this is so far not available through the solve function.

This PR adds an argument P to the solve function that is passed to the LinearSolver. At least in my case, it would be convenient to pass a custom preconditioner matrix directly in this way.

Copy link
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

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

This seems sensible. Thanks!

It would be nice to have a test for this but I think that might be tricky to come up with. We don't even test the P argument to LinearSolver as things stand.

firedrake/solving.py Outdated Show resolved Hide resolved
firedrake/solving.py Outdated Show resolved Hide resolved
@juliusgh
Copy link
Contributor Author

juliusgh commented May 7, 2024

Thanks for the quick reply!

I think a short unit test would indeed be difficult to find. I am using the P matrix passing to solve homogenization problems from computational mechanics with a custom preconditioner. FFT-based preconditioners are very effective for these problems, but in addition to A, a suitable operator P must also be passed. I could provide a documented demo that uses this feature, but maybe that's too specific for firedrake...

dham
dham previously approved these changes May 8, 2024
Copy link
Member

@dham dham left a comment

Choose a reason for hiding this comment

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

Thank you!

@connorjward
Copy link
Contributor

Thanks for the quick reply!

I think a short unit test would indeed be difficult to find. I am using the P matrix passing to solve homogenization problems from computational mechanics with a custom preconditioner. FFT-based preconditioners are very effective for these problems, but in addition to A, a suitable operator P must also be passed. I could provide a documented demo that uses this feature, but maybe that's too specific for firedrake...

To quote @dham re the suggested demo: "yes yes yes please". Demos are always great to have.

@connorjward connorjward enabled auto-merge (squash) May 13, 2024 12:24
connorjward
connorjward previously approved these changes May 13, 2024
@connorjward
Copy link
Contributor

@juliusgh please could you rebase this code on top of the latest master/merge in the latest master and push it again? The tests are failing and that should fix them. Then I will merge this. Thanks.

ksagiyam and others added 5 commits May 13, 2024 17:44
…#3552)

Also default to L2 projection.

---------

Co-authored-by: David A. Ham <david.ham@imperial.ac.uk>
Co-authored-by: Jack Betteridge <43041811+JDBetteridge@users.noreply.github.com>
* update checkout and upload to v4

This reverts commit 8e9b151.

* Update more actions

* Update comments
auto-merge was automatically disabled May 13, 2024 15:44

Head branch was pushed to by a user without write access

@juliusgh juliusgh dismissed stale reviews from connorjward and dham via 2bdda7e May 13, 2024 15:44
@juliusgh
Copy link
Contributor Author

@juliusgh please could you rebase this code on top of the latest master/merge in the latest master and push it again? The tests are failing and that should fix them. Then I will merge this. Thanks.

Ok, I have rebased on top of master. I hope that the CI works now.

To quote @dham re the suggested demo: "yes yes yes please". Demos are always great to have.

Thanks for the feedback! I need some time to finish a well documented demo and would submit a new PR later.

@connorjward
Copy link
Contributor

The rebase appears to have gone a bit wrong (the "Files changed" is now quite large). I have created a fresh PR with just your commits: #3571. I will close this one.

@juliusgh
Copy link
Contributor Author

The rebase appears to have gone a bit wrong (the "Files changed" is now quite large). I have created a fresh PR with just your commits: #3571. I will close this one.

Oh sorry. Thanks!

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.

6 participants