]> https://gitweb.dealii.org/ - dealii.git/commitdiff
various fixes and improvements to SLEPc unit tests
authorDenis Davydov <davydden@gmail.com>
Thu, 14 Jan 2016 19:18:59 +0000 (20:18 +0100)
committerDenis Davydov <davydden@gmail.com>
Fri, 15 Jan 2016 08:14:26 +0000 (09:14 +0100)
some fiddling with solver settings (preconditioner, tolerance, etc) to
produce the same output on OS-X and Linux.
/slepc/step-36_parallel still needs two different outputs, though.

fixed an uninitialised initial vector bug in slepc/step-36 unit test

tests/slepc/solve_01.cc
tests/slepc/solve_01.output
tests/slepc/solve_04.cc
tests/slepc/solve_04.output
tests/slepc/step-36_parallel.cc
tests/slepc/step-36_parallel.with_mpi=true.with_petsc=true.with_slepc=true.mpirun=3.output
tests/slepc/step-36_parallel.with_mpi=true.with_petsc=true.with_slepc=true.mpirun=3.output.2 [new file with mode: 0644]

index a41aca5a8ebbf5615e5248601ef6fe349dcfbe70..eaacd3949c6f01fbd50796a5652015ba4651ac57 100644 (file)
@@ -48,12 +48,11 @@ check_solve( SolverType &solver,
     {
       solver.set_problem_type(EPS_GHEP);
       // reset vectors and set them as initial space
-      // to avoid dependency on random numbers:
+      // to avoid dependency on SLEPc random numbers:
       for (unsigned int i = 0; i < u.size(); i++)
-        {
-          u[i] = 0.0;
-          u[i][i] = 1.0;
-        }
+        for (unsigned int j=0; j<u[i].size(); ++j)
+          u[i][j] = static_cast<double>(Testing::rand())/static_cast<double>(RAND_MAX);
+
       solver.set_initial_space(u);
 
       solver.solve(A,B,v,u,v.size());
@@ -86,7 +85,7 @@ int main(int argc, char **argv)
 
   Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1);
   {
-    SolverControl control(1000, 1000*PETSC_MACHINE_EPSILON);
+    SolverControl control(5000, 1e-11 /*1000*PETSC_MACHINE_EPSILON*/,false,false);
 
     const unsigned int size = 46;
     unsigned int dim = (size-1)*(size-1);
@@ -109,6 +108,10 @@ int main(int argc, char **argv)
                                           PETScWrappers::Vector(dim));
     std::vector<PetscScalar> v(n_eigenvalues);
 
+    PetscOptionsSetValue("-st_ksp_type","cg");
+    PetscOptionsSetValue("-st_pc_type", "jacobi");
+    PetscOptionsSetValue("-st_ksp_tol", "1e-15");
+
     {
       SLEPcWrappers::SolverKrylovSchur solver(control);
       check_solve (solver, control, A,B,u,v);
@@ -124,19 +127,22 @@ int main(int argc, char **argv)
       check_solve (solver, control, A,B,u,v);
     }
 
+    PetscOptionsSetValue("-st_ksp_type","preonly");
     {
       SLEPcWrappers::SolverGeneralizedDavidson solver(control);
       check_solve (solver, control, A,B,u,v);
     }
 
     {
-      SLEPcWrappers::SolverJacobiDavidson solver(control);
+      SLEPcWrappers::SolverGeneralizedDavidson::AdditionalData data(true);
+      SLEPcWrappers::SolverGeneralizedDavidson solver(control,PETSC_COMM_SELF,data);
       check_solve (solver, control, A,B,u,v);
     }
 
+    PetscOptionsSetValue("-st_ksp_type","cg");
+    PetscOptionsSetValue("-st_ksp_max_it", "10");
     {
-      SLEPcWrappers::SolverGeneralizedDavidson::AdditionalData data(true);
-      SLEPcWrappers::SolverGeneralizedDavidson solver(control,PETSC_COMM_SELF,data);
+      SLEPcWrappers::SolverJacobiDavidson solver(control);
       check_solve (solver, control, A,B,u,v);
     }
   }
