addressing comments.

no functional change.
This commit is contained in:
Kai Bao 2016-06-30 16:20:38 +02:00
parent b4fa2b4944
commit 18b76331eb
3 changed files with 20 additions and 22 deletions

View File

@ -28,20 +28,20 @@
namespace Opm namespace Opm
{ {
/// to handle the wells and connections voilating economic limits. /// to handle the wells and connections violating economic limits.
class DynamicListEconLimited class DynamicListEconLimited
{ {
public: public:
bool wellShuttedEconLimited(const std::string& well_name) const { bool wellShutEconLimited(const std::string& well_name) const {
return std::find(m_shutted_wells.begin(), m_shutted_wells.end(), well_name) != m_shutted_wells.end(); return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end();
}; };
void addShuttedWell(const std::string& well_name) { void addShutWell(const std::string& well_name) {
assert( !wellShuttedEconLimited(well_name) ); assert( !wellShutEconLimited(well_name) );
assert( !wellStoppedEconLimited(well_name) ); assert( !wellStoppedEconLimited(well_name) );
m_shutted_wells.push_back(well_name); m_shut_wells.push_back(well_name);
}; };
bool wellStoppedEconLimited(const std::string& well_name) const { bool wellStoppedEconLimited(const std::string& well_name) const {
@ -49,7 +49,7 @@ namespace Opm
}; };
void addStoppedWell(const std::string& well_name) { void addStoppedWell(const std::string& well_name) {
assert( !wellShuttedEconLimited(well_name) ); assert( !wellShutEconLimited(well_name) );
assert( !wellStoppedEconLimited(well_name) ); assert( !wellStoppedEconLimited(well_name) );
m_stopped_wells.push_back(well_name); m_stopped_wells.push_back(well_name);
@ -57,7 +57,7 @@ namespace Opm
// TODO: maybe completion better here // TODO: maybe completion better here
bool connectionClosedForWell(const std::string& well_name) const { bool anyConnectionClosedForWell(const std::string& well_name) const {
return (m_cells_closed_connections.find(well_name) != m_cells_closed_connections.end()); return (m_cells_closed_connections.find(well_name) != m_cells_closed_connections.end());
} }
@ -65,23 +65,20 @@ namespace Opm
return (m_cells_closed_connections.find(well_name)->second); return (m_cells_closed_connections.find(well_name)->second);
} }
std::vector<int>& closedConnectionsForWell(const std::string& well_name) {
return (m_cells_closed_connections.find(well_name)->second);
}
void addClosedConnectionsForWell(const std::string& well_name, void addClosedConnectionsForWell(const std::string& well_name,
const int cell_closed_connection) { const int cell_closed_connection) {
if (!connectionClosedForWell(well_name)) { if (!anyConnectionClosedForWell(well_name)) {
// first time adding a connection for the well // first time adding a connection for the well
std::vector<int> vector_cells = {cell_closed_connection}; std::vector<int> vector_cells = {cell_closed_connection};
m_cells_closed_connections[well_name] = vector_cells; m_cells_closed_connections[well_name] = vector_cells;
} else { } else {
closedConnectionsForWell(well_name).push_back(cell_closed_connection); std::vector<int>& closed_connections = m_cells_closed_connections.find(well_name)->second;
closed_connections.push_back(cell_closed_connection);
} }
} }
private: private:
std::vector <std::string> m_shutted_wells; std::vector <std::string> m_shut_wells;
std::vector <std::string> m_stopped_wells; std::vector <std::string> m_stopped_wells;
// using grid cell number to indicate the location of the connections // using grid cell number to indicate the location of the connections
std::map<std::string, std::vector<int>> m_cells_closed_connections; std::map<std::string, std::vector<int>> m_cells_closed_connections;

View File

@ -332,7 +332,7 @@ namespace Opm
const double* permeability) const double* permeability)
: w_(0), is_parallel_run_(false) : w_(0), is_parallel_run_(false)
{ {
std::vector<double> dummy_well_potentials;; std::vector<double> dummy_well_potentials;
// TODO: not sure about the usage of this WellsManager constructor // TODO: not sure about the usage of this WellsManager constructor
// TODO: not sure whether this is the correct thing to do here. // TODO: not sure whether this is the correct thing to do here.
DynamicListEconLimited dummy_list_econ_limited; DynamicListEconLimited dummy_list_econ_limited;
@ -438,7 +438,7 @@ namespace Opm
continue; continue;
} }
if (list_econ_limited.wellShuttedEconLimited(well->name())) { if (list_econ_limited.wellShutEconLimited(well->name())) {
continue; continue;
} }

View File

@ -145,12 +145,12 @@ void WellsManager::createWellsFromSpecs(std::vector<const Well*>& wells, size_t
continue; continue;
} }
if (list_econ_limited.wellShuttedEconLimited(well->name())) { if (list_econ_limited.wellShutEconLimited(well->name())) {
continue; continue;
} }
std::vector<int> cells_connection_closed; std::vector<int> cells_connection_closed;
if (list_econ_limited.connectionClosedForWell(well->name())) { if (list_econ_limited.anyConnectionClosedForWell(well->name())) {
cells_connection_closed = list_econ_limited.getClosedConnectionsForWell(well->name()); cells_connection_closed = list_econ_limited.getClosedConnectionsForWell(well->name());
} }
@ -187,7 +187,8 @@ void WellsManager::createWellsFromSpecs(std::vector<const Well*>& wells, size_t
int cell = cgit->second; int cell = cgit->second;
// check if the connection is closed due to economic limits // check if the connection is closed due to economic limits
if (!cells_connection_closed.empty()) { if (!cells_connection_closed.empty()) {
const bool connection_found = std::find(cells_connection_closed.begin(), cells_connection_closed.end(), cell) const bool connection_found = std::find(cells_connection_closed.begin(),
cells_connection_closed.end(), cell)
!= cells_connection_closed.end(); != cells_connection_closed.end();
if (connection_found) { if (connection_found) {
continue; continue;