Files
opm-common/python/sunbeam/well.cpp
Joakim Hove 77795b5005 Add 'python/' from commit '278373703455ea6562a0f8e5278b4db46eb1fc7e'
git-subtree-dir: python
git-subtree-mainline: e8dbf7d8ee
git-subtree-split: 2783737034
2019-05-08 07:20:29 +02:00

58 lines
2.1 KiB
C++

#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
#include <pybind11/stl.h>
#include "sunbeam.hpp"
namespace {
std::vector<Connection> connections( const Well& w, size_t timestep ) {
const auto& well_connections = w.getConnections( timestep );
return std::vector<Connection>(well_connections.begin(), well_connections.end());
}
std::string status( const Well& w, size_t timestep ) {
return WellCommon::Status2String( w.getStatus( timestep ) );
}
std::string preferred_phase( const Well& w ) {
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" );
}
}
int (Well::*headI)() const = &Well::getHeadI;
int (Well::*headJ)() const = &Well::getHeadI;
double (Well::*refD)() const = &Well::getRefDepth;
int (Well::*headI_at)(size_t) const = &Well::getHeadI;
int (Well::*headJ_at)(size_t) const = &Well::getHeadI;
double (Well::*refD_at)(size_t) const = &Well::getRefDepth;
}
void sunbeam::export_Well(py::module& module) {
py::class_< Well >( module, "Well")
.def_property_readonly( "name", &Well::name )
.def_property_readonly( "preferred_phase", &preferred_phase )
.def( "I", headI )
.def( "I", headI_at )
.def( "J", headJ )
.def( "J", headJ_at )
.def( "ref", refD )
.def( "ref", refD_at )
.def( "status", &status )
.def( "isdefined", &Well::hasBeenDefined )
.def( "isinjector", &Well::isInjector )
.def( "isproducer", &Well::isProducer )
.def( "group", &Well::getGroupName )
.def( "guide_rate", &Well::getGuideRate )
.def( "available_gctrl", &Well::isAvailableForGroupControl )
.def( "__equal__", &Well::operator== )
.def( "_connections", &connections );
}