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

Barry Smith bsmith at mcs.anl.gov
Thu Apr 23 19:57:37 CDT 2015


  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