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

@ -17,7 +17,7 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_DYNAMICLISTECONLIMITED_HPP
#define OPM_DYNAMICLISTECONLIMITED_HPP
#define OPM_DYNAMICLISTECONLIMITED_HPP
#include <vector>
#include <string>
@ -28,20 +28,20 @@
namespace Opm
{
/// to handle the wells and connections voilating economic limits.
/// to handle the wells and connections violating economic limits.
class DynamicListEconLimited
{
public:
bool wellShuttedEconLimited(const std::string& well_name) const {
return std::find(m_shutted_wells.begin(), m_shutted_wells.end(), well_name) != m_shutted_wells.end();
bool wellShutEconLimited(const std::string& well_name) const {
return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end();
};
void addShuttedWell(const std::string& well_name) {
assert( !wellShuttedEconLimited(well_name) );
void addShutWell(const std::string& well_name) {
assert( !wellShutEconLimited(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 {
@ -49,7 +49,7 @@ namespace Opm
};
void addStoppedWell(const std::string& well_name) {
assert( !wellShuttedEconLimited(well_name) );
assert( !wellShutEconLimited(well_name) );
assert( !wellStoppedEconLimited(well_name) );
m_stopped_wells.push_back(well_name);
@ -57,7 +57,7 @@ namespace Opm
// 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());
}
@ -65,28 +65,25 @@ namespace Opm
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,
const int cell_closed_connection) {
if (!connectionClosedForWell(well_name)) {
if (!anyConnectionClosedForWell(well_name)) {
// first time adding a connection for the well
std::vector<int> vector_cells = {cell_closed_connection};
m_cells_closed_connections[well_name] = vector_cells;
} 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:
std::vector <std::string> m_shutted_wells;
std::vector <std::string> m_shut_wells;
std::vector <std::string> m_stopped_wells;
// using grid cell number to indicate the location of the connections
std::map<std::string, std::vector<int>> m_cells_closed_connections;
};
} // namespace Opm
#endif /* OPM_DYNAMICLISTECONLIMITED_HPP */
#endif /* OPM_DYNAMICLISTECONLIMITED_HPP */

View File

@ -332,7 +332,7 @@ namespace Opm
const double* permeability)
: 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 whether this is the correct thing to do here.
DynamicListEconLimited dummy_list_econ_limited;
@ -438,7 +438,7 @@ namespace Opm
continue;
}
if (list_econ_limited.wellShuttedEconLimited(well->name())) {
if (list_econ_limited.wellShutEconLimited(well->name())) {
continue;
}

View File

@ -145,12 +145,12 @@ void WellsManager::createWellsFromSpecs(std::vector<const Well*>& wells, size_t
continue;
}
if (list_econ_limited.wellShuttedEconLimited(well->name())) {
if (list_econ_limited.wellShutEconLimited(well->name())) {
continue;
}
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());
}
@ -187,7 +187,8 @@ void WellsManager::createWellsFromSpecs(std::vector<const Well*>& wells, size_t
int cell = cgit->second;
// check if the connection is closed due to economic limits
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();
if (connection_found) {
continue;