]> https://gitweb.dealii.org/ - dealii.git/commitdiff
extra options to Lanczos and GD SLEPc solvers
authorDenis Davydov <davydden@gmail.com>
Mon, 9 Nov 2015 14:39:19 +0000 (15:39 +0100)
committerDenis Davydov <davydden@gmail.com>
Mon, 9 Nov 2015 16:38:18 +0000 (17:38 +0100)
include/deal.II/lac/slepc_solver.h
source/lac/slepc_solver.cc

index 0e6770a79f72c29c5034ff68cfce6993b78093fb..3228cdd8f4d299527e44a13ea960210f176f06d0 100644 (file)
@@ -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
index c442b180559db0911f1a96e0a0e304bc3e4983d1..a94af05590a07816807e990b753489c7a1c7bd18 100644 (file)
@@ -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;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.