[petsc-users] How do I scatter a Vec from one processor to many?

Sun, Hui hus003 at ucsd.edu
Fri Apr 24 00:41:39 CDT 2015


Thank you Barry. I think I have figured it out. 


________________________________________
From: Barry Smith [bsmith at mcs.anl.gov]
Sent: Thursday, April 23, 2015 5:57 PM
To: Sun, Hui
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] How do I scatter a Vec from one processor to many?

  All the information about where the data comes from and where it goes is imbedded in the two IS that are passed to the VecScatterCreate(). Those are in terms of the global indices into the vectors so indicate from which particular process the data comes from and where it goes.


  All processes that share the vector (the MPI comm that it was created with) need to call the VecScatterBegin/End in case they have some values to contribute.


> On Apr 23, 2015, at 6:48 PM, Sun, Hui <hus003 at ucsd.edu> wrote:
>
> I have a Sequential Vec v and a parallel Vec u, and I want to scatter v from processor rank 0 to Vec u. How shall I do it?
>
> If I directly call:
> VecScatterBegin(ctx,v,u,INSERT_VALUES,SCATTER_FORWARD);
> VecScatterEnd(ctx,v,u,INSERT_VALUES,SCATTER_FORWARD);
>
> Then how does the computer know that I want to scatter v from processor 0?
>
> If I call:
> if (rank==0) {
>     VecScatterBegin(ctx,v,u,INSERT_VALUES,SCATTER_FORWARD);
>     VecScatterEnd(ctx,v,u,INSERT_VALUES,SCATTER_FORWARD);
>
> }
>
> Then how can other processors know that a scatter has been called?
>
> So what shall I do here?
>
> Best,
> Hui



More information about the petsc-users mailing list