From db66997e973eb8715cc7b88e36311201c14b2c63 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 3 Jun 2017 15:42:35 -0400 Subject: [PATCH] Remove support for versions of PETSc before 3.3.0. --- cmake/configure/configure_3_petsc.cmake | 11 +- doc/external-libs/petsc.html | 6 +- .../incompatibilities/20170603DavidWells | 3 + include/deal.II/lac/petsc_compatibility.h | 40 ++---- include/deal.II/lac/petsc_matrix_base.h | 3 - include/deal.II/lac/slepc_solver.h | 4 - include/deal.II/lac/vector.templates.h | 7 - source/lac/petsc_matrix_base.cc | 16 --- source/lac/petsc_parallel_sparse_matrix.cc | 121 ------------------ source/lac/petsc_parallel_vector.cc | 12 -- source/lac/petsc_precondition.cc | 12 -- source/lac/petsc_solver.cc | 17 --- source/lac/petsc_vector_base.cc | 8 -- source/lac/slepc_solver.cc | 25 +--- source/lac/slepc_spectral_transformation.cc | 4 - 15 files changed, 24 insertions(+), 265 deletions(-) create mode 100644 doc/news/changes/incompatibilities/20170603DavidWells diff --git a/cmake/configure/configure_3_petsc.cmake b/cmake/configure/configure_3_petsc.cmake index 48517c7d74..dab2dd405d 100644 --- a/cmake/configure/configure_3_petsc.cmake +++ b/cmake/configure/configure_3_petsc.cmake @@ -30,15 +30,16 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var) SET(${var} TRUE) # - # We support petsc from version 3.x.x onwards + # We support petsc from version 3.3.x onwards # - IF(PETSC_VERSION_MAJOR LESS 3) + IF(PETSC_VERSION_MAJOR LESS 3 OR + ((PETSC_VERSION_MAJOR EQUAL 3) AND (PETSC_VERSION_MINOR LESS 3))) MESSAGE(STATUS "Could not find a sufficient modern PETSc installation: " - "Version >=3.0.0 required!" + "Version >=3.3.0 required!" ) SET(PETSC_ADDITIONAL_ERROR_STRING "Could not find a sufficient modern PETSc installation: " - "Version >=3.0.0 required!\n" + "Version >=3.3.0 required!\n" ) SET(${var} FALSE) ENDIF() @@ -117,7 +118,7 @@ MACRO(FEATURE_PETSC_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the petsc library!\n" ${PETSC_ADDITIONAL_ERROR_STRING} - "\nPlease ensure that the petsc library version 3.0.0 or newer is " + "\nPlease ensure that the petsc library version 3.3.0 or newer is " "installed on your computer and is configured with the same mpi options " "as deal.II\n" "If the library is not at a default location, either provide some hints\n" diff --git a/doc/external-libs/petsc.html b/doc/external-libs/petsc.html index 04ec2bf6d7..2b767f5900 100644 --- a/doc/external-libs/petsc.html +++ b/doc/external-libs/petsc.html @@ -37,8 +37,10 @@

Note: The most recent version of PETSc that has been reported to be compatible with - deal.II is version 3.6.0. If you use a later - version than this and encounter problems, let us know. + deal.II is version 3.7.6. If you use a later + version than this and encounter problems, let us + know. deal.II does not support versions of PETSc prior + to 3.3.0.

