[petsc-users] matrix elements out of range

Sharp Stone thronesf at gmail.com
Thu May 7 15:39:20 CDT 2015


Hi all,

For the linear solver, if I use the standard 7-point differencing scheme
and use 2-point boundary conditions, it works fine. But when I change the
boundary condition, involving 3-point differencing form at the boundary,
such as x[i+2]-2*x[i+1]+x[i]=0, assuming i is boundary point number, I
always get the errors like
[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: Inserting a new nonzero into matrix

My boundary code is as follows.
if(i==0) {
 v[0] =  1.0;    col[0].i = i;
 v[1] = -2.0;    col[1].i = i+1;
 v[2] =  1.0;    col[2].i = i+2;
 MatSetValuesStencil(appctx->A,1,&row,3,col,v,INSERT_VALUES);
}

Does anyone have some suggestions? Thank you very much in advance.

-- 
Best regards,

Feng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150507/3562b32e/attachment.html>


More information about the petsc-users mailing list