From bcec9fd0f64d073a3a902902324c0ae236415932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 22 Aug 2014 15:12:12 +0200 Subject: [PATCH] Simplify diagonal component thresholding This commit switches the assignment diagonal = max(diagonal, minval) to using a reference in the "diagonal" expression. This guarantees that the indexing is done once which eases maintainability. While here, replace the hard-coded dimension stride ('3') with the current run-time dimension. This is mostly for symmetry because the overall code is only really supported in three space dimension. --- opm/core/props/rock/RockFromDeck.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockFromDeck.cpp b/opm/core/props/rock/RockFromDeck.cpp index 10ee7bf7..50e6982a 100644 --- a/opm/core/props/rock/RockFromDeck.cpp +++ b/opm/core/props/rock/RockFromDeck.cpp @@ -121,8 +121,10 @@ namespace Opm // K(i,j) = (*tensor[kmap[kix]])[glob]; permeability_[off + (i + dim*j)] = (*tensor[kmap[kix]])[glob]; } + // K(i,i) = std::max(K(i,i), perm_threshold); - permeability_[off + 3*i + i] = std::max(permeability_[off + 3*i + i], perm_threshold); + double& kii = permeability_[off + i*(dim + 1)]; + kii = std::max(kii, perm_threshold); } permfield_valid_[c] = std::vector::value_type(1);