This commit is contained in:
Vegard Kippe 2023-11-26 12:13:59 +00:00 committed by GitHub
commit 6fc2d53954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 5 deletions

View File

@ -95,11 +95,13 @@ public:
int num_attempt{0};
bool closed{true};
bool close_on_next_step{false};
std::optional<int> wtest_report_step;
WTestWell() = default;
WTestWell(const std::string& wname, WTest::Reason reason_, double last_test);
WTestWell(const std::string& wname, WTest::Reason reason_, double last_test, bool close_now = false);
void close_now(double sim_time);
int int_reason() const;
static WTest::Reason inverse_ecl_reason(int ecl_reason);
@ -109,6 +111,7 @@ public:
this->last_test == other.last_test &&
this->num_attempt == other.num_attempt &&
this->closed == other.closed &&
this->close_on_next_step == other.close_on_next_step &&
this->wtest_report_step == other.wtest_report_step;
}
@ -122,6 +125,7 @@ public:
serializer(this->last_test);
serializer(this->num_attempt);
serializer(this->closed);
serializer(this->close_on_next_step);
serializer(this->wtest_report_step);
}
@ -132,6 +136,7 @@ public:
buffer.write(this->last_test);
buffer.write(this->num_attempt);
buffer.write(this->closed);
buffer.write(this->close_on_next_step);
buffer.write(this->wtest_report_step);
}
@ -142,6 +147,7 @@ public:
buffer.read(this->last_test);
buffer.read(this->num_attempt);
buffer.read(this->closed);
buffer.read(this->close_on_next_step);
buffer.read(this->wtest_report_step);
}
};
@ -211,6 +217,8 @@ public:
That is the reason we do not have any xxx_is_open() predicates.
*/
void close_well(const std::string& well_name, WTest::Reason reason, double sim_time);
void close_well_on_next_step(const std::string& well_name, WTest::Reason reason, double sim_time);
void update_close_on_next_step_wells(double sim_time);
bool well_is_closed(const std::string& well_name) const;
void open_well(const std::string& well_name);
std::size_t num_closed_wells() const;

View File

@ -21,6 +21,8 @@
#include <ctime>
#include <stdexcept>
#include <fmt/format.h>
#include <opm/input/eclipse/Schedule/Well/WellTestConfig.hpp>
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
@ -28,11 +30,25 @@
namespace Opm {
WellTestState::WTestWell::WTestWell(const std::string& wname, WellTestConfig::Reason reason_, double sim_time)
WellTestState::WTestWell::WTestWell(const std::string& wname, WellTestConfig::Reason reason_, double sim_time, bool close_now)
: name(wname)
, reason(reason_)
, last_test(sim_time)
{}
{
if (! close_now) {
close_on_next_step = true;
closed = false;
last_test = -1.0;
}
}
void WellTestState::WTestWell::close_now(double sim_time) {
if (close_on_next_step) {
close_on_next_step = false;
closed = true;
last_test = sim_time;
}
}
int WellTestState::WTestWell::int_reason() const {
if (!this->closed)
@ -80,16 +96,38 @@ namespace Opm {
void WellTestState::close_well(const std::string& well_name, WellTestConfig::Reason reason, double sim_time) {
OpmLog::debug(fmt::format("Closing well {} at time {:.2f} days", well_name, sim_time/86400.0));
auto well_iter = this->wells.find(well_name);
if (well_iter == this->wells.end())
this->wells.emplace(well_name, WTestWell{well_name, reason, sim_time});
this->wells.emplace(well_name, WTestWell{well_name, reason, sim_time, true});
else {
well_iter->second.closed = true;
well_iter->second.close_on_next_step = false;
well_iter->second.last_test = sim_time;
well_iter->second.reason = reason;
}
}
void WellTestState::close_well_on_next_step(const std::string& well_name, WellTestConfig::Reason reason, double sim_time) {
OpmLog::debug(fmt::format("Time {:.2f} days: Will close well {} on next time step", sim_time/86400.0, well_name));
auto well_iter = this->wells.find(well_name);
if (well_iter == this->wells.end())
this->wells.emplace(well_name, WTestWell{well_name, reason, sim_time, false});
else {
well_iter->second.closed = false;
well_iter->second.close_on_next_step = true;
well_iter->second.last_test = -1.0;
well_iter->second.reason = reason;
}
}
// \Note: iterate and update last_test (time) for wells that that have close_on_next_step = true
void WellTestState::update_close_on_next_step_wells(double sim_time) {
for (auto& [wname, well] : this->wells) {
well.close_now(sim_time);
}
}
void WellTestState::open_well(const std::string& well_name) {
auto& well = this->wells.at(well_name);