From 8557b77e5138bec6339ae4774c36748883f58115 Mon Sep 17 00:00:00 2001 From: Georg Futter <georg.futter@dlr.de> Date: Fri, 6 Nov 2015 13:12:11 +0100 Subject: [PATCH] [mpnc] Rename shadowing variables. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes memory leaks if a fluidsystem with more than 4 components is used in a 2D case. The problem was in each loop the variables i and j for the SCV corners were shadowed by the component indices. Signed-off-by: Christoph Grüninger <christoph.grueninger@iws.uni-stuttgart.de> --- .../implicit/mpnc/diffusion/fluxvariables.hh | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dumux/implicit/mpnc/diffusion/fluxvariables.hh b/dumux/implicit/mpnc/diffusion/fluxvariables.hh index 3b5a6d5881..2fb8041a27 100644 --- a/dumux/implicit/mpnc/diffusion/fluxvariables.hh +++ b/dumux/implicit/mpnc/diffusion/fluxvariables.hh @@ -117,10 +117,10 @@ public: } // initialize the diffusion coefficients to zero - for (int i = 0; i < numComponents; ++i) { - porousDiffCoeffL_[i] = 0.0; - for (int j = 0; j < numComponents; ++j) - porousDiffCoeffG_[i][j] = 0.0; + for (int compIIdx = 0; compIIdx < numComponents; ++compIIdx) { + porousDiffCoeffL_[compIIdx] = 0.0; + for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx) + porousDiffCoeffG_[compIIdx][compJIdx] = 0.0; } // calculate the diffusion coefficients at the integration @@ -149,21 +149,21 @@ public: if (phaseIdx == wPhaseIdx) { // Liquid phase diffusion coefficients in the porous medium - for (int i = 0; i < numComponents; ++i) { + for (int compIIdx = 0; compIIdx < numComponents; ++compIIdx) { // -> arithmetic mean - porousDiffCoeffL_[i] - = 1./2*(red_i * elemVolVars[i].diffCoeff(wPhaseIdx, 0, i) + - red_j * elemVolVars[j].diffCoeff(wPhaseIdx, 0, i)); + porousDiffCoeffL_[compIIdx] + = 1./2*(red_i * elemVolVars[i].diffCoeff(wPhaseIdx, 0, compIIdx) + + red_j * elemVolVars[j].diffCoeff(wPhaseIdx, 0, compIIdx)); } } else { // Gas phase diffusion coefficients in the porous medium - for (int i = 0; i < numComponents; ++i) { - for (int j = 0; j < numComponents; ++j) { + for (int compIIdx = 0; compIIdx < numComponents; ++compIIdx) { + for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx) { // -> arithmetic mean - porousDiffCoeffG_[i][j] - = 1./2*(red_i * elemVolVars[i].diffCoeff(nPhaseIdx, i, j) + - red_j * elemVolVars[j].diffCoeff(nPhaseIdx, i, j)); + porousDiffCoeffG_[compIIdx][compJIdx] + = 1./2*(red_i * elemVolVars[i].diffCoeff(nPhaseIdx, compIIdx, compJIdx) + + red_j * elemVolVars[j].diffCoeff(nPhaseIdx, compIIdx, compJIdx)); } } } -- GitLab