From c64bda1bad725df7a0313347310a02afc79461e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?=
 <christoph.grueninger@iws.uni-stuttgart.de>
Date: Thu, 7 Apr 2016 06:35:57 +0200
Subject: [PATCH] [cleanup] Improve 2p diffusivity code

* Clarify program flow
* Drop unused variables
* Remove superfluous semicolons
* White space changes
---
 .../diffusivityconstanttau.hh                 |  4 ++--
 .../diffusivitymillingtonquirk.hh             |  6 ++---
 dumux/material/fluidstates/2p2c.hh            | 12 ++++------
 .../2p2c/implicit/fluxvariables.hh            | 24 +++++++++----------
 4 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/dumux/material/fluidmatrixinteractions/diffusivityconstanttau.hh b/dumux/material/fluidmatrixinteractions/diffusivityconstanttau.hh
index aae5f2c384..9598f0ab61 100644
--- a/dumux/material/fluidmatrixinteractions/diffusivityconstanttau.hh
+++ b/dumux/material/fluidmatrixinteractions/diffusivityconstanttau.hh
@@ -54,8 +54,8 @@ public:
      * \param diffCoeff The diffusion coefficient of the phase in \f$\mathrm{[m^2/s]}\f$
      */
     static Scalar effectiveDiffusivity(const Scalar porosity,
-                                               const Scalar saturation,
-                                               const Scalar diffCoeff)
+                                       const Scalar saturation,
+                                       const Scalar diffCoeff)
 
     {
         Scalar tau = GET_RUNTIME_PARAM(TypeTag, Scalar, tau);
diff --git a/dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh b/dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh
index 6ab8a4e7ab..c500eab03f 100644
--- a/dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh
+++ b/dumux/material/fluidmatrixinteractions/diffusivitymillingtonquirk.hh
@@ -57,12 +57,12 @@ public:
      * \param diffCoeff The diffusion coefficient of the phase \f$\mathrm{[m^2/s]}\f$
      */
     static Scalar effectiveDiffusivity(const Scalar porosity,
-                                               const Scalar saturation,
-                                               const Scalar diffCoeff)
+                                       const Scalar saturation,
+                                       const Scalar diffCoeff)
 
     {
         Scalar tau = 1.0/(porosity * porosity) *
-                    pow(porosity * saturation, 7.0/3);
+                     std::pow(porosity * saturation, 7.0/3);
 
         return porosity * saturation * tau * diffCoeff;
     }
diff --git a/dumux/material/fluidstates/2p2c.hh b/dumux/material/fluidstates/2p2c.hh
index 89dc426948..f1aef35cc8 100644
--- a/dumux/material/fluidstates/2p2c.hh
+++ b/dumux/material/fluidstates/2p2c.hh
@@ -70,9 +70,10 @@ public:
     Scalar saturation(int phaseIdx) const
     {
         if (phaseIdx == wPhaseIdx)
+        {
             return sw_;
-        else
-            return Scalar(1.0) - sw_;
+        }
+        return 1.0 - sw_;
     }
 
     /*! @copydoc CompositionalFluidState::massFraction()
@@ -155,8 +156,7 @@ public:
             nu_[nPhaseIdx] = 1. - nu_[wPhaseIdx];
             return nu_[phaseIdx];
         }
-        else
-            return nu_[phaseIdx];
+        return nu_[phaseIdx];
     }
     /*!
      * \brief Returns the phase mass fraction \f$ \nu \f$:
@@ -164,7 +164,7 @@ public:
      *
      * \param phaseIdx the index of the phase
      */
-    Scalar&  nu(int phaseIdx) const
+    Scalar& nu(int phaseIdx) const
     {
         return phaseMassFraction(phaseIdx);
     }
@@ -273,8 +273,6 @@ protected:
     Scalar viscosity_[numPhases];
     Scalar massFraction_[numPhases][numComponents];
     Scalar moleFraction_[numPhases][numComponents];
-    Dune::FieldMatrix<Scalar, numPhases, numComponents> equilRatio_;
-    Scalar averageMolarMass_[numPhases];
 };
 
 } // end namespace
diff --git a/dumux/porousmediumflow/2p2c/implicit/fluxvariables.hh b/dumux/porousmediumflow/2p2c/implicit/fluxvariables.hh
index 59c5e34c4b..a7b920c898 100644
--- a/dumux/porousmediumflow/2p2c/implicit/fluxvariables.hh
+++ b/dumux/porousmediumflow/2p2c/implicit/fluxvariables.hh
@@ -221,19 +221,19 @@ class TwoPTwoCFluxVariables : public GET_PROP_TYPE(TypeTag, BaseFluxVariables)
             if (volVarsI.saturation(phaseIdx) <= 0 || volVarsJ.saturation(phaseIdx) <= 0)
             {
                 porousDiffCoeff_[phaseIdx] = 0.0;
-                continue;
             }
+            else
+            {
+                diffCoeffI = EffectiveDiffusivityModel::effectiveDiffusivity(volVarsI.porosity(),
+                                                                             volVarsI.saturation(phaseIdx),
+                                                                             volVarsI.diffCoeff(phaseIdx));
 
-            diffCoeffI = EffectiveDiffusivityModel::effectiveDiffusivity(volVarsI.porosity(),
-                                                                         volVarsI.saturation(phaseIdx),
-                                                                         volVarsI.diffCoeff(phaseIdx));
-
-            diffCoeffJ = EffectiveDiffusivityModel::effectiveDiffusivity(volVarsJ.porosity(),
-                                                                         volVarsJ.saturation(phaseIdx),
-                                                                         volVarsJ.diffCoeff(phaseIdx));
+                diffCoeffJ = EffectiveDiffusivityModel::effectiveDiffusivity(volVarsJ.porosity(),
+                                                                             volVarsJ.saturation(phaseIdx),
+                                                                             volVarsJ.diffCoeff(phaseIdx));
 
-            // -> harmonic mean
-            porousDiffCoeff_[phaseIdx] = harmonicMean(diffCoeffI, diffCoeffJ);
+                porousDiffCoeff_[phaseIdx] = harmonicMean(diffCoeffI, diffCoeffJ);
+            }
         }
     }
 
@@ -245,7 +245,7 @@ class TwoPTwoCFluxVariables : public GET_PROP_TYPE(TypeTag, BaseFluxVariables)
      * \param phaseIdx The phase index
      */
     Scalar porousDiffCoeff(int phaseIdx) const
-    { return porousDiffCoeff_[phaseIdx]; };
+    { return porousDiffCoeff_[phaseIdx]; }
 
     /*!
      * \brief Returns the density \f$\mathrm{[kg/m^3]}\f$ of a phase.
@@ -270,7 +270,7 @@ class TwoPTwoCFluxVariables : public GET_PROP_TYPE(TypeTag, BaseFluxVariables)
      * \param phaseIdx The phase index
      */
     const GlobalPosition &moleFractionGrad(int phaseIdx) const
-    { return moleFractionGrad_[phaseIdx]; };
+    { return moleFractionGrad_[phaseIdx]; }
 
  protected:
     // mole fraction gradients
-- 
GitLab