diff --git a/doc/news/changes/incompatibilities/20170603DavidWells b/doc/news/changes/incompatibilities/20170603DavidWells new file mode 100644 index 0000000000..a0f62d0280 --- /dev/null +++ b/doc/news/changes/incompatibilities/20170603DavidWells @@ -0,0 +1,3 @@ +Changed: Versions of PETSc prior to 3.3.0 are no longer supported. +
+(David Wells, 2017/06/03) diff --git a/include/deal.II/lac/petsc_compatibility.h b/include/deal.II/lac/petsc_compatibility.h index abcbbdf657..17a2da3b43 100644 --- a/include/deal.II/lac/petsc_compatibility.h +++ b/include/deal.II/lac/petsc_compatibility.h @@ -36,11 +36,14 @@ DEAL_II_NAMESPACE_OPEN namespace PETScWrappers { -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - typedef PetscTruth PetscBooleanType; -#else - typedef PetscBool PetscBooleanType; -#endif + /** + * a compatibility typedef for older versions of PETSc. + * + * @deprecated The name of this type changed in PETSc 3.2: deal.II does not + * support versions of PETSc older than this so this typedef will be removed + * in a future release. + */ + typedef PetscBool PetscBooleanType DEAL_II_DEPRECATED; /** * Set an option in the global PETSc database. This function just wraps @@ -73,11 +76,7 @@ namespace PETScWrappers inline PetscErrorCode destroy_matrix (Mat &matrix) { // PETSc will check whether or not matrix is nullptr. -#if DEAL_II_PETSC_VERSION_LT(3, 2, 0) - return MatDestroy (matrix); -#else return MatDestroy (&matrix); -#endif } @@ -95,11 +94,7 @@ namespace PETScWrappers inline PetscErrorCode destroy_krylov_solver (KSP &krylov_solver) { // PETSc will check whether or not matrix is nullptr. -#if DEAL_II_PETSC_VERSION_LT(3, 2, 0) - return KSPDestroy (krylov_solver); -#else return KSPDestroy (&krylov_solver); -#endif } @@ -113,14 +108,9 @@ namespace PETScWrappers */ inline void set_matrix_option (Mat &matrix, const MatOption option_name, - const PetscBooleanType option_value = PETSC_FALSE) + const PetscBool option_value = PETSC_FALSE) { -#if DEAL_II_PETSC_VERSION_LT(3,0,0) - const PetscErrorCode ierr = MatSetOption (matrix, option_name); -#else const PetscErrorCode ierr = MatSetOption (matrix, option_name, option_value); -#endif - AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -132,19 +122,11 @@ namespace PETScWrappers */ inline void close_matrix (Mat &matrix) { -#if DEAL_II_PETSC_VERSION_LT(3, 0, 0) -# ifdef DEBUG - set_matrix_option (matrix, MAT_NEW_NONZERO_LOCATION_ERR); -# else - set_matrix_option (matrix, MAT_NO_NEW_NONZERO_LOCATIONS); -# endif -#else # ifdef DEBUG set_matrix_option (matrix, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE); # else set_matrix_option (matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE); # endif -#endif } @@ -156,11 +138,7 @@ namespace PETScWrappers */ inline void set_keep_zero_rows (Mat &matrix) { -#if DEAL_II_PETSC_VERSION_LT(3, 1, 0) - set_matrix_option (matrix, MAT_KEEP_ZEROED_ROWS, PETSC_TRUE); -#else set_matrix_option (matrix, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE); -#endif } } diff --git a/include/deal.II/lac/petsc_matrix_base.h b/include/deal.II/lac/petsc_matrix_base.h index 81c55596b2..cd3dd12c4e 100644 --- a/include/deal.II/lac/petsc_matrix_base.h +++ b/include/deal.II/lac/petsc_matrix_base.h @@ -678,14 +678,11 @@ namespace PETScWrappers PetscScalar matrix_scalar_product (const VectorBase &u, const VectorBase &v) const; - -#if DEAL_II_PETSC_VERSION_GTE(3,1,0) /** * Return the trace of the matrix, i.e. the sum of all diagonal entries in * the matrix. */ PetscScalar trace () const; -#endif /** * Multiply the entire matrix by a fixed factor. diff --git a/include/deal.II/lac/slepc_solver.h b/include/deal.II/lac/slepc_solver.h index e62ca174ba..a49054f29d 100644 --- a/include/deal.II/lac/slepc_solver.h +++ b/include/deal.II/lac/slepc_solver.h @@ -803,11 +803,7 @@ namespace SLEPcWrappers // One could still build a vector that is rich in the directions of all guesses, // by taking a linear combination of them. (TODO: make function virtual?) -#if DEAL_II_PETSC_VERSION_LT(3,1,0) - const PetscErrorCode ierr = EPSSetInitialVector (eps, &vecs[0]); -#else const PetscErrorCode ierr = EPSSetInitialSpace (eps, vecs.size(), &vecs[0]); -#endif AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } diff --git a/include/deal.II/lac/vector.templates.h b/include/deal.II/lac/vector.templates.h index a67a8b133e..cf4f399007 100644 --- a/include/deal.II/lac/vector.templates.h +++ b/include/deal.II/lac/vector.templates.h @@ -131,17 +131,10 @@ namespace internal ierr = VecRestoreArray (sequential_vector, &start_ptr); AssertThrow (ierr == 0, ExcPETScError(ierr)); -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - ierr = VecScatterDestroy(scatter_context); - AssertNothrow (ierr == 0, ExcPETScError(ierr)); - ierr = VecDestroy (sequential_vector); - AssertNothrow (ierr == 0, ExcPETScError(ierr)); -#else ierr = VecScatterDestroy(&scatter_context); AssertNothrow (ierr == 0, ExcPETScError(ierr)); ierr = VecDestroy (&sequential_vector); AssertNothrow (ierr == 0, ExcPETScError(ierr)); -#endif } } diff --git a/source/lac/petsc_matrix_base.cc b/source/lac/petsc_matrix_base.cc index 41dc140cd1..e74f076ec7 100644 --- a/source/lac/petsc_matrix_base.cc +++ b/source/lac/petsc_matrix_base.cc @@ -149,27 +149,13 @@ namespace PETScWrappers // since this is a collective operation IS index_set; -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - ISCreateGeneral (get_mpi_communicator(), rows.size(), - &petsc_rows[0], &index_set); -#else ISCreateGeneral (get_mpi_communicator(), rows.size(), &petsc_rows[0], PETSC_COPY_VALUES, &index_set); -#endif -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - const PetscErrorCode ierr = MatZeroRowsIS(matrix, index_set, new_diag_value); -#else const PetscErrorCode ierr = MatZeroRowsIS(matrix, index_set, new_diag_value, nullptr, nullptr); -#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); - -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - ISDestroy (index_set); -#else ISDestroy (&index_set); -#endif } @@ -400,7 +386,6 @@ namespace PETScWrappers } -#if DEAL_II_PETSC_VERSION_GTE(3,1,0) PetscScalar MatrixBase::trace () const { @@ -411,7 +396,6 @@ namespace PETScWrappers return result; } -#endif diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc index 48865c33cc..d922448588 100644 --- a/source/lac/petsc_parallel_sparse_matrix.cc +++ b/source/lac/petsc_parallel_sparse_matrix.cc @@ -237,15 +237,6 @@ namespace PETScWrappers // use the call sequence indicating only // a maximal number of elements per row // for all rows globally -#if DEAL_II_PETSC_VERSION_LT(3,3,0) - const PetscErrorCode ierr = MatCreateMPIAIJ - (communicator, - local_rows, local_columns, - m, n, - n_nonzero_per_row, 0, - n_offdiag_nonzero_per_row, 0, - &matrix); -#else const PetscErrorCode ierr = MatCreateAIJ (communicator, local_rows, local_columns, @@ -254,7 +245,6 @@ namespace PETScWrappers n_offdiag_nonzero_per_row, nullptr, &matrix); set_matrix_option (matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); -#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); // set symmetric flag, if so requested @@ -304,15 +294,6 @@ namespace PETScWrappers offdiag_row_lengths.end()); //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 -#if DEAL_II_PETSC_VERSION_LT(3,3,0) - const PetscErrorCode ierr = MatCreateMPIAIJ - (communicator, - local_rows, local_columns, - m, n, - 0, &int_row_lengths[0], - 0, offdiag_row_lengths.size() ? &int_offdiag_row_lengths[0] : 0, - &matrix); -#else const PetscErrorCode ierr = MatCreateAIJ (communicator, local_rows, local_columns, @@ -324,7 +305,6 @@ namespace PETScWrappers //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). set_matrix_option (matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); -#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); // set symmetric flag, if so requested @@ -505,52 +485,6 @@ namespace PETScWrappers const size_type local_row_end = local_row_start + local_rows_per_process[this_process]; -#if DEAL_II_PETSC_VERSION_LT(2,3,3) - //old version to create the matrix, we - //can skip calculating the row length - //at least starting from 2.3.3 (tested, - //see below) - - const size_type - local_col_end = local_col_start + local_columns_per_process[this_process]; - - // then count the elements in- and - // out-of-window for the rows we own - std::vector - - row_lengths_in_window (local_row_end - local_row_start), - row_lengths_out_of_window (local_row_end - local_row_start); - for (size_type row = local_row_start; row= local_col_start) && - (column < local_col_end)) - ++row_lengths_in_window[row-local_row_start]; - else - ++row_lengths_out_of_window[row-local_row_start]; - } - - - // create the matrix. completely - // confusingly, PETSc wants us to pass - // arrays for the local number of - // elements that starts with zero for - // the first _local_ row, i.e. it - // doesn't index into an array for - // _all_ rows. - const PetscErrorCode ierr = MatCreateMPIAIJ(communicator, - local_rows_per_process[this_process], - local_columns_per_process[this_process], - sparsity_pattern.n_rows(), - sparsity_pattern.n_cols(), - 0, &row_lengths_in_window[0], - 0, &row_lengths_out_of_window[0], - &matrix); - AssertThrow (ierr == 0, ExcPETScError(ierr)); - -#else //PETSC_VERSION>=2.3.3 // create the matrix. We // do not set row length but set the // correct SparsityPattern later. @@ -566,8 +500,6 @@ namespace PETScWrappers ierr = MatSetType(matrix,MATMPIAIJ); AssertThrow (ierr == 0, ExcPETScError(ierr)); -#endif - // next preset the exact given matrix // entries with zeros, if the user @@ -631,49 +563,6 @@ namespace PETScWrappers nullptr); AssertThrow (ierr == 0, ExcPETScError(ierr)); -#if DEAL_II_PETSC_VERSION_LT(2,3,3) - // this is only needed for old - // PETSc versions: - - // for some reason, it does not - // seem to be possible to force - // actual allocation of actual - // entries by using the last - // arguments to the call above. if - // we don't initialize the entries - // like in the following loop, then - // the program is unbearably slow - // because elements are allocated - // and accessed in random order, - // which is not what PETSc likes - // - // note that we actually have to - // set the entries to something - // non-zero! do the allocation one - // row at a time - { - const std::vector - values (sparsity_pattern.max_entries_per_row(), - 1.); - - for (size_type i=local_row_start; ipc, MATSOLVERMUMPS); -#else - ierr = PCFactorSetMatSolverPackage (solver_data->pc, MAT_SOLVER_MUMPS); -#endif AssertThrow (ierr == 0, ExcPETScError (ierr)); /** diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index 2b63c29b19..99e0f0f1a1 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -163,11 +163,7 @@ namespace PETScWrappers { if (attained_ownership) { -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - const PetscErrorCode ierr = VecDestroy (vector); -#else const PetscErrorCode ierr = VecDestroy (&vector); -#endif AssertNothrow (ierr == 0, ExcPETScError(ierr)); (void) ierr; } @@ -180,11 +176,7 @@ namespace PETScWrappers { if (attained_ownership) { -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - const PetscErrorCode ierr = VecDestroy (vector); -#else const PetscErrorCode ierr = VecDestroy (&vector); -#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); } diff --git a/source/lac/slepc_solver.cc b/source/lac/slepc_solver.cc index 31d9ea86c2..2d72f29699 100644 --- a/source/lac/slepc_solver.cc +++ b/source/lac/slepc_solver.cc @@ -62,11 +62,8 @@ namespace SLEPcWrappers if (eps != nullptr) { // Destroy the solver object. -#if DEAL_II_PETSC_VERSION_LT(3,2,0) - const PetscErrorCode ierr = EPSDestroy (eps); -#else const PetscErrorCode ierr = EPSDestroy (&eps); -#endif + (void)ierr; AssertNothrow (ierr == 0, ExcSLEPcError(ierr)); } @@ -105,11 +102,8 @@ namespace SLEPcWrappers ExcMessage("Initial vector should be nonzero.")); Vec vec = this_initial_vector; -#if DEAL_II_PETSC_VERSION_LT(3,1,0) - const PetscErrorCode ierr = EPSSetInitialVector (eps, &vec); -#else const PetscErrorCode ierr = EPSSetInitialSpace (eps, 1, &vec); -#endif + AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } @@ -400,7 +394,6 @@ namespace SLEPcWrappers SolverBase (cn, mpi_communicator), additional_data (data) { -#if DEAL_II_PETSC_VERSION_GTE(3,1,0) PetscErrorCode ierr = EPSSetType (eps, const_cast(EPSGD)); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); @@ -409,12 +402,6 @@ namespace SLEPcWrappers ierr = EPSGDSetDoubleExpansion (eps, PETSC_TRUE); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } -#else - // PETSc/SLEPc version must be > 3.1.0. - Assert ((false), - ExcMessage ("Your SLEPc installation does not include a copy of the " - "Generalized Davidson solver. A SLEPc version > 3.1.0 is required.")); -#endif } /* ------------------ Jacobi Davidson -------------------- */ @@ -425,15 +412,8 @@ namespace SLEPcWrappers SolverBase (cn, mpi_communicator), additional_data (data) { -#if DEAL_II_PETSC_VERSION_GTE(3,1,0) const PetscErrorCode ierr = EPSSetType (eps, const_cast(EPSJD)); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); -#else - // PETSc/SLEPc version must be > 3.1.0. - Assert ((false), - ExcMessage ("Your SLEPc installation does not include a copy of the " - "Jacobi-Davidson solver. A SLEPc version > 3.1.0 is required.")); -#endif } /* ---------------------- LAPACK ------------------------- */ @@ -460,4 +440,3 @@ namespace SLEPcWrappers DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_SLEPC - diff --git a/source/lac/slepc_spectral_transformation.cc b/source/lac/slepc_spectral_transformation.cc index bc7c59a126..a5cdf950de 100644 --- a/source/lac/slepc_spectral_transformation.cc +++ b/source/lac/slepc_spectral_transformation.cc @@ -92,11 +92,7 @@ namespace SLEPcWrappers TransformationBase(mpi_communicator), additional_data (data) { -#if DEAL_II_PETSC_VERSION_LT(3,1,0) - PetscErrorCode ierr = STSetType (st, const_cast(STSINV)); -#else PetscErrorCode ierr = STSetType (st, const_cast(STSINVERT)); -#endif AssertThrow (ierr == 0, SolverBase::ExcSLEPcError(ierr)); ierr = STSetShift (st, additional_data.shift_parameter); -- 2.39.5