PETSc Global Vector to local process vector

Ignacio Martínez 100039048 at alumnos.uc3m.es
Tue Nov 25 17:54:38 CST 2008


My apologies, I want all values in all processor, following your indications
I guess I need to use something like:

  Vec natural,allonme;
  VecScatter tozero;

  DACreateNaturalVector(da,&natural);
/***********************************************************/
  VecScatterCreateToAll(natural,&tozero,&allonme);
/***********************************************************/
 /* now to get the values on the that 0th process */

  DAGlobalToNaturalBegin(da,vec,INSERT_VALUES,natural);
  DAGlobalToNaturalEnd(da,vec,INSERT_VALUES,natural);
  VecScatterBegin(tozero,natural,allonme,INSERT_VALUES,SCATTER_FORWARD);
VecScatterEnd(tozero,natural,allonme,INSERT_VALUES,SCATTER_FORWARD);

And all process should have all data. Is this right?

Thank you very much,
Ignacio

2008/11/26 Barry Smith <bsmith at mcs.anl.gov>:
>
>   Your message is unclear.
>
>   DAGlobalToNaturalAllCreate() will give you a scatter to get ALL the
values
> on EACH process in the "natural ordering".
>
>   Do you wish to get ALL the values onto a SINGLE process (and nothing
> on the rest)? If so, here is how you do it.
>
>    Vec natural,allonme;
>    VecScatter tozero;
>
>    DACreateNaturalVector(da,&natural);
>    VecScatterCreateToZero(natural,&tozero,&allonme);
>
>   /* now to get the values on the that 0th process */
>
>    DAGlobalToNaturalBegin(da,vec,INSERT_VALUES,natural);
>    DAGlobalToNaturalEnd(da,vec,INSERT_VALUES,natural);
>    VecScatterBegin(tozero,natural,allonme,INSERT_VALUES,SCATTER_FORWARD);
>  VecScatterEnd(tozero,natural,allonme,INSERT_VALUES,SCATTER_FORWARD);
>
>   Now process 0 will have a sequential vector that contains the entire
> global vector.
> All other processes will have a sequential vector of size 0. ALL
processes,
> of course,
> must call the DAGlobalToNatural.... and VecScatter... routines.
>
>   It is possible to reverse this operation too, to get values from process
0
> out to the other processes.
>
>   If this was not your question, then please clarify what you wish to do.
>
>   Barry
>
>
> On Nov 25, 2008, at 4:46 PM, Ignacio Martínez wrote:
>
>> Hello,
>>
>> I'm a beginner user, and I have a problem:
>>
>> I have a routine in Fortran and I just want to parallelize few lines
>> with PETSc, I'm using DA in order to gather the results, from local
>> vectors to a global vector.
>> It works fine. But I need to return those values to the Fortran
>> routine, and I only get access to local process values.
>>
>> I try to create a sequential vectors with an scatter to get that
>> values. But, PETSc returns an error, something like: "Cannot create
>> VECSEQ on more than one process!" (I try to create the vector only in
>> one process).
>>
>> Exactly in using DAGlobalToNaturalAllCreate and  VecScatterBegin to
>> get global values in to a process.
>>
>> And my question is if someone has tried to do something like this, and
>> how has done it. Or if could you give me some orientation?
>>
>> Thank you in advance,
>> Ignacio
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20081126/2cc343e0/attachment.htm>


More information about the petsc-users mailing list