[petsc-users] How Can I scatter a global vector to a local vector without using DMGlobaltoLocalBegin/DMGlobaltoLocalEnd?

Matthew Knepley knepley at gmail.com
Fri Jan 11 13:27:58 CST 2019


On Fri, Jan 11, 2019 at 3:35 AM leejearl via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi, all Petscer:
>   I am very sorry for disturbing you for my questions.


I like your questions.


> I have a
> problems as follow.
>   1. A DMPlex object dm is created.
>   2. A global vector and a local vector are created using the following
> routines DMCreateGlobalVector and DMCreateLocalVector.
>   3. I have initialed global Vector. Because the local vector have some
> overlap cells, I want to scatter the data from global to local.
>   4. If I don't use the routines
> DMGlobaltoLocalBegin/DMGlobaltoLocalEnd, how can I scatter it?


To understand the question better, why would you not use DMGlobalToLocal()?


> I have
> scatter the vectors using VecScatterBegin and VecScatterEnd, and the IS
> is created using the localId and the glolbalId (Obtained by
> DMPlexGetCellNumbering). I got a wrong result.
>

DMPlexGetCellNumbering() gives you are _arbitrary_ numbering of the cells,
not the
global numbering of unknowns.


>   Can anyone give me some advices, and does it have some to do with the
> natural ids?
>

1) You can get the local ids from the local Section (DMGetSection), and the
global ids
from the global Section (DMGetGlobalSection). You loop over all the points
in the mesh
and get the offset/size pairs. However, this is error-prone (since you can
have constraints)
and probably unnecessary.

2) If you look at the code for DMGlobalToLocalBegin():

https://bitbucket.org/petsc/petsc/src/650136806607101f8eb495880e9efa33f2f75729/src/dm/interface/dm.c#lines-2201

you see it just call PetscSFBcastBegin(), and there is a similar BcastEnd()
in GlobalToLocalEnd(). Thus all
we are doing is using the SF directly. That is the same as using a Scatter.

  Thanks,

   Matt


>   Any helps are approciated. Thanks.
>
> leejearl
>
>

-- 
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/20190111/ffa96a31/attachment.html>


More information about the petsc-users mailing list