<div dir="ltr"><div>Try to build analytical <span class="" style>Jacobian</span> with 4 blocks, I modify the code <span class="" style>src</span>/<span class="" style>snes</span>/examples/tutorials/ex28.c (1D problem, however, my problem is 2D). When building one block of <span class="" style>Jacobian</span>, I got the errors like this:<br>
</div><div>0]<span class="" style>PETSC</span> ERROR: --------------------- Error Message ------------------------------------</div><div>[0]<span class="" style>PETSC</span> ERROR: Argument out of range!</div><div>[0]<span class="" style>PETSC</span> ERROR: New nonzero at (28,58) caused a <span class="" style>malloc</span>!</div>
<div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>MatSetValues</span>_<span class="" style>SeqAIJ</span>() line 353 in <span class="" style>src</span>/mat/<span class="" style>impls</span>/<span class="" style>aij</span>/seq/<span class="" style>aij</span>.c</div>
<div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>MatSetValues</span>() line 1124 in <span class="" style>src</span>/mat/interface/matrix.c</div><div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>MatSetValuesLocal</span>() line 2012 in <span class="" style>src</span>/mat/interface/matrix.c</div>
<div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>FormJacobianLocal</span>_P() line 556 in /Users/<span class="" style>liul</span>/Desktop/FieldSplitcase2.c</div><div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>FormJacobian</span>_All() line 847 in /Users/<span class="" style>liul</span>/Desktop/FieldSplitcase2.c</div>
<div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>SNESComputeJacobian</span>() line 2227 in <span class="" style>src</span>/<span class="" style>snes</span>/interface/<span class="" style>snes</span>.c</div>
<div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>SNESSolve</span>_<span class="" style>NEWTONLS</span>() line 233 in <span class="" style>src</span>/<span class="" style>snes</span>/<span class="" style>impls</span>/ls/ls.c</div>
<div>[0]<span class="" style>PETSC</span> ERROR: <span class="" style>SNESSolve</span>() line 3789 in <span class="" style>src</span>/<span class="" style>snes</span>/interface/<span class="" style>snes</span>.c</div><div>
[0]<span class="" style>PETSC</span> ERROR: main() line 1062 in /Users/<span class="" style>liul</span>/Desktop/FieldSplitcase2.c</div><div>application called <span class="" style>MPI</span>_Abort(<span class="" style>MPI</span>_COMM_WORLD, 63) - process 0</div>
<div>[unset]: aborting job:</div><div>application called <span class="" style>MPI</span>_Abort(<span class="" style>MPI</span>_COMM_WORLD, 63) - process 0  </div><div><br></div><div style>I think that I am not call <span class="" style>MatSetValuesLocal</span> correctly, right? How to fix it? Thanks!</div>
<div>for (j=<span class="" style>yints</span>; j<<span class="" style>yinte</span>; j++) {<br></div><div><div>    for (i=<span class="" style>xints</span>; i<<span class="" style>xinte</span>; i++) {</div><div> //        row.i = i; row.j = j;</div>
<div>           row = i+j*info-><span class="" style>xm</span>;</div><div><br></div><div>           if (i==0 || j==0 || i==<span class="" style>mx</span>-1 || j==my-1) {</div><div>          <span class="" style>num</span> = 0; v_l=0.0; v_r=0.0; v_t=0.0; v_b=0.0;</div>
<div>          if (j!=0) {</div><div>            v=-1;v_b=1;</div><div>            J=row-info-><span class="" style>xm</span>;              </div><div>            <span class="" style>ierr</span> = <span class="" style>MatSetValuesLocal</span>(<span class="" style>Bpp</span>,1,&row,1,&J,&v,INSERT_VALUES);<span class="" style>CHKERRQ</span>(<span class="" style>ierr</span>);               </div>
<div>          }</div><div>          if (i!=0) {</div><div>            v = -1; v_l=1;</div><div>            J=row-1; </div><div>            <span class="" style>ierr</span> = <span class="" style>MatSetValuesLocal</span>(<span class="" style>Bpp</span>,1,&row,1,&J,&v,INSERT_VALUES);<span class="" style>CHKERRQ</span>(<span class="" style>ierr</span>);  </div>
<div>            </div><div>          }</div><div>          if (i!=<span class="" style>mx</span>-1) {</div><div>            v = -1;v_r=1;</div><div>            J=row+1;      </div><div>            <span class="" style>ierr</span> = <span class="" style>MatSetValuesLocal</span>(<span class="" style>Bpp</span>,1,&row,1,&J,&v,INSERT_VALUES);<span class="" style>CHKERRQ</span>(<span class="" style>ierr</span>);            </div>
<div>          }</div><div>          if (j!=my-1) {   </div><div>            v = -1;v_t=1;</div><div>             J=row+info-><span class="" style>xm</span>;</div><div>            <span class="" style>ierr</span> = <span class="" style>MatSetValuesLocal</span>(<span class="" style>Bpp</span>,1,&row,1,&J,&v,INSERT_VALUES);<span class="" style>CHKERRQ</span>(<span class="" style>ierr</span>);            </div>
<div>          }</div><div>          v   = v_l+v_r+v_t+v_b;</div><div><br></div><div>         if(i==0&&j==0){ v+=2;}</div><div>          J=row;</div><div>         <span class="" style>ierr</span> = <span class="" style>MatSetValuesLocal</span>(<span class="" style>Bpp</span>,1,&row,1,&J,&v,INSERT_VALUES);<span class="" style>CHKERRQ</span>(<span class="" style>ierr</span>);</div>
<div>         }else{</div><div>  </div><div>          <span class="" style>PetscInt</span> cols[]={row-info-><span class="" style>xm</span>,row-1,row+1,row+info-><span class="" style>xm</span>,row};</div><div>          <span class="" style>PetscScalar</span> <span class="" style>vals</span>[]= {-1,-1,-1,-1,4};</div>
<div>          <span class="" style>ierr</span> = <span class="" style>MatSetValuesLocal</span>(<span class="" style>Bpp</span>,1,&row,5,cols,<span class="" style>vals</span>,INSERT_VALUES);<span class="" style>CHKERRQ</span>(<span class="" style>ierr</span>);  </div>
<div><br></div><div>         }</div><div>      </div><div>    }</div><div>  }</div></div><div><br></div><div><br></div><br>
</div>

<br>
<div><hr></div><font face="Arial" size="1">This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.</font>