[petsc-users] Question about MatView

Matthew Knepley knepley at gmail.com
Fri Mar 17 05:34:46 CDT 2023

On Fri, Mar 17, 2023 at 5:51 AM user_gong Kim <ksi2443 at gmail.com> wrote:

> Hello,
> I have 2 questions about MatView.
> 1.    I would like to ask if the process below is possible.
> When running in parallel, is it possible to make the matrix of the mpiaij
> format into a txt file, output it, and read it again so that the entire
> process has the same matrix?
No. However, you can do this with a binary viewer. I suggest using

  MatViewFromOptions(mat, NULL, "-my_view");

and then the command line argument

  -my_view binary:mat.bin

and then you can read this in using

  MatCreate(PETSC_COMM_WORLD, &mat);
  PetscViewerBinaryOpen(PETSC_COMM_WORLD, "mat.bin", FILE_MODE_READ,
  MatLoad(mat, viewer);



> 2.    If possible, please let me know which function can be used to
> create a txt file and how to read the txt file.
> Thanks,
> Hyung Kim

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/20230317/d6913190/attachment.html>

More information about the petsc-users mailing list