Expands ALL keyword for summary
Only support F, G, W, not A
This commit is contained in:
parent
1a09986cd2
commit
7f3cbcf91a
@ -43,6 +43,29 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
const std::vector <std::string> SummaryConfig::__ALL_expands_keywords ({
|
||||
"FOPR", "GOPR", "WOPR", "FOPT", "GOPT", "WOPT",
|
||||
"FOIR", "GOIR", "WOIR", "FOIT", "GOIT", "WOIT",
|
||||
"FWPR", "GWPR", "WWPR", "FWPT", "GWPT", "WWPT",
|
||||
"FWIR", "GWIR", "WWIR", "FWIT", "GWIT", "WWIT",
|
||||
"FGPR", "GGPR", "WGPR", "FGPT", "GGPT", "WGPT",
|
||||
"FGIR", "GGIR", "WGIR", "FGIT", "GGIT", "WGIT",
|
||||
"FVPR", "GVPR", "WVPR", "FVPT", "GVPT", "WVPT",
|
||||
"FVIR", "GVIR", "WVIR", "FVIT", "GVIT", "WVIT",
|
||||
"FWCT", "GWCT", "WWCT", "FGOR", "GGOR", "WGOR",
|
||||
"FWGR", "GWGR", "WWGR",
|
||||
"WBHP", "WTHP", "WPI",
|
||||
"FOIP", "FOIPL", "FOIPG",
|
||||
"FWIP",
|
||||
"FGIP", "FGIPL", "FGIPG", "FPR",
|
||||
"FAQR", "FAQRG", "AAQR", "AAQRG",
|
||||
"FAQT", "FAQTG", "AAQT", "AAQTG"
|
||||
});
|
||||
|
||||
std::vector <std::string> SummaryConfig::getAllExpandedKeywords() {
|
||||
return __ALL_expands_keywords;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
static std::string name( const T* x ) {
|
||||
return x->name();
|
||||
@ -73,6 +96,28 @@ namespace Opm {
|
||||
return fun::map( mknode, wnames );
|
||||
}
|
||||
|
||||
static inline std::vector< ERT::smspec_node > keywordW(
|
||||
const std::string& keyword,
|
||||
const Schedule& schedule ) {
|
||||
|
||||
const auto mknode = [&keyword]( const std::string& wname ) {
|
||||
return ERT::smspec_node( ECL_SMSPEC_WELL_VAR, wname, keyword );
|
||||
};
|
||||
|
||||
const auto missing = [&schedule]( const std::string& name ) {
|
||||
return !schedule.hasWell( name );
|
||||
};
|
||||
|
||||
auto wnames = fun::map( name< Well >, schedule.getWells() );
|
||||
|
||||
/* filter all requested names that were not in the Deck */
|
||||
wnames.erase(
|
||||
std::remove_if( wnames.begin(), wnames.end(), missing ),
|
||||
wnames.end() );
|
||||
|
||||
return fun::map( mknode, wnames );
|
||||
}
|
||||
|
||||
static inline std::vector< ERT::smspec_node > keywordG(
|
||||
const DeckKeyword& keyword,
|
||||
const Schedule& schedule ) {
|
||||
@ -97,6 +142,27 @@ namespace Opm {
|
||||
return fun::map( mknode, gnames );
|
||||
}
|
||||
|
||||
static inline std::vector< ERT::smspec_node > keywordG(
|
||||
const std::string& keyword,
|
||||
const Schedule& schedule ) {
|
||||
|
||||
const auto mknode = [&keyword]( const std::string& name ) {
|
||||
return ERT::smspec_node( ECL_SMSPEC_GROUP_VAR, name, keyword );
|
||||
};
|
||||
|
||||
const auto missing = [&schedule]( const std::string& name ) {
|
||||
return !schedule.hasGroup( name );
|
||||
};
|
||||
|
||||
auto gnames = fun::map( name< Group >, schedule.getGroups() );
|
||||
|
||||
gnames.erase(
|
||||
std::remove_if( gnames.begin(), gnames.end(), missing ),
|
||||
gnames.end() );
|
||||
|
||||
return fun::map( mknode, gnames );
|
||||
}
|
||||
|
||||
static inline std::vector< ERT::smspec_node > keywordF(
|
||||
const DeckKeyword& keyword ) {
|
||||
|
||||
@ -105,6 +171,14 @@ namespace Opm {
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline std::vector< ERT::smspec_node > keywordF(
|
||||
const std::string& keyword ) {
|
||||
|
||||
std::vector< ERT::smspec_node > res;
|
||||
res.push_back( ERT::smspec_node( keyword ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline std::array< int, 3 > dimensions( const EclipseGrid& grid ) {
|
||||
return {{
|
||||
int( grid.getNX() ),
|
||||
@ -233,6 +307,34 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector< ERT::smspec_node > handleALL( const Schedule& schedule) {
|
||||
|
||||
|
||||
std::vector< ERT::smspec_node > all;
|
||||
|
||||
for(const std::string& keyword: SummaryConfig::getAllExpandedKeywords()) {
|
||||
const auto var_type = ecl_smspec_identify_var_type(keyword.c_str());
|
||||
switch (var_type) {
|
||||
case ECL_SMSPEC_WELL_VAR:
|
||||
for(auto&k :keywordW(keyword, schedule)) all.push_back(k);
|
||||
break;
|
||||
case ECL_SMSPEC_GROUP_VAR:
|
||||
for(auto& k:keywordG(keyword, schedule)) all.push_back(k);
|
||||
break;
|
||||
case ECL_SMSPEC_FIELD_VAR:
|
||||
for(auto& k:keywordF(keyword)) all.push_back(k);
|
||||
break;
|
||||
case ECL_SMSPEC_AQUIFER_VAR:
|
||||
{}
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Unrecognized keyword type: " + keyword);
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
SummaryConfig::SummaryConfig( const Deck& deck, const EclipseState& es )
|
||||
: SummaryConfig( deck,
|
||||
*es.getSchedule(),
|
||||
@ -253,10 +355,17 @@ namespace Opm {
|
||||
/* This line of code does not compile on VS2015
|
||||
* this->keywords = fun::concat( fun::map( handler, section ) );
|
||||
* The following code is a workaround for this compiler bug */
|
||||
for (auto& x : section)
|
||||
for (auto& x : section) {
|
||||
|
||||
if (x.name().compare("ALL") == 0)
|
||||
{
|
||||
for (auto& keyword : handler(x))
|
||||
this->keywords.push_back(keyword);
|
||||
for (auto& keyword : handleALL(schedule))
|
||||
this->keywords.push_back(keyword);
|
||||
}
|
||||
else {
|
||||
for (auto &keyword : handler(x))
|
||||
this->keywords.push_back(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,11 @@ namespace Opm {
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
static std::vector <std::string> getAllExpandedKeywords();
|
||||
|
||||
private:
|
||||
std::vector< ERT::smspec_node > keywords;
|
||||
static const std::vector <std::string> __ALL_expands_keywords;
|
||||
};
|
||||
|
||||
} //namespace Opm
|
||||
|
@ -66,8 +66,11 @@ static DeckPtr createDeck( const std::string& summary ) {
|
||||
|
||||
static std::vector< std::string > sorted_names( const SummaryConfig& summary ) {
|
||||
std::vector< std::string > ret;
|
||||
for( const auto& x : summary )
|
||||
ret.push_back( x.wgname() );
|
||||
for( const auto& x : summary ) {
|
||||
auto wgname = x.wgname();
|
||||
if(wgname)
|
||||
ret.push_back( x.wgname() );
|
||||
}
|
||||
|
||||
std::sort( ret.begin(), ret.end() );
|
||||
return ret;
|
||||
@ -82,6 +85,21 @@ static std::vector< std::string > sorted_keywords( const SummaryConfig& summary
|
||||
return ret;
|
||||
}
|
||||
|
||||
static std::vector< std::string > sorted_key_names( const SummaryConfig& summary ) {
|
||||
std::vector< std::string > ret;
|
||||
for( const auto& x : summary ) {
|
||||
std::string key = x.keyword();
|
||||
auto wgname = x.wgname();
|
||||
if(wgname) {
|
||||
key += ": "+ std::string(wgname);
|
||||
}
|
||||
ret.push_back( key );
|
||||
}
|
||||
|
||||
std::sort( ret.begin(), ret.end() );
|
||||
return ret;
|
||||
}
|
||||
|
||||
static SummaryConfig createSummary( std::string input ) {
|
||||
auto deck = createDeck( input );
|
||||
EclipseState state( deck, ParseContext() );
|
||||
@ -185,3 +203,39 @@ BOOST_AUTO_TEST_CASE(completions) {
|
||||
keywords.begin(), keywords.end(),
|
||||
names.begin(), names.end() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(summary_ALL) {
|
||||
|
||||
const auto input = "ALL\n";
|
||||
|
||||
const auto summary = createSummary( input );
|
||||
const auto key_names = sorted_key_names( summary );
|
||||
|
||||
std::vector<std::string> all;
|
||||
|
||||
for(const std::string& keyword: SummaryConfig::getAllExpandedKeywords()) {
|
||||
if(keyword[0]=='F') {
|
||||
all.push_back(keyword);
|
||||
}
|
||||
else if (keyword[0]=='G') {
|
||||
auto kn = keyword + ": ";
|
||||
all.push_back(kn + "G");
|
||||
all.push_back(kn + "OP");
|
||||
all.push_back(kn + "FIELD");
|
||||
}
|
||||
else if (keyword[0]=='W') {
|
||||
auto kn = keyword + ": ";
|
||||
all.push_back(kn + "W_1");
|
||||
all.push_back(kn + "WX2");
|
||||
all.push_back(kn + "W_3");
|
||||
all.push_back(kn + "PRODUCER");
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(all.begin(), all.end());
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
all.begin(), all.end(),
|
||||
key_names.begin(), key_names.end());
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user