]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Update step-36 to output the number of iterations taken by the solver.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Jan 2013 19:35:15 +0000 (19:35 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Jan 2013 19:35:15 +0000 (19:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@28134 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-36/doc/results.dox
deal.II/examples/step-36/step-36.cc

index a24f0d6bab1be0700d2ee4e3ae1e70ba36d26bed..02e756fd9cdfd789e031009a08bb0d6b34e189f1 100644 (file)
@@ -21,14 +21,15 @@ examples/\step-36> make run
 ============================ Running \step-36
    Number of active cells:       1024
    Number of degrees of freedom: 1089
+   Solver converged in 67 iterations.
 
-   Eigenvalue 0 : 4.93877
-   Eigenvalue 1 : 12.3707
-   Eigenvalue 2 : 12.3707
-   Eigenvalue 3 : 19.8027
-   Eigenvalue 4 : 24.837
+      Eigenvalue 0 : 4.93877
+      Eigenvalue 1 : 12.3707
+      Eigenvalue 2 : 12.3707
+      Eigenvalue 3 : 19.8027
+      Eigenvalue 4 : 24.837
 
-Job done.  @endcode These eigenvalues are exactly the ones that
+   Job done.  @endcode These eigenvalues are exactly the ones that
 correspond to pairs $(m,n)=(1,1)$, $(1,2)$ and $(2,1)$, $(2,2)$, and
 $(3,1)$. A visualization of the corresponding eigenfunctions would
 look like this:
index 8ade9f3521356dcb404d74c9b3dd7b36a7692c63..bce17c5bb58dd60196093c4a508f482d0b0a5a5b 100644 (file)
@@ -68,7 +68,7 @@ namespace Step36
   private:
     void make_grid_and_dofs ();
     void assemble_system ();
-    void solve ();
+    unsigned int solve ();
     void output_results () const;
 
     Triangulation<dim> triangulation;
@@ -110,6 +110,7 @@ namespace Step36
     fe (1),
     dof_handler (triangulation)
   {
+//TODO investigate why the minimum number of refinement steps required to obtain the correct eigenvalue degeneracies is 6
     parameters.declare_entry ("Global mesh refinement steps", "5",
                               Patterns::Integer (0, 20),
                               "The number of times the 1-cell coarse mesh should "
@@ -295,7 +296,7 @@ namespace Step36
   // the kind of solver we want. Here we choose the Krylov-Schur solver of
   // SLEPc, a pretty fast and robust choice for this kind of problem:
   template <int dim>
-  void EigenvalueProblem<dim>::solve ()
+  unsigned int EigenvalueProblem<dim>::solve ()
   {
 
     // We start here, as we normally do, by assigning convergence control we
@@ -338,6 +339,9 @@ namespace Step36
     // equality is usually nearly true).
     for (unsigned int i=0; i<eigenfunctions.size(); ++i)
       eigenfunctions[i] /= eigenfunctions[i].linfty_norm ();
+
+    // Finally return the number of iterations it took to converge:
+    return solver_control.last_step ();
   }
 
 
@@ -399,15 +403,19 @@ namespace Step36
               << std::endl
               << "   Number of degrees of freedom: "
               << dof_handler.n_dofs ()
-              << std::endl
               << std::endl;
 
     assemble_system ();
-    solve ();
+
+    const unsigned int n_iterations = solve ();
+    std::cout << "   Solver converged in " << n_iterations
+             << " iterations." << std::endl;
+
     output_results ();
 
+    std::cout << std::endl;
     for (unsigned int i=0; i<eigenvalues.size(); ++i)
-      std::cout << "   Eigenvalue " << i
+      std::cout << "      Eigenvalue " << i
                 << " : " << eigenvalues[i]
                 << std::endl;
   }
@@ -468,7 +476,7 @@ int main (int argc, char **argv)
   // If no exceptions are thrown, then we tell the program to stop monkeying
   // around and exit nicely:
   std::cout << std::endl
-            << "Job done."
+            << "   Job done."
             << std::endl;
 
   return 0;

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.