<div>I don't have a problem with a KSPBuildResidual_Richardson, but what about also removing the part that forms the residual at the end of each iteration so that it is skipped if KSP_NORM_NONE?</div><br><div class="gmail_quote">
On Tue, Jun 5, 2012 at 2:02 PM, John Fettig <span dir="ltr"><<a href="mailto:john.fettig@gmail.com" target="_blank">john.fettig@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When using the defaults for Richardson, it calculates the<br>
(unpreconditioned) residual directly on line 138. However, this isn't<br>
made available to the convergence monitor because<br>
ksp->ops->buildresidual = KSPDefaultBuildResidual;<br>
<br>
So if you build the residual explicitly in the convergence monitor it<br>
must calculate it again. Could we do this instead?<br>
<br>
#undef __FUNCT__<br>
#define __FUNCT__ "KSPBuildResidual_Richardson"<br>
PetscErrorCode KSPBuildResidual_Richardson(KSP ksp, Vec t, Vec v, Vec *V)<br>
{<br>
PetscErrorCode ierr;<br>
KSP_Richardson *ctx;<br>
<br>
PetscFunctionBegin;<br>
ctx = (KSP_Richardson *)ksp->data;<br>
if (ctx->selfscale) {<br>
KSPDefaultBuildResidual(ksp,t,v,V);<br>
} else {<br>
if (v) {<br>
ierr = VecCopy( ksp->work[0], v );CHKERRQ(ierr);<br>
if (V) *V = v;<br>
} else if (V) {<br>
*V = ksp->work[0];<br>
}<br>
}<br>
PetscFunctionReturn(0);<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
John<br>
</font></span></blockquote></div><br>