ACTIONX: Works with WELOPEN and msim

This commit is contained in:
Joakim Hove
2019-01-28 10:00:08 +01:00
parent 420b66822b
commit d82be29745
13 changed files with 769 additions and 51 deletions

View File

@@ -1147,7 +1147,7 @@ namespace Opm {
}
}
void Schedule::handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) {
void Schedule::handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors, const std::vector<std::string>& matching_wells) {
auto all_defaulted = []( const DeckRecord& rec ) {
auto defaulted = []( const DeckItem& item ) {
@@ -1163,7 +1163,7 @@ namespace Opm {
const auto& wellNamePattern = record.getItem( "WELL" ).getTrimmedString(0);
const auto& status_str = record.getItem( "STATUS" ).getTrimmedString( 0 );
auto wells = getWells( wellNamePattern );
auto wells = getWells( wellNamePattern, matching_wells );
if (wells.empty())
invalidNamePattern( wellNamePattern, parseContext, errors, keyword);
@@ -1881,22 +1881,32 @@ namespace Opm {
return { tmp.begin(), tmp.end() };
}
std::vector< Well* > Schedule::getWells(const std::string& wellNamePattern) {
size_t wildcard_pos = wellNamePattern.find("*");
std::vector< Well* > Schedule::getWells(const std::string& wellNamePattern, const std::vector<std::string>& matching_wells) {
// If we arrive here during the handling the body of a ACTIONX keyword
// we can arrive with wellname '?' and a set of matching wells.
if (wellNamePattern == "?") {
std::vector<Well*> wells;
for (const auto& well_name : matching_wells)
wells.push_back( std::addressof(m_wells.get(well_name) ));
if( wildcard_pos != wellNamePattern.length()-1 ) {
if( !m_wells.hasKey( wellNamePattern ) ) return {};
return { std::addressof( m_wells.get( wellNamePattern ) ) };
}
return wells;
} else {
auto wildcard_pos = wellNamePattern.find("*");
std::vector< Well* > wells;
for( auto& well : this->m_wells ) {
if( Well::wellNameInWellNamePattern( well.name(), wellNamePattern ) ) {
wells.push_back( std::addressof( well ) );
if( wildcard_pos != wellNamePattern.length()-1 ) {
if( !m_wells.hasKey( wellNamePattern ) ) return {};
return { std::addressof( m_wells.get( wellNamePattern ) ) };
}
}
return wells;
std::vector< Well* > wells;
for( auto& well : this->m_wells ) {
if( Well::wellNameInWellNamePattern( well.name(), wellNamePattern ) ) {
wells.push_back( std::addressof( well ) );
}
}
return wells;
}
}
void Schedule::addGroup(const std::string& groupName, size_t timeStep) {
@@ -2162,5 +2172,20 @@ namespace Opm {
return this->m_actions;
}
void Schedule::applyAction(size_t reportStep, const ActionX& action, const std::vector<std::string>& matching_wells) {
ParseContext parseContext;
ErrorGuard errors;
for (const auto& keyword : action) {
if (actionx_whitelist.find(keyword.name()) == actionx_whitelist.end())
throw std::invalid_argument("The keyword: " + keyword.name() + " can not be handled in the ACTION body");
if (keyword.name() == "WELOPEN")
this->handleWELOPEN(keyword, reportStep, parseContext, errors, matching_wells);
}
}
}