[petsc-users] How to output the values of a parallel PETSc vector to a ASCII file
Jed Brown
jedbrown at mcs.anl.gov
Fri Dec 2 08:07:54 CST 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111202/1a6f030c/attachment-0001.htm>
More information about the petsc-users
mailing list