<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 7, 2015 at 3:39 PM, Sharp Stone <span dir="ltr"><<a href="mailto:thronesf@gmail.com" target="_blank">thronesf@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi all,<br><br></div>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 <br>[0]PETSC ERROR: Argument out of range<br>[0]PETSC ERROR: Inserting a new nonzero into matrix<br></div></div></blockquote><div><br></div><div>When you create the DMDA, you have to tell it that the stencil has width 2.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>My boundary code is as follows.<br>if(i==0) {<br> v[0] =  1.0;    col[0].i = i;   <br> v[1] = -2.0;    col[1].i = i+1; <br> v[2] =  1.0;    col[2].i = i+2; <br> MatSetValuesStencil(appctx->A,1,&row,3,col,v,INSERT_VALUES); <br>}<br><br></div>Does anyone have some suggestions? Thank you very much in advance.<span class="HOEnZb"><font color="#888888"><br clear="all"><div><div><div><br>-- <br><div><div dir="ltr"><div>Best regards,</div><div><br></div>Feng</div></div>
</div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>