[petsc-users] Vec application ordering to petsc ordering

Matthew Knepley knepley at gmail.com
Sun Jun 12 02:02:15 CDT 2016


On Sun, Jun 12, 2016 at 7:49 AM, Santiago Ospina De Los Rios <
sospinar at unal.edu.co> wrote:

> Hello there,
>
> I'm using your Application Ordering (AO) objects to switch between vectors
> with my application ordering to petsc ordering. I built a little routine
> which helps me to gather the information in the proper order:
>
> SUBROUTINE VecApplicationToPetsc(DataMngr,AppVec,ierr)
>
>     IMPLICIT NONE
>
> #include <petsc/finclude/petscsys.h>
> #include <petsc/finclude/petscvec.h>
> #include <petsc/finclude/petscis.h>
> #include <petsc/finclude/petscdm.h>
> #include <petsc/finclude/petscdmda.h>
> #include <petsc/finclude/petscao.h>
>
>     PetscErrorCode,INTENT(INOUT)    :: ierr
>     DM,INTENT(IN)                   :: DataMngr
>     Vec,INTENT(INOUT)               :: AppVec ! it outs as PetscVec
>
>     AO                              :: AppOrd
>     PetscInt                        :: RangeLow,RangeHigh,i
>     IS                              :: PetscIS,AppIS
>     VecScatter                      :: Scatter
>     Vec                             :: PetscVec
>
>     ! It obtains a temporal vector to store in PETSc ordering
>     CALL DMCreateGlobalVector(DataMngr,PetscVec,ierr)
>     CALL AOCreate(PETSC_COMM_WORLD,AppOrd,ierr)
>
>
Here you create a new AO object


>     CALL DMDAGetAO(DataMngr,AppOrd,ierr)
>
>
Here you overwrite that initial AO with the AO from the DMDA, thus leaking
memory.


>     CALL VecGetOwnershipRange(PetscVec,RangeLow,RangeHigh,ierr)
>     CALL
> ISCreateGeneral(PETSC_COMM_WORLD,RangeHigh-RangeLow,(/(i,i=RangeLow,RangeHigh)/),PETSC_COPY_VALUES,PetscIS,ierr)
>     CALL ISDuplicate(PetscIS,AppIS,ierr)
>     CALL ISCopy(PetscIS,AppIS,ierr)
>     CALL AOPetscToApplicationIS(AppOrd,AppIS,ierr)
>     CALL VecScatterCreate(AppVec,AppIS,PetscVec,PetscIS,Scatter,ierr)
>     CALL
> VecScatterBegin(Scatter,AppVec,PetscVec,INSERT_VALUES,SCATTER_FORWARD,ierr)
>     CALL
> VecScatterEnd(Scatter,AppVec,PetscVec,INSERT_VALUES,SCATTER_FORWARD,ierr)
>
>     CALL VecScatterDestroy(Scatter,ierr)
>     CALL ISDestroy(AppIS,ierr)
>     CALL ISDestroy(PetscIS,ierr)
>     CALL AODestroy(AppOrd,ierr)
>
>
Here you destroy the DMDA AO, which causes the error, but not the original
AO, which causes a leak.

Remove the Create/Destroy.

  Matt


>     CALL VecCopy(PetscVec,AppVec,ierr)
>     CALL VecDestroy(PetscVec,ierr)
>
> END SUBROUTINE VecApplicationToPetsc
>
>
> It is working well for my purpose, but just the first time I call it; the
> second time I call it, the AO object give me back an error. The most
> obviously way to avoid it is creating AO, IS and VecScatter objects just
> one time, but I don't want to handle those variables through my whole
> program.
>
> Am I doing something wrong with the AO object?
>
> Thank you.
>
>
> --
>
> --
> Att:
>
> Santiago Ospina De Los Ríos
> National University of Colombia
>



-- 
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/20160612/f1535125/attachment.html>


More information about the petsc-users mailing list