diff --git a/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp b/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp index 6492560c7..5775c982a 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp @@ -52,6 +52,7 @@ public: const ActionX& get(const std::string& name) const; const ActionX& get(std::size_t index) const; std::vector pending(std::time_t sim_time) const; + std::vector pending_python() const; std::vector::const_iterator begin() const; std::vector::const_iterator end() const; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp index f1951e645..cea3384d4 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp @@ -97,6 +97,16 @@ bool Actions::ready(std::time_t sim_time) const { return false; } +std::vector Actions::pending_python() const { + std::vector pyaction_vector; + for (const auto& pyaction : this->pyactions) { + if (pyaction.active()) + pyaction_vector.push_back( &pyaction ); + } + return pyaction_vector; + +} + std::vector Actions::pending(std::time_t sim_time) const { std::vector action_vector; diff --git a/tests/parser/ACTIONX.cpp b/tests/parser/ACTIONX.cpp index 559350b78..5cd4f4faf 100644 --- a/tests/parser/ACTIONX.cpp +++ b/tests/parser/ACTIONX.cpp @@ -168,6 +168,12 @@ BOOST_AUTO_TEST_CASE(TestActions) { Opm::Action::ActionX action3("NAME3", 1000000, 0, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 7, 1 })) ); config.add(action3); + + Opm::Action::PyAction py_action1("PYTHON1", Opm::Action::PyAction::RunCount::single, "import sys"); + config.add(py_action1); + + Opm::Action::PyAction py_action2("PYTHON2", Opm::Action::PyAction::RunCount::single, "import sys"); + config.add(py_action2); } const Opm::Action::ActionX& action2 = config.get("NAME"); // The action2 instance has an empty condition, so it will never evaluate to true. @@ -182,6 +188,10 @@ BOOST_AUTO_TEST_CASE(TestActions) { BOOST_CHECK( !ptr->eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })), context)); } BOOST_CHECK(!action2.eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })), context)); + + + const auto& python_actions = config.pending_python(); + BOOST_CHECK_EQUAL(python_actions.size(), 2); }