added: allowEmpty parameter to Schedule::wellNames

allows bypassing exception if there are no matches.
This commit is contained in:
Arne Morten Kvarving
2023-10-04 17:50:57 +02:00
parent 3f40960469
commit a7a84f6f2f
2 changed files with 8 additions and 3 deletions

View File

@@ -645,7 +645,9 @@ namespace Opm
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,
const HandlerContext& context,
bool allowEmpty = false);
std::vector<std::string> wellNames(const std::string& pattern, std::size_t timeStep, const std::vector<std::string>& matching_wells, InputErrorAction error_action, ErrorGuard& errors, const KeywordLocation& location) const;
void invalidNamePattern( const std::string& namePattern, const HandlerContext& context) const;
static std::string formatDate(std::time_t t);

View File

@@ -1216,11 +1216,14 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
std::vector<std::string> Schedule::wellNames(const std::string& pattern, const HandlerContext& context) {
std::vector<std::string> Schedule::wellNames(const std::string& pattern,
const HandlerContext& context,
bool allowEmpty)
{
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()) {
if (names.empty() && !allowEmpty) {
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 {}.