[petsc-dev] Discussion about time-dependent optimization moved from PR

Lawrence Mitchell wencel at gmail.com
Tue Oct 17 11:02:27 CDT 2017


> On 17 Oct 2017, at 15:47, Jed Brown <jed at jedbrown.org> wrote:
> 
>> c.f. also the petsc-maint discussion last October in the thread:
>> 
>> "Segfault when DM is reused in two SNESes with multigrid"
> 
> What should I do?  That thread petered out when nobody could suggest a
> criteria to distinguish reuse of a DM in related SNES objects (e.g.,
> nonlinear preconditioning or nonlinear multigrid) from reuse with intent
> to solve different problems.

So my initial concern was that if I do:

SNESSetDM(snes, dm);
SNESSolve(snes);
SNESDestroy(&snes);

Then dm still has stale pointers to snes (in the context of the restrict hook).  These aren't cleaned up until DMDestroy.  It was surprising to me that SNESDestroy did not clean up all the things that SNESCreate/Solve set up.

I don't care about the case of:

SNESSetDM(snes1, dm);
SNESSetDM(snes2, dm);

I work around this issue by making new DMs, so it's OK if nothing changes in PETSc.  

Lawrence


More information about the petsc-dev mailing list