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

View File

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

View File

@@ -1853,7 +1853,7 @@ namespace Opm {
const auto& balance = schedule()[episodeIdx].network_balance(); const auto& balance = schedule()[episodeIdx].network_balance();
constexpr double relaxtion_factor = 10.0; constexpr double relaxtion_factor = 10.0;
const double tolerance = relax_network_tolerance ? relaxtion_factor * balance.pressure_tolerance() : balance.pressure_tolerance(); 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; bool changed_well_group = false;
@@ -2239,7 +2239,8 @@ namespace Opm {
BlackoilWellModel<TypeTag>:: BlackoilWellModel<TypeTag>::
prepareTimeStep(DeferredLogger& deferred_logger) 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_) { for (const auto& well : well_container_) {
auto& events = this->wellState().well(well->indexOfWell()).events; auto& events = this->wellState().well(well->indexOfWell()).events;