<div dir="ltr"><div style="line-height:21px"><div style=""><div style="line-height:21px">Hi, Sreeram,<br>You can try this code. Since x, y are both MPI vectors, we just need to say we want to scatter x[0:N] to y[0:N]. The 12 index sets with your example on the 12 processes would be [0..8], [9..17], [18..26], [27..35], [], ..., []. Actually, you can do it arbitrarily, say, with 12 index sets [0..17], [18..35], .., []. PETSc will figure out how to do the communication. <div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"><br></div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> PetscInt rstart, rend, N;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> IS ix;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecScatter vscat;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> Vec y;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> MPI_Comm comm;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecType type;</div><br><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> PetscObjectGetComm((PetscObject)x, &comm);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecGetType(x, &type);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecGetSize(x, &N);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecGetOwnershipRange(x, &rstart, &rend);</div><br><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecCreate(comm, &y);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecSetSizes(y, <span style="color:rgb(0,0,255)">PETSC_DECIDE</span>, N);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecSetType(y, type);</div><br><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> ISCreateStride(PetscObjectComm((PetscObject)x), rend - rstart, rstart, <span style="color:rgb(9,134,88)">1</span>, &ix);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> VecScatterCreate(x, ix, y, ix, &vscat);</div></div></div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"><br></div></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 4, 2023 at 6:03 PM Sreeram R Venkat <<a href="mailto:srvenkat@utexas.edu">srvenkat@utexas.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr" class="gmail_signature"><div dir="ltr"><div style="color:rgb(34,34,34)">Suppose I am running on 12 processors, and I have a vector "v" of size 36 partitioned over the first 4. v still uses the PETSC_COMM_WORLD, so it has a layout of (9, 9, 9, 9, 0, 0, ..., 0). Now, I would like to repartition it over all 12 processors, so that the layout becomes (3, 3, 3, ..., 3). I've been trying to use VecScatter to do this, but I'm not sure what IndexSets to use for the sender and receiver.</div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">The result I am trying to achieve is this:</div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">Assume the vector is v = <0, 1, 2, ..., 35> </div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)"> Start Finish</div><div style="color:rgb(34,34,34)">Proc | Entries Proc | Entries</div><div style="color:rgb(34,34,34)"> 0 | 0,...,8 0 | 0, 1, 2</div><div style="color:rgb(34,34,34)"> 1 | 9,...,17 1 | 3, 4, 5<br></div><div style="color:rgb(34,34,34)"> 2 | 18,...,26 2 | 6, 7, 8<br></div><div style="color:rgb(34,34,34)"> 3 | 27,...,35 3 | 9, 10, 11<br></div><div style="color:rgb(34,34,34)"> 4 | None 4 | 12, 13, 14<br></div><div style="color:rgb(34,34,34)"> 5 | None 5 | 15, 16, 17<br></div><div style="color:rgb(34,34,34)"> 6 | None 6 | 18, 19, 20<br></div><div style="color:rgb(34,34,34)"> 7 | None 7 | 21, 22, 23<br></div><div style="color:rgb(34,34,34)"> 8 | None 8 | 24, 25, 26<br></div><div style="color:rgb(34,34,34)"> 9 | None 9 | 27, 28, 29<br></div><div style="color:rgb(34,34,34)"> 10 | None 10 | 30, 31, 32<br></div><div style="color:rgb(34,34,34)"> 11 | None 11 | 33, 34, 35<br></div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">Appreciate any help you can provide on this.</div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">Thanks,</div><div style="color:rgb(34,34,34)">Sreeram</div></div></div></div>
</blockquote></div>