Sorry, FGMRES does not need to compute residual expilictly. Please forget about what I just asked.<br><br>Yan<br><br><div class="gmail_quote">On Mon, Sep 21, 2009 at 3:04 PM, Ryan Yan <span dir="ltr">&lt;<a href="mailto:vyan2000@gmail.com">vyan2000@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Barry, <br>Thanks for the suggestion.<br><br>I am using FGMRES as the krylov solver.  Is there a direct access to the residual vector for FGMRES. I guess the answer is yes, since that&#39;s the Krylov method which supports right preconditioning and provides the true residual 2_Norm monitor, right?<br>

<br>If so, which header should I include to fetch the residual directly from KSP_FGMRES?<br><font color="#888888"><br>Yan</font><div><div></div><div class="h5"><br><br><br><br><div class="gmail_quote">On Mon, Sep 21, 2009 at 2:43 PM, Barry Smith <span dir="ltr">&lt;<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
  Yan,<br>
<br>
    This depends on the Krylov method being used. For example with GMRES the residual vector is NOT available at each iteration (the 2-norm of the residual is approximated via a recurrence relationship).<br>
<br>
    You can call KSPBuildResidual() to have the true residual computed for you. Note: it is expensive because it actually builds the current solution and computes r = b - A*x<br>
<br>
   What we intended is that if you want the residual efficiently for example for the CG method, you determine what Krylov method you want to use the include the appropriate private include file and access the residual directly from the data structure. This would be efficient. (but like I said does not work for all methods). For cg include src/ksp/ksp/impls/cg/cgctx.h<br>

<font color="#888888">
<br>
<br>
   Barry</font><div><div></div><div><br>
<br>
On Sep 21, 2009, at 12:44 PM, Ryan Yan wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi All,<br>
The following question is only for test and comparison reason.<br>
<br>
Is there a command line option to set up using 1-Norm(sum of absolute value of residuals)  as convergence monitor and test.<br>
<br>
Alternatively, if I can get the residual &quot;r&quot; out at the end of each iteration, then it is going to be much simpler, since I can just call VecNorm(r, NORM_1, &amp;r_ell1) and pass the r_ell1 into the convergence monitor and test. Can anyone inform me if PETSc has an interface for the resuidual r?<br>


<br>
Or one has to call the convergence test:<br>
MyKSPConverged(ksp,n,rnorm,flag,dummy);<br>
and following the steps:<br>
1. fetch the exact solution:<br>
<br>
KSPBuildSolution(ksp,PETSC_NULL_OBJECT,x,ierr)<br>
<br>
2. calculate the residual:<br>
<br>
pass the Right Hand side and the Matrix in to calculate the 1-Norm. But this step is *not* obvious, since the matrix and rhs is already distributed over each processes.<br>
<br>
3. set up the convergence test based on the 1_Norm residual.<br>
<br>
<br>
Thank you very much,<br>
<br>
<br>
Yan<br>
</blockquote>
<br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>