Log well and group names encountered in ACTIONX

This commit is contained in:
Joakim Hove 2021-12-13 18:31:34 +01:00
parent aabc3b999b
commit e4be1e83b0
3 changed files with 36 additions and 3 deletions

View File

@ -40,6 +40,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/MessageLimits.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/RPTConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/WGNames.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleDeck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/PAvg.hpp>
@ -314,6 +315,7 @@ namespace Opm
m_static.serializeOp(serializer);
restart_output.serializeOp(serializer);
this->completed_cells.serializeOp(serializer);
this->action_wgnames.serializeOp(serializer);
pack_unpack<PAvg, Serializer>(serializer);
pack_unpack<WellTestConfig, Serializer>(serializer);
@ -517,6 +519,7 @@ namespace Opm
ScheduleStatic m_static;
ScheduleDeck m_sched_deck;
Action::WGNames action_wgnames;
std::optional<int> exit_status;
std::vector<ScheduleState> snapshots;
WriteRestartFileEvents restart_output;
@ -573,6 +576,7 @@ namespace Opm
const std::unordered_map<std::string, double> * target_wellpi);
void prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword);
void store_wgnames(const DeckKeyword& keyword);
std::vector<std::string> wellNames(const std::string& pattern, const HandlerContext& context);
std::vector<std::string> wellNames(const std::string& pattern, std::size_t timeStep, const std::vector<std::string>& matching_wells, InputError::Action error_action, ErrorGuard& errors, const KeywordLocation& location) const;
void invalidNamePattern( const std::string& namePattern, const HandlerContext& context) const;

View File

@ -496,6 +496,7 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
if (Action::ActionX::valid_keyword(action_keyword.name())){
action.addKeyword(action_keyword);
this->prefetch_cell_properties(grid, action_keyword);
this->store_wgnames(action_keyword);
}
else {
std::string msg_fmt = fmt::format("The keyword {} is not supported in the ACTIONX block", action_keyword.name());
@ -535,6 +536,19 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
this->snapshots.back().actions.update( std::move(new_actions) );
}
void Schedule::store_wgnames(const DeckKeyword& keyword) {
if(keyword.is<ParserKeywords::WELSPECS>()) {
for (const auto& record : keyword) {
const auto& wname = record.getItem<ParserKeywords::WELSPECS::WELL>().get<std::string>(0);
const auto& gname = record.getItem<ParserKeywords::WELSPECS::GROUP>().get<std::string>(0);
this->action_wgnames.add_well(wname);
this->action_wgnames.add_group(gname);
}
}
}
void Schedule::prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword){
if(keyword.is<ParserKeywords::COMPDAT>()){
for (auto record : keyword){
@ -987,9 +1001,16 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
std::vector<std::string> valid_names;
const auto& report_step = context.currentStep;
auto names = this->wellNames(pattern, report_step, context.matching_wells);
if (names.empty())
this->invalidNamePattern(pattern, context);
if (names.empty()) {
const auto& location = context.keyword.location();
if (this->action_wgnames.has_well(pattern)) {
std::string msg = fmt::format(R"(Well: {} not yet defined for keyword {}.
Expecting well to be defined with WELSPECS in ACTIONX before actual use.
File {} line {}.)", pattern, location.keyword, location.filename, location.lineno);
OpmLog::warning(msg);
} else
this->invalidNamePattern(pattern, context);
}
return names;
}

View File

@ -1312,6 +1312,14 @@ ENDACTIO
TSTEP
10 /
WELOPEN
'PROD1' 'OPEN' 5* /
/
TSTEP
10/
)"};
const auto st = SummaryState{ TimeService::now() };