[petsc-users] Printing parallel matrix

Evan Um evanum at gmail.com
Fri Jan 25 11:31:13 CST 2019


Hi Barry,

Yes, it was very large sparse matrix (million rows). I had no problem when
the binary format was used. I think that I need to change my preference.
Thank you very much for your comments and help!

Best regards,
Evan


On Thu, Jan 24, 2019 at 7:58 PM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:

>
>   Is it a very large matrix? The ASCII output is intended for only
> smallish matrices and may take a lot of time for very large matrices. For
> large matrices we recommend the binary format which is much faster for
> large matrices and can handle tens of millions of rows. You can read it
> into Python or Matlab with utilities we provide.
>
>     Barry
>
>
> > On Jan 23, 2019, at 9:40 AM, Jed Brown via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
> >
> > Evan Um via petsc-users <petsc-users at mcs.anl.gov> writes:
> >
> >> Dear PETSC users,
> >>
> >> I try to verify a matrix by printing a PETSC matrix and comparing its
> >> elements with reference values. Below is my test code.
> >>
> >> It works well when a single process is used. The output file is created
> >> quickly. In contrast, when multiple processes (>2) are used, printing
> >> matrix is stuck (the parallel matrix is assembled very quickly owing to
> >> memory preallocation). The output file just prints two lines below. No
> >> element is printed.
> >>
> >> Mat Object: 2 MPI processes
> >>  type: mpiaij
> >>
> >> I assume that printing matrix is also designed for a parallel matrix.
> Does
> >> this suggest that my parallel matrix includes any errors? Otherwise,
> does
> >> this work only for a serial matrix?
> >>
> >> Thanks for reading this question.
> >>
> >> Regards,
> >> Evan
> >>
> >> MatCreateAIJ(PETSC_COMM_WORLD, m, n, M, N, 0, d_nnz_A, 0, o_nnz_A,
> &Mat_A);
> >> MatSetFromOptions(Mat_A);
> >>
> >> for (int i=rstart_A[rank]; i<rend_A[rank]; i++) {
> >> mat_value=val_A[i]+PETSC_i*0.0;
> >> MatSetValue(Mat_A, i_A[i],j_A[i],mat_value,ADD_VALUES);
> >> }
> >>
> >> MatAssemblyBegin(Mat_A, MAT_FINAL_ASSEMBLY);
> >> MatAssemblyEnd(Mat_A, MAT_FINAL_ASSEMBLY);
> >>
> >> PetscViewer viewer;
> >> PetscViewerASCIIOpen(PETSC_COMM_WORLD,"Mat_A",&viewer);
> >> MatView(Mat_A,viewer);
> >> PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
> >
> > Did you intend to use the MATLAB format?  If so, MatView needs to be
> > called while the format is pushed, so swap the two lines above.
> >
> >> PetscViewerPopFormat(viewer);
> >> PetscViewerDestroy(&viewer);
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190125/b3494621/attachment-0001.html>


More information about the petsc-users mailing list