[petsc-users] doubts on VecScatterCreate

Smith, Barry F. bsmith at mcs.anl.gov
Mon Nov 4 08:47:47 CST 2019


   It works for me. Please send a complete code that fails.




> On Nov 3, 2019, at 11:41 PM, Emmanuel Ayala via petsc-users <petsc-users at mcs.anl.gov> wrote:
>
> 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/20191104/af8d6938/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex1.c
Type: application/octet-stream
Size: 1481 bytes
Desc: ex1.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191104/af8d6938/attachment.obj>


More information about the petsc-users mailing list