-
Notifications
You must be signed in to change notification settings - Fork 104
Petsc solver updates #3226
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
Petsc solver updates #3226
Conversation
If run_rhs throws an exception then it should be caught, and SNES notified that an error occurred.
If solver:diagnose is set then a line will be printed for each internal (TS) step. The format is the same as the `snes` solver, so the same post-processing scripts can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| // Print diagnostic information. | ||
| // Using the same format at the SNES solver | ||
|
|
||
| SNESConvergedReason reason; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'reason' is not initialized [cppcoreguidelines-init-variables]
SNESConvergedReason reason;
^| SNESConvergedReason reason; | ||
| SNESGetConvergedReason(s->snes, &reason); | ||
|
|
||
| PetscReal timestep; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'timestep' is not initialized [cppcoreguidelines-init-variables]
src/solver/impls/petsc/petsc.cxx:48:
- #include <petsc.h>
+ #include <math.h>
+ #include <petsc.h>| PetscReal timestep; | |
| PetscReal timestep = NAN; |
|
|
||
| // SNES failure counter is only reset when TSSolve is called | ||
| static PetscInt prev_snes_failures = 0; | ||
| PetscInt snes_failures; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'snes_failures' is not initialized [cppcoreguidelines-init-variables]
| PetscInt snes_failures; | |
| PetscInt snes_failures = 0; |
| prev_snes_failures += snes_failures; | ||
|
|
||
| // Get number of iterations | ||
| int nl_its; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'nl_its' is not initialized [cppcoreguidelines-init-variables]
| int nl_its; | |
| int nl_its = 0; |
| // Get number of iterations | ||
| int nl_its; | ||
| SNESGetIterationNumber(s->snes, &nl_its); | ||
| int lin_its; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'lin_its' is not initialized [cppcoreguidelines-init-variables]
| int lin_its; | |
| int lin_its = 0; |
Calls to run_rhs may throw an exception if given out of domain values. Catch and return error code if this happens.
Improvements to the
petsctime integration solver interface:Catch exceptions in
run_rhs, telling SNES that the solution is out of domain. This should cause PETSc to reject the timestep. Previously some processors would stop and others would hang.Add output diagnostic compatible with
snes. Ifsolver:diagnose=truethen BOUT++ will now output a line that has the same format at the lines printed by thesnesBOUT++ solver. This should enable the log parser to work.