[petsc-dev] getting data out of a PetscFE simulation

Jed Brown jed at jedbrown.org
Tue Jan 28 21:41:55 CST 2014


Matthew Knepley <knepley at gmail.com> writes:
> In ex62:
>
>   if (user.runType == RUN_FULL) {
>     PetscViewer viewer;
>     Vec         uLocal;
>     const char *name;
>
>     ierr = PetscViewerCreate(PETSC_COMM_WORLD, &viewer);CHKERRQ(ierr);
>     ierr = PetscViewerSetType(viewer, PETSCVIEWERVTK);CHKERRQ(ierr);
>     ierr = PetscViewerSetFormat(viewer,
> PETSC_VIEWER_ASCII_VTK);CHKERRQ(ierr);
>     ierr = PetscViewerFileSetName(viewer, "ex62_sol.vtk");CHKERRQ(ierr);

Please don't do this.  Just set the type to PETSCVIEWERVTK, set the file
name to some *.vtu; the VTK viewer will infer output format from
extension and write the VTU XML format with binary-appended data in a
fairly fast and memory-scalable way.  Then

  VecView(u,viewer);


>     ierr = DMGetLocalVector(dm, &uLocal);CHKERRQ(ierr);
>     ierr = PetscObjectGetName((PetscObject) u, &name);CHKERRQ(ierr);
>     ierr = PetscObjectSetName((PetscObject) uLocal, name);CHKERRQ(ierr);
>     ierr = DMGlobalToLocalBegin(dm, u, INSERT_VALUES, uLocal);CHKERRQ(ierr);
>     ierr = DMGlobalToLocalEnd(dm, u, INSERT_VALUES, uLocal);CHKERRQ(ierr);
>     ierr = VecView(uLocal, viewer);CHKERRQ(ierr);
>     ierr = DMRestoreLocalVector(dm, &uLocal);CHKERRQ(ierr);

None of the above, then close the file:

>     ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
>   }

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20140128/c84b65cf/attachment.sig>


More information about the petsc-dev mailing list