Add FieldPropsManager::defaulted() property
This commit is contained in:
@@ -83,6 +83,9 @@ public:
|
||||
template <typename T>
|
||||
std::vector<T> get_global(const std::string& keyword) const;
|
||||
|
||||
template <typename T>
|
||||
std::vector<bool> defaulted(const std::string& keyword) const;
|
||||
|
||||
template <typename T>
|
||||
static bool supported(const std::string& keyword);
|
||||
|
||||
|
||||
@@ -701,4 +701,8 @@ void FieldProps::scanSCHEDULESection(const SCHEDULESection& schedule_section) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template std::vector<bool> FieldProps::defaulted<int>(const std::string& keyword);
|
||||
template std::vector<bool> FieldProps::defaulted<double>(const std::string& keyword);
|
||||
|
||||
}
|
||||
|
||||
@@ -156,6 +156,18 @@ public:
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::vector<bool> defaulted(const std::string& keyword) {
|
||||
const auto& field = this->get<T>(keyword);
|
||||
std::vector<bool> def(field.size());
|
||||
|
||||
for (std::size_t i=0; i < def.size(); i++)
|
||||
def[i] = value::defaulted( field.value_status[i]);
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void scanGRIDSection(const GRIDSection& grid_section);
|
||||
void scanEDITSection(const EDITSection& edit_section);
|
||||
|
||||
@@ -80,12 +80,21 @@ bool FieldPropsManager::has(const std::string& keyword) const {
|
||||
return data_ptr.valid();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<bool> FieldPropsManager::defaulted(const std::string& keyword) const {
|
||||
return this->fp->defaulted<T>(keyword);
|
||||
}
|
||||
|
||||
|
||||
template bool FieldPropsManager::supported<int>(const std::string&);
|
||||
template bool FieldPropsManager::supported<double>(const std::string&);
|
||||
|
||||
template bool FieldPropsManager::has<int>(const std::string&) const;
|
||||
template bool FieldPropsManager::has<double>(const std::string&) const;
|
||||
|
||||
template std::vector<bool> FieldPropsManager::defaulted<int>(const std::string&) const;
|
||||
template std::vector<bool> FieldPropsManager::defaulted<double>(const std::string&) const;
|
||||
|
||||
template std::vector<int> FieldPropsManager::get_global(const std::string& keyword) const;
|
||||
template std::vector<double> FieldPropsManager::get_global(const std::string& keyword) const;
|
||||
|
||||
@@ -94,4 +103,5 @@ template const std::vector<double>& FieldPropsManager::get(const std::string& ke
|
||||
|
||||
template const std::vector<int>* FieldPropsManager::try_get(const std::string& keyword) const;
|
||||
template const std::vector<double>* FieldPropsManager::try_get(const std::string& keyword) const;
|
||||
|
||||
}
|
||||
|
||||
@@ -189,3 +189,31 @@ BOOST_AUTO_TEST_CASE(ASSIGN) {
|
||||
BOOST_CHECK(data.valid());
|
||||
BOOST_CHECK(data.data == ext_data);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Defaulted) {
|
||||
std::string deck_string = R"(
|
||||
GRID
|
||||
|
||||
BOX
|
||||
1 10 1 10 1 1 /
|
||||
|
||||
NTG
|
||||
100*2 /
|
||||
|
||||
)";
|
||||
|
||||
EclipseGrid grid(EclipseGrid(10,10, 2));
|
||||
Deck deck = Parser{}.parseString(deck_string);
|
||||
FieldPropsManager fpm(deck, grid, TableManager());
|
||||
const auto& ntg = fpm.get<double>("NTG");
|
||||
const auto& defaulted = fpm.defaulted<double>("NTG");
|
||||
|
||||
for (std::size_t g=0; g < 100; g++) {
|
||||
BOOST_CHECK_EQUAL(ntg[g], 2);
|
||||
BOOST_CHECK_EQUAL(defaulted[g], false);
|
||||
|
||||
BOOST_CHECK_EQUAL(ntg[g + 100], 1);
|
||||
BOOST_CHECK_EQUAL(defaulted[g + 100], true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user