I notice you do not have a corect return value below.<div><br></div><div> Matt<br><br><div class="gmail_quote">On Mon, Dec 26, 2011 at 6:03 AM, behzad baghapour <span dir="ltr"><<a href="mailto:behzad.baghapour@gmail.com">behzad.baghapour@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Developers,<br><br>I need to change "rtol" manually for each KSP linear solver in each SNES iteration (some sort of inexact Newton method).<br>
<br>I decided to use SNESSetConvergenceTest() as bellow:<br><br>
in main code:<br><br>ierr = SNESSetConvergenceTest( snes, SNESConvTest, PETSC_NULL, PETSC_NULL ); CHKERRQ( ierr );<br><br>in convergence function:<br><br>PetscErrorCode SNESConvTest( SNES snes, PetscInt it, PetscReal xn, PetscReal pn, PetscReal fn, SNESConvergedReason* res, void* ctx)
<br>{
<br> KSP ksp2;<br> PetscReal rtol, atol;<br> SNESGetKSP ( snes, &ksp2 );<br> KSPGetTolerances ( ksp2, &rtol, PETSC_NULL, PETSC_NULL, PETSC_NULL );<br> SNESGetTolerances ( snes, &atol, PETSC_NULL, PETSC_NULL, PETSC_NULL, PETSC_NULL );<br>
if( fn > 1e-3 ){
<br> rtol = 0.01;
<br> }else{
<br> rtol = 1e-5;
<br> }<br> KSPSetTolerances( ksp2, rtol, PETSC_NULL, PETSC_NULL, PETSC_NULL );
<br> if( fn < atol ){<br> *res = SNES_CONVERGED_FNORM_ABS;<br> return 0;<br> }else{<br> *res = SNES_CONVERGED_ITERATING;<br> } <br>}
<br><br>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":<br><br>Linear solve did not converge due to DIVERGED_DTOL iterations 0<br>
Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE<br><br>How should I possibly deal with this??<br><br>Thanks a lot,<br>BehZad<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</div>