Update collection of wells after ACTIONX

This commit is contained in:
Joakim Hove 2021-03-25 14:46:35 +01:00
parent 5fe43c09cb
commit 98f6a9a7ac
5 changed files with 29 additions and 24 deletions

View File

@ -45,6 +45,7 @@
#include <dune/geometry/referenceelements.hh> #include <dune/geometry/referenceelements.hh>
#include <map> #include <map>
#include <unordered_set>
namespace Opm { namespace Opm {
@ -1449,8 +1450,8 @@ protected:
void void
updateEclWell(int, const std::string&) { updateEclWells(int, const std::unordered_set<std::string>&) {
throw std::logic_error("updateEclWell() method not implemented for class eclpeacemanwell"); throw std::logic_error("updateEclWells() method not implemented for class eclpeacemanwell");
} }

View File

@ -1393,14 +1393,10 @@ public:
const auto& wellpi = this->fetchWellPI(reportStep, *action, schedule, matching_wells); const auto& wellpi = this->fetchWellPI(reportStep, *action, schedule, matching_wells);
schedule.applyAction(reportStep, Opm::TimeService::from_time_t(simTime), *action, actionResult, wellpi); auto affected_wells = schedule.applyAction(reportStep, Opm::TimeService::from_time_t(simTime), *action, actionResult, wellpi);
actionState.add_run(*action, simTime); actionState.add_run(*action, simTime);
this->wellModel_.updateEclWells(reportStep, affected_wells);
for ( const auto& [wname, _] : wellpi) {
(void)_;
if (this->wellModel_.hasWell(wname))
this->wellModel_.updateEclWell(reportStep, wname);
}
} else { } else {
std::string msg = "The action: " + action->name() + " evaluated to false at " + ts; std::string msg = "The action: " + action->name() + " evaluated to false at " + ts;
Opm::OpmLog::info(msg); Opm::OpmLog::info(msg);

View File

@ -51,6 +51,7 @@
#include <dune/grid/common/gridenums.hh> #include <dune/grid/common/gridenums.hh>
#include <map> #include <map>
#include <unordered_set>
#include <string> #include <string>
#include <vector> #include <vector>
@ -658,7 +659,7 @@ public:
void void
updateEclWell(int, const std::string&) { updateEclWells(int, const std::unordered_set<std::string>&) {
throw std::logic_error("wellPI() method not implemented for class eclwellmanager"); throw std::logic_error("wellPI() method not implemented for class eclwellmanager");
} }

View File

@ -365,7 +365,7 @@ namespace Opm {
/// Returns true if the well was actually found and shut. /// Returns true if the well was actually found and shut.
bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time); bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time);
void updateEclWell(const int timeStepIdx, const std::string& wname); void updateEclWells(const int timeStepIdx, const std::unordered_set<std::string>& wells);
bool hasWell(const std::string& wname); bool hasWell(const std::string& wname);
double wellPI(const int well_index) const; double wellPI(const int well_index) const;
double wellPI(const std::string& well_name) const; double wellPI(const std::string& well_name) const;

View File

@ -2628,25 +2628,32 @@ namespace Opm {
template<typename TypeTag> template<typename TypeTag>
void void
BlackoilWellModel<TypeTag>:: BlackoilWellModel<TypeTag>::
updateEclWell(const int timeStepIdx, const std::string& wname) updateEclWells(const int timeStepIdx, const std::unordered_set<std::string>& wells) {
{ const auto& schedule = this->ebosSimulator_.vanguard().schedule();
auto well_iter = std::find_if(this->wells_ecl_.begin(), this->wells_ecl_.end(), for (const auto& wname : wells) {
[&wname](const auto& well) -> bool auto well_iter = std::find_if( this->wells_ecl_.begin(), this->wells_ecl_.end(), [wname] (const auto& well) -> bool { return well.name() == wname;});
{ if (well_iter != this->wells_ecl_.end()) {
return well.name() == wname; auto well_index = std::distance( this->wells_ecl_.begin(), well_iter );
}); this->wells_ecl_[well_index] = schedule.getWell(wname, timeStepIdx);
if (well_iter == this->wells_ecl_.end()) { const auto& well = this->wells_ecl_[well_index];
throw std::logic_error { "Could not find well: " + wname }; auto& pd = this->well_perf_data_[well_index];
auto pdIter = pd.begin();
for (const auto& conn : well.getConnections()) {
if (conn.state() != Connection::State::SHUT) {
pdIter->connection_transmissibility_factor = conn.CF();
++pdIter;
}
}
this->wellState().updateStatus(well_index, well.getStatus());
this->wellState().resetConnectionTransFactors(well_index, pd);
this->prod_index_calc_[well_index].reInit(well);
}
} }
auto well_index = std::distance(this->wells_ecl_.begin(), well_iter);
this->updateEclWell(timeStepIdx, well_index);
} }
template<typename TypeTag> template<typename TypeTag>
double double
BlackoilWellModel<TypeTag>:: BlackoilWellModel<TypeTag>::
@ -2753,7 +2760,7 @@ namespace Opm {
++pdIter; ++pdIter;
} }
} }
this->well_state_.resetConnectionTransFactors(well_index, pd); this->wellState().resetConnectionTransFactors(well_index, pd);
this->prod_index_calc_[well_index].reInit(well); this->prod_index_calc_[well_index].reInit(well);
}; };