From 5b2ec6be75f5dde0110541b4eb5a8cb5d9acecfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Fri, 26 Feb 2016 23:41:33 +0100 Subject: [PATCH] GridProperties stores raw vector of keywords Changes the type of the stored supported keywords from pointer-to-vector to vector. This accomplishes the following: * we avoid an unecessary level of indirection * we enable initializer list syntax for tests etc. * GridProperties' interface properly communicates that it takes over ownership of the passed keywords. * it feels more natural in use as generating and returning a vector in a free function can be returned and directly passed to the constructor (the motivation for this change). Bundled with this is the move of the supported keyword population into using loops to exploit the similarities of families of keywords w.r.t. GridProperties representation. --- .../eclipse/EclipseState/EclipseState.cpp | 497 ++++++------------ .../EclipseState/Grid/GridProperties.hpp | 6 +- .../Grid/tests/GridPropertiesTests.cpp | 28 +- .../Grid/tests/GridPropertyTests.cpp | 5 +- .../Grid/tests/MULTREGTScannerTests.cpp | 14 +- .../tests/SimulationConfigTest.cpp | 6 +- .../tests/ThresholdPressureTest.cpp | 5 +- 7 files changed, 194 insertions(+), 367 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 4e8967612..c8e47065f 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -512,395 +512,222 @@ namespace Opm { } } + static std::vector< GridProperties< int >::SupportedKeywordInfo > + makeSupportedIntKeywords() { + return { GridProperties< int >::SupportedKeywordInfo( "SATNUM" , 1, "1" ), + GridProperties< int >::SupportedKeywordInfo( "IMBNUM" , 1, "1" ), + GridProperties< int >::SupportedKeywordInfo( "PVTNUM" , 1, "1" ), + GridProperties< int >::SupportedKeywordInfo( "EQLNUM" , 1, "1" ), + GridProperties< int >::SupportedKeywordInfo( "ENDNUM" , 1, "1" ), + GridProperties< int >::SupportedKeywordInfo( "FLUXNUM" , 1 , "1" ), + GridProperties< int >::SupportedKeywordInfo( "MULTNUM", 1 , "1" ), + GridProperties< int >::SupportedKeywordInfo( "FIPNUM" , 1, "1" ), + GridProperties< int >::SupportedKeywordInfo( "MISCNUM", 1, "1" ) + }; + } - void EclipseState::initProperties(DeckConstPtr deck) { - typedef GridProperties::SupportedKeywordInfo SupportedIntKeywordInfo; - std::shared_ptr > supportedIntKeywords(new std::vector{ - SupportedIntKeywordInfo( "SATNUM" , 1, "1" ), - SupportedIntKeywordInfo( "IMBNUM" , 1, "1" ), - SupportedIntKeywordInfo( "PVTNUM" , 1, "1" ), - SupportedIntKeywordInfo( "EQLNUM" , 1, "1" ), - SupportedIntKeywordInfo( "ENDNUM" , 1, "1" ), - SupportedIntKeywordInfo( "FLUXNUM" , 1 , "1" ), - SupportedIntKeywordInfo( "MULTNUM", 1 , "1" ), - SupportedIntKeywordInfo( "FIPNUM" , 1, "1" ), - SupportedIntKeywordInfo( "MISCNUM", 1, "1" ) - }); + static std::vector< GridProperties< double >::SupportedKeywordInfo > + makeSupportedDoubleKeywords(const Deck& deck, const EclipseState& es) { + const auto SGLLookup = std::make_shared>(deck, es); + const auto ISGLLookup = std::make_shared>(deck, es); + const auto SWLLookup = std::make_shared>(deck, es); + const auto ISWLLookup = std::make_shared>(deck, es); + const auto SGULookup = std::make_shared>(deck, es); + const auto ISGULookup = std::make_shared>(deck, es); + const auto SWULookup = std::make_shared>(deck, es); + const auto ISWULookup = std::make_shared>(deck, es); + const auto SGCRLookup = std::make_shared>(deck, es); + const auto ISGCRLookup = std::make_shared>(deck, es); + const auto SOWCRLookup = std::make_shared>(deck, es); + const auto ISOWCRLookup = std::make_shared>(deck, es); + const auto SOGCRLookup = std::make_shared>(deck, es); + const auto ISOGCRLookup = std::make_shared>(deck, es); + const auto SWCRLookup = std::make_shared>(deck, es); + const auto ISWCRLookup = std::make_shared>(deck, es); - double nan = std::numeric_limits::quiet_NaN(); - const auto SGLLookup = std::make_shared>(*deck, *this); - const auto ISGLLookup = std::make_shared>(*deck, *this); - const auto SWLLookup = std::make_shared>(*deck, *this); - const auto ISWLLookup = std::make_shared>(*deck, *this); - const auto SGULookup = std::make_shared>(*deck, *this); - const auto ISGULookup = std::make_shared>(*deck, *this); - const auto SWULookup = std::make_shared>(*deck, *this); - const auto ISWULookup = std::make_shared>(*deck, *this); - const auto SGCRLookup = std::make_shared>(*deck, *this); - const auto ISGCRLookup = std::make_shared>(*deck, *this); - const auto SOWCRLookup = std::make_shared>(*deck, *this); - const auto ISOWCRLookup = std::make_shared>(*deck, *this); - const auto SOGCRLookup = std::make_shared>(*deck, *this); - const auto ISOGCRLookup = std::make_shared>(*deck, *this); - const auto SWCRLookup = std::make_shared>(*deck, *this); - const auto ISWCRLookup = std::make_shared>(*deck, *this); + const auto PCWLookup = std::make_shared>(deck, es); + const auto IPCWLookup = std::make_shared>(deck, es); + const auto PCGLookup = std::make_shared>(deck, es); + const auto IPCGLookup = std::make_shared>(deck, es); + const auto KRWLookup = std::make_shared>(deck, es); + const auto IKRWLookup = std::make_shared>(deck, es); + const auto KRWRLookup = std::make_shared>(deck, es); + const auto IKRWRLookup = std::make_shared>(deck, es); + const auto KROLookup = std::make_shared>(deck, es); + const auto IKROLookup = std::make_shared>(deck, es); + const auto KRORWLookup = std::make_shared>(deck, es); + const auto IKRORWLookup = std::make_shared>(deck, es); + const auto KRORGLookup = std::make_shared>(deck, es); + const auto IKRORGLookup = std::make_shared>(deck, es); + const auto KRGLookup = std::make_shared>(deck, es); + const auto IKRGLookup = std::make_shared>(deck, es); + const auto KRGRLookup = std::make_shared>(deck, es); + const auto IKRGRLookup = std::make_shared>(deck, es); - const auto PCWLookup = std::make_shared>(*deck, *this); - const auto IPCWLookup = std::make_shared>(*deck, *this); - const auto PCGLookup = std::make_shared>(*deck, *this); - const auto IPCGLookup = std::make_shared>(*deck, *this); - const auto KRWLookup = std::make_shared>(*deck, *this); - const auto IKRWLookup = std::make_shared>(*deck, *this); - const auto KRWRLookup = std::make_shared>(*deck, *this); - const auto IKRWRLookup = std::make_shared>(*deck, *this); - const auto KROLookup = std::make_shared>(*deck, *this); - const auto IKROLookup = std::make_shared>(*deck, *this); - const auto KRORWLookup = std::make_shared>(*deck, *this); - const auto IKRORWLookup = std::make_shared>(*deck, *this); - const auto KRORGLookup = std::make_shared>(*deck, *this); - const auto IKRORGLookup = std::make_shared>(*deck, *this); - const auto KRGLookup = std::make_shared>(*deck, *this); - const auto IKRGLookup = std::make_shared>(*deck, *this); - const auto KRGRLookup = std::make_shared>(*deck, *this); - const auto IKRGRLookup = std::make_shared>(*deck, *this); + const auto tempLookup = std::make_shared>(deck, es); + const auto distributeTopLayer = std::make_shared(es); + const auto initPORV = std::make_shared(es); - const auto tempLookup = std::make_shared>(*deck, *this); - const auto distributeTopLayer = std::make_shared(*this); - const auto initPORV = std::make_shared(*this); + std::vector< GridProperties< double >::SupportedKeywordInfo > supportedDoubleKeywords; - - // Note that the variants of grid keywords for radial grids - // are not supported. (and hopefully never will be) - typedef GridProperties::SupportedKeywordInfo SupportedDoubleKeywordInfo; - std::shared_ptr > supportedDoubleKeywords(new std::vector); - - // keywords to specify the scaled connate gas - // saturations. - supportedDoubleKeywords->emplace_back( "SGL" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGLX" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGLX-" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGLY" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGLY-" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGLZ" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGLZ-" , SGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGL" , ISGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGLX" , ISGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGLX-" , ISGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGLY" , ISGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGLY-" , ISGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGLZ" , ISGLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGLZ-" , ISGLLookup, "1" ); + // keywords to specify the scaled connate gas saturations. + for( const auto& kw : { "SGL", "SGLX", "SGLX-", "SGLY", "SGLY-", "SGLZ", "SGLZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SGLLookup, "1" ); + for( const auto& kw : { "ISGL", "ISGLX", "ISGLX-", "ISGLY", "ISGLY-", "ISGLZ", "ISGLZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISGLLookup, "1" ); // keywords to specify the connate water saturation. - supportedDoubleKeywords->emplace_back( "SWL" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWLX" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWLX-" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWLY" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWLY-" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWLZ" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWLZ-" , SWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWL" , ISWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWLX" , ISWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWLX-" , ISWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWLY" , ISWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWLY-" , ISWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWLZ" , ISWLLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWLZ-" , ISWLLookup, "1" ); + for( const auto& kw : { "SWL", "SWLX", "SWLX-", "SWLY", "SWLY-", "SWLZ", "SWLZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SWLLookup, "1" ); + for( const auto& kw : { "ISWL", "ISWLX", "ISWLX-", "ISWLY", "ISWLY-", "ISWLZ", "ISWLZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISWLLookup, "1" ); // keywords to specify the maximum gas saturation. - supportedDoubleKeywords->emplace_back( "SGU" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGUX" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGUX-" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGUY" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGUY-" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGUZ" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGUZ-" , SGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGU" , ISGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGUX" , ISGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGUX-" , ISGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGUY" , ISGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGUY-" , ISGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGUZ" , ISGULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGUZ-" , ISGULookup, "1" ); + for( const auto& kw : { "SGU", "SGUX", "SGUX-", "SGUY", "SGUY-", "SGUZ", "SGUZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SGULookup, "1" ); + for( const auto& kw : { "ISGU", "ISGUX", "ISGUX-", "ISGUY", "ISGUY-", "ISGUZ", "ISGUZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISGULookup, "1" ); // keywords to specify the maximum water saturation. - supportedDoubleKeywords->emplace_back( "SWU" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWUX" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWUX-" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWUY" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWUY-" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWUZ" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWUZ-" , SWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWU" , ISWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWUX" , ISWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWUX-" , ISWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWUY" , ISWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWUY-" , ISWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWUZ" , ISWULookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWUZ-" , ISWULookup, "1" ); + for( const auto& kw : { "SWU", "SWUX", "SWUX-", "SWUY", "SWUY-", "SWUZ", "SWUZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SWULookup, "1" ); + for( const auto& kw : { "ISWU", "ISWUX", "ISWUX-", "ISWUY", "ISWUY-", "ISWUZ", "ISWUZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISWULookup, "1" ); - // keywords to specify the scaled critical gas - // saturation. - supportedDoubleKeywords->emplace_back( "SGCR" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGCRX" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGCRX-" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGCRY" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGCRY-" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGCRZ" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SGCRZ-" , SGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCR" , ISGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCRX" , ISGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCRX-" , ISGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCRY" , ISGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCRY-" , ISGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCRZ" , ISGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISGCRZ-" , ISGCRLookup, "1" ); + // keywords to specify the scaled critical gas saturation. + for( const auto& kw : { "SGCR", "SGCRX", "SGCRX-", "SGCRY", "SGCRY-", "SGCRZ", "SGCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SGCRLookup, "1" ); + for( const auto& kw : { "ISGCR", "ISGCRX", "ISGCRX-", "ISGCRY", "ISGCRY-", "ISGCRZ", "ISGCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISGCRLookup, "1" ); - // keywords to specify the scaled critical oil-in-water - // saturation. - supportedDoubleKeywords->emplace_back( "SOWCR" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOWCRX" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOWCRX-" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOWCRY" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOWCRY-" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOWCRZ" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOWCRZ-" , SOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCR" , ISOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCRX" , ISOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCRX-" , ISOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCRY" , ISOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCRY-" , ISOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCRZ" , ISOWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOWCRZ-" , ISOWCRLookup, "1" ); + // keywords to specify the scaled critical oil-in-water saturation. + for( const auto& kw : { "SOWCR", "SOWCRX", "SOWCRX-", "SOWCRY", "SOWCRY-", "SOWCRZ", "SOWCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SOWCRLookup, "1" ); + for( const auto& kw : { "ISOWCR", "ISOWCRX", "ISOWCRX-", "ISOWCRY", "ISOWCRY-", "ISOWCRZ", "ISOWCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISOWCRLookup, "1" ); - // keywords to specify the scaled critical oil-in-gas - // saturation. - supportedDoubleKeywords->emplace_back( "SOGCR" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOGCRX" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOGCRX-" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOGCRY" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOGCRY-" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOGCRZ" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SOGCRZ-" , SOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCR" , ISOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCRX" , ISOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCRX-" , ISOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCRY" , ISOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCRY-" , ISOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCRZ" , ISOGCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISOGCRZ-" , ISOGCRLookup, "1" ); + // keywords to specify the scaled critical oil-in-gas saturation. + for( const auto& kw : { "SOGCR", "SOGCRX", "SOGCRX-", "SOGCRY", "SOGCRY-", "SOGCRZ", "SOGCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SOGCRLookup, "1" ); + for( const auto& kw : { "ISOGCR", "ISOGCRX", "ISOGCRX-", "ISOGCRY", "ISOGCRY-", "ISOGCRZ", "ISOGCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISOGCRLookup, "1" ); - // keywords to specify the scaled critical water - // saturation. - supportedDoubleKeywords->emplace_back( "SWCR" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWCRX" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWCRX-" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWCRY" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWCRY-" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWCRZ" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "SWCRZ-" , SWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCR" , ISWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCRX" , ISWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCRX-" , ISWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCRY" , ISWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCRY-" , ISWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCRZ" , ISWCRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "ISWCRZ-" , ISWCRLookup, "1" ); + // keywords to specify the scaled critical water saturation. + for( const auto& kw : { "SWCR", "SWCRX", "SWCRX-", "SWCRY", "SWCRY-", "SWCRZ", "SWCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, SWCRLookup, "1" ); + for( const auto& kw : { "ISWCR", "ISWCRX", "ISWCRX-", "ISWCRY", "ISWCRY-", "ISWCRZ", "ISWCRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, ISWCRLookup, "1" ); // keywords to specify the scaled oil-water capillary pressure - supportedDoubleKeywords->emplace_back( "PCW" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCWX" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCWX-" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCWY" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCWY-" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCWZ" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCWZ-" , PCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCW" , IPCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCWX" , IPCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCWX-" , IPCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCWY" , IPCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCWY-" , IPCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCWZ" , IPCWLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCWZ-" , IPCWLookup, "Pressure" ); + for( const auto& kw : { "PCW", "PCWX", "PCWX-", "PCWY", "PCWY-", "PCWZ", "PCWZ-" } ) + supportedDoubleKeywords.emplace_back( kw, PCWLookup, "1" ); + for( const auto& kw : { "IPCW", "IPCWX", "IPCWX-", "IPCWY", "IPCWY-", "IPCWZ", "IPCWZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IPCWLookup, "1" ); // keywords to specify the scaled gas-oil capillary pressure - supportedDoubleKeywords->emplace_back( "PCG" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCGX" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCGX-" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCGY" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCGY-" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCGZ" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "PCGZ-" , PCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCG" , IPCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCGX" , IPCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCGX-" , IPCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCGY" , IPCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCGY-" , IPCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCGZ" , IPCGLookup, "Pressure" ); - supportedDoubleKeywords->emplace_back( "IPCGZ-" , IPCGLookup, "Pressure" ); + for( const auto& kw : { "PCG", "PCGX", "PCGX-", "PCGY", "PCGY-", "PCGZ", "PCGZ-" } ) + supportedDoubleKeywords.emplace_back( kw, PCGLookup, "1" ); + for( const auto& kw : { "IPCG", "IPCGX", "IPCGX-", "IPCGY", "IPCGY-", "IPCGZ", "IPCGZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IPCGLookup, "1" ); // keywords to specify the scaled water relative permeability - supportedDoubleKeywords->emplace_back( "KRW" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWX" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWX-" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWY" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWY-" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWZ" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWZ-" , KRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRW" , IKRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWX" , IKRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWX-" , IKRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWY" , IKRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWY-" , IKRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWZ" , IKRWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWZ-" , IKRWLookup, "1" ); + for( const auto& kw : { "KRW", "KRWX", "KRWX-", "KRWY", "KRWY-", "KRWZ", "KRWZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KRWLookup, "1" ); + for( const auto& kw : { "IKRW", "IKRWX", "IKRWX-", "IKRWY", "IKRWY-", "IKRWZ", "IKRWZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKRWLookup, "1" ); // keywords to specify the scaled water relative permeability at the critical // saturation - supportedDoubleKeywords->emplace_back( "KRWR" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWRX" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWRX-" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWRY" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWRY-" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWRZ" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRWRZ-" , KRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWR" , IKRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWRX" , IKRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWRX-" , IKRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWRY" , IKRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWRY-" , IKRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWRZ" , IKRWRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRWRZ-" , IKRWRLookup, "1" ); + for( const auto& kw : { "KRWR" , "KRWRX" , "KRWRX-" , "KRWRY" , "KRWRY-" , "KRWRZ" , "KRWRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KRWRLookup, "1" ); + for( const auto& kw : { "IKRWR" , "IKRWRX" , "IKRWRX-" , "IKRWRY" , "IKRWRY-" , "IKRWRZ" , "IKRWRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKRWRLookup, "1" ); // keywords to specify the scaled oil relative permeability - supportedDoubleKeywords->emplace_back( "KRO" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KROX" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KROX-" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KROY" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KROY-" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KROZ" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KROZ-" , KROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRO" , IKROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKROX" , IKROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKROX-" , IKROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKROY" , IKROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKROY-" , IKROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKROZ" , IKROLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKROZ-" , IKROLookup, "1" ); + for( const auto& kw : { "KRO", "KROX", "KROX-", "KROY", "KROY-", "KROZ", "KROZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KROLookup, "1" ); + for( const auto& kw : { "IKRO", "IKROX", "IKROX-", "IKROY", "IKROY-", "IKROZ", "IKROZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKROLookup, "1" ); // keywords to specify the scaled water relative permeability at the critical // water saturation - supportedDoubleKeywords->emplace_back( "KRORW" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORWX" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORWX-" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORWY" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORWY-" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORWZ" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORWZ-" , KRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORW" , IKRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORWX" , IKRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORWX-" , IKRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORWY" , IKRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORWY-" , IKRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORWZ" , IKRORWLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORWZ-" , IKRORWLookup, "1" ); + for( const auto& kw : { "KRORW", "KRORWX", "KRORWX-", "KRORWY", "KRORWY-", "KRORWZ", "KRORWZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KRORWLookup, "1" ); + for( const auto& kw : { "IKRORW", "IKRORWX", "IKRORWX-", "IKRORWY", "IKRORWY-", "IKRORWZ", "IKRORWZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKRORWLookup, "1" ); // keywords to specify the scaled water relative permeability at the critical // water saturation - supportedDoubleKeywords->emplace_back( "KRORG" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORGX" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORGX-" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORGY" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORGY-" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORGZ" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRORGZ-" , KRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORG" , IKRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORGX" , IKRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORGX-" , IKRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORGY" , IKRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORGY-" , IKRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORGZ" , IKRORGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRORGZ-" , IKRORGLookup, "1" ); + for( const auto& kw : { "KRORG", "KRORGX", "KRORGX-", "KRORGY", "KRORGY-", "KRORGZ", "KRORGZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KRORGLookup, "1" ); + for( const auto& kw : { "IKRORG", "IKRORGX", "IKRORGX-", "IKRORGY", "IKRORGY-", "IKRORGZ", "IKRORGZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKRORGLookup, "1" ); // keywords to specify the scaled gas relative permeability - supportedDoubleKeywords->emplace_back( "KRG" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGX" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGX-" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGY" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGY-" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGZ" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGZ-" , KRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRG" , IKRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGX" , IKRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGX-" , IKRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGY" , IKRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGY-" , IKRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGZ" , IKRGLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGZ-" , IKRGLookup, "1" ); + for( const auto& kw : { "KRG", "KRGX", "KRGX-", "KRGY", "KRGY-", "KRGZ", "KRGZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KRGLookup, "1" ); + for( const auto& kw : { "IKRG", "IKRGX", "IKRGX-", "IKRGY", "IKRGY-", "IKRGZ", "IKRGZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKRGLookup, "1" ); // keywords to specify the scaled gas relative permeability - supportedDoubleKeywords->emplace_back( "KRGR" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGRX" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGRX-" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGRY" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGRY-" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGRZ" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "KRGRZ-" , KRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGR" , IKRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGRX" , IKRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGRX-" , IKRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGRY" , IKRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGRY-" , IKRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGRZ" , IKRGRLookup, "1" ); - supportedDoubleKeywords->emplace_back( "IKRGRZ-" , IKRGRLookup, "1" ); + for( const auto& kw : { "KRGR", "KRGRX", "KRGRX-", "KRGRY", "KRGRY-", "KRGRZ", "KRGRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, KRGRLookup, "1" ); + for( const auto& kw : { "IKRGR", "IKRGRX", "IKRGRX-", "IKRGRY", "IKRGRY-", "IKRGRZ", "IKRGRZ-" } ) + supportedDoubleKeywords.emplace_back( kw, IKRGRLookup, "1" ); + + // cell temperature (E300 only, but makes a lot of sense for E100, too) - supportedDoubleKeywords->emplace_back( "TEMPI" , tempLookup, "Temperature" ); + supportedDoubleKeywords.emplace_back( "TEMPI", tempLookup, "Temperature" ); + double nan = std::numeric_limits::quiet_NaN(); // porosity - supportedDoubleKeywords->emplace_back( "PORO" , nan, distributeTopLayer , "1" ); + supportedDoubleKeywords.emplace_back( "PORO", nan, distributeTopLayer, "1" ); // pore volume - supportedDoubleKeywords->emplace_back( "PORV" , nan, initPORV , "Volume" ); + supportedDoubleKeywords.emplace_back( "PORV", nan, initPORV, "Volume" ); // pore volume multipliers - supportedDoubleKeywords->emplace_back( "MULTPV", 1.0, "1" ); + supportedDoubleKeywords.emplace_back( "MULTPV", 1.0, "1" ); // the permeability keywords - supportedDoubleKeywords->emplace_back( "PERMX" , nan, distributeTopLayer , "Permeability" ); - supportedDoubleKeywords->emplace_back( "PERMY" , nan, distributeTopLayer , "Permeability" ); - supportedDoubleKeywords->emplace_back( "PERMZ" , nan, distributeTopLayer , "Permeability" ); - supportedDoubleKeywords->emplace_back( "PERMXY", nan, distributeTopLayer , "Permeability" ); // E300 only - supportedDoubleKeywords->emplace_back( "PERMYZ", nan, distributeTopLayer , "Permeability" ); // E300 only - supportedDoubleKeywords->emplace_back( "PERMZX", nan, distributeTopLayer , "Permeability" ); // E300 only + for( const auto& kw : { "PERMX", "PERMY", "PERMZ" } ) + supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" ); - // the transmissibility keywords for neighboring - // conections. note that these keywords don't seem to - // require a post-processor... - supportedDoubleKeywords->emplace_back( "TRANX", nan, "Transmissibility" ); - supportedDoubleKeywords->emplace_back( "TRANY", nan, "Transmissibility" ); - supportedDoubleKeywords->emplace_back( "TRANZ", nan, "Transmissibility" ); + /* E300 only */ + for( const auto& kw : { "PERMXY", "PERMYZ", "PERMZX" } ) + supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" ); - // gross-to-net thickness (acts as a multiplier for PORO - // and the permeabilities in the X-Y plane as well as for - // the well rates.) - supportedDoubleKeywords->emplace_back( "NTG" , 1.0, "1" ); + /* the transmissibility keywords for neighboring connections. note that + * these keywords don't seem to require a post-processor + */ + for( const auto& kw : { "TRANX", "TRANY", "TRANZ" } ) + supportedDoubleKeywords.emplace_back( kw, nan, "Transmissibility" ); + + /* gross-to-net thickness (acts as a multiplier for PORO and the + * permeabilities in the X-Y plane as well as for the well rates.) + */ + supportedDoubleKeywords.emplace_back( "NTG", 1.0, "1" ); // transmissibility multipliers - supportedDoubleKeywords->emplace_back( "MULTX" , 1.0, "1" ); - supportedDoubleKeywords->emplace_back( "MULTY" , 1.0, "1" ); - supportedDoubleKeywords->emplace_back( "MULTZ" , 1.0, "1" ); - supportedDoubleKeywords->emplace_back( "MULTX-", 1.0, "1" ); - supportedDoubleKeywords->emplace_back( "MULTY-", 1.0, "1" ); - supportedDoubleKeywords->emplace_back( "MULTZ-", 1.0, "1" ); + for( const auto& kw : { "MULTX", "MULTY", "MULTZ", "MULTX-", "MULTY-", "MULTZ-" } ) + supportedDoubleKeywords.emplace_back( kw, 1.0, "1" ); // initialisation - supportedDoubleKeywords->emplace_back( "SWATINIT" , 0.0, "1"); - supportedDoubleKeywords->emplace_back( "THCONR" , 0.0, "1"); + supportedDoubleKeywords.emplace_back( "SWATINIT", 0.0, "1"); + supportedDoubleKeywords.emplace_back( "THCONR", 0.0, "1"); + + return supportedDoubleKeywords; + } + + void EclipseState::initProperties(DeckConstPtr deck) { + + // Note that the variants of grid keywords for radial grids + // are not supported. (and hopefully never will be) // register the grid properties - m_intGridProperties = std::make_shared >(m_eclipseGrid , supportedIntKeywords); - m_doubleGridProperties = std::make_shared >(m_eclipseGrid , supportedDoubleKeywords); + m_intGridProperties = std::make_shared< GridProperties< int > >(m_eclipseGrid , makeSupportedIntKeywords() ); + m_doubleGridProperties = std::make_shared< GridProperties< double > >( m_eclipseGrid, makeSupportedDoubleKeywords(*deck, *this) ); // actually create the grid property objects. we need to first // process all integer grid properties before the double ones diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp b/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp index 8ad4640b3..610715ee8 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp @@ -52,11 +52,11 @@ class GridProperties { public: typedef typename GridProperty::SupportedKeywordInfo SupportedKeywordInfo; - GridProperties(std::shared_ptr eclipseGrid , std::shared_ptr > supportedKeywords) { + GridProperties(std::shared_ptr eclipseGrid, std::vector< SupportedKeywordInfo >&& supportedKeywords) { m_eclipseGrid = eclipseGrid; - for (auto iter = supportedKeywords->begin(); iter != supportedKeywords->end(); ++iter) - m_supportedKeywords[iter->getKeywordName()] = *iter; + for (auto iter = supportedKeywords.begin(); iter != supportedKeywords.end(); ++iter) + m_supportedKeywords[iter->getKeywordName()] = std::move( *iter ); } diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp index 000a85ddd..4aa704226 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp @@ -40,13 +40,13 @@ BOOST_AUTO_TEST_CASE(Empty) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; - std::shared_ptr > supportedKeywords(new std::vector{ - SupportedKeywordInfo("SATNUM" , 0, "1"), - SupportedKeywordInfo("FIPNUM" , 2, "1") - }); + std::vector supportedKeywords = { + SupportedKeywordInfo("SATNUM" , 0, "1"), + SupportedKeywordInfo("FIPNUM" , 2, "1") + }; std::shared_ptr grid = std::make_shared(10,7,9); - Opm::GridProperties gridProperties( grid , supportedKeywords); + Opm::GridProperties gridProperties( grid, std::move( supportedKeywords ) ); BOOST_CHECK( gridProperties.supportsKeyword("SATNUM") ); BOOST_CHECK( gridProperties.supportsKeyword("FIPNUM") ); @@ -62,11 +62,11 @@ BOOST_AUTO_TEST_CASE(Empty) { BOOST_AUTO_TEST_CASE(addKeyword) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; - std::shared_ptr > supportedKeywords(new std::vector{ + std::vector supportedKeywords = { SupportedKeywordInfo("SATNUM" , 0, "1") - }); + }; std::shared_ptr grid = std::make_shared(10,7,9); - Opm::GridProperties gridProperties( grid , supportedKeywords); + Opm::GridProperties gridProperties( grid , std::move( supportedKeywords ) ); BOOST_CHECK_THROW( gridProperties.addKeyword("NOT-SUPPORTED") , std::invalid_argument); @@ -78,11 +78,11 @@ BOOST_AUTO_TEST_CASE(addKeyword) { BOOST_AUTO_TEST_CASE(hasKeyword) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; - std::shared_ptr > supportedKeywords(new std::vector{ + std::vector supportedKeywords = { SupportedKeywordInfo("SATNUM" , 0, "1") - }); + }; std::shared_ptr grid = std::make_shared(10,7,9); - Opm::GridProperties gridProperties( grid , supportedKeywords); + Opm::GridProperties gridProperties( grid, std::move( supportedKeywords ) ); // calling getKeyword() should not change the semantics of hasKeyword()! BOOST_CHECK(!gridProperties.hasKeyword("SATNUM")); @@ -93,11 +93,11 @@ BOOST_AUTO_TEST_CASE(hasKeyword) { BOOST_AUTO_TEST_CASE(getKeyword) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; - std::shared_ptr > supportedKeywords(new std::vector{ + std::vector supportedKeywords = { SupportedKeywordInfo("SATNUM" , 0, "1") - }); + }; std::shared_ptr grid = std::make_shared(10,7,9); - Opm::GridProperties gridProperties( grid , supportedKeywords); + Opm::GridProperties gridProperties( grid, std::move( supportedKeywords ) ); std::shared_ptr > satnum1 = gridProperties.getKeyword("SATNUM"); std::shared_ptr > satnum2 = gridProperties.getKeyword("SATNUM"); std::shared_ptr > satnum3 = gridProperties.getKeyword(0); diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp index c8c38cc5d..2eb6f4384 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp @@ -435,11 +435,10 @@ BOOST_AUTO_TEST_CASE(GridPropertyPostProcessors) { typedef Opm::GridPropertySupportedKeywordInfo SupportedKeywordInfo; SupportedKeywordInfo kwInfo1("MULTPV" , 1.0 , "1"); SupportedKeywordInfo kwInfo2("PORO" , 1.0 , testPostP , "1"); - std::shared_ptr > supportedKeywords(new std::vector{ - kwInfo1 , kwInfo2 }); + std::vector supportedKeywords = { kwInfo1, kwInfo2 }; Opm::DeckPtr deck = createDeck(); std::shared_ptr grid = std::make_shared(deck); - Opm::GridProperties properties(grid, supportedKeywords); + Opm::GridProperties properties(grid, std::move( supportedKeywords ) ); { auto poro = properties.getKeyword("PORO"); diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp index 4a99278a0..07e157b3b 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp @@ -101,15 +101,16 @@ static Opm::DeckPtr createInvalidMULTREGTDeck() { BOOST_AUTO_TEST_CASE(InvalidInput) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; - std::shared_ptr > supportedKeywords(new std::vector{ + std::vector supportedKeywords = { SupportedKeywordInfo("FLUXNUM" , 1 , "1") , SupportedKeywordInfo("OPERNUM" , 1 , "1") , - SupportedKeywordInfo("MULTNUM" , 1 , "1") }); + SupportedKeywordInfo("MULTNUM" , 1 , "1") + }; Opm::DeckPtr deck = createInvalidMULTREGTDeck(); std::shared_ptr grid = std::make_shared( deck ); - std::shared_ptr > gridProperties = std::make_shared >(grid, supportedKeywords); + std::shared_ptr > gridProperties = std::make_shared >(grid, std::move( supportedKeywords ) ); // Invalid direction std::vector< const Opm::DeckKeyword* > keywords0; @@ -168,14 +169,15 @@ static Opm::DeckPtr createNotSupportedMULTREGTDeck() { BOOST_AUTO_TEST_CASE(NotSupported) { typedef Opm::GridProperties::SupportedKeywordInfo SupportedKeywordInfo; - std::shared_ptr > supportedKeywords(new std::vector{ + std::vector supportedKeywords = { SupportedKeywordInfo("FLUXNUM" , 1 , "1") , SupportedKeywordInfo("OPERNUM" , 1 , "1") , - SupportedKeywordInfo("MULTNUM" , 1 , "1") }); + SupportedKeywordInfo("MULTNUM" , 1 , "1") + }; Opm::DeckPtr deck = createNotSupportedMULTREGTDeck(); std::shared_ptr grid = std::make_shared( deck ); - std::shared_ptr > gridProperties = std::make_shared >(grid, supportedKeywords); + std::shared_ptr > gridProperties = std::make_shared >(grid, std::move( supportedKeywords ) ); // Not support NOAQUNNC behaviour std::vector< const Opm::DeckKeyword* > keywords0; diff --git a/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp b/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp index f435738b2..60c70ffed 100644 --- a/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp +++ b/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp @@ -113,10 +113,10 @@ static DeckPtr createDeck(const ParseMode& parseMode , const std::string& input) static std::shared_ptr> getGridProperties() { GridPropertySupportedKeywordInfo kwInfo = GridPropertySupportedKeywordInfo("EQLNUM", 3, ""); - std::shared_ptr>> supportedKeywordsVec = std::make_shared>>(); - supportedKeywordsVec->push_back(kwInfo); + std::vector> supportedKeywordsVec; + supportedKeywordsVec.push_back(kwInfo); EclipseGridConstPtr eclipseGrid = std::make_shared(3, 3, 3); - std::shared_ptr> gridProperties = std::make_shared>(eclipseGrid, supportedKeywordsVec); + std::shared_ptr> gridProperties = std::make_shared>(eclipseGrid, std::move(supportedKeywordsVec)); gridProperties->addKeyword("EQLNUM"); return gridProperties; } diff --git a/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp b/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp index 7c89e6e83..19c7bcec6 100644 --- a/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp +++ b/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp @@ -141,10 +141,9 @@ static DeckPtr createDeck(const ParseMode& parseMode , const std::string& input) static std::shared_ptr> getGridProperties(int defaultEqlnum = 3, bool addKeyword = true) { GridPropertySupportedKeywordInfo kwInfo = GridPropertySupportedKeywordInfo("EQLNUM", defaultEqlnum, ""); - std::shared_ptr>> supportedKeywordsVec = std::make_shared>>(); - supportedKeywordsVec->push_back(kwInfo); + std::vector> supportedKeywordsVec( 1, kwInfo ); EclipseGridConstPtr eclipseGrid = std::make_shared(3, 3, 3); - std::shared_ptr> gridProperties = std::make_shared>(eclipseGrid, supportedKeywordsVec); + std::shared_ptr> gridProperties = std::make_shared>(eclipseGrid, std::move( supportedKeywordsVec ) ); if (addKeyword) { gridProperties->addKeyword("EQLNUM"); }