<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 12, 2014 at 8:53 AM, Mari Pecha <span dir="ltr"><<a href="mailto:pecha.mari@gmail.com" target="_blank">pecha.mari@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Good morning,<br>
<br>
I'm Mari and I'm beginner PETSc user and I'd like to ask about tough problem, especially for me.<br>
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<br>
</blockquote><div><br></div><div>I have no idea what you really want to do. How about describing your problem with</div><div>2 procs and 3 values per proc.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
...<br>
<br>
ierr = DMDAGlobalToNaturalAllCreate( da, &tolocalall ); CHKERRQ(ierr);<br>
ierr = DMDANaturalAllToGlobalCreate( da, &fromlocalall ); CHKERRQ(ierr);<br>
<br>
if( rank == 0 )<br>
{<br>
<br>
ierr = VecCreateSeq( PETSC_COMM_SELF, SIZE, &localall );<br>
<br>
ierr = VecScatterBegin( tolocalall, x, localall, ADD_VALUES, SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);<br>
ierr = VecScatterEnd( tolocalall, x, localall, ADD_VALUES, SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);<br></blockquote><div><br></div><div>This will not work since you have a collective call (VecScatterBegin) inside if(!rank)</div>
<div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ierr = VecGetArray( x, &vlocal ); CHKERRQ(ierr);<br>
<br>
PetscInt s;<br>
VecGetSize( localall, &s );<br>
<br>
ierr = VecView( localall, PETSC_VIEWER_STDOUT_SELF ); CHKERRQ( ierr );<br>
<br>
//create data on zero rank process<br>
for ( int i = 0; i < s; i++) *vlocal++ = i;<br>
<br>
ierr = VecRestoreArray( localall, &vlocal ); CHKERRQ(ierr);<br>
<br>
ierr = VecScatterBegin(fromlocalall, localall, x, ADD_VALUES, SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);<br>
ierr = VecScatterEnd( fromlocalall, localall, x, ADD_VALUES, SCATTER_FORWARD_LOCAL ); CHKERRQ(ierr);<br>
}<br>
<br>
....<br>
<br>
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?<br>
<br>
Thanks for your response<span class="HOEnZb"><font color="#888888"><br>
Mari<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>