<div dir="ltr"><br><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 8:03 AM Dmitry Karpeyev <<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote">On Wed Feb 25 2015 at 10:56:30 PM Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> On Feb 25, 2015, at 10:45 PM, Dmitry Karpeyev <<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>> wrote:<br>
><br>
> Since user callbacks, such as the one to compute the Jacobian, are now supposed to modify matrices in place, we need to provide the equivalent of MatReset() so that the user can do things like reset the sparsity pattern, etc. What should that call do?<br>
><br>
> I assume it would keep the type, sizes and the block size of the matrix and reset everything else.   The impl-specific stuff is handled by MatDestroy(), but what about the generic data members?  I imagine that the structural properties, such as symmetry and others set with MatSetOption()<br>
<br>
Yes (this is in analogy to how KSPReset etc work, they clean out data objects but keep the options the user has selected for them)<br>
<br>
> as well as MatFactorType and MatStencilInfo should be preserved,<br>
<br>
<br>
Don't know about these.<br>
<br>
> while MatRedundant and the (Near)NullSpace have to go.<br>
<br>
  Yes<br>
<br>
> What about the logging info? num_ass?<br>
<br>
  Keep I think<br>
>  Do we increment nonzerostate or reset it?<br>
<br>
increment<br></blockquote></div></div></blockquote><div><br></div><div>This is trickier than it might appear: nonzerostate effectively counts the global number of nonzeros. The PC will rebuild if its state is stale, but it will reuse matrices (e.g., subdomain matrices in PCASM) if nonzerostate is up to date.  This works if the sparsity pattern never drops nonzeros, but that's no longer true if reset is allowed. I can reset a matrix, preallocate and assemble it so that the global number of nonzeros will be the same as before the resetting, but local sparsity patterns will change.  This could happen, for example, when I have moving particles or, less exotically, when I have elastic contact and nodes move past each other. That will break PCASM.</div><div><br></div><div>As far as I can tell this is a bug, since, in principle, we allow MatType to be reset, which is equivalent to MatReset(). In part that's what</div><div>enables the  SNES Jacobian callback to take Mat arguments, rather than Mat*.  I'm not sure how to fix this in maint, though.  <span style="font-size:13.1999998092651px">In master we could add a resetcounter and have PC check that in addition to nonzerostate, but that seems to be too intrusive for maint.</span></div><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">Dmitry.</span></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>  The PetscObject state?<br>
<br>
increment<br></blockquote></div></div><div dir="ltr"><div class="gmail_quote"><div>Yes, these two need to be incremented, as I realized, to avoid a situation where the same Mat object with a completely different structure has the same state index as a previous incarnation.  The PC will think it doesn't need to rebuild ...</div></div></div><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> I don't know what to do about the GPU pointers.<br>
<br>
I would clean those all out.<br></blockquote></div></div><div dir="ltr"><div class="gmail_quote"><div>I'm not sure how -- isn't freeing these implementation-dependent?</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
><br>
> While MatReset() isn't yet available,  MatSetType(mat,newtype); MatSetType(mat,oldtype); should have the same effect,<br>
> but it doesn't, which to me is a bug<br>
<br>
   I agree it seems like a bug<br>
<br>
> and I'd like to fix it in maint.<br>
> It would be good, however, to do it "right" by answering the questions above.  Any opinions?<br>
><br>
> Dmitry.<br>
><br>
<br>
</blockquote></div></div></blockquote></div></div>