<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 24, 2016 at 11:22 AM, Alice Raeli <span dir="ltr"><<a href="mailto:alice.raeli@math.u-bordeaux.fr" target="_blank">alice.raeli@math.u-bordeaux.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi All,<div><br></div><div>I had the necessity to read data on another node of a Vector Petsc. </div><div>I followed the structure showed in the tutorial of <span style="color:rgb(76,191,87);font-family:Menlo;font-size:11px">VecScatterCreateToAll.</span></div><div>I call the function below 2 times with 2 different vectors vec1 and vec2.</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo">void Scatter(Vec vec, PetscScalar &value, vector<int> NeighboursIndex, int NeighNumber){</div><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;font-family:Menlo"> Vec V_SEQ;</div><div style="margin:0px;font-size:11px;font-family:Menlo"> VecScatter ctx;</div><div style="margin:0px;font-size:11px;font-family:Menlo"> PetscScalar *vecArray;</div><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> <br></p><div style="margin:0px;font-size:11px;font-family:Menlo"> VecScatterCreateToAll(vec,&ctx,&V_SEQ);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> VecScatterBegin(ctx,vec,V_SEQ,INSERT_VALUES,SCATTER_FORWARD);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> VecScatterEnd(ctx,vec,V_SEQ,INSERT_VALUES,SCATTER_FORWARD);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> ierr = VecGetArray(V_SEQ,&vecArray);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> for(int i=0; i<NeighNumber;i++){</div><div style="margin:0px;font-size:11px;font-family:Menlo"> PetscInt index=NeighboursIndex[i];</div><div style="margin:0px;font-size:11px;font-family:Menlo"> value = vecArray[index];</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo"> if(NeighboursIndex[0]==869 && (index==363 || index == 364 || index ==365) ){</div><div style="margin:0px;font-size:11px;font-family:Menlo"> cout << endl << index << " inside function " << value;</div><div style="margin:0px;font-size:11px;font-family:Menlo"> }</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo"> }</div><div style="margin:0px;font-size:11px;font-family:Menlo"> //</div><div style="margin:0px;font-size:11px;font-family:Menlo"> ierr = VecRestoreArray(V_SEQ,&vecArray);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> VecScatterDestroy(&ctx);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> VecDestroy(&V_SEQ);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> return; </div><div style="margin:0px;font-size:11px;font-family:Menlo">}</div></div><div><br></div><div>When I run my code with one node i have a result coherent but if I use 2 nodes the vectors are inverted in values.</div></div></blockquote><div><br></div><div>VecScatter just sends values. It does not process them in any way. You must have other code in your program</div><div>that is altering the values. If you can send a small example, we will look at it.</div><div><br></div><div> Thanks,</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"><div style="word-wrap:break-word"><div>I used for a test a vector of 1 and a vector of 0 and I concentrated the output on a point that communicates with the other node.</div><div><br></div><div>Can you explain me what is effectively wrong when I call the vecscatter routines? I can’t see a reason coherent with a simple inversion of values from 2 vectors. </div><div><br></div><div>Example of output</div><div>1 node:</div><div>first call vec1</div><div><div style="margin:0px;font-size:11px;font-family:Menlo">364 inside function 87.797</div><div style="margin:0px;font-size:11px;font-family:Menlo">363 inside function 89.0416</div><div style="margin:0px;font-size:11px;font-family:Menlo">365 inside function 86.4618</div><div style="margin:0px;font-size:11px;font-family:Menlo">second call vec2</div><div style="margin:0px;font-size:11px;font-family:Menlo">364 inside function 0.0268704</div><div style="margin:0px;font-size:11px;font-family:Menlo">363 inside function 0.0322394</div><div style="margin:0px;font-size:11px;font-family:Menlo">365 inside function 0.0199141</div></div><div><br></div><div>2 nodes:</div><div>first call vec1</div><div><div style="margin:0px;font-size:11px;font-family:Menlo">364 inside function 0.0268704</div><div style="margin:0px;font-size:11px;font-family:Menlo">363 inside function 0.0322394</div><div style="margin:0px;font-size:11px;font-family:Menlo">365 inside function 0.0199141</div><div style="margin:0px;font-size:11px;font-family:Menlo">second call vec2</div><div style="margin:0px;font-size:11px;font-family:Menlo">364 inside function 87.797</div><div style="margin:0px;font-size:11px;font-family:Menlo">363 inside function 89.0416</div><div style="margin:0px;font-size:11px;font-family:Menlo">365 inside function 86.4618</div></div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo"><b>Many Thanks</b></div><div style="margin:0px;font-size:11px;font-family:Menlo"><b>Alice Raeli</b></div><div style="margin:0px;font-size:11px;font-family:Menlo"><b style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">I</b><span style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">nstitut de </span><b style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">M</b><span style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">athématiques de </span><b style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">B</b><span style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">ordeaux </span><b style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px">(IMB)</b><br style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px"><br style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px"><a href="mailto:alice.raeli@math.u-bordeaux1.fr" style="font-family:Helvetica;font-size:12px" target="_blank">alice.raeli@math.u-bordeaux1.fr</a><br style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px"><br style="color:rgb(136,136,136);font-family:Helvetica;font-size:12px"><a href="mailto:alice.raeli@u-bordeaux.fr" style="font-family:Helvetica;font-size:12px" target="_blank">alice.raeli@u-bordeaux.fr</a></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">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></div>