[petsc-users] Append vector to existing file

Yuyun Yang yyang85 at stanford.edu
Fri Mar 8 19:10:41 CST 2019


I see, thank you!
Yuyun

From: Matthew Knepley <knepley at gmail.com>
Sent: Friday, March 8, 2019 4:51 PM
To: Yuyun Yang <yyang85 at stanford.edu>
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] Append vector to existing file

On Fri, Mar 8, 2019 at 5:53 PM Yuyun Yang via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:
Hello team,

This is a very simple question, but I just want to be sure I understand how the viewer works. I have a file with some vectors already written into it. Now I’m calling PetscViewerASCIIOpen, setting the format and then the file mode into append:
  PetscViewer viewer;
  ierr = PetscViewerASCIIOpen(PETSC_COMM_WORLD, filename.c_str(), &viewer);

ASCIIOpen() is a simplified interface. For append, I think you need

  PetscViewerCreate()
  PetscViewerSetType()
  PetscViewerFileSetMode()
  PetscViewerFileSetName()
  PetscViewerPushFormat()

    Matt

  ierr = PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); CHKERRQ(ierr);
ierr = PetscViewerFileSetMode(viewer, FILE_MODE_APPEND); CHKERRQ(ierr);

After which I call VecView to append some new vectors to the existing file. But this operation is clearing out my existing file and writing it with new information. Does the append mode happen to not work with this type of viewer, or am I missing something here?

Thanks a lot,
Yuyun


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

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190309/86e6f90a/attachment.html>


More information about the petsc-users mailing list