From f4f163e874b187bae2f332b8e87de8b8dc844eb4 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 3 Mar 2015 16:19:05 +0100 Subject: [PATCH] Using defaultRegion for MULTREGTSCANNER --- .../eclipse/EclipseState/EclipseState.cpp | 5 +---- .../EclipseState/Grid/MULTREGTScanner.cpp | 18 +++++++++--------- .../EclipseState/Grid/MULTREGTScanner.hpp | 8 ++++---- .../Grid/tests/MULTREGTScannerTests.cpp | 14 +++++++------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 68020d36e..3621b1f13 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -403,10 +403,7 @@ namespace Opm { if (deck->hasKeyword("MULTREGT")) multregtKeywords = deck->getKeywordList("MULTREGT"); - std::shared_ptr scanner = - std::make_shared(m_intGridProperties, - multregtKeywords); - + std::shared_ptr scanner = std::make_shared(m_intGridProperties, multregtKeywords , m_defaultRegion); m_transMult->setMultregtScanner( scanner ); } diff --git a/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp b/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp index 47524e02b..51829f544 100644 --- a/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp @@ -65,10 +65,10 @@ namespace Opm { - MULTREGTRecord::MULTREGTRecord(DeckRecordConstPtr deckRecord) : + MULTREGTRecord::MULTREGTRecord(DeckRecordConstPtr deckRecord , const std::string& defaultRegion) : m_srcRegion("SRC_REGION"), m_targetRegion("TARGET_REGION"), - m_region("REGION") + m_region("REGION" , defaultRegion) { DeckItemConstPtr srcItem = deckRecord->getItem("SRC_REGION"); DeckItemConstPtr targetItem = deckRecord->getItem("TARGET_REGION"); @@ -122,11 +122,11 @@ namespace Opm { Then it will go through the different regions and looking for interface with the wanted region values. */ - MULTREGTScanner::MULTREGTScanner(std::shared_ptr > cellRegionNumbers, const std::vector& keywords ) : + MULTREGTScanner::MULTREGTScanner(std::shared_ptr > cellRegionNumbers, const std::vector& keywords , const std::string& defaultRegion ) : m_cellRegionNumbers(cellRegionNumbers) { for (size_t idx = 0; idx < keywords.size(); idx++) - addKeyword(keywords[idx]); + addKeyword(keywords[idx] , defaultRegion); MULTREGTSearchMap searchPairs; for (std::vector::const_iterator record = m_records.begin(); record != m_records.end(); ++record) { @@ -159,9 +159,9 @@ namespace Opm { } - void MULTREGTScanner::assertKeywordSupported(DeckKeywordConstPtr deckKeyword) { + void MULTREGTScanner::assertKeywordSupported(DeckKeywordConstPtr deckKeyword, const std::string& defaultRegion) { for (auto iter = deckKeyword->begin(); iter != deckKeyword->end(); ++iter) { - MULTREGTRecord record( *iter ); + MULTREGTRecord record( *iter , defaultRegion); if (record.m_nncBehaviour == MULTREGT::NOAQUNNC) throw std::invalid_argument("Sorry - currently we do not support \'NOAQUNNC\' for MULTREGT."); @@ -180,11 +180,11 @@ namespace Opm { - void MULTREGTScanner::addKeyword(DeckKeywordConstPtr deckKeyword) { - assertKeywordSupported( deckKeyword ); + void MULTREGTScanner::addKeyword(DeckKeywordConstPtr deckKeyword , const std::string& defaultRegion) { + assertKeywordSupported( deckKeyword , defaultRegion ); for (auto iter = deckKeyword->begin(); iter != deckKeyword->end(); ++iter) { - MULTREGTRecord record( *iter ); + MULTREGTRecord record( *iter , defaultRegion ); /* The default value for the region item is to use the region item on the previous record, or alternatively diff --git a/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp b/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp index d01df43a0..ac1b17263 100644 --- a/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp @@ -48,7 +48,7 @@ namespace Opm { class MULTREGTRecord { public: - MULTREGTRecord(DeckRecordConstPtr deckRecord); + MULTREGTRecord(DeckRecordConstPtr deckRecord , const std::string& defaultRegion); Value m_srcRegion; Value m_targetRegion; @@ -66,12 +66,12 @@ namespace Opm { class MULTREGTScanner { public: - MULTREGTScanner(std::shared_ptr > cellRegionNumbers, const std::vector& keywords); + MULTREGTScanner(std::shared_ptr > cellRegionNumbers, const std::vector& keywords, const std::string& defaultRegion); double getRegionMultiplier(size_t globalCellIdx1, size_t globalCellIdx2, FaceDir::DirEnum faceDir) const; private: - void addKeyword(DeckKeywordConstPtr deckKeyword); - void assertKeywordSupported(DeckKeywordConstPtr deckKeyword); + void addKeyword(DeckKeywordConstPtr deckKeyword , const std::string& defaultRegion); + void assertKeywordSupported(DeckKeywordConstPtr deckKeyword , const std::string& defaultRegion); std::vector< MULTREGTRecord > m_records; std::map m_searchMap; std::shared_ptr > m_cellRegionNumbers; diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp index eb116cbad..2dea2a25c 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp @@ -116,19 +116,19 @@ BOOST_AUTO_TEST_CASE(InvalidInput) { std::vector keywords0; Opm::DeckKeywordConstPtr multregtKeyword0 = deck->getKeyword("MULTREGT",0); keywords0.push_back( multregtKeyword0 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords0); , std::invalid_argument); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords0,"MULTNUM"); , std::invalid_argument); // Not supported region std::vector keywords1; Opm::DeckKeywordConstPtr multregtKeyword1 = deck->getKeyword("MULTREGT",1); keywords1.push_back( multregtKeyword1 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords1); , std::invalid_argument); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords1,"MULTNUM"); , std::invalid_argument); // The keyword is ok; but it refers to a region which is not in the deck. std::vector keywords2; Opm::DeckKeywordConstPtr multregtKeyword2 = deck->getKeyword("MULTREGT",2); keywords2.push_back( multregtKeyword2 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords2); , std::logic_error); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords2,"MULTNUM"); , std::logic_error); } @@ -182,26 +182,26 @@ BOOST_AUTO_TEST_CASE(NotSupported) { std::vector keywords0; Opm::DeckKeywordConstPtr multregtKeyword0 = deck->getKeyword("MULTREGT",0); keywords0.push_back( multregtKeyword0 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords0); , std::invalid_argument); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords0,"MULTNUM"); , std::invalid_argument); // Defaulted from value - not supported std::vector keywords1; Opm::DeckKeywordConstPtr multregtKeyword1 = deck->getKeyword("MULTREGT",1); keywords1.push_back( multregtKeyword1 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords1); , std::invalid_argument); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords1,"MULTNUM"); , std::invalid_argument); // Defaulted to value - not supported std::vector keywords2; Opm::DeckKeywordConstPtr multregtKeyword2 = deck->getKeyword("MULTREGT",2); keywords2.push_back( multregtKeyword2 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords2); , std::invalid_argument); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords2,"MULTNUM"); , std::invalid_argument); // srcValue == targetValue - not supported std::vector keywords3; Opm::DeckKeywordConstPtr multregtKeyword3 = deck->getKeyword("MULTREGT",3); keywords3.push_back( multregtKeyword3 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords3); , std::invalid_argument); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords3 , "MULTNUM"); , std::invalid_argument); }