[petsc-users] Troubles with VecScatter routines: inverting vectors values
Alice Raeli
alice.raeli at math.u-bordeaux.fr
Tue May 24 11:22:39 CDT 2016
Hi All,
I had the necessity to read data on another node of a Vector Petsc.
I followed the structure showed in the tutorial of VecScatterCreateToAll.
I call the function below 2 times with 2 different vectors vec1 and vec2.
void Scatter(Vec vec, PetscScalar &value, vector<int> NeighboursIndex, int NeighNumber){
Vec V_SEQ;
VecScatter ctx;
PetscScalar *vecArray;
VecScatterCreateToAll(vec,&ctx,&V_SEQ);
VecScatterBegin(ctx,vec,V_SEQ,INSERT_VALUES,SCATTER_FORWARD);
VecScatterEnd(ctx,vec,V_SEQ,INSERT_VALUES,SCATTER_FORWARD);
ierr = VecGetArray(V_SEQ,&vecArray);
for(int i=0; i<NeighNumber;i++){
PetscInt index=NeighboursIndex[i];
value = vecArray[index];
if(NeighboursIndex[0]==869 && (index==363 || index == 364 || index ==365) ){
cout << endl << index << " inside function " << value;
}
}
//
ierr = VecRestoreArray(V_SEQ,&vecArray);
VecScatterDestroy(&ctx);
VecDestroy(&V_SEQ);
return;
}
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.
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.
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.
Example of output
1 node:
first call vec1
364 inside function 87.797
363 inside function 89.0416
365 inside function 86.4618
second call vec2
364 inside function 0.0268704
363 inside function 0.0322394
365 inside function 0.0199141
2 nodes:
first call vec1
364 inside function 0.0268704
363 inside function 0.0322394
365 inside function 0.0199141
second call vec2
364 inside function 87.797
363 inside function 89.0416
365 inside function 86.4618
Many Thanks
Alice Raeli
Institut de Mathématiques de Bordeaux (IMB)
alice.raeli at math.u-bordeaux1.fr <mailto:alice.raeli at math.u-bordeaux1.fr>
alice.raeli at u-bordeaux.fr <mailto:alice.raeli at u-bordeaux.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160524/70b165bc/attachment.html>
More information about the petsc-users
mailing list