Add active_size() method to FieldPropsManager

This commit is contained in:
Joakim Hove
2019-12-16 08:50:21 +01:00
parent 1e221e478c
commit 617bb07b0b
3 changed files with 14 additions and 0 deletions

View File

@@ -66,6 +66,15 @@ public:
std::vector<double> porv(bool global = false) const;
MemInfo meminfo( ) const;
/*
The number of cells in the fields managed by this FieldPropsManager.
Initially this will correspond to the number of active cells in the grid
used when constructing the FieldPropsManager, but using the reset_actnum()
method it is possible to deactivate additional cells.
*/
std::size_t active_size() const;
/*
Because the FieldProps class can autocreate properties the semantics of
get() and has() is slightly non intuitve:

View File

@@ -117,6 +117,9 @@ std::vector<double> FieldPropsManager::porv(bool global) const {
return data;
}
std::size_t FieldPropsManager::active_size() const {
return this->fp->active_size;
}
template bool FieldPropsManager::supported<int>(const std::string&);
template bool FieldPropsManager::supported<double>(const std::string&);

View File

@@ -157,6 +157,7 @@ SATNUM
BOOST_CHECK_EQUAL(s1[3], 6);
BOOST_CHECK_EQUAL(s1[4], 7);
BOOST_CHECK_EQUAL(s1[5], 8);
BOOST_CHECK_EQUAL(fpm.active_size(), 6);
std::vector<int> actnum2 = {1,0,1,0,0,0,1,0,1};
fpm.reset_actnum(actnum2);
@@ -166,6 +167,7 @@ SATNUM
BOOST_CHECK_EQUAL(s1[1], 2);
BOOST_CHECK_EQUAL(s1[2], 6);
BOOST_CHECK_EQUAL(s1[3], 8);
BOOST_CHECK_EQUAL(fpm.active_size(), 4);
BOOST_CHECK_THROW(fpm.reset_actnum(actnum1), std::logic_error);
}