[petsc-users] Checking if a vector is a localvector of a given DMDA
Matthew Knepley
knepley at gmail.com
Tue Sep 25 06:20:04 CDT 2018
On Tue, Sep 25, 2018 at 7:03 AM Dave May <dave.mayhem23 at gmail.com> wrote:
> On Tue, 25 Sep 2018 at 11:49, Phil Tooley <phil.tooley at sheffield.ac.uk>
> wrote:
>
>> Hi all,
>>
>> Given a vector I know I can get an associated DM (if there is one) by
>> calling VecGetDM, but I need to also be able to check that
>>
>> a) the vector is the localvector of that DM rather than the global
>>
>
> Given the vector, you can check the communicator size via
> PetscObjectGetComm()
>
>
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectGetComm.html
> and then MPI_Comm_size()
> If the comm size 1, it is local vector.
>
In serial, both vectors have comm size 1.
Matt
> You can check the size matches your local DMDA space by using
> DMDAGetGhostCorners()
>
>
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDAGetGhostCorners.html
>
> and return the quantities m, n, and p.
>
> You also need to use DMDAGetInfo()
>
>
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDAGetInfo.html
>
> The important quantity you want returned is "dof"
>
> If m x n x p x dof matches the number returned by VecGetSize() (assuming
> you know the vector is sequential) then you know the local space will fit
> within your vector.
>
>
>
>>
>> b) the DM is a DMDA rather than some other subclass
>>
>
> See Matt's answer
>
>
>>
>> I can't immediately see routines that do what I need, but I am likely
>> missing something obvious. Is there a way to achieve the above?
>>
>> Thanks
>>
>> Phil
>>
>> --
>> Phil Tooley
>> Research Software Engineering
>> University of Sheffield
>>
>>
--
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
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180925/a10c5f4a/attachment-0001.html>
More information about the petsc-users
mailing list