index 635bea8a23a179cf56640e7ff126cf540af2487f..9208eccc98929852ea605b20663cf3646b9300af 100644 (file)
@@ -2,29 +2,26 @@
 DEAL::Size 46 Unknowns 2025
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers17SolverKrylovSchurE
-DEAL::Convergence step 23 value 0
-DEAL::Solver stopped after 23 iterations
+DEAL::Solver stopped after 18 iterations
 DEAL::Eigenvalues: 29.73524, 29.67536, 29.58873, 29.46785
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers13SolverArnoldiE
-DEAL::Convergence step 80 value 0
-DEAL::Solver stopped after 80 iterations
+DEAL::Solver stopped after 63 iterations
 DEAL::Eigenvalues: 29.73524, 29.67536, 29.58873, 29.46785
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers13SolverLanczosE
-DEAL::Convergence step 79 value 0
-DEAL::Solver stopped after 79 iterations
+DEAL::Solver stopped after 60 iterations
 DEAL::Eigenvalues: 29.73524, 29.67536, 29.58873, 29.46785
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers25SolverGeneralizedDavidsonE
-DEAL::Solver stopped after 278 iterations
+DEAL::Solver stopped after 334 iterations
 DEAL::Eigenvalues: 29.73524, 29.67536, 29.58873, 29.46785
 DEAL::
-DEAL::Solver type: N6dealii13SLEPcWrappers20SolverJacobiDavidsonE
-DEAL::Solver stopped after 40 iterations
+DEAL::Solver type: N6dealii13SLEPcWrappers25SolverGeneralizedDavidsonE
+DEAL::Solver stopped after 504 iterations
 DEAL::Eigenvalues: 29.73524, 29.67536, 29.58873, 29.46785
 DEAL::
-DEAL::Solver type: N6dealii13SLEPcWrappers25SolverGeneralizedDavidsonE
-DEAL::Solver stopped after 581 iterations
+DEAL::Solver type: N6dealii13SLEPcWrappers20SolverJacobiDavidsonE
+DEAL::Solver stopped after 58 iterations
 DEAL::Eigenvalues: 29.73524, 29.67536, 29.58873, 29.46785
 DEAL::
index f0f7d368a27d38cfb75153fd29a0fe82c2e5b22c..e22dcb382a12fce670de036f6596e509d95545f6 100644 (file)
@@ -50,10 +50,9 @@ check_solve( SolverType &solver,
       // reset vectors and set them as initial space
       // to avoid dependency on random numbers:
       for (unsigned int i = 0; i < u.size(); i++)
-        {
-          u[i] = 0.0;
-          u[i][i] = 1.0;
-        }
+        for (unsigned int j=0; j<u[i].size(); ++j)
+          u[i][j] = static_cast<double>(Testing::rand())/static_cast<double>(RAND_MAX);
+
       solver.set_initial_space(u);
       // solve
       solver.solve(A,v,u,v.size());
@@ -86,7 +85,8 @@ int main(int argc, char **argv)
 
   Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1);
   {
-    SolverControl control(500, 1000*PETSC_MACHINE_EPSILON);
+    SolverControl control(500,1e-12 /*1000*PETSC_MACHINE_EPSILON*/,false,false);
+
 
     const unsigned int size = 31;
     unsigned int dim = (size-1);
@@ -126,15 +126,21 @@ int main(int argc, char **argv)
     }
 
     {
-      SLEPcWrappers::SolverJacobiDavidson solver(control);
+      SLEPcWrappers::SolverGeneralizedDavidson::AdditionalData data(true);
+      SLEPcWrappers::SolverGeneralizedDavidson solver(control,PETSC_COMM_SELF,data);
       check_solve (solver, control, A,u,v);
     }
 
+    // set extra settings for JD; Otherwise, at least on OSX,
+    // the number of eigensolver iterations is different between debug and release modes!
+    PetscOptionsSetValue("-st_ksp_type","cg");
+    PetscOptionsSetValue("-st_pc_type", "jacobi");
+    PetscOptionsSetValue("-st_ksp_max_it", "10");
     {
-      SLEPcWrappers::SolverGeneralizedDavidson::AdditionalData data(true);
-      SLEPcWrappers::SolverGeneralizedDavidson solver(control,PETSC_COMM_SELF,data);
+      SLEPcWrappers::SolverJacobiDavidson solver(control);
       check_solve (solver, control, A,u,v);
     }
+
   }
 
 }
