From 442cdafeda36ff9f5a1fa9ae7a7ec628fa478e62 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Mon, 15 Feb 2016 12:45:12 +0100 Subject: [PATCH] EclipseState: make the grid properties returned by get*GridProperty() constant that's because they are not supposed to be modified outside of the EclipseState. (if they are, why? I'd consider that *very* bad style since it is also possible to copy these objects and modify the copy and also this was used nowhere within the OPM project.) also, the has*Property() is now working as expected: if e.g., ```c++ bool hasSatnum = eclipseState->hasIntProperty("SATNUM"); eclipseState->getIntProperty("SATNUM"); assert(hasSatnum == eclipseState->hasIntProperty("SATNUM")); ``` will now work for decks which does not explicitly specify SATNUM. (before the getIntProperty() method silently created the SATNUM property which caused hasIntProperty() to change its opinion. With this patch, the property will still be silently created, but has*Property() ignores it, i.e., that method could be renamed to hasExplicit*Property() which -- as far as I understand this -- was its intention from start.) --- .../eclipse/EclipseState/EclipseState.cpp | 145 ++++++++++-------- .../eclipse/EclipseState/EclipseState.hpp | 12 +- .../EclipseState/Grid/GridProperties.hpp | 50 ++++-- .../EclipseState/Grid/GridProperty.hpp | 2 +- .../EclipseState/Grid/MULTREGTScanner.cpp | 2 +- .../EclipseState/Grid/tests/ADDREGTests.cpp | 4 +- .../EclipseState/Grid/tests/CopyRegTests.cpp | 2 +- .../EclipseState/Grid/tests/EqualRegTests.cpp | 8 +- .../Grid/tests/GridPropertiesTests.cpp | 14 ++ .../EclipseState/Grid/tests/MultiRegTests.cpp | 2 +- .../EclipseState/tests/EclipseStateTests.cpp | 6 +- .../eclipse/IntegrationTests/BoxTest.cpp | 18 +-- 12 files changed, 163 insertions(+), 102 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 692e02ddb..d8a929a13 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -80,7 +80,7 @@ namespace Opm { { } - void apply(std::vector& ) const { + void apply(std::vector& values) const { EclipseGridConstPtr grid = m_eclipseState.getEclipseGrid(); /* Observe that this apply method does not alter the @@ -93,21 +93,24 @@ namespace Opm { auto ntg = m_eclipseState.getDoubleGridProperty("NTG"); if (poro->containsNaN()) throw std::logic_error("Do not have information for the PORV keyword - some defaulted values in PORO"); - { + else { + const auto& poroData = poro->getData(); for (size_t globalIndex = 0; globalIndex < porv->getCartesianSize(); globalIndex++) { - if (std::isnan(porv->iget(globalIndex))) { - double cell_poro = poro->iget(globalIndex); + if (std::isnan(values[globalIndex])) { + double cell_poro = poroData[globalIndex]; double cell_ntg = ntg->iget(globalIndex); double cell_volume = grid->getCellVolume(globalIndex); - porv->iset( globalIndex , cell_poro * cell_volume * cell_ntg); + values[globalIndex] = cell_poro * cell_volume * cell_ntg; } } } } if (m_eclipseState.hasDoubleGridProperty("MULTPV")) { - auto multpv = m_eclipseState.getDoubleGridProperty("MULTPV"); - porv->multiplyWith( *multpv ); + auto multpvData = m_eclipseState.getDoubleGridProperty("MULTPV")->getData(); + for (size_t globalIndex = 0; globalIndex < porv->getCartesianSize(); globalIndex++) { + values[globalIndex] *= multpvData[globalIndex]; + } } } @@ -452,11 +455,11 @@ namespace Opm { been explicitly added. */ - std::shared_ptr > EclipseState::getIntGridProperty( const std::string& keyword ) const { + std::shared_ptr > EclipseState::getIntGridProperty( const std::string& keyword ) const { return m_intGridProperties->getKeyword( keyword ); } - std::shared_ptr > EclipseState::getDoubleGridProperty( const std::string& keyword ) const { + std::shared_ptr > EclipseState::getDoubleGridProperty( const std::string& keyword ) const { auto gridProperty = m_doubleGridProperties->getKeyword( keyword ); if (gridProperty->postProcessorRunRequired()) gridProperty->runPostProcessor(); @@ -464,11 +467,11 @@ namespace Opm { return gridProperty; } - std::shared_ptr > EclipseState::getDefaultRegion() const { - return m_intGridProperties->getInitializedKeyword( m_defaultRegion ); + std::shared_ptr > EclipseState::getDefaultRegion() const { + return m_intGridProperties->getKeyword( m_defaultRegion ); } - std::shared_ptr > EclipseState::getRegion( const DeckItem& regionItem ) const { + std::shared_ptr > EclipseState::getRegion( const DeckItem& regionItem ) const { if (regionItem.defaultApplied(0)) return getDefaultRegion(); else { @@ -493,12 +496,12 @@ namespace Opm { const std::string& keyword = deckKeyword.name(); if (m_intGridProperties->supportsKeyword( keyword )) { if (enabledTypes & IntProperties) { - auto gridProperty = m_intGridProperties->getKeyword( keyword ); + auto gridProperty = getOrCreateIntProperty_( keyword ); gridProperty->loadFromDeckKeyword( inputBox , deckKeyword ); } } else if (m_doubleGridProperties->supportsKeyword( keyword )) { if (enabledTypes & DoubleProperties) { - auto gridProperty = m_doubleGridProperties->getKeyword( keyword ); + auto gridProperty = getOrCreateDoubleProperty_( keyword ); gridProperty->loadFromDeckKeyword( inputBox , deckKeyword ); } } else { @@ -1014,36 +1017,34 @@ namespace Opm { if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties)) throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray); - if (supportsGridProperty( targetArray , enabledTypes)) { - double doubleValue = record.getItem("VALUE").get< double >(0); - int regionValue = record.getItem("REGION_NUMBER").get< int >(0); - std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); - std::vector mask; + double doubleValue = record.getItem("VALUE").template get(0); + int regionValue = record.getItem("REGION_NUMBER").template get(0); + std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); + std::vector mask; - regionProperty->initMask( regionValue , mask); + regionProperty->initMask( regionValue , mask); - if (m_intGridProperties->supportsKeyword( targetArray )) { - if (enabledTypes & IntProperties) { - if (isInt( doubleValue )) { - std::shared_ptr > targetProperty = m_intGridProperties->getKeyword(targetArray); - int intValue = static_cast( doubleValue + 0.5 ); - targetProperty->maskedSet( intValue , mask); - } else - throw std::invalid_argument("Fatal error processing EQUALREG keyword - expected integer value for: " + targetArray); - } + if (m_intGridProperties->supportsKeyword( targetArray )) { + if (enabledTypes & IntProperties) { + if (isInt( doubleValue )) { + std::shared_ptr > targetProperty = getOrCreateIntProperty_(targetArray); + int intValue = static_cast( doubleValue + 0.5 ); + targetProperty->maskedSet( intValue , mask); + } else + throw std::invalid_argument("Fatal error processing EQUALREG keyword - expected integer value for: " + targetArray); } - else if (m_doubleGridProperties->supportsKeyword( targetArray )) { - if (enabledTypes & DoubleProperties) { - std::shared_ptr > targetProperty = m_doubleGridProperties->getKeyword(targetArray); - const std::string& dimensionString = targetProperty->getDimensionString(); - double SIValue = doubleValue * getSIScaling( dimensionString ); - targetProperty->maskedSet( SIValue , mask); - } - } - else { - throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray); + } + else if (m_doubleGridProperties->supportsKeyword( targetArray )) { + if (enabledTypes & DoubleProperties) { + std::shared_ptr > targetProperty = getOrCreateDoubleProperty_(targetArray); + const std::string& dimensionString = targetProperty->getDimensionString(); + double SIValue = doubleValue * getSIScaling( dimensionString ); + targetProperty->maskedSet( SIValue , mask); } } + else { + throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray); + } } } @@ -1059,7 +1060,7 @@ namespace Opm { if (supportsGridProperty( targetArray , enabledTypes)) { double doubleValue = record.getItem("SHIFT").get< double >(0); int regionValue = record.getItem("REGION_NUMBER").get< int >(0); - std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); + std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); std::vector mask; regionProperty->initMask( regionValue , mask); @@ -1103,29 +1104,22 @@ namespace Opm { if (supportsGridProperty( targetArray , enabledTypes)) { double doubleValue = record.getItem("FACTOR").get< double >(0); int regionValue = record.getItem("REGION_NUMBER").get< int >(0); - std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); + std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); std::vector mask; regionProperty->initMask( regionValue , mask); - if (m_intGridProperties->hasKeyword( targetArray )) { - if (enabledTypes & IntProperties) { - if (isInt( doubleValue )) { - std::shared_ptr > targetProperty = m_intGridProperties->getKeyword( targetArray ); - int intValue = static_cast( doubleValue + 0.5 ); - targetProperty->maskedMultiply( intValue , mask); - } else - throw std::invalid_argument("Fatal error processing MULTIREG keyword - expected integer value for: " + targetArray); - } + if (enabledTypes & IntProperties) { + if (isInt( doubleValue )) { + std::shared_ptr > targetProperty = getOrCreateIntProperty_( targetArray ); + int intValue = static_cast( doubleValue + 0.5 ); + targetProperty->maskedMultiply( intValue , mask); + } else + throw std::invalid_argument("Fatal error processing MULTIREG keyword - expected integer value for: " + targetArray); } - else if (m_doubleGridProperties->hasKeyword( targetArray )) { - if (enabledTypes & DoubleProperties) { - std::shared_ptr > targetProperty = m_doubleGridProperties->getKeyword(targetArray); - targetProperty->maskedMultiply( doubleValue , mask); - } - } - else { - throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + targetArray); + if (enabledTypes & DoubleProperties) { + std::shared_ptr > targetProperty = getOrCreateDoubleProperty_(targetArray); + targetProperty->maskedMultiply( doubleValue , mask); } } } @@ -1146,22 +1140,22 @@ namespace Opm { if (supportsGridProperty( srcArray , enabledTypes)) { int regionValue = record.getItem("REGION_NUMBER").get< int >(0); - std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); + std::shared_ptr > regionProperty = getRegion( record.getItem("REGION_NAME") ); std::vector mask; regionProperty->initMask( regionValue , mask ); if (m_intGridProperties->hasKeyword( srcArray )) { - std::shared_ptr > srcProperty = m_intGridProperties->getInitializedKeyword( srcArray ); + std::shared_ptr > srcProperty = m_intGridProperties->getInitializedKeyword( srcArray ); if (supportsGridProperty( targetArray , IntProperties)) { - std::shared_ptr > targetProperty = m_intGridProperties->getKeyword( targetArray ); + std::shared_ptr > targetProperty = getOrCreateIntProperty_( targetArray ); targetProperty->maskedCopy( *srcProperty , mask ); } else throw std::invalid_argument("Fatal error processing COPYREG keyword."); } else if (m_doubleGridProperties->hasKeyword( srcArray )) { - std::shared_ptr > srcProperty = m_doubleGridProperties->getInitializedKeyword( srcArray ); + std::shared_ptr > srcProperty = m_doubleGridProperties->getInitializedKeyword( srcArray ); if (supportsGridProperty( targetArray , DoubleProperties)) { - std::shared_ptr > targetProperty = m_doubleGridProperties->getKeyword( targetArray ); + std::shared_ptr > targetProperty = getOrCreateDoubleProperty_( targetArray ); targetProperty->maskedCopy( *srcProperty , mask ); } } @@ -1245,14 +1239,14 @@ namespace Opm { if (m_intGridProperties->supportsKeyword( field )) { if (enabledTypes & IntProperties) { int intValue = static_cast(value); - std::shared_ptr > property = m_intGridProperties->getKeyword( field ); + std::shared_ptr > property = getOrCreateIntProperty_( field ); property->setScalar( intValue , boxManager.getActiveBox() ); } } else if (m_doubleGridProperties->supportsKeyword( field )) { if (enabledTypes & DoubleProperties) { - std::shared_ptr > property = m_doubleGridProperties->getKeyword( field ); + std::shared_ptr > property = getOrCreateDoubleProperty_( field ); double siValue = value * getSIScaling(property->getKeywordInfo().getDimensionString()); property->setScalar( siValue , boxManager.getActiveBox() ); @@ -1289,7 +1283,7 @@ namespace Opm { void EclipseState::copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr inputBox) { std::shared_ptr > src = m_intGridProperties->getKeyword( srcField ); - std::shared_ptr > target = m_intGridProperties->getKeyword( targetField ); + std::shared_ptr > target = getOrCreateIntProperty_( targetField ); target->copyFrom( *src , inputBox ); } @@ -1297,7 +1291,7 @@ namespace Opm { void EclipseState::copyDoubleKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr inputBox) { std::shared_ptr > src = m_doubleGridProperties->getKeyword( srcField ); - std::shared_ptr > target = m_doubleGridProperties->getKeyword( targetField ); + std::shared_ptr > target = getOrCreateDoubleProperty_( targetField ); target->copyFrom( *src , inputBox ); } @@ -1397,4 +1391,21 @@ namespace Opm { } } } + + std::shared_ptr > EclipseState::getOrCreateIntProperty_(const std::string name) + { + if (!m_intGridProperties->hasKeyword(name)) { + m_intGridProperties->addKeyword(name); + } + return m_intGridProperties->getKeyword(name); + } + + std::shared_ptr > EclipseState::getOrCreateDoubleProperty_(const std::string name) + { + if (!m_doubleGridProperties->hasKeyword(name)) { + m_doubleGridProperties->addKeyword(name); + } + return m_doubleGridProperties->getKeyword(name); + } + } diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp index 59c2ed72f..692cda538 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -20,6 +20,7 @@ #ifndef OPM_ECLIPSE_STATE_HPP #define OPM_ECLIPSE_STATE_HPP +#include #include #include @@ -73,10 +74,10 @@ namespace Opm { std::string getTitle() const; bool supportsGridProperty(const std::string& keyword, int enabledTypes=AllProperties) const; - std::shared_ptr > getRegion( const DeckItem& regionItem ) const; - std::shared_ptr > getDefaultRegion() const; - std::shared_ptr > getIntGridProperty( const std::string& keyword ) const; - std::shared_ptr > getDoubleGridProperty( const std::string& keyword ) const; + std::shared_ptr > getRegion( const DeckItem& regionItem ) const; + std::shared_ptr > getDefaultRegion() const; + std::shared_ptr > getIntGridProperty( const std::string& keyword ) const; + std::shared_ptr > getDoubleGridProperty( const std::string& keyword ) const; bool hasIntGridProperty(const std::string& keyword) const; bool hasDoubleGridProperty(const std::string& keyword) const; @@ -142,6 +143,9 @@ namespace Opm { void complainAboutAmbiguousKeyword(std::shared_ptr< const Deck > deck, const std::string& keywordName) const; + std::shared_ptr > getOrCreateIntProperty_(const std::string name); + std::shared_ptr > getOrCreateDoubleProperty_(const std::string name); + std::shared_ptr< const EclipseGrid > m_eclipseGrid; std::shared_ptr< IOConfig > m_ioConfig; std::shared_ptr< const InitConfig > m_initConfig; diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp b/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp index e22d7d430..f0effaee3 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp @@ -19,7 +19,7 @@ #ifndef ECLIPSE_GRIDPROPERTIES_HPP_ #define ECLIPSE_GRIDPROPERTIES_HPP_ - +#include #include #include #include @@ -65,22 +65,21 @@ public: } bool hasKeyword(const std::string& keyword) const { - return m_properties.count( keyword ) > 0; + return m_properties.count( keyword ) > 0 && !isAutoGenerated_(keyword); } size_t size() const { return m_property_list.size(); } - - std::shared_ptr > getKeyword(const std::string& keyword) { + std::shared_ptr > getKeyword(const std::string& keyword) const { if (!hasKeyword(keyword)) - addKeyword(keyword); + addAutoGeneratedKeyword_(keyword); return m_properties.at( keyword ); } - std::shared_ptr > getKeyword(size_t index) { + std::shared_ptr > getKeyword(size_t index) const { if (index < size()) return m_property_list[index]; else @@ -107,6 +106,13 @@ public: if (hasKeyword(keywordName)) return false; else { + // if the property was already added auto generated, we just need to make it + // non-auto generated + if (m_autoGeneratedProperties_.count(keywordName)) { + m_autoGeneratedProperties_.erase(m_autoGeneratedProperties_.find(keywordName)); + return true; + } + auto supportedKeyword = m_supportedKeywords.at( keywordName ); int nx = m_eclipseGrid->getNX(); int ny = m_eclipseGrid->getNY(); @@ -126,7 +132,7 @@ public: } template - std::shared_ptr > getKeyword() { + std::shared_ptr > getKeyword() const { return getKeyword( Keyword::keywordName ); } @@ -138,10 +144,36 @@ public: private: + bool addAutoGeneratedKeyword_(const std::string& keywordName) const { + if (!supportsKeyword( keywordName )) + throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container"); + + if (m_properties.count( keywordName ) > 0) + return false; // property already exists (if it is auto generated or not doesn't matter) + else { + auto supportedKeyword = m_supportedKeywords.at( keywordName ); + int nx = m_eclipseGrid->getNX(); + int ny = m_eclipseGrid->getNY(); + int nz = m_eclipseGrid->getNZ(); + std::shared_ptr > newProperty(new GridProperty(nx , ny , nz , supportedKeyword)); + + m_autoGeneratedProperties_.insert(keywordName); + + m_properties.insert( std::pair > > ( keywordName , newProperty )); + m_property_list.push_back( newProperty ); + return true; + } + } + + bool isAutoGenerated_(const std::string& keyword) const { + return m_autoGeneratedProperties_.count(keyword); + } + std::shared_ptr m_eclipseGrid; std::unordered_map m_supportedKeywords; - std::map > > m_properties; - std::vector > > m_property_list; + mutable std::map > > m_properties; + mutable std::set m_autoGeneratedProperties_; + mutable std::vector > > m_property_list; }; } diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp b/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp index 743489816..eff8cccd5 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp @@ -262,7 +262,7 @@ public: - void initMask(T value, std::vector& mask) { + void initMask(T value, std::vector& mask) const { mask.resize(getCartesianSize()); for (size_t g = 0; g < getCartesianSize(); g++) { if (m_data[g] == value) diff --git a/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp b/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp index eb0bc871e..4b0884be5 100644 --- a/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp @@ -231,7 +231,7 @@ namespace Opm { double MULTREGTScanner::getRegionMultiplier(size_t globalIndex1 , size_t globalIndex2, FaceDir::DirEnum faceDir) const { for (auto iter = m_searchMap.begin(); iter != m_searchMap.end(); iter++) { - std::shared_ptr > region = m_cellRegionNumbers->getKeyword( (*iter).first ); + std::shared_ptr > region = m_cellRegionNumbers->getKeyword( (*iter).first ); MULTREGTSearchMap map = (*iter).second; int regionId1 = region->iget(globalIndex1); diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp index 4659fc716..7f069228c 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp @@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { BOOST_AUTO_TEST_CASE(IntSetCorrectly) { Opm::DeckPtr deck = createValidIntDeck(); Opm::EclipseState state(deck , Opm::ParseMode()); - std::shared_ptr > property = state.getIntGridProperty( "SATNUM"); + std::shared_ptr > property = state.getIntGridProperty( "SATNUM"); for (size_t j=0; j< 5; j++) for (size_t i = 0; i < 5; i++) { if (i < 2) @@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) { BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) { Opm::DeckPtr deck = createValidPERMXDeck(); Opm::EclipseState state(deck , Opm::ParseMode()); - std::shared_ptr > permx = state.getDoubleGridProperty( "PERMX"); + std::shared_ptr > permx = state.getDoubleGridProperty( "PERMX"); for (size_t j=0; j< 5; j++) for (size_t i = 0; i < 5; i++) { diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp index cda3fb579..02341c5e3 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp @@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(TypeMismatchThrows) { BOOST_AUTO_TEST_CASE(IntSetCorrectly) { Opm::DeckPtr deck = createValidIntDeck(); Opm::EclipseState state(deck , Opm::ParseMode() ); - std::shared_ptr > property = state.getIntGridProperty( "FLUXNUM"); + std::shared_ptr > property = state.getIntGridProperty( "FLUXNUM"); for (size_t j=0; j< 5; j++) for (size_t i = 0; i < 5; i++) { if (i < 2) diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp index f5913ffaf..470fb1c01 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { BOOST_AUTO_TEST_CASE(IntSetCorrectly) { Opm::DeckPtr deck = createValidIntDeck(); Opm::EclipseState state(deck , Opm::ParseMode()); - std::shared_ptr > property = state.getIntGridProperty( "SATNUM"); + std::shared_ptr > property = state.getIntGridProperty( "SATNUM"); for (size_t j=0; j< 5; j++) for (size_t i = 0; i < 5; i++) { if (i < 2) @@ -233,9 +233,9 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) { BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) { Opm::DeckPtr deck = createValidPERMXDeck(); Opm::EclipseState state(deck , Opm::ParseMode()); - std::shared_ptr > permx = state.getDoubleGridProperty( "PERMX"); - std::shared_ptr > permy = state.getDoubleGridProperty( "PERMY"); - std::shared_ptr > permz = state.getDoubleGridProperty( "PERMZ"); + std::shared_ptr > permx = state.getDoubleGridProperty( "PERMX"); + std::shared_ptr > permy = state.getDoubleGridProperty( "PERMY"); + std::shared_ptr > permz = state.getDoubleGridProperty( "PERMZ"); for (size_t g=0; g< 25; g++) { BOOST_CHECK_EQUAL( permz->iget(g), permx->iget(g)); BOOST_CHECK_EQUAL( permy->iget(g), permx->iget(g)); diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp index e69c5fafc..000a85ddd 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp @@ -76,6 +76,20 @@ BOOST_AUTO_TEST_CASE(addKeyword) { } +BOOST_AUTO_TEST_CASE(hasKeyword) { + typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; + std::shared_ptr > supportedKeywords(new std::vector{ + SupportedKeywordInfo("SATNUM" , 0, "1") + }); + std::shared_ptr grid = std::make_shared(10,7,9); + Opm::GridProperties gridProperties( grid , supportedKeywords); + + // calling getKeyword() should not change the semantics of hasKeyword()! + BOOST_CHECK(!gridProperties.hasKeyword("SATNUM")); + gridProperties.getKeyword("SATNUM"); + BOOST_CHECK(!gridProperties.hasKeyword("SATNUM")); +} + BOOST_AUTO_TEST_CASE(getKeyword) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp index 5b863800d..61d10cbc9 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { BOOST_AUTO_TEST_CASE(IntSetCorrectly) { Opm::DeckPtr deck = createValidIntDeck(); Opm::EclipseState state(deck , Opm::ParseMode()); - std::shared_ptr > property = state.getIntGridProperty( "SATNUM"); + std::shared_ptr > property = state.getIntGridProperty( "SATNUM"); for (size_t j=0; j< 5; j++) for (size_t i = 0; i < 5; i++) { if (i < 2) diff --git a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp index 1d798d2fc..c72aa6334 100644 --- a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp +++ b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -100,8 +100,8 @@ BOOST_AUTO_TEST_CASE(GetPOROTOPBased) { DeckPtr deck = createDeckTOP(); EclipseState state(deck , ParseMode()); - std::shared_ptr > poro = state.getDoubleGridProperty( "PORO" ); - std::shared_ptr > permx = state.getDoubleGridProperty( "PERMX" ); + std::shared_ptr > poro = state.getDoubleGridProperty( "PORO" ); + std::shared_ptr > permx = state.getDoubleGridProperty( "PERMX" ); BOOST_CHECK_EQUAL(1000U , poro->getCartesianSize() ); BOOST_CHECK_EQUAL(1000U , permx->getCartesianSize() ); @@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(GetProperty) { DeckPtr deck = createDeck(); EclipseState state(deck, ParseMode()); - std::shared_ptr > satNUM = state.getIntGridProperty( "SATNUM" ); + std::shared_ptr > satNUM = state.getIntGridProperty( "SATNUM" ); BOOST_CHECK_EQUAL(1000U , satNUM->getCartesianSize() ); for (size_t i=0; i < satNUM->getCartesianSize(); i++) diff --git a/opm/parser/eclipse/IntegrationTests/BoxTest.cpp b/opm/parser/eclipse/IntegrationTests/BoxTest.cpp index bbe8796c9..1fb07b32a 100644 --- a/opm/parser/eclipse/IntegrationTests/BoxTest.cpp +++ b/opm/parser/eclipse/IntegrationTests/BoxTest.cpp @@ -51,9 +51,9 @@ EclipseState makeState(const std::string& fileName) { BOOST_AUTO_TEST_CASE( PERMX ) { EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1" ); - std::shared_ptr > permx = state.getDoubleGridProperty("PERMX"); - std::shared_ptr > permy = state.getDoubleGridProperty("PERMY"); - std::shared_ptr > permz = state.getDoubleGridProperty("PERMZ"); + std::shared_ptr > permx = state.getDoubleGridProperty("PERMX"); + std::shared_ptr > permy = state.getDoubleGridProperty("PERMY"); + std::shared_ptr > permz = state.getDoubleGridProperty("PERMZ"); size_t i,j,k; std::shared_ptr grid = state.getEclipseGrid(); @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE( PERMX ) { BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) { EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1"); - std::shared_ptr > satnum = state.getIntGridProperty("SATNUM"); + std::shared_ptr > satnum = state.getIntGridProperty("SATNUM"); { size_t i,j,k; std::shared_ptr grid = state.getEclipseGrid(); @@ -97,8 +97,8 @@ BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) { BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) { EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1"); - std::shared_ptr > satnum = state.getIntGridProperty("SATNUM"); - std::shared_ptr > fipnum = state.getIntGridProperty("FIPNUM"); + std::shared_ptr > satnum = state.getIntGridProperty("SATNUM"); + std::shared_ptr > fipnum = state.getIntGridProperty("FIPNUM"); size_t i,j,k; std::shared_ptr grid = state.getEclipseGrid(); @@ -128,9 +128,9 @@ BOOST_AUTO_TEST_CASE( KEYWORD_BOX_TOO_SMALL) { BOOST_AUTO_TEST_CASE( EQUAL ) { EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1"); - std::shared_ptr > pvtnum = state.getIntGridProperty("PVTNUM"); - std::shared_ptr > eqlnum = state.getIntGridProperty("EQLNUM"); - std::shared_ptr > poro = state.getDoubleGridProperty("PORO"); + std::shared_ptr > pvtnum = state.getIntGridProperty("PVTNUM"); + std::shared_ptr > eqlnum = state.getIntGridProperty("EQLNUM"); + std::shared_ptr > poro = state.getDoubleGridProperty("PORO"); size_t i,j,k; std::shared_ptr grid = state.getEclipseGrid();