[petsc-users] Vec application ordering to petsc ordering

Santiago Ospina De Los Rios sospinar at unal.edu.co
Sun Jun 12 02:20:04 CDT 2016


2016-06-12 2:14 GMT-05:00 Santiago Ospina De Los Rios <sospinar at unal.edu.co>
:

>
>
> 2016-06-12 2:02 GMT-05:00 Matthew Knepley <knepley at gmail.com>:
>
>> 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.
>>
>>
> It worked pretty well, thank you.
> But what do you mean with "original AO"? is it not supposed one have to
> destroy every petsc object created?
>
> Forget it, I already understand.


> Santiago O.
>
>   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
>>
>
>
>
> --
>
> --
> Att:
>
> Santiago Ospina De Los Ríos
> National University of Colombia
>



-- 

-- 
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/9a152574/attachment.html>


More information about the petsc-users mailing list