Separate network active and need for rebalance bool + perform check per timestep only.

This commit is contained in:
Vegard Kippe 2023-09-21 08:31:53 +02:00
parent 663c62e366
commit a8b4c25bfb
3 changed files with 31 additions and 12 deletions

View File

@ -139,6 +139,13 @@ wellsActive() const
return wells_active_;
}
bool
BlackoilWellModelGeneric::
networkActive() const
{
return network_active_;
}
bool
BlackoilWellModelGeneric::
anyMSWellOpenLocal() const
@ -978,29 +985,35 @@ hasTHPConstraints() const
return BlackoilWellModelConstraints(*this).hasTHPConstraints();
}
bool
std::pair<bool, bool>
BlackoilWellModelGeneric::
needRebalanceNetwork(const int report_step) const
{
const auto& network = schedule()[report_step].network();
if (!network.active()) {
return false;
return {false, false};
}
bool network_active = false;
bool network_rebalance_necessary = false;
for (const auto& well : well_container_generic_) {
const auto& events = this->wellState().well(well->indexOfWell()).events;
const bool is_partof_network = network.has_node(well->wellEcl().groupName());
const bool prediction_mode = well->wellEcl().predictionMode();
// TODO: we might find more relevant events to be included here
if (prediction_mode && is_partof_network && events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)) {
network_rebalance_necessary = true;
break;
if (is_partof_network && prediction_mode) {
network_active = true;
}
// TODO: we might find more relevant events to be included here
const auto& events = this->wellState().well(well->indexOfWell()).events;
if (is_partof_network && events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)) {
network_rebalance_necessary = true;
}
if (network_active && network_rebalance_necessary)
break;
}
network_rebalance_necessary = comm_.max(network_rebalance_necessary);
network_active = comm_.max(network_active);
return network_rebalance_necessary;
return {network_active, network_rebalance_necessary};
}
bool

View File

@ -103,6 +103,9 @@ public:
bool wellsActive() const;
bool hasWell(const std::string& wname) const;
/// return true if network is active (at least one network well in prediction mode)
bool networkActive() const;
// whether there exists any multisegment well open on this process
bool anyMSWellOpenLocal() const;
@ -169,8 +172,9 @@ public:
/// Return true if any well has a THP constraint.
bool hasTHPConstraints() const;
/// Whether it is necessary to re-balance network
bool needRebalanceNetwork(const int report_step) const;
/// Checks if network is active (at least one network well on prediction),
/// and whether it is necessary to re-balance the network
std::pair<bool,bool> needRebalanceNetwork(const int report_step) const;
/// Shut down any single well
/// Returns true if the well was actually found and shut.
@ -431,6 +435,7 @@ protected:
PhaseUsage phase_usage_;
bool terminal_output_{false};
bool wells_active_{false};
bool network_active_{false};
bool initial_step_{};
bool report_step_starts_{};

View File

@ -1853,7 +1853,7 @@ namespace Opm {
const auto& balance = schedule()[episodeIdx].network_balance();
constexpr double relaxtion_factor = 10.0;
const double tolerance = relax_network_tolerance ? relaxtion_factor * balance.pressure_tolerance() : balance.pressure_tolerance();
more_network_update = this->needRebalanceNetwork(episodeIdx) && network_imbalance > tolerance;
more_network_update = this->networkActive() && network_imbalance > tolerance;
}
bool changed_well_group = false;
@ -2239,7 +2239,8 @@ namespace Opm {
BlackoilWellModel<TypeTag>::
prepareTimeStep(DeferredLogger& deferred_logger)
{
const bool network_rebalance_necessary = this->needRebalanceNetwork(ebosSimulator_.episodeIndex());
bool network_rebalance_necessary{false};
std::tie(this->network_active_, network_rebalance_necessary) = this->needRebalanceNetwork(ebosSimulator_.episodeIndex());
for (const auto& well : well_container_) {
auto& events = this->wellState().well(well->indexOfWell()).events;