Merge pull request #2073 from joakim-hove/summary-completion-commits

Summary completion commits
This commit is contained in:
Joakim Hove 2020-11-05 12:40:06 +01:00 committed by GitHub
commit 25dee84f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 91 additions and 74 deletions

View File

@ -488,6 +488,7 @@ public:
const std::string& groupName() const; const std::string& groupName() const;
Phase getPreferredPhase() const; Phase getPreferredPhase() const;
const std::vector<const Connection *> getConnections(int completion) const;
const WellConnections& getConnections() const; const WellConnections& getConnections() const;
const WellSegments& getSegments() const; const WellSegments& getSegments() const;
@ -530,9 +531,6 @@ public:
connections. The integer ID is assigned with the COMPLUMP keyword. connections. The integer ID is assigned with the COMPLUMP keyword.
*/ */
bool hasCompletion(int completion) const; bool hasCompletion(int completion) const;
const std::vector<const Connection *> getConnections(int completion) const;
bool updatePrediction(bool prediction_mode); bool updatePrediction(bool prediction_mode);
bool updateAutoShutin(bool auto_shutin); bool updateAutoShutin(bool auto_shutin);
bool updateCrossFlow(bool allow_cross_flow); bool updateCrossFlow(bool allow_cross_flow);

View File

@ -95,7 +95,7 @@ namespace Opm {
}; };
SummaryConfigNode::Category parseKeywordCategory(const std::string& keyword); SummaryConfigNode::Category parseKeywordCategory(const std::string& keyword);
SummaryConfigNode::Type parseKeywordType(const std::string& keyword); SummaryConfigNode::Type parseKeywordType(std::string keyword);
bool operator==(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs); bool operator==(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
bool operator<(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs); bool operator<(const SummaryConfigNode& lhs, const SummaryConfigNode& rhs);
@ -212,6 +212,9 @@ namespace Opm {
return runSummaryConfig.create; return runSummaryConfig.create;
} }
const SummaryConfigNode& operator[](std::size_t index) const;
private: private:
SummaryConfig( const Deck& deck, SummaryConfig( const Deck& deck,
const Schedule& schedule, const Schedule& schedule,

View File

@ -1036,8 +1036,8 @@ bool Well::handleWELOPEN(const DeckRecord& record, Connection::State state_arg,
bool Well::handleCOMPLUMP(const DeckRecord& record) { bool Well::handleCOMPLUMP(const DeckRecord& record) {
auto match = [=]( const Connection &c) -> bool { auto match = [=]( const Connection &c) -> bool {
if (!match_eq(c.getI(), record, "I" , -1)) return false; if (!match_eq(c.getI(), record, "I" , -1)) return false;
if (!match_eq(c.getJ(), record, "J" , -1)) return false; if (!match_eq(c.getJ(), record, "J" , -1)) return false;
if (!match_ge(c.getK(), record, "K1", -1)) return false; if (!match_ge(c.getK(), record, "K1", -1)) return false;
if (!match_le(c.getK(), record, "K2", -1)) return false; if (!match_le(c.getK(), record, "K2", -1)) return false;

View File

@ -395,6 +395,14 @@ inline void keywordAquifer( SummaryConfig::keyword_list& list,
} }
} }
inline std::array< int, 3 > getijk( const DeckRecord& record ) {
return {{
record.getItem( "I" ).get< int >( 0 ) - 1,
record.getItem( "J" ).get< int >( 0 ) - 1,
record.getItem( "K" ).get< int >( 0 ) - 1
}};
}
inline void keywordW( SummaryConfig::keyword_list& list, inline void keywordW( SummaryConfig::keyword_list& list,
const std::string& keyword, const std::string& keyword,
KeywordLocation loc, KeywordLocation loc,
@ -577,14 +585,6 @@ inline void keywordF( SummaryConfig::keyword_list& list,
keywordF( list, keyword.name(), keyword.location() ); keywordF( list, keyword.name(), keyword.location() );
} }
inline std::array< int, 3 > getijk( const DeckRecord& record,
int offset = 0 ) {
return {{
record.getItem( offset + 0 ).get< int >( 0 ) - 1,
record.getItem( offset + 1 ).get< int >( 0 ) - 1,
record.getItem( offset + 2 ).get< int >( 0 ) - 1
}};
}
inline std::array< int, 3 > getijk( const Connection& completion ) { inline std::array< int, 3 > getijk( const Connection& completion ) {
return { { completion.getI(), completion.getJ(), completion.getK() }}; return { { completion.getI(), completion.getJ(), completion.getK() }};
@ -711,7 +711,7 @@ inline void keywordMISC( SummaryConfig::keyword_list& list,
auto cijk = getijk( connection ); auto cijk = getijk( connection );
int global_index = 1 + dims.getGlobalIndex(cijk[0], cijk[1], cijk[2]); int global_index = 1 + dims.getGlobalIndex(cijk[0], cijk[1], cijk[2]);
if( ijk_defaulted || ( cijk == getijk(record, 1) ) ) if( ijk_defaulted || ( cijk == getijk(record) ) )
list.push_back( param.number(global_index) ); list.push_back( param.number(global_index) );
} }
} }
@ -999,7 +999,7 @@ inline void handleKW( SummaryConfig::keyword_list& list,
// ===================================================================== // =====================================================================
SummaryConfigNode::Type parseKeywordType(const std::string& keyword) { SummaryConfigNode::Type parseKeywordType(std::string keyword) {
if (is_rate(keyword)) return SummaryConfigNode::Type::Rate; if (is_rate(keyword)) return SummaryConfigNode::Type::Rate;
if (is_total(keyword)) return SummaryConfigNode::Type::Total; if (is_total(keyword)) return SummaryConfigNode::Type::Total;
if (is_ratio(keyword)) return SummaryConfigNode::Type::Ratio; if (is_ratio(keyword)) return SummaryConfigNode::Type::Ratio;
@ -1327,6 +1327,10 @@ bool SummaryConfig::hasSummaryKey(const std::string& keyword ) const {
return summary_keywords.find(keyword) != summary_keywords.end(); return summary_keywords.find(keyword) != summary_keywords.end();
} }
const SummaryConfigNode& SummaryConfig::operator[](std::size_t index) const {
return this->m_keywords[index];
}
bool SummaryConfig::match(const std::string& keywordPattern) const { bool SummaryConfig::match(const std::string& keywordPattern) const {
int flags = 0; int flags = 0;

View File

@ -73,61 +73,73 @@ static Deck createDeck_no_wells( const std::string& summary ) {
static Deck createDeck( const std::string& summary ) { static Deck createDeck( const std::string& summary ) {
Opm::Parser parser; Opm::Parser parser;
std::string input = std::string input = R"(
"START -- 0 \n" START -- 0
"10 MAI 2007 / \n" 10 MAI 2007 /
"RUNSPEC\n" RUNSPEC
"\n"
"DIMENS\n" DIMENS
" 10 10 10 /\n" 10 10 10 /
"REGDIMS\n" REGDIMS
" 3/\n" 3/
"AQUDIMS\n" AQUDIMS
"1* 1* 1* 1* 3 200 1* 1* /\n" 1* 1* 1* 1* 3 200 1* 1* /
"GRID\n" GRID
"DXV \n 10*400 /\n" DXV
"DYV \n 10*400 /\n" 10*400 /
"DZV \n 10*400 /\n" DYV
"TOPS \n 100*2202 / \n" 10*400 /
"PERMX\n" DZV
" 1000*0.25 /\n" 10*400 /
"COPY\n" TOPS
" PERMX PERMY /\n" 100*2202 /
" PERMX PERMZ /\n" PERMX
"/\n" 1000*0.25 /
"PORO \n" COPY
" 1000*0.15 /\n" PERMX PERMY /
"REGIONS\n" PERMX PERMZ /
"FIPNUM\n" /
"200*1 300*2 500*3 /\n" PORO
"FIPREG\n" 1000*0.15 /
"200*10 300*20 500*30 /\n" REGIONS
"SOLUTION\n" FIPNUM
"AQUCT\n" 200*1 300*2 500*3 /
"1 2040 1* 1000 .3 3.0e-5 1330 10 360.0 1 1* /\n" FIPREG
"2 2040 1* 1000 .3 3.0e-5 1330 10 360.0 1 1* /\n" 200*10 300*20 500*30 /
"3 2040 1* 1000 .3 3.0e-5 1330 10 360.0 1 1* /\n" SOLUTION
"/\n" AQUCT
"AQUANCON\n" 1 2040 1* 1000 .3 3.0e-5 1330 10 360.0 1 1* /
"1 1 10 10 2 10 10 'I-' 0.88 1 /\n" 2 2040 1* 1000 .3 3.0e-5 1330 10 360.0 1 1* /
"2 9 10 10 10 10 10 'I+' 0.88 1 /\n" 3 2040 1* 1000 .3 3.0e-5 1330 10 360.0 1 1* /
"3 9 9 8 10 9 8 'I+' 0.88 1 /\n" /
"/\n" AQUANCON
"SCHEDULE\n" 1 1 10 10 2 10 10 'I-' 0.88 1 /
"WELSPECS\n" 2 9 10 10 10 10 10 'I+' 0.88 1 /
" \'W_1\' \'OP\' 1 1 3.33 \'OIL\' 7* / \n" 3 9 9 8 10 9 8 'I+' 0.88 1 /
" \'WX2\' \'OP\' 2 2 3.33 \'OIL\' 7* / \n" /
" \'W_3\' \'OP\' 2 5 3.92 \'OIL\' 7* / \n" SCHEDULE
" 'PRODUCER' 'G' 5 5 2000 'GAS' /\n" WELSPECS
"/\n" 'W_1' 'OP' 1 1 3.33 'OIL' 7* /
"COMPDAT\n" 'WX2' 'OP' 2 2 3.33 'OIL' 7* /
"'PRODUCER' 5 5 1 1 'OPEN' 1* -1 0.5 / \n" 'W_3' 'OP' 2 5 3.92 'OIL' 7* /
"'W_1' 3 7 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 / \n" 'PRODUCER' 'G' 5 5 2000 'GAS' /
"'W_1' 2 2 1 1 /\n" /
"'WX2' 2 2 1 1 /\n" COMPDAT
"/\n" 'PRODUCER' 5 5 1 1 'OPEN' 1* -1 0.5 /
"SUMMARY\n" 'W_1' 3 7 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 /
+ summary; 'W_1' 2 2 1 1 /
'W_1' 2 2 2 2 /
'WX2' 2 2 1 1 /
/
COMPLUMP
W_1 3 7 2 2 2 /
W_1 2 2 2 2 2 /
W_1 2 2 1 1 4 /
/
SUMMARY
)" + summary;
return parser.parseString(input); return parser.parseString(input);
} }
@ -353,11 +365,11 @@ BOOST_AUTO_TEST_CASE(completions) {
"/\n"; "/\n";
const auto summary = createSummary( input ); const auto summary = createSummary( input );
const auto keywords = { "CGIR", "CGIR", "CGIR", "CGIR", const auto keywords = { "CGIR", "CGIR", "CGIR", "CGIR", "CGIR",
"CGIT", "CGIT", "CGIT", "CGIT",
"CPRL", "CPRL", "CPRL", "CPRL", "CPRL", "CPRL", "CPRL", "CPRL", "CPRL",
"CWIR", "CWIR", "CWIR", "CWIR",
"CWIT", "CWIT" }; "CWIT", "CWIT", "CWIT" };
const auto names = sorted_keywords( summary ); const auto names = sorted_keywords( summary );
BOOST_CHECK_EQUAL_COLLECTIONS( BOOST_CHECK_EQUAL_COLLECTIONS(