From 68aca83aae80857c0f68074af7c50dfd1015f851 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Mon, 9 Nov 2015 15:39:19 +0100 Subject: [PATCH] extra options to Lanczos and GD SLEPc solvers --- include/deal.II/lac/slepc_solver.h | 28 ++++++++++++++++++++++++---- source/lac/slepc_solver.cc | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/include/deal.II/lac/slepc_solver.h b/include/deal.II/lac/slepc_solver.h index 0e6770a79f..3228cdd8f4 100644 --- a/include/deal.II/lac/slepc_solver.h +++ b/include/deal.II/lac/slepc_solver.h @@ -526,7 +526,7 @@ namespace SLEPcWrappers * * @ingroup SLEPcWrappers * - * @author Toby D. Young 2009 + * @author Toby D. Young 2009; Denis Davydov 2015; */ class SolverLanczos : public SolverBase { @@ -536,7 +536,17 @@ namespace SLEPcWrappers * it be needed. */ struct AdditionalData - {}; + { + /** + * The type of reorthogonalization used during the Lanczos iteration. + */ + EPSLanczosReorthogType reorthog; + + /** + * Constructor. By default sets the type of reorthogonalization used during the Lanczos iteration to full. + */ + AdditionalData(const EPSLanczosReorthogType r = EPS_LANCZOS_REORTHOG_FULL); + }; /** * SLEPc solvers will want to have an MPI communicator context over which @@ -608,7 +618,7 @@ namespace SLEPcWrappers * * @ingroup SLEPcWrappers * - * @author Toby D. Young 2010 + * @author Toby D. Young 2010; Denis Davydov 2015 */ class SolverGeneralizedDavidson : public SolverBase { @@ -618,7 +628,17 @@ namespace SLEPcWrappers * it be needed. */ struct AdditionalData - {}; + { + /** + * Use double expansion in search subspace. + */ + bool double_expansion; + + /** + * Constructor. By default set double_expansion to false. + */ + AdditionalData(bool double_expansion = false); + }; /** * SLEPc solvers will want to have an MPI communicator context over which diff --git a/source/lac/slepc_solver.cc b/source/lac/slepc_solver.cc index c442b18055..a94af05590 100644 --- a/source/lac/slepc_solver.cc +++ b/source/lac/slepc_solver.cc @@ -420,6 +420,11 @@ namespace SLEPcWrappers } /* ---------------------- Lanczos ------------------------ */ + SolverLanczos::AdditionalData:: + AdditionalData(const EPSLanczosReorthogType r) + : reorthog(r) + {} + SolverLanczos::SolverLanczos (SolverControl &cn, const MPI_Comm &mpi_communicator, const AdditionalData &data) @@ -440,6 +445,9 @@ namespace SLEPcWrappers ierr = EPSSetTolerances (eps, this->solver_control.tolerance(), this->solver_control.max_steps()); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); + + ierr = EPSLanczosSetReorthog(eps,additional_data.reorthog); + AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } /* ----------------------- Power ------------------------- */ @@ -466,6 +474,11 @@ namespace SLEPcWrappers } /* ---------------- Generalized Davidson ----------------- */ + SolverGeneralizedDavidson::AdditionalData:: + AdditionalData(bool double_expansion) + : double_expansion(double_expansion) + {} + SolverGeneralizedDavidson::SolverGeneralizedDavidson (SolverControl &cn, const MPI_Comm &mpi_communicator, const AdditionalData &data) @@ -487,6 +500,12 @@ namespace SLEPcWrappers ierr = EPSSetTolerances (eps, this->solver_control.tolerance(), this->solver_control.max_steps()); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); + + if (additional_data.double_expansion) + { + ierr = EPSGDSetDoubleExpansion (eps, PETSC_TRUE); + AssertThrow (ierr == 0, ExcSLEPcError(ierr)); + } #else // Suppress compiler warnings about unused parameters. (void) eps; -- 2.39.5