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

Matthew Knepley knepley at gmail.com
Tue Jan 28 19:27:17 CST 2014


On Tue, Jan 28, 2014 at 7:03 PM, Geoffrey Irving <irving at naml.us> wrote:

> On Tue, Jan 28, 2014 at 4:18 PM, Matthew Knepley <knepley at gmail.com>
> wrote:
> > On Tue, Jan 28, 2014 at 6:04 PM, Geoffrey Irving <irving at naml.us> wrote:
> >>
> >> What's the cleanest way to save data from a petsc finite element
> >> simulation including boundary conditions?  First, is it correct that
> >> the local sections contains dofs for boundary conditions, while the
> >> global section does not?  If so, is the following the right plan?
> >>
> >> 1. At start, save the DMPlex
> >> 2. At start, save the local section
> >> 3. Every frame, sync the global vector a local vector and write out in
> >> petsc binary format.
> >>
> >> Are there standard binary formats for DMPlex and sections?  All I see
> >> is the following sad commented out call to DMPlexView_Binary.
> >
> > We are having a big discussion about this on petsc-dev. I will write a
> longer
> > thing, but now the only thing that works all the way is VTK. You should
> just
> > be able to create the Viewer, do VecView for your fields, and then
> destroy
> > it.
>
> Thanks, and apologies for missing that thread.
>
> Is there a working example of that kind of viewer use?
> DMPlexVTKWriteAll_ASCII seems to traverse a linked list of vectors
> attached to the viewer and write them all out, which is a bit
> confusing.


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);

    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);

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



> > I create a global section with all the boundary values in it.
>
> Do you mean this is what I'll need to do, or is that taken care of
> automatically in the VTK path?  It seems like boundary condition
> handling can't be automatic, but DMPlexVTKWriteAll_ASCII reads a bunch
> of section information out of the DM so I'm sure how one would
> substitute a global section + boundaries.


You are right, this is not what I do anymore. I decided it was easier for
all the Viewers
to just take local vectors. I handle all the "globalization" automatically.
See the code snippet above.

  Thanks,

    Matt


> > I plan on having HDF5+Xdmf and Exodus.
>
> Thanks,
> Geoffrey
>



-- 
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-dev/attachments/20140128/2f826ca0/attachment.html>


More information about the petsc-dev mailing list