[petsc-users] Append vector to existing file

Matthew Knepley knepley at gmail.com
Fri Mar 8 18:50:59 CST 2019


On Fri, Mar 8, 2019 at 5:53 PM Yuyun Yang via petsc-users <
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/20190308/b19fa8da/attachment.html>


More information about the petsc-users mailing list