[petsc-users] Checking if a vector is a localvector of a given DMDA
Dave May
dave.mayhem23 at gmail.com
Tue Sep 25 06:02:37 CDT 2018
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.
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180925/7628b01f/attachment.html>
More information about the petsc-users
mailing list