Add size() method to UDQConfig

This commit is contained in:
Joakim Hove
2019-07-28 18:32:41 +02:00
committed by Jostein Alvestad
parent 74d0703dc2
commit 9e309375b6
3 changed files with 18 additions and 0 deletions

View File

@@ -53,6 +53,11 @@ namespace Opm {
std::vector<UDQDefine> definitions(UDQVarType var_type) const;
std::vector<UDQInput> input() const;
// The size() method will return the number of active DEFINE and ASSIGN
// statements; this will correspond to the length of the vector returned
// from input().
size_t size() const;
std::vector<UDQAssign> assignments() const;
std::vector<UDQAssign> assignments(UDQVarType var_type) const;
const UDQParams& params() const;

View File

@@ -122,6 +122,17 @@ namespace Opm {
return res;
}
std::size_t UDQConfig::size() const {
std::size_t s = 0;
for (const auto& index_pair : this->input_index) {
if (index_pair.second.second == UDQAction::DEFINE)
s += 1;
else if (index_pair.second.second == UDQAction::ASSIGN)
s += 1;
}
return s;
}
std::vector<UDQAssign> UDQConfig::assignments() const {
std::vector<UDQAssign> ret;

View File

@@ -1177,6 +1177,7 @@ UDQ
const auto& input = udq.input();
const auto& def = udq.definitions();
BOOST_CHECK_EQUAL(input.size(), 7);
BOOST_CHECK_EQUAL(udq.size(), 7);
BOOST_CHECK( input[0].is<UDQAssign>() );
BOOST_CHECK( input[1].is<UDQAssign>() );
@@ -1227,6 +1228,7 @@ UDQ
const auto& input = udq.input();
const auto& def = udq.definitions();
BOOST_CHECK_EQUAL(input.size(), 5);
BOOST_CHECK_EQUAL(udq.size(), 5);
BOOST_CHECK( input[0].is<UDQDefine>());
}