Added simple test for hasKeyword.
This commit is contained in:
parent
afedca7b18
commit
c42d2a7022
@ -300,10 +300,10 @@ SummaryConfig::SummaryConfig( const Deck& deck, const EclipseState& es , const P
|
||||
{}
|
||||
|
||||
SummaryConfig::SummaryConfig( const Deck& deck,
|
||||
const Schedule& schedule,
|
||||
const Eclipse3DProperties& props,
|
||||
const ParseContext& parseContext,
|
||||
std::array< int, 3 > n_xyz ) {
|
||||
const Schedule& schedule,
|
||||
const Eclipse3DProperties& props,
|
||||
const ParseContext& parseContext,
|
||||
std::array< int, 3 > n_xyz ) {
|
||||
|
||||
SUMMARYSection section( deck );
|
||||
for( auto& x : section )
|
||||
@ -313,6 +313,8 @@ SummaryConfig::SummaryConfig( const Deck& deck,
|
||||
this->merge( { ALL_keywords, schedule, props, parseContext, n_xyz } );
|
||||
|
||||
uniq( this->keywords );
|
||||
for (const auto& kw: this->keywords)
|
||||
this->short_keywords.insert( kw.keyword() );
|
||||
}
|
||||
|
||||
SummaryConfig::const_iterator SummaryConfig::begin() const {
|
||||
@ -342,4 +344,8 @@ SummaryConfig& SummaryConfig::merge( SummaryConfig&& other ) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool SummaryConfig::hasKeyword( const std::string& keyword ) const {
|
||||
return (this->short_keywords.count( keyword ) == 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include <ert/ecl/Smspec.hpp>
|
||||
|
||||
@ -50,8 +51,22 @@ namespace Opm {
|
||||
SummaryConfig& merge( const SummaryConfig& );
|
||||
SummaryConfig& merge( SummaryConfig&& );
|
||||
|
||||
/*
|
||||
The hasKeyword() method will consult the internal set
|
||||
'short_keywords', i.e. the query should be based on pure
|
||||
keywords like 'WWCT' and 'BPR' - and *not* fully
|
||||
identifiers like 'WWCT:OPX' and 'BPR:10,12,3'.
|
||||
*/
|
||||
bool hasKeyword( const std::string& keyword ) const;
|
||||
private:
|
||||
|
||||
/*
|
||||
The short_keywords set contains only the pure keyword
|
||||
part, e.g. "WWCT", and not the qualification with
|
||||
well/group name or a numerical value.
|
||||
*/
|
||||
std::vector< ERT::smspec_node > keywords;
|
||||
std::set<std::string> short_keywords;
|
||||
};
|
||||
|
||||
} //namespace Opm
|
||||
|
@ -305,6 +305,11 @@ BOOST_AUTO_TEST_CASE(summary_ALL) {
|
||||
all.begin(), all.end(),
|
||||
key_names.begin(), key_names.end());
|
||||
|
||||
BOOST_CHECK_EQUAL( true , summary.hasKeyword( "FOPT"));
|
||||
BOOST_CHECK_EQUAL( true , summary.hasKeyword( "GGIT"));
|
||||
BOOST_CHECK_EQUAL( true , summary.hasKeyword( "WWCT"));
|
||||
|
||||
BOOST_CHECK_EQUAL( false , summary.hasKeyword("NO-NOT-THIS"));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user