[petsc-users] VecGetSubVector

Matthew Knepley knepley at gmail.com
Thu May 7 15:44:52 CDT 2020


On Thu, May 7, 2020 at 4:37 PM Emmanuel Ayala <juaneah at gmail.com> wrote:

> Hi, I hope everyone is well.
>
> I have a MPI vector, I selected some elements of this vector and for some
> processes there is not selected elements (I stored the indices elements
> into an array). So, I wan to to create a MPI vector using these selected
> elements, the selected elements must be fully distributed in a MPI vector,
> but I do not figure out how to do it properly.
>
> If I use VecGetSubVector, it creates a MPI vector, but in those processes
> where there is not selected elements, the subvector portion is empty, this
> means that the resultant vector is unbalanced.
>

Yes, you cannot use SubVector.


> If I use:
>
> VecScatterCreate(Vec x,IS ix,Vec y,IS iy,VecScatter *ctx);
> VecScatterBegin(VecScatter ctx,Vec x,Vec y,INSERT VALUES,SCATTER FORWARD);
> VecScatterEnd(VecScatter ctx,Vec x,Vec y,INSERT VALUES,SCATTER FORWARD);
>
> The vector is still unbalanced.
>

You have not sent the elements to the places that you really wanted.
VecScatter moves the elements that you ask for
to the place you tell it. If you want them to be balanced, you must send
them to balanced locations using iy.

  Thanks,

     Matt


> Any suggestion?
>
> Kind regards.
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200507/1d384ea3/attachment.html>


More information about the petsc-users mailing list