index 2f8efd4c1f42cc5474fbaf98729595cd08dc09d6..ef11b2948de8e016639a2d175ed6874c239b81da 100644 (file)
@@ -2,32 +2,26 @@
 DEAL::Size 31 Unknowns 30
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers17SolverKrylovSchurE
-DEAL::Convergence step 5 value 0
 DEAL::Solver stopped after 5 iterations
 DEAL::Eigenvalues: 3.98974, 3.95906, 3.90828, 3.83792
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers13SolverArnoldiE
-DEAL::Convergence step 21 value 0
-DEAL::Solver stopped after 21 iterations
+DEAL::Solver stopped after 24 iterations
 DEAL::Eigenvalues: 3.98974, 3.95906, 3.90828, 3.83792
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers13SolverLanczosE
-DEAL::Convergence step 23 value 0
-DEAL::Solver stopped after 23 iterations
+DEAL::Solver stopped after 21 iterations
 DEAL::Eigenvalues: 3.98974, 3.95906, 3.90828, 3.83792
 DEAL::
 DEAL::Solver type: N6dealii13SLEPcWrappers25SolverGeneralizedDavidsonE
-DEAL::Convergence step 120 value 0
-DEAL::Solver stopped after 120 iterations
+DEAL::Solver stopped after 123 iterations
 DEAL::Eigenvalues: 3.98974, 3.95906, 3.90828, 3.83792
 DEAL::
-DEAL::Solver type: N6dealii13SLEPcWrappers20SolverJacobiDavidsonE
-DEAL::Convergence step 399 value 0
-DEAL::Solver stopped after 399 iterations
+DEAL::Solver type: N6dealii13SLEPcWrappers25SolverGeneralizedDavidsonE
+DEAL::Solver stopped after 138 iterations
 DEAL::Eigenvalues: 3.98974, 3.95906, 3.90828, 3.83792
 DEAL::
-DEAL::Solver type: N6dealii13SLEPcWrappers25SolverGeneralizedDavidsonE
-DEAL::Convergence step 145 value 0
-DEAL::Solver stopped after 145 iterations
+DEAL::Solver type: N6dealii13SLEPcWrappers20SolverJacobiDavidsonE
+DEAL::Solver stopped after 50 iterations
 DEAL::Eigenvalues: 3.98974, 3.95906, 3.90828, 3.83792
 DEAL::
index a675833b29138a607b14b6a6cb9e5ca9c5911ba8..c7764521db42a88b86395794e4da37e311eb1cef 100644 (file)
@@ -11,7 +11,7 @@
 #include <deal.II/fe/fe_tools.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/lac/sparsity_tools.h>
-#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
 
 #include <deal.II/lac/petsc_parallel_vector.h>
 #include <deal.II/lac/petsc_parallel_sparse_matrix.h>
@@ -99,7 +99,7 @@ void test (std::string solver_name,
                                                     constraints);
   constraints.close ();
 
