Use ScheduleState to manage groups

This commit is contained in:
Joakim Hove
2021-02-02 07:25:16 +01:00
parent bd22745ec0
commit e016d357d8
14 changed files with 181 additions and 184 deletions
+8 -3
View File
@@ -85,6 +85,11 @@ namespace {
return sch.hasWell( wellName );
}
const Group& get_group(const ScheduleState& st, const std::string& group_name) {
return st.groups.get(group_name);
}
const RestartConfig& restart(const Schedule& sch) {
return sch.restart();
}
@@ -104,7 +109,8 @@ void python::common::export_Schedule(py::module& module) {
py::class_<ScheduleState>(module, "ScheduleState")
.def_property_readonly("nupcol", py::overload_cast<>(&ScheduleState::nupcol, py::const_));
.def_property_readonly("nupcol", py::overload_cast<>(&ScheduleState::nupcol, py::const_))
.def("group", &get_group, ref_internal);
py::class_< Schedule >( module, "Schedule")
@@ -122,8 +128,7 @@ void python::common::export_Schedule(py::module& module) {
.def( "get_wells", &Schedule::getWells)
.def("well_names", py::overload_cast<const std::string&>(&Schedule::wellNames, py::const_))
.def( "get_well", &get_well)
.def( "__contains__", &has_well )
.def( "group", &Schedule::getGroup, ref_internal);
.def( "__contains__", &has_well );
py::class_< RestartConfig >( module, "RestartConfig")
.def( "getKeyword", &RestartConfig::getKeyword )
+3 -3
View File
@@ -43,7 +43,7 @@ class TestSchedule(unittest.TestCase):
def testGroups(self):
G1 = self.sch.group( 'G1', 0 )
G1 = self.sch[0].group( 'G1')
self.assertTrue(G1.name == 'G1')
self.assertTrue(G1.num_wells == 2)
@@ -54,8 +54,8 @@ class TestSchedule(unittest.TestCase):
self.assertTrue(self.sch.get_well('INJ', 0).isinjector())
self.assertTrue(self.sch.get_well('PROD', 0).isproducer())
with self.assertRaises(ValueError):
self.sch.group('foo', 0)
with self.assertRaises(Exception):
self.sch[0].group('foo')
def test_open_shut(self):
deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA'))