[petsc-users] output vec

Matthew Knepley knepley at gmail.com
Thu May 22 09:42:52 CDT 2014


On Thu, May 22, 2014 at 9:32 AM, <likunt at caltech.edu> wrote:

> Dear Petsc developers,
>
> I am trying to output my vec M={m1 m2 m3 m4 m5 m6 ...} in a form like this:
>
> m1 m2 m3
> m4 m5 m6
> ...
>
> Here is my code to do this:
>
> ==================================================================
> PetscViewerASCIIOpen(PETSC_COMM_WORLD, NAME, &view);
> PetscViewerSetFormat(view, PETSC_VIEWER_ASCII_SYMMODU);
> PetscViewerASCIISynchronizedAllow(view, PETSC_TRUE);
> for(int step=0; step<STEP; step++)
> {
>     //calculate M at current step
>     DMDAVecGetArray(da, M, &aM);
>     DMDAGetCorners(da, &xs, 0, 0, &xm, 0, 0);
>     for(int node=xs; node<xs+xm; node++)
>     {
>        PetscViewerASCIISynchronizedPrintf(view, "%3.12f %3.12f %3.12f\n",
> aM[node].x, aM[node].y, aM[node].z);
>        PetscViewerFlush(view);
>     }
>     DMDAVecRestoreArray(da, M, &aM);
> }
> =================================================================
>
> but this turns out to be very slow. I am trying to write it in a binary
> file, but I cannot find the corresponding functionality (such as
> PETSC_VIEWER_ASCII_SYMMODU and PetscViewerASCIISynchronizedPrintf in
> binary form).  Thanks.
>

There is PetscViewerBindaryWrite(), but what do you really want to do? What
you suggest
doing will be very slow. Why not just use PETSc binary 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/20140522/c19d5b43/attachment.html>


More information about the petsc-users mailing list