[petsc-users] error on MatZeroRowsColumns

Matthew Knepley knepley at gmail.com
Wed Jan 13 04:17:36 CST 2016


On Wed, Jan 13, 2016 at 3:34 AM, Hoang Giang Bui <hgbk2008 at gmail.com> wrote:

> Dear PETSc developers
>
> I got an error with MatZeroRowsColumns, which said there was one missing
> diagonal entries
>
> This is the full log message that I got:
>
> Mat Object: 2 MPI processes
>   type: mpiaij
>   rows=41064, cols=41064, bs=4
>   total: nonzeros=5.66069e+06, allocated nonzeros=1.28112e+07
>   total number of mallocs used during MatSetValues calls =0
>     using I-node (on process 0) routines: found 5647 nodes, limit used is 5
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Object is in wrong state
> [0]PETSC ERROR: Matrix is missing diagonal entry in row 7
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
> for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.6.3, Dec, 03, 2015
> [0]PETSC ERROR: python on a arch-linux2-cxx-opt named bermuda by hbui2 Wed
> Jan 13 10:27:42 2016
> [0]PETSC ERROR: Configure options --with-shared-libraries
> --with-debugging=0 --with-pic --with-clanguage=cxx
> --download-fblas-lapack=yes --download-ptscotch=yes --download-metis=yes
> --download-parmetis=yes --download-scalapack=yes --download-mumps=yes
> --download-hypre=yes --download-ml=yes --download-klu=yes
> --download-pastix=yes --with-mpi-dir=/opt/openmpi-1.10.1_thread-multiple
> --prefix=/home/hbui/opt/petsc-3.6.3
> [0]PETSC ERROR: #1 MatZeroRowsColumns_SeqAIJ() line 1901 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/impls/aij/seq/aij.c
> [0]PETSC ERROR: #2 MatZeroRowsColumns() line 5476 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/interface/matrix.c
> [0]PETSC ERROR: #3 MatZeroRowsColumns_MPIAIJ() line 908 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/impls/aij/mpi/mpiaij.c
> [0]PETSC ERROR: #4 MatZeroRowsColumns() line 5476 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/interface/matrix.c
> [1]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [1]PETSC ERROR: Object is in wrong state
> [1]PETSC ERROR: Matrix is missing diagonal entry in row 7
> [1]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
> for trouble shooting.
> [1]PETSC ERROR: Petsc Release Version 3.6.3, Dec, 03, 2015
> [1]PETSC ERROR: python on a arch-linux2-cxx-opt named bermuda by hbui2 Wed
> Jan 13 10:27:42 2016
> [1]PETSC ERROR: Configure options --with-shared-libraries
> --with-debugging=0 --with-pic --with-clanguage=cxx
> --download-fblas-lapack=yes --download-ptscotch=yes --download-metis=yes
> --download-parmetis=yes --download-scalapack=yes --download-mumps=yes
> --download-hypre=yes --download-ml=yes --download-klu=yes
> --download-pastix=yes --with-mpi-dir=/opt/openmpi-1.10.1_thread-multiple
> --prefix=/home/hbui/opt/petsc-3.6.3
> [1]PETSC ERROR: #1 MatZeroRowsColumns_SeqAIJ() line 1901 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/impls/aij/seq/aij.c
> [1]PETSC ERROR: #2 MatZeroRowsColumns() line 5476 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/interface/matrix.c
> [1]PETSC ERROR: #3 MatZeroRowsColumns_MPIAIJ() line 908 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/impls/aij/mpi/mpiaij.c
> [1]PETSC ERROR: #4 MatZeroRowsColumns() line 5476 in
> /media/NEW_HOME/sw2/petsc-3.6.3/src/mat/interface/matrix.c
>
>
> The problem is, before calling MatZeroRowsColumns, I searched for zero
> rows and set the respective diagonal:
>
>         PetscInt Istart, Iend;
>         MatGetOwnershipRange(rA.Get(), &Istart, &Iend);
>
>         // loop through each row in the current partition
>         for(PetscInt row = Istart; row < Iend; ++row)
>         {
>             int ncols;
>             const PetscInt* cols;
>             const PetscScalar* vals;
>             MatGetRow(rA.Get(), row, &ncols, &cols, &vals);
>
>             PetscScalar row_norm = 0.0;
>             for(int i = 0; i < ncols; ++i)
>             {
>                 PetscScalar val = vals[i];
>                 row_norm += pow(val, 2);
>             }
>             row_norm = sqrt(row_norm);
>
>             if(row_norm == 0.0)
>             {
>                 for(int i = 0; i < ncols; ++i)
>                 {
>                     PetscInt col = cols[i];
>                     if(col == row)
>                     {
>                         MatSetValue(rA.Get(), row, col, 1.0,
> INSERT_VALUES);
>                     }
>                 }
>             }
>
>             MatRestoreRow(rA.Get(), row, &ncols, &cols, &vals);
>         }
>
>         // cached the modification
>         MatAssemblyBegin(rA.Get(), MAT_FINAL_ASSEMBLY);
>         MatAssemblyEnd(rA.Get(), MAT_FINAL_ASSEMBLY);
>
> This should set all the missing diagonal for missing rows. But I could not
> figure out why the error message above happen. Any ideas?
>

My guess would be that you have a row missing the diagonal, but with other
entries.

  Matt


> Regards
> Giang
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160113/e4b6b114/attachment.html>


More information about the petsc-users mailing list