From: young Date: Sat, 17 Mar 2012 16:01:07 +0000 (+0000) Subject: Stop petsc-dev from complaining about unknown nonzero off-diagonal entries. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f5c6c46424f83bd7b25666ef3e2eb15562ab9e2;p=dealii-svn.git Stop petsc-dev from complaining about unknown nonzero off-diagonal entries. git-svn-id: https://svn.dealii.org/trunk@25295 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc index 8c5838729c..2137903d74 100644 --- a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc +++ b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc @@ -193,12 +193,26 @@ namespace PETScWrappers // use the call sequence indicating only // a maximal number of elements per row // for all rows globally - const int ierr - = MatCreateMPIAIJ(communicator, - local_rows, local_columns, - m, n, - n_nonzero_per_row, 0, 0, 0, - &matrix); + int ierr; + +#ifdef DEAL_II_USE_PETSC_DEV + ierr + = MatCreateAIJ (communicator, + local_rows, local_columns, + m, n, + n_nonzero_per_row, 0, 0, 0, + &matrix); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + ierr = MatSetOption (matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); +#else + ierr + = MatCreateMPIAIJ (communicator, + local_rows, local_columns, + m, n, + n_nonzero_per_row, 0, 0, 0, + &matrix); +#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); // set symmetric flag, if so requested @@ -259,12 +273,28 @@ namespace PETScWrappers //TODO: There must be a significantly better way to provide information about the off-diagonal blocks of the matrix. this way, petsc keeps allocating tiny chunks of memory, and gets completely hung up over this - const int ierr - = MatCreateMPIAIJ(communicator, - local_rows, local_columns, - m, n, - 0, &int_row_lengths[0], 0, 0, - &matrix); + int ierr; + +#ifdef DEAL_II_USE_PETSC_DEV + ierr + = MatCreateAIJ (communicator, + local_rows, local_columns, + m, n, + 0, &int_row_lengths[0], 0, 0, + &matrix); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + +//TODO: Sometimes the actual number of nonzero entries allocated is greater than the number of nonzero entries, which petsc will complain about unless explicitly disabled with MatSetOption. There is probably a way to prevent a different number nonzero elements being allocated in the first place. (See also previous TODO). + + ierr = MatSetOption (matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); +#else + ierr + = MatCreateMPIAIJ (communicator, + local_rows, local_columns, + m, n, + 0, &int_row_lengths[0], 0, 0, + &matrix); +#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); // set symmetric flag, if so requested