<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-family:Consolas,"Courier New",monospace;font-size:16px;line-height:22px;white-space:pre"><div style="color:rgb(0,0,0)"><span style="color:rgb(0,128,0)">/* Solve J Y = F, where J is Jacobian matrix */</span></div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,16,128)">ierr</span> = <span style="color:rgb(121,94,38)">SNESComputeJacobian</span>(<span style="color:rgb(0,16,128)">snes</span>, <span style="color:rgb(0,16,128)">X</span>, <span style="color:rgb(0,16,128)">snes</span>-><span style="color:rgb(0,16,128)">jacobian</span>, <span style="color:rgb(0,16,128)">snes</span>-><span style="color:rgb(0,16,128)">jacobian_pre</span>);</div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)">CHKERRQ</span>(<span style="color:rgb(0,16,128)">ierr</span>);</div><div style="color:rgb(0,0,0)"><br></div><div><div style="line-height:22px"><div style="color:rgb(0,0,0)"><span style="color:rgb(38,127,153)">PetscInt</span> <span style="color:rgb(0,16,128)">rstart</span>, <span style="color:rgb(0,16,128)">rend</span>;</div><div style="color:rgb(0,0,0)"><span style="color:rgb(121,94,38)">MatGetOwnershipRange</span>(<span style="color:rgb(0,16,128)">snes</span>-><span style="color:rgb(0,16,128)">jacobian</span>, &<span style="color:rgb(0,16,128)">rstart</span>, &<span style="color:rgb(0,16,128)">rend</span>);</div><div><span style="color:rgb(38,127,153)">PetscInt</span><font color="#000000"> </font><span style="color:rgb(0,16,128)">row</span><font color="#000000">=</font><font color="#098658">1000</font><font color="#000000">, </font><span style="color:rgb(0,16,128)">col</span><font color="#000000">=</font><font color="#098658">1000</font><font color="#000000">;</font></div><div style="color:rgb(0,0,0)"><span style="color:rgb(38,127,153)">PetscScalar</span> <span style="color:rgb(0,16,128)">v</span>;</div><div style="color:rgb(0,0,0)">if (row>=rstart && row<rend)</div><div style="color:rgb(0,0,0)">{</div><div><span style="color:rgb(0,0,0)">    <span style="color:rgb(121,94,38)">MatGetValues</span>(<span style="color:rgb(0,16,128)">snes</span>-><span style="color:rgb(0,16,128)">jacobian</span>, <span style="color:rgb(9,134,88)">1</span>, </span><font color="#001080">&row</font><font color="#000000">, </font><span style="color:rgb(9,134,88)">1</span><font color="#000000">, </font><font color="#001080">&col</font><font color="#000000">, &</font><span style="color:rgb(0,16,128)">v</span><font color="#000000">);</font></div><div style="color:rgb(0,0,0)">    <span style="color:rgb(121,94,38)">PetscPrintf</span>(<span style="color:rgb(0,16,128)">PETSC_COMM_WORLD</span>, <span style="color:rgb(163,21,21)">"rstart: </span><span style="color:rgb(0,16,128)">%d</span><span style="color:rgb(163,21,21)">, rend: </span><span style="color:rgb(0,16,128)">%d</span><span style="color:rgb(163,21,21)">, row: </span><span style="color:rgb(0,16,128)">%d</span><span style="color:rgb(163,21,21)">, col: </span><span style="color:rgb(0,16,128)">%d</span><span style="color:rgb(163,21,21)">, v: </span><span style="color:rgb(0,16,128)">%e</span><span style="color:rgb(238,0,0)">\n</span><span style="color:rgb(163,21,21)">"</span>, <span style="color:rgb(0,16,128)">rstart</span>, <span style="color:rgb(0,16,128)">rend</span>, <span style="color:rgb(0,16,128)">row</span>, <span style="color:rgb(0,16,128)">col</span>, <span style="color:rgb(0,16,128)">v</span>);</div></div></div><div style="color:rgb(0,0,0)">}</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)"><span style="color:rgb(15,23,42);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";white-space:pre-wrap;background-color:rgb(252,252,252)">It was supposed to return the value of the matrix at row 1001 and column 1001, but it returned the value at row 2001 and column 2001 instead. There is a two-fold relationship between these coordinates, and I'm not sure if it's related to the fact that I set the number of processes to 2.</span><br></div></div></div></div></div></div>