<div dir="ltr">Thank you very much Barry for the suggestion. <div><br></div><div>Unfortunately, I am using Fortran and not C++ . Do you have an equivalent trick in this case? :)<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">------<div><br></div><div>Edoardo Alinovi, Ph.D.</div><div><br></div><div>DICCA, Scuola Politecnica,<br>Universita' degli Studi di Genova,<br>1, via Montallegro,<br>16145 Genova, Italy<br></div><div><br></div><div>Email: <a href="mailto:edoardo.alinovi@dicca.unige.it" target="_blank">edoardo.alinovi@dicca.unige.it</a></div><div>Tel: +39 010 353 2540<br></div><div><br></div><div><br></div><div><br></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno dom 3 feb 2019 alle ore 20:03 Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
If you use the default KSP convergence tests (which almost everyone does) the initial residual norm is stored in ksp->rnorm0. Thus to access it you need to include the private header file that defines the KSP object kspimpl.h so something like <br>
<br>
#include <petsc/private/kspimpl.h> <br>
<br>
PetscErrorCode KSPGetInitialResidualNorm(KSP ksp,PetscReal *norm0)<br>
{<br>
*norm0 = ksp->rnorm0;<br>
return 0;<br>
}<br>
<br>
should work.<br>
<br>
Barry<br>
<br>
<br>
<br>
<br>
<br>
<br>
> On Feb 3, 2019, at 8:27 AM, Edoardo alinovi via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
> <br>
> Dear all,<br>
> <br>
> I have a very simple question for you. How can I get the initial residual from a ksp solver? I can easily extract the final (preconditioned) residual norm but when I try to use to do the same with the initial residual using:<br>
> <br>
> kspInitialResidual()<br>
> <br>
> PETSc tells me that this feature is not supported. I am actually doing it applying the definition of residual "by hand", but I am wondering if somenthing already built-in is available or not. <br>
> <br>
> Thank you very much! <br>
> ------<br>
> <br>
> Edoardo Alinovi, Ph.D.<br>
> <br>
> DICCA, Scuola Politecnica,<br>
> Universita' degli Studi di Genova,<br>
> 1, via Montallegro,<br>
> 16145 Genova, Italy<br>
> <br>
> Email: <a href="mailto:edoardo.alinovi@dicca.unige.it" target="_blank">edoardo.alinovi@dicca.unige.it</a><br>
> Tel: +39 010 353 2540<br>
> <br>
> <br>
> <br>
<br>
</blockquote></div>