]> https://gitweb.dealii.org/ - dealii.git/commitdiff
set target with SLEPc shift-and-invert to comply with 3.8.0 5347/head
authorDenis Davydov <davydden@gmail.com>
Sat, 28 Oct 2017 09:42:50 +0000 (11:42 +0200)
committerDenis Davydov <davydden@gmail.com>
Sat, 28 Oct 2017 09:42:50 +0000 (11:42 +0200)
include/deal.II/base/config.h.in
include/deal.II/lac/slepc_spectral_transformation.h
source/lac/slepc_solver.cc
tests/slepc/step-36_parallel.cc

index 8a9ecc3e8e8358914378a3df19920bde210f7c0d..0c083b3974dc24c4404e0dc6e11d8ef367b3e99b 100644 (file)
     >=  \
     (major)*10000 + (minor)*100 + (subminor))
 
+/*
+ * SLEPC
+ * see slepcversion.h
+ */
+#define DEAL_II_SLEPC_VERSION_GTE(major,minor,subminor) \
+  ((SLEPC_VERSION_MAJOR * 10000 + \
+    SLEPC_VERSION_MINOR * 100 + \
+    SLEPC_VERSION_SUBMINOR) \
+    >=  \
+    (major)*10000 + (minor)*100 + (subminor))
+
 /*
  * Trilinos:
  */
index c421ef6e50e965cfb831ad78e05d0aeef40bd779..11760a4d46d85793e3ce9f85a169118a8186e0a6 100644 (file)
@@ -196,6 +196,12 @@ namespace SLEPcWrappers
      * Store a copy of the flags for this particular solver.
      */
     const AdditionalData additional_data;
+
+    /**
+     * Make the solver class a friend, since it may need to set target
+     * equal the provided shift value.
+     */
+    friend class SolverBase;
   };
 
   /**
index 2d72f296991dd819b8810c10f25b5d07fe431c29..18fbc7e708bd155ffbcbec2807d4e1798eb83b69 100644 (file)
@@ -91,8 +91,21 @@ namespace SLEPcWrappers
   {
     // set transformation type if any
     // STSetShift is called inside
-    const PetscErrorCode ierr = EPSSetST(eps,transformation.st);
+    PetscErrorCode ierr = EPSSetST(eps,transformation.st);
     AssertThrow (ierr == 0, SolverBase::ExcSLEPcError(ierr));
+
+#if DEAL_II_SLEPC_VERSION_GTE(3, 8, 0)
+    // see https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2017-October/033649.html
+    // From 3.8.0 SLEPc insists that when looking for smallest eigenvalues with shift-and-invert
+    // users should (a) set target (b) use EPS_TARGET_MAGNITUDE
+    // The former, however, needs to be applied to eps object and not spectral transformation.
+    if (SLEPcWrappers::TransformationShiftInvert *sinv = dynamic_cast<SLEPcWrappers::TransformationShiftInvert *>(&transformation))
+      {
+        ierr = EPSSetTarget (eps, sinv->additional_data.shift_parameter);
+        AssertThrow (ierr == 0, SolverBase::ExcSLEPcError(ierr));
+      }
+#endif
+
   }
 
   void
index 3a270d25b45164a2528ca0493b066d987d74f578..ec31dabbdfd86c30347845b07e7e3a00cddf0edf 100644 (file)
@@ -289,7 +289,7 @@ void test (std::string solver_name,
     // Set the initial vector. This is optional, if not done the initial vector is set to random values
     eigensolver->set_initial_space(eigenfunctions);
 
-    eigensolver->set_which_eigenpairs (EPS_SMALLEST_REAL);
+    eigensolver->set_which_eigenpairs (EPS_TARGET_MAGNITUDE);
     eigensolver->set_problem_type (EPS_GHEP);
 
     eigensolver->solve (stiffness_matrix,

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.