Merge pull request #4363 from akva2/balance_hpp_include

add missing Balance.hpp includes
This commit is contained in:
Markus Blatt 2023-01-11 13:29:24 +01:00 committed by GitHub
commit 286d00f434
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 31 deletions

View File

@ -35,6 +35,7 @@
#include <opm/input/eclipse/Schedule/Group/GuideRateConfig.hpp>
#include <opm/input/eclipse/Schedule/MSW/SICD.hpp>
#include <opm/input/eclipse/Schedule/MSW/Valve.hpp>
#include <opm/input/eclipse/Schedule/Network/Balance.hpp>
#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQASTNode.hpp>

View File

@ -278,7 +278,6 @@ namespace Opm {
// at the beginning of each time step (Not report step)
void prepareTimeStep(DeferredLogger& deferred_logger);
void initPrimaryVariablesEvaluation() const;
bool shouldBalanceNetwork(const int reportStepIndex, const int iterationIdx) const;
std::tuple<bool, bool, double> updateWellControls(DeferredLogger& deferred_logger);
void updateAndCommunicate(const int reportStepIdx,

View File

@ -34,6 +34,7 @@
#include <opm/input/eclipse/Schedule/Group/GConSump.hpp>
#include <opm/input/eclipse/Schedule/Group/GuideRateConfig.hpp>
#include <opm/input/eclipse/Schedule/Group/GuideRate.hpp>
#include <opm/input/eclipse/Schedule/Network/Balance.hpp>
#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
@ -1206,4 +1207,35 @@ runWellPIScaling(const int timeStepIdx,
this->last_run_wellpi_ = timeStepIdx;
}
bool
BlackoilWellModelGeneric::
shouldBalanceNetwork(const int reportStepIdx, const int iterationIdx) const
{
const auto& balance = schedule()[reportStepIdx].network_balance();
if (balance.mode() == Network::Balance::CalcMode::TimeStepStart) {
return iterationIdx == 0;
} else if (balance.mode() == Network::Balance::CalcMode::NUPCOL) {
const int nupcol = schedule()[reportStepIdx].nupcol();
return iterationIdx < nupcol;
} else {
// We do not support any other rebalancing modes,
// i.e. TimeInterval based rebalancing is not available.
// This should be warned about elsewhere, so we choose to
// avoid spamming with a warning here.
return false;
}
}
bool
BlackoilWellModelGeneric::
shouldIterateNetwork(const int reportStepIdx,
const std::size_t recursion_level,
const double network_imbalance) const
{
const auto& balance = schedule()[reportStepIdx].network_balance();
// Iterate if not converged, and number of iterations is not yet max (NETBALAN item 3).
return recursion_level < balance.pressure_max_iter() &&
network_imbalance > balance.pressure_tolerance();
}
}

View File

@ -170,6 +170,13 @@ public:
bool reportStepStarts() const { return report_step_starts_; }
bool shouldBalanceNetwork(const int reportStepIndex,
const int iterationIdx) const;
bool shouldIterateNetwork(const int reportStepIndex,
const std::size_t recursion_level,
const double network_imbalance) const;
protected:
/*

View File

@ -23,6 +23,7 @@
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/grid/utility/cartesianToCompressed.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/simulators/wells/BlackoilWellModelConstraints.hpp>
@ -934,12 +935,9 @@ namespace Opm {
// Maybe do a recursive call to iterate network and well controls.
if (network_changed) {
if (shouldBalanceNetwork(reportStepIdx, iterationIdx)) {
const auto& balance = schedule()[reportStepIdx].network_balance();
// Iterate if not converged, and number of iterations is not yet max (NETBALAN item 3).
if (recursion_level < balance.pressure_max_iter() && network_imbalance > balance.pressure_tolerance()) {
well_group_control_changed = assembleImpl(iterationIdx, dt, recursion_level + 1, local_deferredLogger);
}
if (shouldBalanceNetwork(reportStepIdx, iterationIdx) &&
shouldIterateNetwork(reportStepIdx, recursion_level, network_imbalance)) {
well_group_control_changed = assembleImpl(iterationIdx, dt, recursion_level + 1, local_deferredLogger);
}
}
return well_group_control_changed;
@ -1446,30 +1444,6 @@ namespace Opm {
template<typename TypeTag>
bool
BlackoilWellModel<TypeTag>::
shouldBalanceNetwork(const int reportStepIdx, const int iterationIdx) const
{
const auto& balance = schedule()[reportStepIdx].network_balance();
if (balance.mode() == Network::Balance::CalcMode::TimeStepStart) {
return iterationIdx == 0;
} else if (balance.mode() == Network::Balance::CalcMode::NUPCOL) {
const int nupcol = schedule()[reportStepIdx].nupcol();
return iterationIdx < nupcol;
} else {
// We do not support any other rebalancing modes,
// i.e. TimeInterval based rebalancing is not available.
// This should be warned about elsewhere, so we choose to
// avoid spamming with a warning here.
return false;
}
}
template<typename TypeTag>
std::tuple<bool, bool, double>
BlackoilWellModel<TypeTag>::

View File

@ -72,6 +72,7 @@
#include <opm/input/eclipse/Schedule/MSW/AICD.hpp>
#include <opm/input/eclipse/Schedule/MSW/SICD.hpp>
#include <opm/input/eclipse/Schedule/MSW/Valve.hpp>
#include <opm/input/eclipse/Schedule/Network/Balance.hpp>
#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
#include <opm/input/eclipse/Schedule/Network/Node.hpp>
#include <opm/input/eclipse/Schedule/OilVaporizationProperties.hpp>