[petsc-users] Data Distribution from zero-rank process

Matthew Knepley knepley at gmail.com
Tue Aug 12 09:12:06 CDT 2014


On Tue, Aug 12, 2014 at 8:53 AM, Mari Pecha <pecha.mari at gmail.com> wrote:

> Good morning,
>
> I'm Mari and I'm beginner PETSc user and I'd like to ask about tough
> problem, especially for me.
> I solve problem of data-set distribution, which are saved only on
> zero-rank process, to DMDA global vector. It means that every process
> stores a appropriate  subset of data-set. I used
> DMDAGlobalToNaturalAllCreate and DMDANaturalAllToGlobalCreate function, and
> then VecScatterBegin and VecScatterEnd functions ... see please code below
>

I have no idea what you really want to do. How about describing your
problem with
2 procs and 3 values per proc.


>     ...
>
>     ierr = DMDAGlobalToNaturalAllCreate( da, &tolocalall   );
> CHKERRQ(ierr);
>     ierr = DMDANaturalAllToGlobalCreate( da, &fromlocalall );
> CHKERRQ(ierr);
>
>     if( rank == 0  )
>     {
>
>         ierr = VecCreateSeq( PETSC_COMM_SELF, SIZE, &localall );
>
>         ierr = VecScatterBegin( tolocalall, x, localall, ADD_VALUES,
> SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);
>         ierr = VecScatterEnd(   tolocalall, x, localall, ADD_VALUES,
> SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);
>

This will not work since you have a collective call (VecScatterBegin)
inside if(!rank)

   Matt


>         ierr = VecGetArray( x, &vlocal ); CHKERRQ(ierr);
>
>         PetscInt s;
>         VecGetSize( localall, &s );
>
>         ierr = VecView( localall, PETSC_VIEWER_STDOUT_SELF ); CHKERRQ(
> ierr );
>
>         //create data on zero rank process
>         for ( int i = 0; i < s; i++) *vlocal++ = i;
>
>         ierr = VecRestoreArray( localall, &vlocal ); CHKERRQ(ierr);
>
>         ierr = VecScatterBegin(fromlocalall, localall, x, ADD_VALUES,
> SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);
>         ierr = VecScatterEnd(  fromlocalall, localall, x, ADD_VALUES,
> SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);
>     }
>
>     ....
>
> But the piece of code gets and distributes only vector-values belong to
> zero-rank process. So, I haven't any idea how can I solve my problem only
> with PETSc functions. I'd like to get all values from global vector to
> zero-rank process and put back all data-set only from zero-rank to global
> vector. Can you help me, please?
>
> Thanks for your response
> Mari
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140812/6339f099/attachment-0001.html>


More information about the petsc-users mailing list