From 38d8aa7a73874febc3b19c01139f984b3e85e063 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Fri, 11 Jul 2014 14:20:25 +0200
Subject: [PATCH] [Cleanup] Fixed point iteration counter logic

---
 src/sand-wedge.cc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/sand-wedge.cc b/src/sand-wedge.cc
index b0a41e8d..392f046a 100644
--- a/src/sand-wedge.cc
+++ b/src/sand-wedge.cc
@@ -131,7 +131,8 @@ class FixedPointIterator {
 
     Vector previousVelocityIterate = velocityIterate;
 
-    for (size_t fixedPointIteration = 1;
+    size_t fixedPointIteration;
+    for (fixedPointIteration = 1;
          fixedPointIteration <= fixedPointMaxIterations_;
          ++fixedPointIteration) {
       Vector v_m;
@@ -157,11 +158,11 @@ class FixedPointIterator {
           fixedPointTolerance_)
         break;
 
-      if (fixedPointIteration == fixedPointMaxIterations_)
-        DUNE_THROW(Dune::Exception, "FPI failed to converge");
-
       previousVelocityIterate = velocityIterate;
     }
+    if (fixedPointIteration == fixedPointMaxIterations_)
+      DUNE_THROW(Dune::Exception, "FPI failed to converge");
+
     velocityUpdater->postProcess(velocityIterate);
     velocityUpdater->postProcessRelativeQuantities();
   }
-- 
GitLab