Skip to content

Add abc for KSPMonitorFunction #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

connorjward
Copy link
Collaborator

This is something @JDBetteridge had in his own code at one point. It would be good to include in petsctools.

@JHopeCollins this is likely of interest to you. I would be interested in hearing your thoughts.

from petsc4py import PETSc


class AbstractKSPMonitorFunction(abc.ABC):
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a good idea, but there's nothing that makes python monitors in particular special. If we're doing ABCs we should do as much of the suite of possible python types as possible, e.g. KSP, PC, SNES, Monitor, Linesearch etc. (see for example the KSP and PC examples in the petsc4py docs)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Except I know how to do this for monitors but not anything else! I agree we should look to add more things. Have you implemented any of these before?

Copy link
Member

@JHopeCollins JHopeCollins May 28, 2025

Choose a reason for hiding this comment

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

Some of the protocols are here: https://petsc.org/main/petsc4py/petsc_python_types.html
I think there's some discussion about what should be an abstract method (i.e. throw an error if a child class doesn't implement it), and what are just blank methods to show what you can customise.

The main one missing from that link is SNES, but I know some of the methods and we can find the others from the petsc4py sauce.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What I really want to have in petsctools are implementations of useful monitor functions and such. I'm less bothered about abstract classes and since petsc4py advertise most of the interfaces anyway it might be unnecessary here.

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