diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 9e8f19c4c..8a91f0edd 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -80,6 +80,7 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.cpp + src/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionParser.cpp @@ -528,6 +529,7 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp + opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.hpp opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp diff --git a/opm/parser/eclipse/EclipseState/Runspec.hpp b/opm/parser/eclipse/EclipseState/Runspec.hpp index 52c60d35d..78444a2f6 100644 --- a/opm/parser/eclipse/EclipseState/Runspec.hpp +++ b/opm/parser/eclipse/EclipseState/Runspec.hpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace Opm { class Deck; @@ -171,6 +172,7 @@ public: const WellSegmentDims& wellSegmentDimensions() const noexcept; int eclPhaseMask( ) const noexcept; const EclHysterConfig& hysterPar() const noexcept; + const Actdims& actdims() const noexcept; private: Phases active_phases; @@ -180,6 +182,7 @@ private: WellSegmentDims wsegdims; UDQParams udq_params; EclHysterConfig hystpar; + Actdims m_actdims; }; diff --git a/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.hpp b/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.hpp new file mode 100644 index 000000000..1fae0e831 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.hpp @@ -0,0 +1,46 @@ +/* + Copyright 2019 Equinor 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 ACTDIMS_HPP_ +#define ACTDIMS_HPP_ + +#include + +namespace Opm { +class Actdims { +public: + Actdims(); + explicit Actdims(const Deck& deck); + + std::size_t max_keywords() const; + std::size_t max_line_count() const; + std::size_t max_characters() const; + std::size_t max_conditions() const; + +private: + std::size_t keywords; + std::size_t line_count; + std::size_t characters; + std::size_t conditions; +}; + +} + +#endif diff --git a/src/opm/parser/eclipse/EclipseState/Runspec.cpp b/src/opm/parser/eclipse/EclipseState/Runspec.cpp index cde1489a1..b86839c1f 100644 --- a/src/opm/parser/eclipse/EclipseState/Runspec.cpp +++ b/src/opm/parser/eclipse/EclipseState/Runspec.cpp @@ -209,7 +209,8 @@ Runspec::Runspec( const Deck& deck ) : welldims( deck ), wsegdims( deck ), udq_params( deck ), - hystpar( deck ) + hystpar( deck ), + m_actdims( deck ) {} const Phases& Runspec::phases() const noexcept { @@ -220,6 +221,10 @@ const Tabdims& Runspec::tabdims() const noexcept { return this->m_tabdims; } +const Actdims& Runspec::actdims() const noexcept { + return this->m_actdims; +} + const EndpointScaling& Runspec::endpointScaling() const noexcept { return this->endscale; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.cpp new file mode 100644 index 000000000..4fc898907 --- /dev/null +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actdims.cpp @@ -0,0 +1,64 @@ +/* + Copyright 2019 Equinor 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 { + +Actdims::Actdims(): + keywords(ParserKeywords::ACTDIMS::MAX_ACTION::defaultValue), + line_count(ParserKeywords::ACTDIMS::MAX_ACTION_LINES::defaultValue), + characters(ParserKeywords::ACTDIMS::MAX_ACTION_LINE_CHARACTERS::defaultValue), + conditions(ParserKeywords::ACTDIMS::MAX_ACTION_COND::defaultValue) +{} + + +Actdims::Actdims(const Deck& deck) + : Actdims() +{ + if (deck.hasKeyword()) { + const auto& keyword = deck.getKeyword(); + const auto& record = keyword.getRecord(0); + + this->keywords = record.getItem().get(0); + this->line_count = record.getItem().get(0); + this->characters = record.getItem().get(0); + this->conditions = record.getItem().get(0); + } +} + +std::size_t Actdims::max_keywords() const { + return this->keywords; +} + +std::size_t Actdims::max_line_count() const { + return this->line_count; +} + +std::size_t Actdims::max_characters() const { + return this->characters; +} + +std::size_t Actdims::max_conditions() const { + return this->conditions; +} + + +} diff --git a/tests/parser/RunspecTests.cpp b/tests/parser/RunspecTests.cpp index d53e39db9..ab2e3edd6 100644 --- a/tests/parser/RunspecTests.cpp +++ b/tests/parser/RunspecTests.cpp @@ -571,4 +571,23 @@ BOOST_AUTO_TEST_CASE(Foam) { BOOST_CHECK( phases.active( Phase::WATER ) ); BOOST_CHECK( phases.active( Phase::FOAM) ); + // not in deck - default constructor. + const auto& actdims = runspec.actdims(); + BOOST_CHECK_EQUAL(actdims.max_keywords(), 2); +} + +BOOST_AUTO_TEST_CASE(ACTDIMS) { + const std::string input = R"( + RUNSPEC + ACTDIMS + 2* 13 14 / + )"; + + Parser parser; + auto deck = parser.parseString(input); + + Runspec runspec( deck ); + const auto& actdims = runspec.actdims(); + BOOST_CHECK_EQUAL(actdims.max_keywords(), 2); + BOOST_CHECK_EQUAL(actdims.max_conditions(), 14); }