<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
It works for me. Please send a complete code that fails.<br>
<br>
<br>
</div>
</span></font></div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
<br>
> On Nov 3, 2019, at 11:41 PM, Emmanuel Ayala via petsc-users <petsc-users@mcs.anl.gov> wrote:<br>
> <br>
> Hi everyone, thanks in advance.<br>
> <br>
> 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.<br>
> <br>
> For these propose I use Scatters:<br>
> <br>
> 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.<br>
> <br>
> For the specific case with order [A;B]<br>
> <br>
> VecGetOwnershipRange(A,&start,&end);<br>
> ISCreateStride(MPI_COMM_WORLD,(end-start),start,1,&is_fromA);<br>
> ISCreateStride(MPI_COMM_WORLD,(end-start),start,1,&is_toC1);// this is redundant<br>
> VecScatterCreate(A,is_fromA,C,is_toC1,&scatter1);<br>
> <br>
> VecGetSize(A,&sizeA)<br>
> VecGetOwnershipRange(B,&start,&end);<br>
> ISCreateStride(MPI_COMM_WORLD,(end-start),start,1,&is_fromB);<br>
> ISCreateStride(MPI_COMM_WORLD,(end-start),(start+sizeA),1,&is_toC2); //shifts the index location<br>
> VecScatterCreate(B,is_fromB,C,is_toC2,&scatter2);<br>
> <br>
> Then I can use <br>
> VecScatterBegin(scatter1,A,C,INSERT_VALUES,SCATTER_FORWARD);<br>
> VecScatterEnd(scatter1,A,C,INSERT_VALUES,SCATTER_FORWARD);<br>
> <br>
> and<br>
> VecScatterBegin(scatter1,C,A,INSERT_VALUES,SCATTER_REVERSE);<br>
> VecScatterEnd(scatter1,C,A,INSERT_VALUES,SCATTER_REVERSE);<br>
> <br>
> and the same with B.<br>
> I used MPI_COMM SELF and I got the same results.<br>
> <br>
> 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?<br>
> <br>
> Best regards.<br>
<br>
</div>
</span></font></div>
</body>
</html>