[petsc-users] How to output the values of a parallel PETSc vector to a ASCII file

Matthew Knepley knepley at gmail.com
Fri Dec 2 08:11:25 CST 2011


On Fri, Dec 2, 2011 at 8:07 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

>
>
> On Fri, Dec 2, 2011 at 08:04, Feng-Chao Wang <wolfshow at gmail.com> wrote:
>
>> **
>> Dear all,
>>
>> I intend to postprocess the solution of a PDE (stored in a
>> parallel PETSc vector ) using tecplot. Thus I want to  output the values of
>> the parallel vector as well as other data (such as the grid information) to
>> a ASCII file.
>>
>> When I deal this with
>>
>>
>> VecGetArray(U, &u);
>>
>> for (i=0; i<Mx*My; i++)
>> {
>> PetscViewerASCIIPrintf(viewer,"%F %F %F", x, y, u[i]);
>> }
>>
>> If more than 1 processor are used, I found that only part of the value of
>> u was output correctly (that stored on the first processor).
>> I found in the manual page of "PetscViewerASCIIPrintf" that "Not
>> Collective, but only first processor in set has any effect"
>>
>
> If you can afford the memory:
>
>
> http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Vec/VecScatterCreateToZero.html
>
> Slower:
>
>
> http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Sys/PetscSynchronizedPrintf.html
>
> Binary output can be written in parallel using
>
> http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Vec/VecView.html
>

Note that VecView also does ASCII output

  Matt

-- 
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/20111202/1a335a63/attachment.htm>


More information about the petsc-users mailing list