[petsc-users] matrix elements out of range

Matthew Knepley knepley at gmail.com
Thu May 7 15:40:47 CDT 2015


On Thu, May 7, 2015 at 3:39 PM, Sharp Stone <thronesf at gmail.com> wrote:

> 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
>

When you create the DMDA, you have to tell it that the stencil has width 2.

   Matt


> 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
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150507/0ad63872/attachment.html>


More information about the petsc-users mailing list