[petsc-users] Vec application ordering to petsc ordering

Santiago Ospina De Los Rios sospinar at unal.edu.co
Sun Jun 12 01:49:11 CDT 2016


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)
    CALL DMDAGetAO(DataMngr,AppOrd,ierr)
    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)
    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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160612/6b08f24a/attachment.html>


More information about the petsc-users mailing list