Added maskedSet() and initMask() GridProperties<T>

This commit is contained in:
Joakim Hove
2014-12-12 08:18:12 +01:00
parent 60ad53c7d1
commit 867fdb2de5
2 changed files with 38 additions and 0 deletions

View File

@@ -224,6 +224,27 @@ public:
return m_data;
}
void maskedSet(T value, const std::vector<bool>& mask) {
for (size_t g = 0; g < getCartesianSize(); g++) {
if (mask[g])
m_data[g] = value;
}
}
void initMask(T value, std::vector<bool>& 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

View File

@@ -484,3 +484,20 @@ BOOST_AUTO_TEST_CASE(multiply) {
}
BOOST_AUTO_TEST_CASE(mask) {
typedef Opm::GridProperty<int>::SupportedKeywordInfo SupportedKeywordInfo;
SupportedKeywordInfo keywordInfo1("P" , 10 , "1");
SupportedKeywordInfo keywordInfo2("P" , 20 , "1");
Opm::GridProperty<int> p1( 5 , 5 , 4 , keywordInfo1);
Opm::GridProperty<int> p2( 5 , 5 , 4 , keywordInfo2);
std::vector<bool> 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));
}