From efddce474c6c9f97e16d4c90c5e13b1b9e3bfb73 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 28 Aug 2007 11:27:57 +0000
Subject: [PATCH] print the n-to-last total convergence rate

[[Imported from SVN: r1613]]
---
 dirneucoupling.cc | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/dirneucoupling.cc b/dirneucoupling.cc
index 0e40b35f..45762eec 100644
--- a/dirneucoupling.cc
+++ b/dirneucoupling.cc
@@ -224,6 +224,8 @@ int main (int argc, char *argv[]) try
                     baseTolerance,
                     false);
 
+    rodSolver.verbosity_ = Solver::QUIET;
+
     // ////////////////////////////////
     //   Create a multigrid solver
     // ////////////////////////////////
@@ -454,7 +456,6 @@ int main (int argc, char *argv[]) try
 
     double error = std::numeric_limits<double>::max();
     double oldError = 0;
-    double totalConvRate = 1;
 
     VectorType      intermediateSol3d(x3d.size());
     RodSolutionType intermediateSolRod(rodX.size());
@@ -471,7 +472,11 @@ int main (int argc, char *argv[]) try
 
     oldError = std::sqrt(oldError);
 
-    
+    // Store the history of total conv rates so we can filter out numerical
+    // dirt in the end.
+    std::vector<double> totalConvRate(maxDirichletNeumannSteps);
+    totalConvRate[0] = 1;
+
 
     int i;
     for (i=0; i<maxDirichletNeumannSteps; i++) {
@@ -522,12 +527,12 @@ int main (int argc, char *argv[]) try
         
 
         double convRate = error / oldError;
-        totalConvRate *= convRate;
+        totalConvRate[i+1] = totalConvRate[i] * convRate;
 
         // Output
         std::cout << "DD iteration: " << i << "  error : " << error << ",      "
                   << "convrate " << convRate 
-                  << "    total conv rate " << std::pow(totalConvRate, 1/((double)i+1)) << std::endl;
+                  << "    total conv rate " << std::pow(totalConvRate[i+1], 1/((double)i+1)) << std::endl;
 
         if (error < 1e-12)
           break;
@@ -536,8 +541,10 @@ int main (int argc, char *argv[]) try
         
     }            
 
+    int backTrace = 1;
     std::cout << "damping: " << damping
-              << "   convRate: " << std::pow(totalConvRate, 1/((double)i+1)) << std::endl;
+              << "   convRate: " << std::pow(totalConvRate[i+1-backTrace], 1/((double)i+1-backTrace)) 
+              << std::endl;
 
 
     // //////////////////////////////
-- 
GitLab