[petsc-users] Printing parallel matrix
Evan Um
evanum at gmail.com
Wed Jan 23 02:24:36 CST 2019
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);
PetscViewerPopFormat(viewer);
PetscViewerDestroy(&viewer);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190123/f94b4405/attachment.html>
More information about the petsc-users
mailing list