<div class="gmail_quote">2011/8/27 Алексей Рязанов <span dir="ltr"><<a href="mailto:ram@ibrae.ac.ru">ram@ibrae.ac.ru</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
So. All memory and time issues appeared because of my KSPConvergedTest function, which calls KSPBuildResidual to monitor true residual. KSPBuildResidual incorrectly works with memory. As soon as I've commented the line with KSPBuildResidual, all troubles gone. So now I use default monitor and have to monitor preconditioned residual. This is inconvenient for me, but I cant figure out, how can I set up using true monitor for all methods without any memory or performance leaks. I'll try to get used t deal with preconditioned norm.</blockquote>
</div><br><div>1. You can actually run the Krylov method with unpreconditioned residuals by using -ksp_right_pc (some output is inconsistent with 3.1 this way, it's fixed in petsc-dev and you can just use -ksp_norm_type unpreconditioned). This is inexpensive and does the right thing.</div>
<div><br></div><div>2. You can run the Krylov method in the preconditioned norm, but monitor the true residual using -ksp_monitor_true_residual. The code is in src/ksp/ksp/interface/iterativ.c KSPMonitorTrueResidualNorm(). You can also use this code as a template to make a similar custom monitor without memory leaks. This calls KSPBuildResidual() which is very expensive for GMRES, but is cheap for some other methods (including GCR which is closely related).</div>