<div dir="ltr">Hi all,<div>
</div><div><br></div><div>I've implemented a solver for a contact problem using SNES. The sparsity pattern of the jacobian matrix needs to change at each nonlinear iteration (because the elements which are in contact can change), so I tried to deal with this by calling MatSeqAIJSetPreallocation and MatMPIAIJSetPreallocation during each iteration in order to update the preallocation.</div><div><br></div><div>This seems to work fine in serial, but with two or more MPI processes I run into the error "nnz cannot be greater than row length", e.g.:</div><div>nnz cannot be greater than row length: local row 528 value 12 rowlength 0<br></div><div><br></div><div>This error is from the call to</div><div>MatSeqAIJSetPreallocation(b->B,o_nz,o_nnz); in MatMPIAIJSetPreallocation_MPIAIJ.</div><div><br></div><div>Any guidance on what the problem might be would be most appreciated. For example, I was wondering if there is a problem with calling SetPreallocation on a matrix that has already been preallocated?</div><div><br></div><div>Some notes:</div><div>- I'm using PETSc via libMesh</div><div>- The code that triggers this issue is available as a PR on the libMesh github repo, in case anyone is interested: <a href="https://github.com/libMesh/libmesh/pull/460/">https://github.com/libMesh/libmesh/pull/460/</a></div><div>- I can try to make a minimal pure-PETSc example that reproduces this error, if that would be helpful.</div><div><br></div><div>Many thanks,</div><div>David</div><div><br></div></div>