File: well.cpp

package info (click to toggle)
opm-common 2022.10%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,468 kB
  • sloc: cpp: 164,554; python: 2,872; sh: 216; xml: 174; ansic: 149; pascal: 136; makefile: 12
file content (49 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <tuple>

#include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <pybind11/stl.h>
#include "export.hpp"


namespace {

    std::vector<Connection> connections( const Well& w ) {
        const auto& well_connections = w.getConnections();
        return std::vector<Connection>(well_connections.begin(), well_connections.end());
    }

    std::string status( const Well& w )  {
        return Well::Status2String( w.getStatus() );
    }

    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" );
        }
    }

    std::tuple<int, int, double> get_pos( const Well& w ) {
        return std::make_tuple(w.getHeadI(), w.getHeadJ(), w.getRefDepth());
    }

}

void python::common::export_Well(py::module& module) {

    py::class_< Well >( module, "Well")
        .def_property_readonly( "name", &Well::name )
        .def_property_readonly( "preferred_phase", &preferred_phase )
        .def( "pos",             &get_pos )
        .def( "status",          &status )
        .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 );

}