[petsc-users] return -1 instead of raising an error in ao.app2petsc

Xin Zhao sean.null at gmail.com
Wed Aug 8 16:52:53 CDT 2012


I run
ao = PETSc.AO().createMapping([5,4,3])

then
ao.app2petsc([6,5])
will give
array([-1,  0])


I think it works fine.

Thanks, Barry.

Best,
Xin


On Wed, Aug 8, 2012 at 10:37 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> On Aug 8, 2012, at 4:22 PM, Xin Zhao <sean.null at gmail.com> wrote:
>
> >  if (low > high) {ia[i] = -1;continue;}
> >
>
>    With this change; does it now run as you would like?
>
>     Barry
>
>
> > On Wed, Aug 8, 2012 at 10:18 PM, Xin Zhao <sean.null at gmail.com> wrote:
> > PetscErrorCode AOApplicationToPetsc_Mapping(AO ao, PetscInt n, PetscInt
> *ia)
> >
> > has
> >
> >     if (low > high) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,
> "Invalid input index %D", idex);
> >
> > Well.... is it a good idea to rewrite this part as
> >
> >  if (low > high) ia[i] = -1;
> >
> > And wait for comments from PETSc developers?
> >
> > Need I recompile petsc4py after compiling PETSc?
> >
> > Best,
> > Xin
> >
> > On Wed, Aug 8, 2012 at 9:26 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> >   Hmm,
> >
> > PetscErrorCode AOApplicationToPetsc_Basic(AO ao,PetscInt n,PetscInt *ia)
> >
> >    has
> >
> >     if (ia[i] >= 0 && ia[i] < N) {
> >       ia[i] = aobasic->petsc[ia[i]];
> >     } else {
> >       ia[i] = -1;
> >     }
> >
> > PetscErrorCode AOApplicationToPetsc_Mapping(AO ao, PetscInt n, PetscInt
> *ia)
> >
> > has
> >
> >     if (low > high) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,
> "Invalid input index %D", idex);
> >
> > PetscErrorCode AOApplicationToPetsc_MemoryScalable(AO ao,PetscInt
> n,PetscInt *ia)
> >
> > has
> >
> >       if (ia[i] >= owners[rank] && ia[i] < owners[rank+1] ) {
> >         ia[i] = maploc[ia[i]-owners[rank]];
> >       } else {
> >         ia[i] = -1 ; /* ia[i] is not in the range of 0 and N-1, maps it
> to -1 */
> >       }
> >
> > So it seems the intention is to return -1 for out of range not an error.
> >
> > 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
> >
> >    Barry
> >
> >
> > On Aug 8, 2012, at 3:10 PM, Xin Zhao <sean.null at gmail.com> wrote:
> >
> > > Dear all,
> > >
> > > Assume that I want to convert an indices in application order into
> petsc order.
> > > But I don't know the indices in application is in range.
> > >
> > > Say
> > > I call
> > > ao = PETSc.AO().createMapping([4,2,3])
> > >
> > > then
> > > ao.app2petsc([2,5,3])
> > > will raise an error.
> > >
> > > is there any way to make return value to [1,-1,2] instead of raising
> an error?
> > >
> > >
> > > Or there is any way I can handle this error to make it work?
> > >
> > > Best,
> > > Xin
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120808/aa73f998/attachment.html>


More information about the petsc-users mailing list