moving function needRebalanceNetwork to BlackoilWellModelGeneric

This commit is contained in:
Kai Bao 2023-05-08 13:26:23 +02:00
parent 05795c0bb1
commit 926228401a
4 changed files with 28 additions and 31 deletions

View File

@ -372,9 +372,6 @@ namespace Opm {
// the reservoir should stay static during this solution procedure.
void balanceNetwork(DeferredLogger& deferred_logger);
// TODO: funciton can go to BlackoilWellModelGeneric?
bool needRebalanceNetwork() const;
// used to better efficiency of calcuation
mutable BVector scaleAddRes_{};

View File

@ -906,6 +906,30 @@ hasTHPConstraints() const
return BlackoilWellModelConstraints(*this).hasTHPConstraints();
}
bool
BlackoilWellModelGeneric::
needRebalanceNetwork(const int report_step) const
{
const auto& network = schedule()[report_step].network();
if (!network.active()) {
return 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());
// TODO: we might find more relevant events to be included here
if (is_partof_network && events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)) {
network_rebalance_necessary = true;
break;
}
}
network_rebalance_necessary = comm_.max(network_rebalance_necessary);
return network_rebalance_necessary;
}
bool
BlackoilWellModelGeneric::
forceShutWellByName(const std::string& wellname,

View File

@ -158,6 +158,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;
/// Shut down any single well
/// Returns true if the well was actually found and shut.
bool forceShutWellByName(const std::string& wellname,

View File

@ -1802,39 +1802,12 @@ namespace Opm {
template<typename TypeTag>
bool
BlackoilWellModel<TypeTag>::
needRebalanceNetwork() const
{
const int reportStepIdx = ebosSimulator_.episodeIndex();
const auto& network = schedule()[reportStepIdx].network();
if (!network.active()) {
return false;
}
bool network_rebalance_necessary = false;
for (const auto& well : well_container_) {
const auto& events = this->wellState().well(well->indexOfWell()).events;
const bool is_partof_network = network.has_node(well->wellEcl().groupName());
// TODO: we might find more relevant events to be included here
if (is_partof_network && events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)) {
network_rebalance_necessary = true;
break;
}
}
network_rebalance_necessary = comm_.max(network_rebalance_necessary);
return network_rebalance_necessary;
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
prepareTimeStep(DeferredLogger& deferred_logger)
{
const bool network_rebalance_necessary = this->needRebalanceNetwork();
const bool network_rebalance_necessary = this->needRebalanceNetwork(ebosSimulator_.episodeIndex());
for (const auto& well : well_container_) {
auto& events = this->wellState().well(well->indexOfWell()).events;