-  dealii::CompressedSimpleSparsityPattern csp (locally_relevant_dofs);
+  dealii::DynamicSparsityPattern csp (locally_relevant_dofs);
   // Fill in ignoring all cells that are not locally owned
   dealii::DoFTools::make_sparsity_pattern (dof_handler, csp,
                                            constraints,
@@ -127,7 +127,13 @@ void test (std::string solver_name,
 
   eigenfunctions.resize (5);
   for (unsigned int i=0; i<eigenfunctions.size (); ++i)
-    eigenfunctions[i].reinit (locally_owned_dofs, mpi_communicator);//without ghost dofs
+    {
+      eigenfunctions[i].reinit (locally_owned_dofs, mpi_communicator);//without ghost dofs
+      for (unsigned int j=0; j<locally_owned_dofs.n_elements(); ++j)
+        eigenfunctions[i][locally_owned_dofs.nth_index_in_set(j)] = static_cast<double>(Testing::rand())/static_cast<double>(RAND_MAX);
+
+      eigenfunctions[i].compress(dealii::VectorOperation::insert);
+    }
 
   eigenvalues.resize (eigenfunctions.size ());
 
@@ -220,14 +226,11 @@ void test (std::string solver_name,
         preconditioner = new PETScWrappers::PreconditionJacobi(mpi_communicator);
       }
 
-    dealii::SolverControl linear_solver_control (dof_handler.n_dofs(), 1e-12,/*log_history*/false,/*log_results*/false);
+    dealii::SolverControl linear_solver_control (dof_handler.n_dofs(), 1e-15,/*log_history*/false,/*log_results*/false);
     PETScWrappers::SolverCG  linear_solver(linear_solver_control,mpi_communicator);
     linear_solver.initialize(*preconditioner);
 
-    for (unsigned int i=0; i < eigenvalues.size(); i++)
-      eigenfunctions[i] = PetscScalar();
-
-    dealii::SolverControl solver_control (dof_handler.n_dofs(), 1e-9,/*log_history*/false,/*log_results*/false);
+    dealii::SolverControl solver_control (100, 1e-11,/*log_history*/false,/*log_results*/false);
 
     dealii::SLEPcWrappers::SolverBase *eigensolver;
 
@@ -264,18 +267,16 @@ void test (std::string solver_name,
                                                                     mpi_communicator);
       }
 
-    SLEPcWrappers::TransformationShift spectral_transformation(mpi_communicator);
+    SLEPcWrappers::TransformationShiftInvert::AdditionalData additional_data(4.0);
+    SLEPcWrappers::TransformationShiftInvert spectral_transformation(mpi_communicator,additional_data);
     spectral_transformation.set_solver(linear_solver);
     eigensolver->set_transformation(spectral_transformation);
-    eigensolver->set_initial_vector(eigenfunctions[0]);
+    // 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_problem_type (EPS_GHEP);
 
-    //zero constrained DoFs
-    for (unsigned int i=0; i<eigenfunctions.size(); ++i)
-      constraints.set_zero (eigenfunctions[i]);
-
     eigensolver->solve (stiffness_matrix,
                         mass_matrix,
                         eigenvalues,
@@ -294,7 +295,7 @@ void test (std::string solver_name,
     // a) (A*x_i-\lambda*B*x_i).L2() == 0
     // b) x_j*B*x_i=\delta_{ij}
     {
-      const double precision = 1e-5; // ridiculously small...
+      const double precision = 1e-5;
       PETScWrappers::MPI::Vector Ax(eigenfunctions[0]), Bx(eigenfunctions[0]);
       for (unsigned int i=0; i < eigenfunctions.size(); ++i)
         {
index 1da79e5f3c72ba5f994779df19f6294e0850c0c3..0b44ab8366e8cf0b5f0c3ac9f1ba687e72438959 100644 (file)
@@ -1,7 +1,7 @@
 DEAL::Jacobi
 DEAL::KrylovSchur
-DEAL::outer iterations: 69
-DEAL::last inner iterations: 13
+DEAL::outer iterations: 3
+DEAL::last inner iterations: 33
 DEAL::4.93877
 DEAL::12.3707
 DEAL::12.3707
@@ -10,8 +10,8 @@ DEAL::24.8370
 DEAL::Ok
 DEAL::BlockJacobi
 DEAL::KrylovSchur
-DEAL::outer iterations: 64
-DEAL::last inner iterations: 5
+DEAL::outer iterations: 3
+DEAL::last inner iterations: 58
 DEAL::4.93877
 DEAL::12.3707
 DEAL::12.3707
@@ -20,11 +20,11 @@ DEAL::24.8370
 DEAL::Ok
 DEAL::Boomer
 DEAL::KrylovSchur
-DEAL::outer iterations: 63
-DEAL::last inner iterations: 19
+DEAL::outer iterations: 3
+DEAL::last inner iterations: 13
 DEAL::4.93877
 DEAL::12.3707
 DEAL::12.3707
 DEAL::19.8027
 DEAL::24.8370
-DEAL::Ok
+DEAL::Ok
\ No newline at end of file
diff --git a/tests/slepc/step-36_parallel.with_mpi=true.with_petsc=true.with_slepc=true.mpirun=3.output.2 b/tests/slepc/step-36_parallel.with_mpi=true.with_petsc=true.with_slepc=true.mpirun=3.output.2
new file mode 100644 (file)
index 0000000..fa3f55b
--- /dev/null
@@ -0,0 +1,30 @@
+DEAL::Jacobi
+DEAL::KrylovSchur
+DEAL::outer iterations: 3
+DEAL::last inner iterations: 28
+DEAL::4.93877
+DEAL::12.3707
+DEAL::12.3707
+DEAL::19.8027
+DEAL::24.8370
+DEAL::Ok
+DEAL::BlockJacobi
+DEAL::KrylovSchur
+DEAL::outer iterations: 3
+DEAL::last inner iterations: 58
+DEAL::4.93877
+DEAL::12.3707
+DEAL::12.3707
+DEAL::19.8027
+DEAL::24.8370
+DEAL::Ok
+DEAL::Boomer
+DEAL::KrylovSchur
+DEAL::outer iterations: 2
+DEAL::last inner iterations: 13
+DEAL::4.93877
+DEAL::12.3707
+DEAL::12.3707
+DEAL::19.8027
+DEAL::24.8370
+DEAL::Ok
\ No newline at end of file

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.