From 944759b5020f0e7a907d89a9586d395ea2bbc606 Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 27 Jul 2022 11:30:19 -0400 Subject: [PATCH] Remove some old PETSc workarounds. --- .../lac/slepc_spectral_transformation.h | 6 ++- source/lac/petsc_parallel_vector.cc | 12 ----- source/lac/petsc_solver.cc | 45 +------------------ source/lac/slepc_spectral_transformation.cc | 14 ++---- 4 files changed, 10 insertions(+), 67 deletions(-) diff --git a/include/deal.II/lac/slepc_spectral_transformation.h b/include/deal.II/lac/slepc_spectral_transformation.h index 8a98dd0e45..4031ff83c0 100644 --- a/include/deal.II/lac/slepc_spectral_transformation.h +++ b/include/deal.II/lac/slepc_spectral_transformation.h @@ -203,9 +203,13 @@ namespace SLEPcWrappers * Spectrum Folding. This transformation type has been removed in SLEPc * 3.5.0 and thus cannot be used in the newer versions. * + * @deprecated Since deal.II requires PETSc 3.7 or newer this class no longer + * does anything. + * * @ingroup SLEPcWrappers */ - class TransformationSpectrumFolding : public TransformationBase + class DEAL_II_DEPRECATED TransformationSpectrumFolding + : public TransformationBase { public: /** diff --git a/source/lac/petsc_parallel_vector.cc b/source/lac/petsc_parallel_vector.cc index 97496965b6..4e7e29a553 100644 --- a/source/lac/petsc_parallel_vector.cc +++ b/source/lac/petsc_parallel_vector.cc @@ -337,18 +337,6 @@ namespace PETScWrappers static_cast(ghost_indices.n_elements())); } # endif - - - // in PETSc versions up to 3.5, VecCreateGhost zeroed out the locally - // owned vector elements but forgot about the ghost elements. we need to - // do this ourselves - // - // see https://code.google.com/p/dealii/issues/detail?id=233 -# if DEAL_II_PETSC_VERSION_LT(3, 6, 0) - PETScWrappers::MPI::Vector zero; - zero.reinit(communicator, this->size(), locally_owned_size); - *this = zero; -# endif } diff --git a/source/lac/petsc_solver.cc b/source/lac/petsc_solver.cc index b1515e6c66..2bb04ffe55 100644 --- a/source/lac/petsc_solver.cc +++ b/source/lac/petsc_solver.cc @@ -94,16 +94,7 @@ namespace PETScWrappers // setting the preconditioner overwrites the used matrices. // hence, we need to set the matrices after the preconditioner. -# if DEAL_II_PETSC_VERSION_LT(3, 5, 0) - // the last argument is irrelevant here, - // since we use the solver only once anyway - ierr = KSPSetOperators(solver_data->ksp, - A, - preconditioner, - SAME_PRECONDITIONER); -# else ierr = KSPSetOperators(solver_data->ksp, A, preconditioner); -# endif AssertThrow(ierr == 0, ExcPETScError(ierr)); // then a convergence monitor @@ -398,37 +389,10 @@ namespace PETScWrappers PetscErrorCode ierr = KSPSetType(ksp, KSPGMRES); AssertThrow(ierr == 0, ExcPETScError(ierr)); - // set the restart parameter from the - // data. we would like to use the simple - // code that is commented out, but this - // leads to nasty warning and error - // messages due to some stupidity on - // PETSc's side: KSPGMRESSetRestart is - // implemented as a macro in which return - // statements are hidden. This may work - // if people strictly follow the PETSc - // coding style of always having - // functions return an integer error - // code, but the present function isn't - // like this. - /* - ierr = KSPGMRESSetRestart (ksp, additional_data.restart_parameter); - AssertThrow (ierr == 0, ExcPETScError(ierr)); - */ - // so rather expand their macros by hand, - // and do some equally nasty stuff that at - // least doesn't yield warnings... - int (*fun_ptr)(KSP, int); - ierr = PetscObjectQueryFunction(reinterpret_cast(ksp), - "KSPGMRESSetRestart_C", - reinterpret_cast(&fun_ptr)); + ierr = KSPGMRESSetRestart(ksp, additional_data.restart_parameter); AssertThrow(ierr == 0, ExcPETScError(ierr)); - ierr = (*fun_ptr)(ksp, additional_data.restart_parameter); - AssertThrow(ierr == 0, ExcPETScError(ierr)); - - // Set preconditioning side to - // right + // Set preconditioning side to right if (additional_data.right_preconditioning) { ierr = KSPSetPCSide(ksp, PC_RIGHT); @@ -711,12 +675,7 @@ namespace PETScWrappers * set the matrices involved. the last argument is irrelevant here, * since we use the solver only once anyway */ -# if DEAL_II_PETSC_VERSION_LT(3, 5, 0) - ierr = - KSPSetOperators(solver_data->ksp, A, A, DIFFERENT_NONZERO_PATTERN); -# else ierr = KSPSetOperators(solver_data->ksp, A, A); -# endif AssertThrow(ierr == 0, ExcPETScError(ierr)); /* diff --git a/source/lac/slepc_spectral_transformation.cc b/source/lac/slepc_spectral_transformation.cc index f1b856be34..dc68c3c8c7 100644 --- a/source/lac/slepc_spectral_transformation.cc +++ b/source/lac/slepc_spectral_transformation.cc @@ -111,20 +111,12 @@ namespace SLEPcWrappers : TransformationBase(mpi_communicator) , additional_data(data) { -# if DEAL_II_PETSC_VERSION_LT(3, 5, 0) - PetscErrorCode ierr = STSetType(st, const_cast(STFOLD)); - AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr)); - - ierr = STSetShift(st, additional_data.shift_parameter); - AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr)); -# else - // PETSc/SLEPc version must be < 3.5.0. - (void)st; - Assert((false), + // This feature is only in PETSc/SLEPc versions 3.4 or older, which we no + // longer support. + Assert(false, ExcMessage( "Folding transformation has been removed in SLEPc 3.5.0 and newer." " You cannot use this transformation anymore.")); -# endif } /* ------------------- TransformationCayley --------------------- */ -- 2.39.5