addressing some reviewing comments for PR#3067

This commit is contained in:
Kai Bao 2022-07-06 14:32:59 +02:00
parent b87867d144
commit 96ab0e036d
4 changed files with 26 additions and 35 deletions

View File

@ -504,7 +504,7 @@ namespace Opm
ErrorGuard& errors;
SimulatorUpdate * sim_update;
const std::unordered_map<std::string, double> * target_wellpi;
std::unordered_map<std::string, double>* wellpi_global_factor;
std::unordered_map<std::string, double>* wpimult_global_factor;
const ScheduleGrid& grid;
HandlerContext(const ScheduleBlock& block_,
@ -517,7 +517,7 @@ namespace Opm
ErrorGuard& errors_,
SimulatorUpdate * sim_update_,
const std::unordered_map<std::string, double> * target_wellpi_,
std::unordered_map<std::string, double>* wellpi_global_factor_ = nullptr)
std::unordered_map<std::string, double>* wpimult_global_factor_)
: block(block_)
, keyword(keyword_)
, currentStep(currentStep_)
@ -527,7 +527,7 @@ namespace Opm
, errors(errors_)
, sim_update(sim_update_)
, target_wellpi(target_wellpi_)
, wellpi_global_factor(wellpi_global_factor_)
, wpimult_global_factor(wpimult_global_factor_)
, grid(grid_)
{}
@ -596,7 +596,7 @@ namespace Opm
bool actionx_mode,
SimulatorUpdate* sim_update,
const std::unordered_map<std::string, double>* target_wellpi,
std::unordered_map<std::string, double>* wellpi_global_factor = nullptr);
std::unordered_map<std::string, double>* wpimult_global_factor = nullptr);
void prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword);
void store_wgnames(const DeckKeyword& keyword);
@ -605,7 +605,7 @@ namespace Opm
void invalidNamePattern( const std::string& namePattern, const HandlerContext& context) const;
static std::string formatDate(std::time_t t);
std::string simulationDays(std::size_t currentStep) const;
void applyGlobalWPIMULT( const std::unordered_map<std::string, double>& factors);
void applyGlobalWPIMULT( const std::unordered_map<std::string, double>& wpimult_global_factor);
bool must_write_rst_file(std::size_t report_step) const;

View File

@ -1778,16 +1778,13 @@ Well{0} entered with disallowed 'FIELD' parent group:
// the I, J, K location and completion number range.
// When defaulted, it assumes it is negative
// When inputting a negative value, it assumes it is defaulted.
auto defaultConCompRec = [] (const DeckRecord& rec)-> bool {
bool default_con_comp = true;
for (size_t i = 2; i < rec.size(); ++i) {
const auto& item = rec.getItem(i);
if (item.get<int>(0) >= 0) {
default_con_comp = false;
break;
}
}
return default_con_comp;
auto defaultConCompRec = [](const DeckRecord& wpimult)
{
return std::all_of(wpimult.begin() + 2, wpimult.end(),
[](const DeckItem& item)
{
return item.defaultApplied(0) || (item.get<int>(0) < 0);
});
};
for (const auto& record : handlerContext.keyword) {
@ -1801,13 +1798,13 @@ Well{0} entered with disallowed 'FIELD' parent group:
// whether it is the last one.
const bool default_con_comp = defaultConCompRec(record);
if (default_con_comp) {
auto wellpi_global_factor = handlerContext.wellpi_global_factor;
if (!wellpi_global_factor) {
throw std::runtime_error(" wellpi_global_factor is nullptr in function handleWPIMULT ");
auto wpimult_global_factor = handlerContext.wpimult_global_factor;
if (!wpimult_global_factor) {
throw std::runtime_error(" wpimult_global_factor is nullptr in function handleWPIMULT ");
}
const auto scaling_factor = record.getItem("WELLPI").get<double>(0);
for (const auto& wname : well_names) {
(*wellpi_global_factor)[wname] = scaling_factor;
(*wpimult_global_factor)[wname] = scaling_factor;
}
continue;
}

View File

@ -314,7 +314,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const std::optional
bool actionx_mode,
SimulatorUpdate* sim_update,
const std::unordered_map<std::string, double>* target_wellpi,
std::unordered_map<std::string, double>* wellpi_global_factor)
std::unordered_map<std::string, double>* wpimult_global_factor)
{
static const std::unordered_set<std::string> require_grid = {
@ -323,7 +323,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const std::optional
};
HandlerContext handlerContext { block, keyword, grid, currentStep, matching_wells, actionx_mode, parseContext, errors, sim_update, target_wellpi, wellpi_global_factor};
HandlerContext handlerContext { block, keyword, grid, currentStep, matching_wells, actionx_mode, parseContext, errors, sim_update, target_wellpi,
wpimult_global_factor};
/*
The grid and fieldProps members create problems for reiterating the
Schedule section. We therefor single them out very clearly here.
@ -537,10 +538,8 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
} // for (auto report_step = load_start
}
void Schedule::applyGlobalWPIMULT( const std::unordered_map<std::string, double>& wellpi_global_factor) {
for (const auto& elem : wellpi_global_factor) {
const auto& well_name = elem.first;
const auto factor = elem.second;
void Schedule::applyGlobalWPIMULT( const std::unordered_map<std::string, double>& wpimult_global_factor) {
for (const auto& [well_name, factor] : wpimult_global_factor) {
auto well = this->snapshots.back().wells(well_name);
if (well.applyGlobalWPIMULT(factor)) {
this->snapshots.back().wells.update(std::move(well));

View File

@ -15,28 +15,23 @@
},
{
"name": "I",
"value_type": "INT",
"default" : -1
"value_type": "INT"
},
{
"name": "J",
"value_type": "INT",
"default" : -1
"value_type": "INT"
},
{
"name": "K",
"value_type": "INT",
"default" : -1
"value_type": "INT"
},
{
"name": "FIRST",
"value_type": "INT",
"default" : -1
"value_type": "INT"
},
{
"name": "LAST",
"value_type": "INT",
"default" : -1
"value_type": "INT"
}
]
}