adding hasTable() method to the VFP properties

and give a clear message about non-accessible table ID in the function
isVFPActive() in WellInterface.
This commit is contained in:
Kai Bao 2018-11-14 14:29:28 +01:00
parent cf2eb1c336
commit bf967e50a7
6 changed files with 35 additions and 3 deletions

View File

@ -557,6 +557,15 @@ const T* getTable(const std::map<int, T*> tables, int table_id) {
}
}
/**
* Check whether we have a table with the table number
*/
template <typename T>
bool hasTable(const std::map<int, T*> tables, int table_id) {
const auto entry = tables.find(table_id);
return (entry != tables.end() );
}
/**
* Returns the type variable for FLO/GFR/WFR for production tables

View File

@ -91,9 +91,12 @@ double VFPInjProperties::thp(int table_id,
return retval;
}
const VFPInjTable* VFPInjProperties::getTable(const int table_id) const {
return detail::getTable(m_tables, table_id);
}
bool VFPInjProperties::hasTable(const int table_id) const {
return detail::hasTable(m_tables, table_id);
}
} //Namespace Opm

View File

@ -109,6 +109,11 @@ public:
*/
const VFPInjTable* getTable(const int table_id) const;
/**
* Check whether there is table associated with ID
*/
bool hasTable(const int table_id) const;
/**
* Returns true if no vfp tables are in the current map
*/

View File

@ -105,5 +105,9 @@ const VFPProdTable* VFPProdProperties::getTable(const int table_id) const {
return detail::getTable(m_tables, table_id);
}
bool VFPProdProperties::hasTable(const int table_id) const {
return detail::hasTable(m_tables, table_id);
}
}

View File

@ -158,6 +158,11 @@ public:
*/
const VFPProdTable* getTable(const int table_id) const;
/**
* Check whether there is table associated with ID
*/
bool hasTable(const int table_id) const;
/**
* Returns true if no vfp tables are in the current map
*/

View File

@ -994,8 +994,11 @@ namespace Opm
if (table_id <= 0) {
return false;
} else {
if (vfp_properties_->getProd()->getTable(table_id)) {
if (vfp_properties_->getProd()->hasTable(table_id)) {
return true;
} else {
OPM_THROW(std::runtime_error, "VFPPROD table " << std::to_string(table_id) << " is specfied,"
<< " for well " << name() << ", while we could not access it during simulation");
}
}
@ -1004,8 +1007,11 @@ namespace Opm
if (table_id <= 0) {
return false;
} else {
if (vfp_properties_->getInj()->getTable(table_id)) {
if (vfp_properties_->getInj()->hasTable(table_id)) {
return true;
} else {
OPM_THROW(std::runtime_error, "VFPINJ table " << std::to_string(table_id) << " is specfied,"
<< " for well " << name() << ", while we could not access it during simulation");
}
}
}