From caa0337b655af61f4d15b5cffee471a4cfd07b9f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 4 Apr 2005 15:17:26 +0000 Subject: [PATCH] Use MatMPIAIJSetPreallocationCSR git-svn-id: https://svn.dealii.org/trunk@10342 0785d39b-7218-0410-832d-ea1e28bc413d --- .../source/petsc_parallel_sparse_matrix.cc | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/deal.II/lac/source/petsc_parallel_sparse_matrix.cc b/deal.II/lac/source/petsc_parallel_sparse_matrix.cc index f74c23b41f..d0822ad99a 100644 --- a/deal.II/lac/source/petsc_parallel_sparse_matrix.cc +++ b/deal.II/lac/source/petsc_parallel_sparse_matrix.cc @@ -255,7 +255,6 @@ namespace PETScWrappers const unsigned int this_process, const bool preset_nonzero_locations) { -//TODO[WB]: The next PETSc release should contain a function MatMPI[B]AIJSetPreallocationCSR that we will want to use here. it may also be worthwhile to look at the functions MatPreallocateXXX in include/petscmat.h Assert (local_rows_per_process.size() == local_columns_per_process.size(), ExcDimensionMismatch (local_rows_per_process.size(), local_columns_per_process.size())); @@ -314,7 +313,7 @@ namespace PETScWrappers 0, &row_lengths_out_of_window[0], &matrix); AssertThrow (ierr == 0, ExcPETScError(ierr)); - + // next preset the exact given matrix // entries with zeros, if the user // requested so. this doesn't avoid any @@ -330,6 +329,18 @@ namespace PETScWrappers // class. if (preset_nonzero_locations == true) { + // starting with petsc 2.2.1, there is + // a function + // MatMPIAIJSetPreallocationCSR that + // can be used to allocate the sparsity + // pattern of a matrix if it is already + // available. if we don't have this, we + // have to somehow clumsily work around + // the whole thing: +#if (PETSC_VERSION_MAJOR <= 2) && \ + ((PETSC_VERSION_MINOR < 2) || \ + ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0))) + std::vector row_entries; std::vector row_values; for (unsigned int i=0; i rowstart_in_window (local_row_end - + local_row_start + 1, + 0); + std::vector colnums_in_window; + { + unsigned int n_cols = 0; + for (unsigned int i=local_row_start; i