Added GridProperties::hasDeckKeyword( )
The GridProperties::hasDeckKewyord( ) will return false for keywords which have only been auto generated. Have also renamed getInitializedkeyword( ) to getDeckKeyword( ).
This commit is contained in:
parent
0dcf411e8c
commit
ebc3a3ac79
@ -549,7 +549,7 @@ namespace Opm {
|
||||
return m_intGridProperties.getKeyword( m_defaultRegion );
|
||||
else {
|
||||
const std::string regionArray = MULTREGT::RegionNameFromDeckValue( regionItem.get< std::string >(0) );
|
||||
return m_intGridProperties.getInitializedKeyword( regionArray );
|
||||
return m_intGridProperties.getDeckKeyword( regionArray );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,6 +181,16 @@ namespace Opm {
|
||||
return positive;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
bool GridProperties<T>::hasDeckKeyword(const std::string& keyword) const {
|
||||
const std::string kw = normalize( keyword );
|
||||
|
||||
const auto cnt = m_properties.count( kw );
|
||||
const bool positive = cnt > 0;
|
||||
|
||||
return positive && !isAutoGenerated_( kw );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template< typename T >
|
||||
@ -209,10 +219,10 @@ namespace Opm {
|
||||
|
||||
|
||||
template< typename T >
|
||||
const GridProperty<T>& GridProperties<T>::getInitializedKeyword(const std::string& keyword) const {
|
||||
const GridProperty<T>& GridProperties<T>::getDeckKeyword(const std::string& keyword) const {
|
||||
const std::string kw = normalize(keyword);
|
||||
|
||||
if (hasKeyword(kw))
|
||||
if (hasDeckKeyword(kw))
|
||||
return m_properties.at( kw );
|
||||
else {
|
||||
if (supportsKeyword(kw))
|
||||
@ -222,7 +232,6 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< typename T >
|
||||
void GridProperties<T>::insertKeyword(const SupportedKeywordInfo& supportedKeyword) const {
|
||||
m_properties.emplace( supportedKeyword.getKeywordName(),
|
||||
|
@ -79,11 +79,31 @@ namespace Opm {
|
||||
T convertInputValue( double doubleValue ) const;
|
||||
|
||||
bool supportsKeyword(const std::string& keyword) const;
|
||||
|
||||
/*
|
||||
The difference between hasKeyword() and hasDeckKeyword( ) is
|
||||
that hasDeckKeyword( ) will return false for keywords which
|
||||
have only been auto created - and are not explicitly
|
||||
mentioned in the deck.
|
||||
*/
|
||||
|
||||
bool hasKeyword(const std::string& keyword) const;
|
||||
bool hasDeckKeyword(const std::string& keyword) const;
|
||||
|
||||
|
||||
size_t size() const;
|
||||
void assertKeyword(const std::string& keyword) const;
|
||||
|
||||
/*
|
||||
The getKeyword() method will auto create a keyword if
|
||||
requested, the getDeckKeyword() method will onyl return a
|
||||
keyword if it has been explicitly mentioned in the deck. The
|
||||
getDeckKeyword( ) method will throw an exception instead of
|
||||
auto creating the keyword.
|
||||
*/
|
||||
|
||||
const GridProperty<T>& getKeyword(const std::string& keyword) const;
|
||||
const GridProperty<T>& getInitializedKeyword(const std::string& keyword) const;
|
||||
const GridProperty<T>& getDeckKeyword(const std::string& keyword) const;
|
||||
|
||||
|
||||
bool addKeyword(const std::string& keywordName);
|
||||
|
@ -51,8 +51,8 @@ BOOST_AUTO_TEST_CASE(Empty) {
|
||||
BOOST_CHECK( !gridProperties.hasKeyword("SATNUM"));
|
||||
BOOST_CHECK( !gridProperties.hasKeyword("FLUXNUM"));
|
||||
|
||||
BOOST_CHECK_THROW( gridProperties.getInitializedKeyword("SATNUM") , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( gridProperties.getInitializedKeyword("NONONO") , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( gridProperties.getDeckKeyword("SATNUM") , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( gridProperties.getDeckKeyword("NONONO") , std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user