From 4b36741f3366e4c4519e37f29265e43562ee153c Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 28 Apr 2023 09:25:43 +0200 Subject: [PATCH] Rename BC to BCPROP and add error message for BC --- CMakeLists_files.cmake | 4 +- .../eclipse/Schedule/{BC.hpp => BCProp.hpp} | 18 ++++---- opm/input/eclipse/Schedule/Schedule.hpp | 2 +- opm/input/eclipse/Schedule/ScheduleState.hpp | 6 +-- .../SimulationConfig/BCConfig.cpp | 13 ++++++ .../eclipse/Schedule/{BC.cpp => BCProp.cpp} | 30 +++++++------- .../eclipse/Schedule/KeywordHandlers.cpp | 8 ++-- .../input/eclipse/share/keywords/900_OPM/B/BC | 28 ++++++++++++- .../eclipse/share/keywords/900_OPM/B/BCPROP | 38 +++++++++++++++++ .../eclipse/share/keywords/keyword_list.cmake | 1 + tests/parser/ScheduleTests.cpp | 21 ++-------- tests/parser/SimulationConfigTest.cpp | 41 +++++++++++++++++++ 12 files changed, 157 insertions(+), 53 deletions(-) rename opm/input/eclipse/Schedule/{BC.hpp => BCProp.hpp} (87%) rename src/opm/input/eclipse/Schedule/{BC.cpp => BCProp.cpp} (82%) create mode 100644 src/opm/input/eclipse/share/keywords/900_OPM/B/BCPROP diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 64145d5e8..c1987eedf 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -161,7 +161,7 @@ if(ENABLE_ECL_INPUT) src/opm/input/eclipse/Schedule/Action/State.cpp src/opm/input/eclipse/Schedule/Action/WGNames.cpp src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp - src/opm/input/eclipse/Schedule/BC.cpp + src/opm/input/eclipse/Schedule/BCProp.cpp src/opm/input/eclipse/Schedule/CompletedCells.cpp src/opm/input/eclipse/Schedule/eval_uda.cpp src/opm/input/eclipse/Schedule/Events.cpp @@ -1210,7 +1210,7 @@ if(ENABLE_ECL_INPUT) opm/input/eclipse/Schedule/Action/State.hpp opm/input/eclipse/Schedule/Action/WGNames.hpp opm/input/eclipse/Schedule/ArrayDimChecker.hpp - opm/input/eclipse/Schedule/BC.hpp + opm/input/eclipse/Schedule/BCProp.hpp opm/input/eclipse/Schedule/GasLiftOpt.hpp opm/input/eclipse/Schedule/Network/Balance.hpp opm/input/eclipse/Schedule/Network/Branch.hpp diff --git a/opm/input/eclipse/Schedule/BC.hpp b/opm/input/eclipse/Schedule/BCProp.hpp similarity index 87% rename from opm/input/eclipse/Schedule/BC.hpp rename to opm/input/eclipse/Schedule/BCProp.hpp index b5afa2877..abad52d31 100644 --- a/opm/input/eclipse/Schedule/BC.hpp +++ b/opm/input/eclipse/Schedule/BCProp.hpp @@ -18,8 +18,8 @@ along with OPM. If not, see . */ -#ifndef OPM_BC_HPP -#define OPM_BC_HPP +#ifndef OPM_BC_PROP_HPP +#define OPM_BC_PROP_HPP #include #include @@ -53,7 +53,7 @@ enum class BCComponent { }; -class BCVAL { +class BCPROP { public: struct BCFace { @@ -84,18 +84,18 @@ public: }; - BCVAL() = default; - explicit BCVAL(const Deck& deck); + BCPROP() = default; + explicit BCPROP(const Deck& deck); - static BCVAL serializationTestObject(); + static BCPROP serializationTestObject(); std::size_t size() const; std::vector::const_iterator begin() const; std::vector::const_iterator end() const; - bool operator==(const BCVAL& other) const; - BCFace operator[](std::size_t index) const; + bool operator==(const BCPROP& other) const; + BCFace operator[](int index) const; - void updateBC(const DeckRecord& record); + void updateBCProp(const DeckRecord& record); template void serializeOp(Serializer& serializer) diff --git a/opm/input/eclipse/Schedule/Schedule.hpp b/opm/input/eclipse/Schedule/Schedule.hpp index a135b074b..e140eb75d 100644 --- a/opm/input/eclipse/Schedule/Schedule.hpp +++ b/opm/input/eclipse/Schedule/Schedule.hpp @@ -679,7 +679,7 @@ namespace Opm void handleAQUCT (HandlerContext&); void handleAQUFETP (HandlerContext&); void handleAQUFLUX (HandlerContext&); - void handleBC (HandlerContext&); + void handleBCProp (HandlerContext&); void handleBRANPROP (HandlerContext&); void handleCOMPDAT (HandlerContext&); void handleCOMPLUMP (HandlerContext&); diff --git a/opm/input/eclipse/Schedule/ScheduleState.hpp b/opm/input/eclipse/Schedule/ScheduleState.hpp index b0dc4c0b7..6bd65b0e0 100644 --- a/opm/input/eclipse/Schedule/ScheduleState.hpp +++ b/opm/input/eclipse/Schedule/ScheduleState.hpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -483,7 +483,7 @@ namespace Opm { map_member wells; // constant flux aquifers std::unordered_map aqufluxs; - BCVAL bc; + BCPROP bcprop; std::unordered_map target_wellpi; std::optional next_tstep; @@ -512,7 +512,7 @@ namespace Opm { serializer(m_whistctl_mode); serializer(target_wellpi); serializer(aqufluxs); - serializer(bc); + serializer(bcprop); } diff --git a/src/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.cpp b/src/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.cpp index 9119a8851..0aef552f1 100644 --- a/src/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.cpp +++ b/src/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.cpp @@ -22,6 +22,8 @@ #include #include #include +#include + namespace Opm { @@ -85,6 +87,17 @@ bool BCConfig::BCFace::operator==(const BCConfig::BCFace& other) const { BCConfig::BCConfig(const Deck& deck) { + + if(deck.hasKeyword()){ + for (const auto* keyword : deck.getKeywordList()) { + const std::string reason = "ERROR: The BC keyword is obsolute. \n " + "Instead use BCCON in the GRID section to specify the connections. \n " + "And BCPROP in the SCHEDULE section to specify the type and values. \n" + "Check the OPM manual for details."; + throw OpmInputError { reason, keyword->location()}; + } + } + GridDims grid( deck ); for (const auto& kw: deck.getKeywordList()) { for (const auto& record : *kw) diff --git a/src/opm/input/eclipse/Schedule/BC.cpp b/src/opm/input/eclipse/Schedule/BCProp.cpp similarity index 82% rename from src/opm/input/eclipse/Schedule/BC.cpp rename to src/opm/input/eclipse/Schedule/BCProp.cpp index ac984c2f7..7440354df 100644 --- a/src/opm/input/eclipse/Schedule/BC.cpp +++ b/src/opm/input/eclipse/Schedule/BCProp.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include namespace Opm { namespace { @@ -74,8 +74,8 @@ BCComponent component(const std::string& s) { } } -using BCKEY = ParserKeywords::BC; -BCVAL::BCFace::BCFace(const DeckRecord& record) : +using BCKEY = ParserKeywords::BCPROP; +BCPROP::BCFace::BCFace(const DeckRecord& record) : index(record.getItem().get(0)), bctype(fromstring::bctype(record.getItem().get(0))), component(fromstring::component(record.getItem().get(0))), @@ -89,7 +89,7 @@ BCVAL::BCFace::BCFace(const DeckRecord& record) : } } -BCVAL::BCFace BCVAL::BCFace::serializationTestObject() +BCPROP::BCFace BCPROP::BCFace::serializationTestObject() { BCFace result; result.index = 100; @@ -103,7 +103,7 @@ BCVAL::BCFace BCVAL::BCFace::serializationTestObject() } -bool BCVAL::BCFace::operator==(const BCVAL::BCFace& other) const { +bool BCPROP::BCFace::operator==(const BCPROP::BCFace& other) const { return this->index == other.index && this->bctype == other.bctype && this->component == other.component && @@ -114,12 +114,12 @@ bool BCVAL::BCFace::operator==(const BCVAL::BCFace& other) const { -BCVAL::BCVAL(const Deck& /*deck*/) { +BCPROP::BCPROP(const Deck& /*deck*/) { // TODO Read the indices from BCCON and initial with NONE type??? } -void BCVAL::updateBC(const DeckRecord& record) { - const BCVAL::BCFace bcnew( record ); +void BCPROP::updateBCProp(const DeckRecord& record) { + const BCPROP::BCFace bcnew( record ); for (auto& bc : m_faces) { if (bc.index == bcnew.index) { @@ -132,28 +132,28 @@ void BCVAL::updateBC(const DeckRecord& record) { -BCVAL BCVAL::serializationTestObject() +BCPROP BCPROP::serializationTestObject() { - BCVAL result; + BCPROP result; result.m_faces = {BCFace::serializationTestObject()}; return result; } -std::size_t BCVAL::size() const { +std::size_t BCPROP::size() const { return this->m_faces.size(); } -std::vector::const_iterator BCVAL::begin() const { +std::vector::const_iterator BCPROP::begin() const { return this->m_faces.begin(); } -std::vector::const_iterator BCVAL::end() const { +std::vector::const_iterator BCPROP::end() const { return this->m_faces.end(); } -BCVAL::BCFace BCVAL::operator[](std::size_t index) const { +BCPROP::BCFace BCPROP::operator[](int index) const { for (auto& bc : m_faces) { if (bc.index == index) { @@ -164,7 +164,7 @@ BCVAL::BCFace BCVAL::operator[](std::size_t index) const { return this->m_faces[0]; } -bool BCVAL::operator==(const BCVAL& other) const { +bool BCPROP::operator==(const BCPROP& other) const { return this->m_faces == other.m_faces; } diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index 9c6f1839f..b10ea759f 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -145,10 +145,10 @@ namespace { } } - void Schedule::handleBC(Schedule::HandlerContext& handlerContext) { - auto& bc = this->snapshots.back().bc; + void Schedule::handleBCProp(Schedule::HandlerContext& handlerContext) { + auto& bcprop = this->snapshots.back().bcprop; for (const auto& record : handlerContext.keyword) { - bc.updateBC(record); + bcprop.updateBCProp(record); } } @@ -2473,7 +2473,7 @@ Well{0} entered with 'FIELD' parent group: { "AQUCT", &Schedule::handleAQUCT }, { "AQUFETP", &Schedule::handleAQUFETP }, { "AQUFLUX", &Schedule::handleAQUFLUX }, - { "BC", &Schedule::handleBC }, + { "BCPROP", &Schedule::handleBCProp }, { "BOX", &Schedule::handleGEOKeyword}, { "BRANPROP", &Schedule::handleBRANPROP }, { "COMPDAT" , &Schedule::handleCOMPDAT }, diff --git a/src/opm/input/eclipse/share/keywords/900_OPM/B/BC b/src/opm/input/eclipse/share/keywords/900_OPM/B/BC index eb398890c..8326aaeec 100644 --- a/src/opm/input/eclipse/share/keywords/900_OPM/B/BC +++ b/src/opm/input/eclipse/share/keywords/900_OPM/B/BC @@ -1,13 +1,37 @@ { "name": "BC", "sections": [ - "SCHEDULE" + "SOLUTION" ], "items": [ { - "name": "INDEX", + "name": "I1", "value_type": "INT" }, + { + "name": "I2", + "value_type": "INT" + }, + { + "name": "J1", + "value_type": "INT" + }, + { + "name": "J2", + "value_type": "INT" + }, + { + "name": "K1", + "value_type": "INT" + }, + { + "name": "K2", + "value_type": "INT" + }, + { + "name": "DIRECTION", + "value_type": "STRING" + }, { "name": "TYPE", "value_type": "STRING" diff --git a/src/opm/input/eclipse/share/keywords/900_OPM/B/BCPROP b/src/opm/input/eclipse/share/keywords/900_OPM/B/BCPROP new file mode 100644 index 000000000..2f0ffd28b --- /dev/null +++ b/src/opm/input/eclipse/share/keywords/900_OPM/B/BCPROP @@ -0,0 +1,38 @@ +{ + "name": "BCPROP", + "sections": [ + "SCHEDULE" + ], + "items": [ + { + "name": "INDEX", + "value_type": "INT" + }, + { + "name": "TYPE", + "value_type": "STRING" + }, + { + "name": "COMPONENT", + "value_type": "STRING", + "default": "NONE" + }, + { + "name": "RATE", + "value_type": "DOUBLE", + "dimension": "Mass/Time*Length*Length", + "default": 0 + }, + { + "name": "PRESSURE", + "value_type": "DOUBLE", + "dimension": "Pressure", + "default": 1 + }, + { + "name": "TEMPERATURE", + "value_type": "DOUBLE", + "dimension": "Temperature" + } + ] +} diff --git a/src/opm/input/eclipse/share/keywords/keyword_list.cmake b/src/opm/input/eclipse/share/keywords/keyword_list.cmake index 4bd13472b..f5f77c0d5 100644 --- a/src/opm/input/eclipse/share/keywords/keyword_list.cmake +++ b/src/opm/input/eclipse/share/keywords/keyword_list.cmake @@ -1105,6 +1105,7 @@ set( keywords 900_OPM/B/BC 900_OPM/B/BCCON + 900_OPM/B/BCPROP 900_OPM/C/CO2STOR 900_OPM/C/COMPTRAJ 900_OPM/D/DISGASW diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index 24a6d7e1a..d7452d47e 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -5442,22 +5442,11 @@ BOOST_AUTO_TEST_CASE(createDeckWithBC) { START -- 0 19 JUN 2007 / -DIMENS - 20 1 10 / - -GRID - -BCCON -1 1 1 1 1 1 10 X- / -2 20 20 1 1 6 10 X / -/ - SOLUTION - SCHEDULE -BC +BCPROP 1 RATE GAS 100.0 / 2 FREE / / @@ -5465,18 +5454,16 @@ BC DATES -- 1 10 OKT 2008 / / -BC +BCPROP 1 RATE GAS 200.0 / 2 FREE 4* / / )"; const auto& schedule = make_schedule(input); - const auto& deck = Parser{}.parseString(input); - BCConfig bcconfig(deck); { size_t currentStep = 0; - const auto& bc = schedule[currentStep].bc; + const auto& bc = schedule[currentStep].bcprop; BOOST_CHECK_EQUAL(bc.size(), 2); const auto& bcface0 = bc[0]; BOOST_CHECK_CLOSE(bcface0.rate * 3600 * 24, 100, 1e-8 ); @@ -5484,7 +5471,7 @@ BC { size_t currentStep = 1; - const auto& bc = schedule[currentStep].bc; + const auto& bc = schedule[currentStep].bcprop; BOOST_CHECK_EQUAL(bc.size(), 2); const auto& bcface0 = bc[0]; BOOST_CHECK_CLOSE(bcface0.rate * 3600 * 24, 200, 1e-8 ); diff --git a/tests/parser/SimulationConfigTest.cpp b/tests/parser/SimulationConfigTest.cpp index 30dc78e7c..41375b6c0 100644 --- a/tests/parser/SimulationConfigTest.cpp +++ b/tests/parser/SimulationConfigTest.cpp @@ -119,6 +119,30 @@ GRID REGIONS )"; +const std::string& inputStr_bc = R"( +RUNSPEC +DIMENS + 10 3 4 / +GRID +SOLUTION +BC +1 1 1 1 1 10 X- FREE GAS/ +/ +REGIONS +)"; + +const std::string& inputStr_bccon = R"( +RUNSPEC +DIMENS + 10 3 4 / +GRID +BCCON +1 1 1 1 1 1 1 X- / +2 10 10 4* X / +/ +REGIONS +)"; + namespace { std::string simDeckStringTEMP() { @@ -150,6 +174,23 @@ static Deck createDeck(const std::string& input) { return parser.parseString(input); } +BOOST_AUTO_TEST_CASE(SimulationConfigBCCON) { + auto deck = createDeck(inputStr_bccon); + BCConfig bcconfig(deck); + std::vector i1s = { 1, 10}; + std::vector k2s = { 1, 4}; + std::vector dirs = { Opm::FaceDir::XMinus , Opm::FaceDir::XPlus}; + for (const auto bc : bcconfig) { + BOOST_CHECK(bc.i1 == (i1s[bc.index - 1 ]) - 1); + BOOST_CHECK(bc.k2 == (k2s[bc.index - 1 ]) - 1); + BOOST_CHECK(bc.dir == dirs[bc.index -1 ]); + } + +} +BOOST_AUTO_TEST_CASE(SimulationConfigBC) { + BOOST_CHECK_THROW( BCConfig(createDeck(inputStr_bc)), OpmInputError ); +} + BOOST_AUTO_TEST_CASE(SimulationConfigGetThresholdPressureTableTest) { auto deck = createDeck(inputStr);