diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 51c5202ca..921b502d6 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -73,6 +73,7 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp src/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp src/opm/parser/eclipse/EclipseState/Runspec.cpp + src/opm/parser/eclipse/EclipseState/Schedule/ActionX.cpp src/opm/parser/eclipse/EclipseState/Schedule/Connection.cpp src/opm/parser/eclipse/EclipseState/Schedule/WellConnections.cpp src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp @@ -173,6 +174,7 @@ list (APPEND TEST_SOURCE_FILES ) if(ENABLE_ECL_INPUT) list(APPEND TEST_SOURCE_FILES + tests/parser/ACTIONX.cpp tests/parser/ADDREGTests.cpp tests/parser/AquiferCTTests.cpp tests/parser/AqudimsTests.cpp @@ -443,6 +445,7 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/EclipseConfig.hpp opm/parser/eclipse/EclipseState/Aquancon.hpp opm/parser/eclipse/EclipseState/AquiferCT.hpp + opm/parser/eclipse/EclipseState/Schedule/ActionX.hpp opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp diff --git a/opm/parser/eclipse/EclipseState/Schedule/ActionX.hpp b/opm/parser/eclipse/EclipseState/Schedule/ActionX.hpp new file mode 100644 index 000000000..92b946251 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Schedule/ActionX.hpp @@ -0,0 +1,68 @@ +/* + Copyright 2013 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + + +#ifndef ActionX_HPP_ +#define ActionX_HPP_ + +#include + +namespace Opm { +/* + The ActionX class internalizes the ACTIONX keyword. This keyword represents a + small in-deck programming language for the SCHEDULE section. In the deck the + ACTIONX keyword comes together with a 'ENDACTIO' kewyord and then a list of + regular keywords in the between. The principle is then that ACTIONX represents + a condition, and when that condition is satisfied the keywords are applied. In + the example below the ACTIONX keyword defines a condition whether well OPX has + watercut above 0.75, when the condition is met the WELOPEN keyword is applied + - and the well is shut. + + ACTIONX + 'NAME' / + WWCT OPX > 0.50 / + / + + WELOPEN + 'OPX' OPEN / + / + + ENDACTION + + +*/ + +class DeckKeyword; + +class ActionX { +public: + ActionX(const std::string& name, size_t max_run, double max_wait); + explicit ActionX(const DeckKeyword& kw); + + const std::string& name() const; +private: + std::string m_name; + size_t max_run; + double max_wait; + + std::vector keywords; +}; + +} +#endif /* WELL_HPP_ */ diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/ActionX.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/ActionX.cpp new file mode 100644 index 000000000..fe7a62e8b --- /dev/null +++ b/src/opm/parser/eclipse/EclipseState/Schedule/ActionX.cpp @@ -0,0 +1,50 @@ +/* + Copyright 2018 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#include +#include + + +namespace Opm { + +ActionX::ActionX(const std::string& name, size_t max_run, double max_wait) : + m_name(name), + max_run(max_run), + max_wait(max_wait) +{} + + +ActionX::ActionX(const DeckKeyword& kw) { + const auto& record = kw.getRecord(0); + this->m_name = record.getItem("NAME").getTrimmedString(0); + this->max_run = record.getItem("NUM").get(0); + this->max_wait = record.getItem("MAX_WAIT").getSIDouble(0); +} + + +void ActionX::addKeyword(const DeckKeyword& kw) { + this->keywords.push_back(kw); +} + + +const std::string& ActionX::name() const { + return this->m_name; +} + +} diff --git a/tests/parser/ACTIONX.cpp b/tests/parser/ACTIONX.cpp new file mode 100644 index 000000000..9c1b432de --- /dev/null +++ b/tests/parser/ACTIONX.cpp @@ -0,0 +1,54 @@ +/* + Copyright 2018 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#include +#include +#include + +#define BOOST_TEST_MODULE ACTIONX + +#include +#include + +#include +#include +#include +#include + +using namespace Opm; + + + + +BOOST_AUTO_TEST_CASE(Create) { + const auto action_kw = std::string{ R"( +ACTIONX + 'ACTION' / + WWCT OPX > 0.75 / +/ +)"}; + ActionX action1("NAME", 10, 100); + BOOST_CHECK_EQUAL(action1.name(), "NAME"); + + const auto deck = Parser{}.parseString( action_kw ); + const auto& kw = deck.getKeyword("ACTIONX"); + + ActionX action2(kw); + BOOST_CHECK_EQUAL(action2.name(), "ACTION"); +}