2017-08-31 13:49:09 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
2018-01-30 07:46:03 +01:00
|
|
|
#include <pybind11/stl.h>
|
2017-08-31 13:49:09 +02:00
|
|
|
|
2019-08-15 11:19:18 +02:00
|
|
|
#include "common.hpp"
|
2018-01-30 07:46:03 +01:00
|
|
|
#include "converters.hpp"
|
2017-08-31 13:49:09 +02:00
|
|
|
|
2017-09-07 14:38:31 +02:00
|
|
|
namespace {
|
2017-08-31 13:49:09 +02:00
|
|
|
|
|
|
|
|
py::list getitem( const Eclipse3DProperties& p, const std::string& kw) {
|
|
|
|
|
const auto& ip = p.getIntProperties();
|
|
|
|
|
if (ip.supportsKeyword(kw) && ip.hasKeyword(kw))
|
|
|
|
|
return iterable_to_pylist(p.getIntGridProperty(kw).getData());
|
|
|
|
|
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
const auto& dp = p.getDoubleProperties();
|
|
|
|
|
if (dp.supportsKeyword(kw) && dp.hasKeyword(kw))
|
|
|
|
|
return iterable_to_pylist(p.getDoubleGridProperty(kw).getData());
|
2018-01-30 07:46:03 +01:00
|
|
|
|
|
|
|
|
throw py::key_error( "no such grid property " + kw );
|
2017-08-31 13:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool contains( const Eclipse3DProperties& p, const std::string& kw) {
|
|
|
|
|
return
|
|
|
|
|
(p.getIntProperties().supportsKeyword(kw) &&
|
|
|
|
|
p.getIntProperties().hasKeyword(kw))
|
|
|
|
|
||
|
|
|
|
|
(p.getDoubleProperties().supportsKeyword(kw) &&
|
|
|
|
|
p.getDoubleProperties().hasKeyword(kw))
|
|
|
|
|
;
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
|
|
|
|
std::vector<int> regions( const Eclipse3DProperties& p, const std::string& kw) {
|
|
|
|
|
return p.getRegions(kw);
|
2017-08-31 13:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-07 14:38:31 +02:00
|
|
|
}
|
2017-08-31 13:49:09 +02:00
|
|
|
|
2019-08-15 11:35:28 +02:00
|
|
|
void opmcommon_python::export_Eclipse3DProperties(py::module& module) {
|
2017-08-31 13:49:09 +02:00
|
|
|
|
2018-01-30 07:46:03 +01:00
|
|
|
py::class_< Eclipse3DProperties >( module, "Eclipse3DProperties")
|
|
|
|
|
.def( "getRegions", ®ions )
|
|
|
|
|
.def( "__contains__", &contains )
|
|
|
|
|
.def( "__getitem__", &getitem )
|
|
|
|
|
;
|
2017-08-31 13:49:09 +02:00
|
|
|
|
|
|
|
|
}
|