[petsc-dev] What should MatReset() do?

Barry Smith bsmith at mcs.anl.gov
Fri Mar 6 18:03:29 CST 2015


> On Mar 6, 2015, at 4:41 PM, Jed Brown <jed at jedbrown.org> wrote:
> 
> Dmitry Karpeyev <karpeev at mcs.anl.gov> writes:
>> This is trickier than it might appear: nonzerostate effectively counts the
>> global number of nonzeros.

   No it does not. Note in MatZeroRows_SeqAIJ() when entries are deleted from the matrix we still increase the nonzerostate.

>> 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.

  Just increase the nonzerostate flag by one on a reset (that is there is no reason to ever set it back to zero). Now nonzerostate is monotonically increasing. 

  Barry


  Barry

> 
> On pretty simple and reliable solution would be to take a cryptographic
> hash of the row/col arrays.  I assume BG is really atrocious at hashing,
> but is it so bad that this is not viable?  (There are several places
> where we use kinda fragile state counters or trust the user, but hashes
> would make rebuilding more reliable and transparent.)




More information about the petsc-dev mailing list