Added containsNaN() method to GridProperty
This commit is contained in:
@@ -32,4 +32,25 @@ void GridProperty<double>::setDataPoint(size_t sourceIdx, size_t targetIdx, Opm:
|
||||
m_data[targetIdx] = deckItem->getSIDouble(sourceIdx);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
bool GridProperty<double>::containsNaN( ) {
|
||||
bool return_value = false;
|
||||
size_t size = m_data.size();
|
||||
size_t index = 0;
|
||||
while (true) {
|
||||
if (std::isnan(m_data[index])) {
|
||||
return_value = true;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
if (index == size)
|
||||
break;
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -144,6 +144,9 @@ public:
|
||||
iset(g,value);
|
||||
}
|
||||
|
||||
bool containsNaN( ) {
|
||||
throw std::logic_error("Only <double> and can be meaningfully queried for nan");
|
||||
}
|
||||
|
||||
void multiplyWith(const GridProperty<T>& other) {
|
||||
if ((m_nx == other.m_nx) && (m_ny == other.m_ny) && (m_nz == other.m_nz)) {
|
||||
|
||||
@@ -61,6 +61,21 @@ BOOST_AUTO_TEST_CASE(Empty) {
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(HasNAN) {
|
||||
double nan = std::numeric_limits<double>::quiet_NaN();
|
||||
typedef Opm::GridProperty<double>::SupportedKeywordInfo SupportedKeywordInfo;
|
||||
SupportedKeywordInfo keywordInfo("PORO" , nan , "1");
|
||||
Opm::GridProperty<double> poro( 2 , 2 , 1 , keywordInfo);
|
||||
|
||||
BOOST_CHECK( poro.containsNaN() );
|
||||
poro.iset(0,0.15);
|
||||
poro.iset(1,0.15);
|
||||
poro.iset(2,0.15);
|
||||
BOOST_CHECK( poro.containsNaN() );
|
||||
poro.iset(3,0.15);
|
||||
BOOST_CHECK( !poro.containsNaN() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(EmptyDefault) {
|
||||
typedef Opm::GridProperty<int>::SupportedKeywordInfo SupportedKeywordInfo;
|
||||
SupportedKeywordInfo keywordInfo("SATNUM" , 0, "1");
|
||||
|
||||
Reference in New Issue
Block a user