On Tue, Sep 25, 2018 at 7:03 AM Dave May <[email protected]> wrote:
> On Tue, 25 Sep 2018 at 11:49, Phil Tooley <[email protected]> > 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/>
