From e61d097e0db1c819671359d5c7a3de57fd3a1ac7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?=
 <christoph.grueninger@iws.uni-stuttgart.de>
Date: Fri, 19 Feb 2016 13:24:36 +0100
Subject: [PATCH] Minor code improvement

* Delete unused variable sumx.
* Simplify function code flow.
* Use unsigned int in loop.
---
 .../compositionfromfugacities.hh              | 27 ++++++++-----------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/dumux/material/constraintsolvers/compositionfromfugacities.hh b/dumux/material/constraintsolvers/compositionfromfugacities.hh
index 8c256fafbb..62d89f7b3a 100644
--- a/dumux/material/constraintsolvers/compositionfromfugacities.hh
+++ b/dumux/material/constraintsolvers/compositionfromfugacities.hh
@@ -60,15 +60,15 @@ public:
                              int phaseIdx,
                              const ComponentVector &fugVec)
     {
-        if (FluidSystem::isIdealMixture(phaseIdx))
-            return;
-
-        // Pure component fugacities
-        for (int i = 0; i < numComponents; ++ i) {
-            //std::cout << f << " -> " << mutParams.fugacity(phaseIdx, i)/f << "\n";
-            fluidState.setMoleFraction(phaseIdx,
-                                   i,
-                                   1.0/numComponents);
+        if (!FluidSystem::isIdealMixture(phaseIdx))
+        {
+            // Pure component fugacities
+            for (unsigned int i = 0; i < numComponents; ++ i)
+            {
+                fluidState.setMoleFraction(phaseIdx,
+                                           i,
+                                           1.0/numComponents);
+            }
         }
     }
 
@@ -207,7 +207,6 @@ protected:
 
         Scalar rho = FluidSystem::density(fluidState, paramCache, phaseIdx);
         fluidState.setDensity(phaseIdx, rho);
-        return;
     }
 
     template <class FluidState>
@@ -291,21 +290,17 @@ protected:
         Dune::FieldVector<Scalar, numComponents> origComp;
         Scalar relError = 0;
         Scalar sumDelta = 0;
-        Scalar sumx = 0;
-        for (int i = 0; i < numComponents; ++i) {
+        for (unsigned int i = 0; i < numComponents; ++i)
+        {
             origComp[i] = fluidState.moleFraction(phaseIdx, i);
             relError = std::max(relError, std::abs(x[i]));
-
-            sumx += std::abs(fluidState.moleFraction(phaseIdx, i));
             sumDelta += std::abs(x[i]);
         }
 
-#if 1
         // chop update to at most 20% change in composition
         const Scalar maxDelta = 0.2;
         if (sumDelta > maxDelta)
             x /= (sumDelta/maxDelta);
-#endif
 
         //Scalar curDefect = calculateDefect_(fluidState, phaseIdx, targetFug);
         //Scalar nextDefect;
-- 
GitLab