Files
opm-common/python/cxx/well.cpp
T

50 lines
1.6 KiB
C++
Raw Normal View History

#include <tuple>
2019-11-12 08:29:28 +01:00
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
2018-01-30 07:46:03 +01:00
#include <pybind11/stl.h>
#include "export.hpp"
2017-08-31 13:49:09 +02:00
namespace {
2017-08-31 13:49:09 +02:00
2019-11-12 08:29:28 +01:00
std::vector<Connection> connections( const Well& w ) {
2019-06-19 11:41:37 +02:00
const auto& well_connections = w.getConnections();
2018-07-09 16:54:15 +02:00
return std::vector<Connection>(well_connections.begin(), well_connections.end());
2017-08-31 13:49:09 +02:00
}
2019-11-12 08:29:28 +01:00
std::string status( const Well& w ) {
return Well::Status2String( w.getStatus() );
2017-08-31 13:49:09 +02:00
}
2019-11-12 08:29:28 +01:00
std::string preferred_phase( const Well& w ) {
2017-08-31 13:49:09 +02:00
switch( w.getPreferredPhase() ) {
case Phase::OIL: return "OIL";
case Phase::GAS: return "GAS";
case Phase::WATER: return "WATER";
default: throw std::logic_error( "Unhandled enum value" );
}
}
2019-11-12 08:29:28 +01:00
std::tuple<int, int, double> get_pos( const Well& w ) {
return std::make_tuple(w.getHeadI(), w.getHeadJ(), w.getRefDepth());
}
2017-08-31 13:49:09 +02:00
}
2017-08-31 13:49:09 +02:00
void python::common::export_Well(py::module& module) {
2019-11-12 08:29:28 +01:00
py::class_< Well >( module, "Well")
.def_property_readonly( "name", &Well::name )
2018-01-30 07:46:03 +01:00
.def_property_readonly( "preferred_phase", &preferred_phase )
.def( "pos", &get_pos )
.def( "status", &status )
2019-11-12 08:29:28 +01:00
.def( "isdefined", &Well::hasBeenDefined )
.def( "isinjector", &Well::isInjector )
.def( "isproducer", &Well::isProducer )
.def( "group", &Well::groupName )
.def( "guide_rate", &Well::getGuideRate )
.def( "available_gctrl", &Well::isAvailableForGroupControl )
.def( "connections", &connections );
2017-08-31 13:49:09 +02:00
}