From 867fdb2de5c71fe101606c4dd223f37037012449 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 12 Dec 2014 08:18:12 +0100 Subject: [PATCH] Added maskedSet() and initMask() GridProperties --- .../EclipseState/Grid/GridProperty.hpp | 21 +++++++++++++++++++ .../Grid/tests/GridPropertyTests.cpp | 17 +++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp b/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp index 7110a8304..bf4c0dee5 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp @@ -224,6 +224,27 @@ public: return m_data; } + + void maskedSet(T value, const std::vector& mask) { + for (size_t g = 0; g < getCartesianSize(); g++) { + if (mask[g]) + m_data[g] = value; + } + } + + + void initMask(T value, std::vector& mask) { + mask.resize(getCartesianSize()); + for (size_t g = 0; g < getCartesianSize(); g++) { + if (m_data[g] == value) + mask[g] = true; + else + mask[g] = false; + } + } + + + /** Due to the convention where it is only neceassary to supply the top layer of the petrophysical properties we can unfortunately diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp index a9d9c27f7..1a9611bd0 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp @@ -484,3 +484,20 @@ BOOST_AUTO_TEST_CASE(multiply) { } + + +BOOST_AUTO_TEST_CASE(mask) { + typedef Opm::GridProperty::SupportedKeywordInfo SupportedKeywordInfo; + SupportedKeywordInfo keywordInfo1("P" , 10 , "1"); + SupportedKeywordInfo keywordInfo2("P" , 20 , "1"); + Opm::GridProperty p1( 5 , 5 , 4 , keywordInfo1); + Opm::GridProperty p2( 5 , 5 , 4 , keywordInfo2); + + std::vector mask; + + p1.initMask(10 , mask); + p2.maskedSet( 10 , mask); + + for (size_t g = 0; g < p1.getCartesianSize(); g++) + BOOST_CHECK_EQUAL( p1.iget(g) , p2.iget(g)); +}