[petsc-users] Most efficient way to transfer a vector to a single processor

Matthew Knepley knepley at gmail.com
Wed Apr 4 16:51:15 CDT 2012


On Wed, Apr 4, 2012 at 4:47 PM, Andrew Spott <andrew.spott at gmail.com> wrote:

> I'm interested in moving a vector to a single processor (so I can output
> it in some custom way), but I can't find a simple way to do that.
>
> Is the easiest way to output the parallel vector to a file and then read
> it in to a single processor vector?
>

http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Vec/VecScatterCreateToZero.html


> Also, an unrelated question:  If I have a vector that I'm using as the
> result of a matrix vector product, but it is initially empty, do I need to
> initialize it in any way?  or can I just create it and run with it:
>
> … create x and A ...
> VecCreate(world, &b);
>

This create is wrong, that Vec will be overwritten.


> MatGetVecs(A,&x,&b);
>

You can jsut use these vectors.

   Matt


> … do stuff with x and A ...
>
> MatMult(A,x,b);
>
> Thanks for the help,
>
> -Andrew




-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120404/8ea1870b/attachment.htm>


More information about the petsc-users mailing list