Thank you Barry. I think I have figured it out.
________________________________________ From: Barry Smith [[email protected]] Sent: Thursday, April 23, 2015 5:57 PM To: Sun, Hui Cc: [email protected] 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 <[email protected]> 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
