From 61f1fa4473f3198f4cf86459cb9037a290cafbf0 Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 19 May 2004 14:33:31 +0000 Subject: [PATCH] Attempt a different fix for the problem where local_rows is larger than the total number of columns. git-svn-id: https://svn.dealii.org/trunk@9269 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/petsc_parallel_sparse_matrix.h | 21 ++++++++++++------- .../source/petsc_parallel_sparse_matrix.cc | 12 +++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h index 33c938db9b..40b1b50f40 100644 --- a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h @@ -171,8 +171,22 @@ namespace PETScWrappers const std::vector &row_lengths, const bool is_symmetric = false); + /** + * Exception + */ + DeclException2 (ExcLocalRowsTooLarge, + int, int, + << "The number of local rows " << arg1 + << " must be larger than the total number of rows " << arg2); + private: + /** + * Copy of the communicator object to + * be used for this parallel vector. + */ + MPI_Comm communicator; + /** * Do the actual work for the * respective reinit() function and the @@ -194,13 +208,6 @@ namespace PETScWrappers const unsigned int local_rows, const std::vector &row_lengths, const bool is_symmetric = false); - - private: - /** - * Copy of the communicator object to - * be used for this parallel vector. - */ - MPI_Comm communicator; }; } diff --git a/deal.II/lac/source/petsc_parallel_sparse_matrix.cc b/deal.II/lac/source/petsc_parallel_sparse_matrix.cc index e71ba0ae96..c596fbe0a6 100644 --- a/deal.II/lac/source/petsc_parallel_sparse_matrix.cc +++ b/deal.II/lac/source/petsc_parallel_sparse_matrix.cc @@ -121,6 +121,8 @@ namespace PETScWrappers const unsigned int n_nonzero_per_row, const bool is_symmetric) { + Assert (local_rows < m, ExcLocalRowsTooLarge (local_rows, m)); + // use the call sequence indicating only // a maximal number of elements per row // for all rows globally @@ -132,7 +134,9 @@ namespace PETScWrappers // local_rows as they do for local_size // on parallel vectors const int ierr - = MatCreateMPIAIJ(communicator, local_rows, local_rows, m, n, + = MatCreateMPIAIJ(communicator, + local_rows, std::min(local_rows, n), + m, n, n_nonzero_per_row, 0, 0, 0, &matrix); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -155,6 +159,8 @@ namespace PETScWrappers const std::vector &row_lengths, const bool is_symmetric) { + Assert (local_rows < m, ExcLocalRowsTooLarge (local_rows, m)); + Assert (row_lengths.size() == m, ExcDimensionMismatch (row_lengths.size(), m)); @@ -176,7 +182,9 @@ namespace PETScWrappers // local_rows as they do for local_size // on parallel vectors const int ierr - = MatCreateMPIAIJ(communicator, local_rows, local_rows, m, n, + = MatCreateMPIAIJ(communicator, + local_rows, local_rows, + m, std::min(local_rows, n), 0, &int_row_lengths[0], 0, 0, &matrix); AssertThrow (ierr == 0, ExcPETScError(ierr)); -- 2.39.5