From 6e2d08928667768443d4bb83d8cfd4ee778e5f26 Mon Sep 17 00:00:00 2001 From: young Date: Wed, 7 Mar 2012 12:28:20 +0000 Subject: [PATCH] Completely stop PETSc from complaining about new nonzero elements in MPI matices; instead, just allocate the memoty (read TODO). git-svn-id: https://svn.dealii.org/trunk@25217 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/petsc_parallel_sparse_matrix.cc | 59 +++++++++++-------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc index 9e83e7aa12..8681dc0438 100644 --- a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc +++ b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc @@ -193,20 +193,25 @@ namespace PETScWrappers // use the call sequence indicating only // a maximal number of elements per row // for all rows globally + int ierr; + #ifdef DEAL_II_PETSC_VERSION_DEV - const int ierr - = MatCreateAIJ(communicator, - local_rows, local_columns, - m, n, - n_nonzero_per_row, 0, 0, 0, - &matrix); + 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 - const int ierr - = MatCreateMPIAIJ(communicator, - local_rows, local_columns, - m, n, - n_nonzero_per_row, 0, 0, 0, - &matrix); + ierr + = MatCreateMPIAIJ (communicator, + local_rows, local_columns, + m, n, + n_nonzero_per_row, 0, 0, 0, + &matrix); #endif AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -268,20 +273,26 @@ 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 + int ierr; + #ifdef DEAL_II_PETSC_VERSION_DEV - const int ierr - = MatCreateAIJ(communicator, - local_rows, local_columns, - m, n, - 0, &int_row_lengths[0], 0, 0, - &matrix); + 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. 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 - const int ierr - = MatCreateMPIAIJ(communicator, - local_rows, local_columns, - m, n, - 0, &int_row_lengths[0], 0, 0, - &matrix); + ierr + = MatCreateMPIAIJ (communicator, + local_rows, local_columns, + m, n, + 0, &int_row_lengths[0], 0, 0, + &matrix); #endif AssertThrow (ierr == 0, ExcPETScError(ierr)); -- 2.39.5