Avoid iterating network if no network wells are in prediciton mode

This commit is contained in:
Vegard Kippe 2023-09-20 09:43:58 +02:00
parent f2d3d2d144
commit 663c62e366
4 changed files with 8 additions and 4 deletions

View File

@ -214,6 +214,7 @@ namespace Opm {
void endTimeStep() void endTimeStep()
{ {
updateNetworkPressures(ebosSimulator_.episodeIndex(), true);
OPM_TIMEBLOCK(endTimeStep); OPM_TIMEBLOCK(endTimeStep);
timeStepSucceeded(ebosSimulator_.time(), ebosSimulator_.timeStepSize()); timeStepSucceeded(ebosSimulator_.time(), ebosSimulator_.timeStepSize());
} }

View File

@ -991,8 +991,9 @@ needRebalanceNetwork(const int report_step) const
for (const auto& well : well_container_generic_) { for (const auto& well : well_container_generic_) {
const auto& events = this->wellState().well(well->indexOfWell()).events; 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();
// TODO: we might find more relevant events to be included here // TODO: we might find more relevant events to be included here
if (is_partof_network && events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)) { if (prediction_mode && is_partof_network && events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE)) {
network_rebalance_necessary = true; network_rebalance_necessary = true;
break; break;
} }
@ -1057,7 +1058,7 @@ inferLocalShutWells()
double double
BlackoilWellModelGeneric:: BlackoilWellModelGeneric::
updateNetworkPressures(const int reportStepIdx) updateNetworkPressures(const int reportStepIdx, const bool compute_only)
{ {
// Get the network and return if inactive. // Get the network and return if inactive.
const auto& network = schedule()[reportStepIdx].network(); const auto& network = schedule()[reportStepIdx].network();
@ -1076,6 +1077,8 @@ updateNetworkPressures(const int reportStepIdx)
// here, the network imbalance is the difference between the previous nodal pressure and the new nodal pressure // here, the network imbalance is the difference between the previous nodal pressure and the new nodal pressure
double network_imbalance = 0.; double network_imbalance = 0.;
if (compute_only)
return network_imbalance;
if (!previous_node_pressures.empty()) { if (!previous_node_pressures.empty()) {
for (const auto& [name, pressure]: previous_node_pressures) { for (const auto& [name, pressure]: previous_node_pressures) {

View File

@ -320,7 +320,7 @@ protected:
bool wasDynamicallyShutThisTimeStep(const int well_index) const; bool wasDynamicallyShutThisTimeStep(const int well_index) const;
double updateNetworkPressures(const int reportStepIdx); double updateNetworkPressures(const int reportStepIdx, const bool compute_only = false);
void updateWsolvent(const Group& group, void updateWsolvent(const Group& group,
const int reportStepIdx, const int reportStepIdx,

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 = network_imbalance > tolerance; more_network_update = this->needRebalanceNetwork(episodeIdx) && network_imbalance > tolerance;
} }
bool changed_well_group = false; bool changed_well_group = false;