[petsc-users] Unable to use SNESSetConvergenceTest()
behzad baghapour
behzad.baghapour at gmail.com
Mon Dec 26 06:03:14 CST 2011
Dear Developers,
I need to change "rtol" manually for each KSP linear solver in each SNES
iteration (some sort of inexact Newton method).
I decided to use SNESSetConvergenceTest() as bellow:
in main code:
ierr = SNESSetConvergenceTest( snes, SNESConvTest, PETSC_NULL, PETSC_NULL
); CHKERRQ( ierr );
in convergence function:
PetscErrorCode SNESConvTest( SNES snes, PetscInt it, PetscReal xn,
PetscReal pn, PetscReal fn, SNESConvergedReason* res, void* ctx)
{
KSP ksp2;
PetscReal rtol, atol;
SNESGetKSP ( snes, &ksp2 );
KSPGetTolerances ( ksp2, &rtol, PETSC_NULL, PETSC_NULL, PETSC_NULL );
SNESGetTolerances ( snes, &atol, PETSC_NULL, PETSC_NULL, PETSC_NULL,
PETSC_NULL );
if( fn > 1e-3 ){
rtol = 0.01;
}else{
rtol = 1e-5;
}
KSPSetTolerances( ksp2, rtol, PETSC_NULL, PETSC_NULL, PETSC_NULL );
if( fn < atol ){
*res = SNES_CONVERGED_FNORM_ABS;
return 0;
}else{
*res = SNES_CONVERGED_ITERATING;
}
}
BUT I really don't know how to control the convergence criterion for SNES.
So when I run my previous code with the new convergence test I received
divergence error after "first iteration":
Linear solve did not converge due to DIVERGED_DTOL iterations 0
Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE
How should I possibly deal with this??
Thanks a lot,
BehZad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111226/f8605b43/attachment.htm>
More information about the petsc-users
mailing list