[petsc-users] Is it possible to add a hook function after SNES_DIVERGED_LINEAR_SOLVE
Gong Ding
gdiso at ustc.edu
Thu Jan 27 06:23:48 CST 2011
Hello,
I sometimes try to use iterative solvers in the SENS.
However, it may fail to convergence for some difficult problems.
SNES will report SNES_DIVERGED_LINEAR_SOLVE for this situation.
Is it possible to add a hook function here?
i.e. I'd like to change the linear solver to LU and solve the
Newton step again instead of break the nonlinear solver.
Here is the code from ls.c which report the SNES_DIVERGED_LINEAR_SOLVE
if (kspreason < 0) {
if (++snes->numLinearSolveFailures >= snes->maxLinearSolveFailures) {
ierr = PetscInfo2(snes,"iter=%D, number linear solve failures %D greater than current SNES allowed, stopping solve\n",snes->iter,snes->numLinearSolveFailures);CHKERRQ(ierr);
snes->reason = SNES_DIVERGED_LINEAR_SOLVE;
break;
}
}
The hook function may be added befour the break.
Regards,
Gong Ding
More information about the petsc-users
mailing list