From 194b6eda7a133247cfb52e899aaba991fe290146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 22 Aug 2014 14:02:13 +0200 Subject: [PATCH 1/3] Fix semantics of permeability assignment Calling code relies on permeability tensors being stored in column major order (row index cycling the most rapidly). Honour that requirement. The previous assignment implied row major ordering (column index cycling the most rapidly). This, however, is a pedantic rather than visible change because the surrounding code enforces symmetric tensors whence both orderings produce the same results when the array is viewed contiguously. --- opm/core/props/rock/RockFromDeck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockFromDeck.cpp b/opm/core/props/rock/RockFromDeck.cpp index a2080bed..6c24b3c7 100644 --- a/opm/core/props/rock/RockFromDeck.cpp +++ b/opm/core/props/rock/RockFromDeck.cpp @@ -126,7 +126,7 @@ namespace Opm for (int i = 0; i < dim; ++i) { for (int j = 0; j < dim; ++j, ++kix) { // K(i,j) = (*tensor[kmap[kix]])[glob]; - permeability_[off + kix] = (*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); From 2ae64c1df29c9c16375bae2b5b61b6b5c4b00e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 22 Aug 2014 14:09:08 +0200 Subject: [PATCH 2/3] Remove obsolete comment This comment was needed when the code was first developed, but subsequent development has rendered it obsolete. Remove it to avoid confusion. --- opm/core/props/rock/RockFromDeck.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/opm/core/props/rock/RockFromDeck.cpp b/opm/core/props/rock/RockFromDeck.cpp index 6c24b3c7..10ee7bf7 100644 --- a/opm/core/props/rock/RockFromDeck.cpp +++ b/opm/core/props/rock/RockFromDeck.cpp @@ -107,13 +107,6 @@ namespace Opm OPM_THROW(std::runtime_error, "Invalid permeability field."); } - // Assign permeability values only if such values are - // given in the input deck represented by 'deck'. In - // other words: Don't set any (arbitrary) default values. - // It is infinitely better to experience a reproducible - // crash than subtle errors resulting from a (poorly - // chosen) default value... - // if (tensor.size() > 1) { const int* gc = global_cell; int off = 0; 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 3/3] 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);