[petsc-users] doubts on VecScatterCreate

Emmanuel Ayala juaneah at gmail.com
Sun Nov 3 23:41:50 CST 2019


Hi everyone, thanks in advance.

I have three parallel vectors: A, B and C. A and B have different sizes,
and C must be contain these two vectors (MatLab notation C=[A;B]). I need
to do some operations on C then put back the proper portion of C on A and
B, then I do some computations on A and B y put again on C, and the loop
repeats.

For these propose I use Scatters:

C is created as a parallel vector with size of (sizeA + sizeB) with
petsc_decide for parallel layout. The vectors have been distributed on the
same amount of processes.

For the specific case with order [A;B]

VecGetOwnershipRange(A,&start,&end);
ISCreateStride(MPI_COMM_WORLD,(end-start),start,1,&is_fromA);
ISCreateStride(MPI_COMM_WORLD,(end-start),start,1,&is_toC1);// this is
redundant
VecScatterCreate(A,is_fromA,C,is_toC1,&scatter1);

VecGetSize(A,&sizeA)
VecGetOwnershipRange(B,&start,&end);
ISCreateStride(MPI_COMM_WORLD,(end-start),start,1,&is_fromB);
ISCreateStride(MPI_COMM_WORLD,(end-start),(start+sizeA),1,&is_toC2);
//shifts the index location
VecScatterCreate(B,is_fromB,C,is_toC2,&scatter2);

Then I can use
VecScatterBegin(scatter1,A,C,INSERT_VALUES,SCATTER_FORWARD);
VecScatterEnd(scatter1,A,C,INSERT_VALUES,SCATTER_FORWARD);

and
VecScatterBegin(scatter1,C,A,INSERT_VALUES,SCATTER_REVERSE);
VecScatterEnd(scatter1,C,A,INSERT_VALUES,SCATTER_REVERSE);

and the same with B.
I used MPI_COMM SELF and I got the same results.

*The situation is: My results look good for the portion of B, but no for
the portion of A, there is something that I'm doing wrong with the
scattering?*

Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191103/b7ba25e2/attachment.html>


More information about the petsc-users mailing list