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

robert robert.bodner at unil.ch
Wed Dec 14 08:44:39 CST 2011


On 12/14/2011 03:32 PM, Barry Smith wrote:
> On Dec 14, 2011, at 8:00 AM, robert wrote:
>
>> 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.
>>
>>
>>     2) How are you reading the vectors into Matlab? For example   [u,rhs] = PetscBinaryRead('filename') will read in two vectors.  If you want to call PetscBinaryRead() repeatedly to read more information than ...

Hi,

thank you for your fast reply. It's as easy as that and I spent hours 
... :-)
>>


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



More information about the petsc-users mailing list