[petsc-users] Files saved with PetscViewerBinaryOpen - Binary file format ?
Barry Smith
bsmith at petsc.dev
Tue Dec 29 13:15:44 CST 2020
https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecLoad.html <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecLoad.html> and https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatLoad.html <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatLoad.html> define the simple format.
There are loaders for Matlab and Python distributed with PETSc so for those two languages you do not need to write your own custom loaders.
Barry
> On Dec 29, 2020, at 12:32 PM, C B <cebau.mail at gmail.com> wrote:
>
> Hello PETSc community !
>
> I would like to read in another code a matrix / rhs / sol saved by PETSc.
> I am dealing with large matrices and for precision I would like to use the binary format.
>
> To save a matrix I am using the following lines (please let me know if I should make any changes), I am using an old version PETSc 2.1.5 for backward compatibility.
>
> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,PETSC_BINARY_CREATE,&petsc_view);CHKERRQ(ierr);
> ierr = VecView(solut,petsc_view);CHKERRQ(ierr);
> ierr = PetscViewerDestroy(petsc_view);CHKERRQ(ierr);
>
> And to save a vector:
>
> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename, PETSC_BINARY_CREATE, &petsc_view);CHKERRQ(ierr);
> ierr = VecView(solut, petsc_view);CHKERRQ(ierr);
> ierr = PetscViewerDestroy(petsc_view);CHKERRQ(ierr);
>
> The files are saved without any problems, and now I need to write the code to read the binary files.
> Please, would anyone point me to the format of these binary files and/or a code snippet to take as an example ?
>
> Thank you very much in advance !
> Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20201229/43b1d618/attachment.html>
More information about the petsc-users
mailing list