Petsc solver updates#3226
Merged
Merged
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.
| // Print diagnostic information. | ||
| // Using the same format at the SNES solver | ||
|
|
||
| SNESConvergedReason reason; |
Contributor
There was a problem hiding this comment.
warning: variable 'reason' is not initialized [cppcoreguidelines-init-variables]
SNESConvergedReason reason;
^| SNESConvergedReason reason; | ||
| SNESGetConvergedReason(s->snes, &reason); | ||
|
|
||
| PetscReal timestep; |
Contributor
There was a problem hiding this comment.
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>
Suggested change
| PetscReal timestep; | |
| PetscReal timestep = NAN; |
|
|
||
| // SNES failure counter is only reset when TSSolve is called | ||
| static PetscInt prev_snes_failures = 0; | ||
| PetscInt snes_failures; |
Contributor
There was a problem hiding this comment.
warning: variable 'snes_failures' is not initialized [cppcoreguidelines-init-variables]
Suggested change
| PetscInt snes_failures; | |
| PetscInt snes_failures = 0; |
| prev_snes_failures += snes_failures; | ||
|
|
||
| // Get number of iterations | ||
| int nl_its; |
Contributor
There was a problem hiding this comment.
warning: variable 'nl_its' is not initialized [cppcoreguidelines-init-variables]
Suggested change
| int nl_its; | |
| int nl_its = 0; |
| // Get number of iterations | ||
| int nl_its; | ||
| SNESGetIterationNumber(s->snes, &nl_its); | ||
| int lin_its; |
Contributor
There was a problem hiding this comment.
warning: variable 'lin_its' is not initialized [cppcoreguidelines-init-variables]
Suggested change
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.