[petsc-users] save vector to bin-file at each time step

robert robert.bodner at unil.ch
Wed Dec 14 08:00:03 CST 2011


Hello,

I am quite new to petsc and therefore my question might be quite trivial.

I have a 1D finite difference code and want to store several vectors in 
a binary:

     ierr = PetscViewerCreate(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr);
     ierr = 
PetscViewerBinaryOpen(PETSC_COMM_WORLD,"out.bin",FILE_MODE_APPEND,&viewer); 
CHKERRQ(ierr);
     ierr = PetscObjectSetName((PetscObject)u,"u");CHKERRQ(ierr);
     ierr = PetscObjectSetName((PetscObject)rhs,"rhs");CHKERRQ(ierr);
     ierr = VecView(u,viewer); CHKERRQ(ierr);
     ierr = VecView(rhs,viewer);CHKERRQ(ierr);

However, when I read the file with matlab (PetscBinaryRead.m) I only get 
the first vector.

In further application I would like to use something similar but putting 
out the solution vector every timestep.

Could someone just provide me some sample code?

Thanks,
Robert


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111214/5a31167d/attachment.htm>


More information about the petsc-users mailing list