Pushed: <a href="http://petsc.cs.iit.edu/petsc/petsc-dev/rev/76f5543c7e89">http://petsc.cs.iit.edu/petsc/petsc-dev/rev/76f5543c7e89</a><br><br><div class="gmail_quote">On Thu, Mar 29, 2012 at 11:07 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@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"><br>
I think Jed is suggesting changing:<br>
<br>
PetscErrorCode KSPDestroy(KSP *ksp)<br>
{<br>
PetscErrorCode ierr;<br>
<br>
PetscFunctionBegin;<br>
if (!*ksp) PetscFunctionReturn(0);<br>
PetscValidHeaderSpecific((*ksp),KSP_CLASSID,1);<br>
if (--((PetscObject)(*ksp))->refct > 0) {*ksp = 0; PetscFunctionReturn(0);}<br>
<br>
ierr = KSPReset((*ksp));CHKERRQ(ierr);<br>
<br>
<br>
<br>
to<br>
<br>
<br>
PetscErrorCode KSPDestroy(KSP *ksp)<br>
{<br>
PetscErrorCode ierr;<br>
PC pc = (*ksp)->pc;<br>
<br>
PetscFunctionBegin;<br>
if (!*ksp) PetscFunctionReturn(0);<br>
PetscValidHeaderSpecific((*ksp),KSP_CLASSID,1);<br>
if (--((PetscObject)(*ksp))->refct > 0) {*ksp = 0; PetscFunctionReturn(0);}<br>
<br>
<br>
pc = (*ksp)->pc;<br>
(*ksp)->pc = PETSC_NULL;<br>
ierr = KSPReset((*ksp));CHKERRQ(ierr);<br>
(*ksp)->pc = pc;<br>
<br>
<br>
Since KSPDestroy() doesn't need to have PCReset() called. This doesn't require any special code for users.<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Mar 29, 2012, at 10:38 AM, Dmitry Karpeev wrote:<br>
<br>
><br>
><br>
> On Thu, Mar 29, 2012 at 10:13 AM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
> On Thu, Mar 29, 2012 at 08:28, Dmitry Karpeev <<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>> wrote:<br>
> Back to the original problem: how shall we prevent a shared pc from being gutted by an unprotected PCReset() cascading from a KSPDestroy() on one of the containing ksps? I can factor out KSPReset_Private()/PCReset_Private() as indicated before, unless there are objections.<br>
><br>
> What do you think of my suggestion of masking ksp->pc when KSPDestroy calls KSPReset? Then KSPReset does not call PCReset if ksp->pc does not exist.<br>
> I guess that works too, but I thought your suggestion applied to userland code right before calling KSPDestroy(&ksp)?<br>
> I suppose that will fix Mark's problem. Maybe that's the right approach: he got himself into this mess by reusing a pc<br>
> in the inner ksp, he should know how to extricate himself :-)<br>
><br>
> Dmitry.<br>
><br>
<br>
</div></div></blockquote></div><br>