<div dir="ltr">Hello everyone,<br>I am trying to solve the Poisson equation using SNES class. I am running into a problem where PETSc complains that an object is in wrong state. I opened the matrix object in matlab to see if any diagonal entry is missing but I see that it is not the case. Could you please let me know what I am missing here? 

The complete error is as follows: <div><br></div><div>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[0]PETSC ERROR: Object is in wrong state<br>[0]PETSC ERROR: Matrix is missing diagonal entry 0<br>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>[0]PETSC ERROR: Petsc Release Version 3.11.1, Apr, 12, 2019 <br>[0]PETSC ERROR: ./a.out on a linux-gnu-c-debug named <a href="http://cg17-9.agave.rc.asu.edu">cg17-9.agave.rc.asu.edu</a> by pbaikadi Wed Oct 14 11:33:45 2020<br>[0]PETSC ERROR: Configure options <br>[0]PETSC ERROR: #1 MatILUFactorSymbolic_SeqAIJ() line 1687 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/mat/impls/aij/seq/aijfact.c<br>[0]PETSC ERROR: #2 MatILUFactorSymbolic() line 6737 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/mat/interface/matrix.c<br>[0]PETSC ERROR: #3 PCSetUp_ILU() line 144 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/ksp/pc/impls/factor/ilu/ilu.c<br>[0]PETSC ERROR: #4 PCSetUp() line 932 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/ksp/pc/interface/precon.c<br>[0]PETSC ERROR: #5 KSPSetUp() line 391 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/ksp/ksp/interface/itfunc.c<br>[0]PETSC ERROR: #6 KSPSolve() line 725 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/ksp/ksp/interface/itfunc.c<br>[0]PETSC ERROR: #7 SNESSolve_NEWTONLS() line 225 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/snes/impls/ls/ls.c<br>[0]PETSC ERROR: #8 SNESSolve() line 4560 in /packages/7x/petsc/3.11.1/petsc-3.11.1/src/snes/interface/snes.c<br>[0]PETSC ERROR: #9 User provided function() line 0 in User file<br></div><div><br></div><div>On a different note, I have two more questions.<br>1) When a matrix is being filled using MatSetValues, does the nnz vector also have a 0-based indexing?<br>2) If I explicitly have nnz 1-based indexing, then does nnz(i) indicate the number of nonzeros in the (i-1)^th row or the i^th row?<br><br>Thank you in advance for your help.<br>Best Regards,<br>Pranay.</div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=acHJhbmF5cmVkZHk4NjVAZ21haWwuY29t&type=zerocontent&guid=d0526111-7c96-45b0-ae25-e4b8d51c4807"><font color="#ffffff" size="1">ᐧ</font></div>