I run <div><div>ao = PETSc.AO().createMapping([5,4,3])</div><div><div><br></div><div>then</div><div>ao.app2petsc([6,5])</div></div><div>will give</div><div><div>array([-1, 0])</div></div><div><br></div><div><br></div><div>
I think it works fine.</div><div><br></div><div>Thanks, Barry.</div><div><br></div><div>Best,</div><div>Xin</div><div><br></div><br><div class="gmail_quote">On Wed, Aug 8, 2012 at 10:37 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Aug 8, 2012, at 4:22 PM, Xin Zhao <<a href="mailto:sean.null@gmail.com">sean.null@gmail.com</a>> wrote:<br>
<br>
> if (low > high) {ia[i] = -1;continue;}<br>
><br>
<br>
</div> With this change; does it now run as you would like?<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> On Wed, Aug 8, 2012 at 10:18 PM, Xin Zhao <<a href="mailto:sean.null@gmail.com">sean.null@gmail.com</a>> wrote:<br>
> PetscErrorCode AOApplicationToPetsc_Mapping(AO ao, PetscInt n, PetscInt *ia)<br>
><br>
> has<br>
><br>
> if (low > high) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE, "Invalid input index %D", idex);<br>
><br>
> Well.... is it a good idea to rewrite this part as<br>
><br>
> if (low > high) ia[i] = -1;<br>
><br>
> And wait for comments from PETSc developers?<br>
><br>
> Need I recompile petsc4py after compiling PETSc?<br>
><br>
> Best,<br>
> Xin<br>
><br>
> On Wed, Aug 8, 2012 at 9:26 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> Hmm,<br>
><br>
> PetscErrorCode AOApplicationToPetsc_Basic(AO ao,PetscInt n,PetscInt *ia)<br>
><br>
> has<br>
><br>
> if (ia[i] >= 0 && ia[i] < N) {<br>
> ia[i] = aobasic->petsc[ia[i]];<br>
> } else {<br>
> ia[i] = -1;<br>
> }<br>
><br>
> PetscErrorCode AOApplicationToPetsc_Mapping(AO ao, PetscInt n, PetscInt *ia)<br>
><br>
> has<br>
><br>
> if (low > high) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE, "Invalid input index %D", idex);<br>
><br>
> PetscErrorCode AOApplicationToPetsc_MemoryScalable(AO ao,PetscInt n,PetscInt *ia)<br>
><br>
> has<br>
><br>
> if (ia[i] >= owners[rank] && ia[i] < owners[rank+1] ) {<br>
> ia[i] = maploc[ia[i]-owners[rank]];<br>
> } else {<br>
> ia[i] = -1 ; /* ia[i] is not in the range of 0 and N-1, maps it to -1 */<br>
> }<br>
><br>
> So it seems the intention is to return -1 for out of range not an error.<br>
><br>
> Can the PETSc developer who wrote all this stuff comment? Likely our bug! Also we should fix the manual page for AOApplicationToPetsc() to clearly indicate what happens for out of range values<br>
><br>
> Barry<br>
><br>
><br>
> On Aug 8, 2012, at 3:10 PM, Xin Zhao <<a href="mailto:sean.null@gmail.com">sean.null@gmail.com</a>> wrote:<br>
><br>
> > Dear all,<br>
> ><br>
> > Assume that I want to convert an indices in application order into petsc order.<br>
> > But I don't know the indices in application is in range.<br>
> ><br>
> > Say<br>
> > I call<br>
> > ao = PETSc.AO().createMapping([4,2,3])<br>
> ><br>
> > then<br>
> > ao.app2petsc([2,5,3])<br>
> > will raise an error.<br>
> ><br>
> > is there any way to make return value to [1,-1,2] instead of raising an error?<br>
> ><br>
> ><br>
> > Or there is any way I can handle this error to make it work?<br>
> ><br>
> > Best,<br>
> > Xin<br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>