From: Denis Davydov Date: Mon, 9 Nov 2015 14:39:19 +0000 (+0100) Subject: extra options to Lanczos and GD SLEPc solvers X-Git-Tag: v8.4.0-rc2~233^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68aca83aae80857c0f68074af7c50dfd1015f851;p=dealii.git extra options to Lanczos and GD SLEPc solvers --- 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;