<div class="gmail_extra">On Tue, May 1, 2012 at 5:48 PM, TAY wee-beng <span dir="ltr"><<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Do you mean my method is wrong?<br>
<br>
I am following the template of ex22f,<br>
<br>
where the variables are declared as :<br>
<br>
PetscScalar v(5)<br>
<br>
MatStencil row(4),col(4,5)<br>
<br>
Hence,<br>
<br>
for the neumann BC<br>
<br>
num = 1<br>
<br>
if (j/=0) then<br>
<br>
v(num) = -rho*HxdHy<br>
<br>
col(MatStencil_i,num) = i<br>
<br>
col(MatStencil_j,num) = j-1<br>
<br>
num = num + 1<br>
<br>
end if<br>
<br>
if (i/=0) then<br>
<br>
v(num) = -rho*HydHx<br>
<br>
col(MatStencil_i,num) = i-1<br>
<br>
col(MatStencil_j,num) = j<br>
<br>
num = num + 1<br>
<br>
end if<br>
<br>
if (i/=mx-1) then<br>
<br>
v(num) = -rho*HydHx<br>
<br>
col(MatStencil_i,num) = i+1<br>
<br>
col(MatStencil_j,num) = j<br>
<br>
num = num + 1<br>
<br>
end if<br>
<br>
if (j/=my-1) then<br>
<br>
v(num) = -rho*HxdHy<br>
<br>
col(MatStencil_i,num) = i<br>
<br>
col(MatStencil_j,num) = j+1<br>
<br>
num = num + 1<br>
<br>
end if<br>
<br>
v(num) = ((num-1)/2.0)*rho*(HxdHy + HydHx)<br>
<br>
print *, v<br>
<br>
col(MatStencil_i,num) = i<br>
<br>
col(MatStencil_j,num) = j<br>
<br>
!num = num + 1<br>
<br>
call MatSetValuesStencil(jac,i1,<u></u>row,num,col,v,INSERT_VALUES,<u></u>ierr)<br>
<br>
I do not get any more out of range error. However,my ans is still different from that of ex29 in C.<br></blockquote><div><br></div><div>This is very simple. You have an error in your code. Checking it is very simple: run the code and</div>
<div>break in MatSetValues(). Make sure ex29 makes calls with exactly the same indices as your ex29f.</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">
Yours sincerely,<br>
<br>
TAY wee-beng<br></blockquote></div><div><br></div>-- <br>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<br>
</div>