<div class="gmail_quote">On Thu, Mar 29, 2012 at 07:16, Dmitry Karpeev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Here the problem isn't in needing to call PCReset() twice per se. The issue is that if the user uses the same PC object in</div><div>two different KSPs and destroys one ksp, that will cause a PCReset() and invalidate the pc for the other ksp -- all despite increfing the pc.</div>
</blockquote></div><br><div>Yeah, this is tricky. In this case, is it acceptable to break the dependency explicitly using</div><div><br></div><div>PCSetType(ksp,PCNONE); // will decrement the reference count, but not PCReset()</div>
<div>KSPDestroy(&ksp);</div><div><br></div><div><br></div><div>Skipping the reset means that KSPReset() is basically always incorrect if the user created the PC (for example). I think a top-level KSPReset() should always reset the PC. Now maybe ksp->pc should be withheld by KSPDestroy() before calling KSPReset(); if the PC refct hits 0, it will be destroyed in the subsequent PCDestroy().</div>