Update VREP even for iter > nupcol if VREP changes significant

This commit is contained in:
Tor Harald Sandve
2024-11-20 17:46:31 +01:00
parent 3188ac713a
commit 7639450ce1
5 changed files with 70 additions and 17 deletions
@@ -1179,7 +1179,8 @@ groupAndNetworkData(const int reportStepIdx) const
template<class Scalar>
void BlackoilWellModelGeneric<Scalar>::
updateAndCommunicateGroupData(const int reportStepIdx,
const int iterationIdx)
const int iterationIdx,
DeferredLogger& deferred_logger)
{
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
const int nupcol = schedule()[reportStepIdx].nupcol();
@@ -1188,8 +1189,48 @@ updateAndCommunicateGroupData(const int reportStepIdx,
// before we copy to well_state_nupcol_.
this->wellState().updateGlobalIsGrup(comm_);
if (iterationIdx < nupcol) {
if (iterationIdx <= nupcol) {
this->updateNupcolWGState();
} else {
Scalar tol_nupcol = 0.01;
for (const auto& gr_name : schedule().groupNames(reportStepIdx)) {
const Phase all[] = { Phase::WATER, Phase::OIL, Phase::GAS };
for (Phase phase : all) {
if (this->groupState().has_injection_control(gr_name, phase)) {
if (this->groupState().injection_control(gr_name, phase) == Group::InjectionCMode::VREP) {
const Group& group = schedule().getGroup(gr_name, reportStepIdx);
const int np = this->wellState().numPhases();
Scalar resv_nupcol = 0.0;
for (int phaseIdx = 0; phaseIdx < np; ++phaseIdx) {
resv_nupcol += WellGroupHelpers<Scalar>::sumWellPhaseRates(true,
group,
schedule(),
this->nupcolWellState(),
reportStepIdx,
phaseIdx,
/*isInjector*/ false);
}
Scalar resv_wellstate = 0.0;
for (int phaseIdx = 0; phaseIdx < np; ++phaseIdx) {
resv_wellstate += WellGroupHelpers<Scalar>::sumWellPhaseRates(true,
group,
schedule(),
this->wellState(),
reportStepIdx,
phaseIdx,
/*isInjector*/ false);
}
if ( std::abs( (resv_nupcol - resv_wellstate) / (0.5*resv_nupcol + 0.5*resv_wellstate)) > tol_nupcol) {
this->updateNupcolWGState();
const std::string msg = fmt::format("Group prodution relative change larger than tolerance {} "
"at iteration {}. Update VREP for Group {} even if iteration is larger than {} given by NUPCOL." ,
tol_nupcol, iterationIdx, gr_name, nupcol);
deferred_logger.info(msg);
}
}
}
}
}
}
auto& well_state = this->wellState();
@@ -376,7 +376,8 @@ protected:
const int reportStepIdx);
void updateAndCommunicateGroupData(const int reportStepIdx,
const int iterationIdx);
const int iterationIdx,
DeferredLogger& deferred_logger);
void inferLocalShutWells();
@@ -472,7 +472,7 @@ namespace Opm {
const int reportStepIdx = simulator_.episodeIndex();
this->updateAndCommunicateGroupData(reportStepIdx,
simulator_.model().newtonMethod().numIterations());
simulator_.model().newtonMethod().numIterations(), local_deferredLogger);
this->wellState().updateWellsDefaultALQ(this->schedule(), reportStepIdx, this->summaryState());
this->wellState().gliftTimeStepInit();
@@ -2176,7 +2176,7 @@ namespace Opm {
const int iterationIdx = simulator_.model().newtonMethod().numIterations();
const auto& comm = simulator_.vanguard().grid().comm();
this->updateAndCommunicateGroupData(episodeIdx, iterationIdx);
this->updateAndCommunicateGroupData(episodeIdx, iterationIdx, deferred_logger);
// network related
bool more_network_update = false;
@@ -2430,7 +2430,7 @@ namespace Opm {
const int iterationIdx,
DeferredLogger& deferred_logger)
{
this->updateAndCommunicateGroupData(reportStepIdx, iterationIdx);
this->updateAndCommunicateGroupData(reportStepIdx, iterationIdx, deferred_logger);
// updateWellStateWithTarget might throw for multisegment wells hence we
// have a parallel try catch here to thrown on all processes.
@@ -2442,7 +2442,7 @@ namespace Opm {
}
OPM_END_PARALLEL_TRY_CATCH("BlackoilWellModel::updateAndCommunicate failed: ",
simulator_.gridView().comm())
this->updateAndCommunicateGroupData(reportStepIdx, iterationIdx);
this->updateAndCommunicateGroupData(reportStepIdx, iterationIdx, deferred_logger);
}
template<typename TypeTag>
+12 -10
View File
@@ -75,14 +75,19 @@ namespace {
return {oilRate, gasRate, waterRate};
}
} // namespace Anonymous
namespace Opm {
template<class Scalar>
Scalar sumWellPhaseRates(bool res_rates,
const Opm::Group& group,
const Opm::Schedule& schedule,
const Opm::WellState<Scalar>& wellState,
const int reportStepIdx,
const int phasePos,
const bool injector)
Scalar WellGroupHelpers<Scalar>::
sumWellPhaseRates(bool res_rates,
const Opm::Group& group,
const Opm::Schedule& schedule,
const Opm::WellState<Scalar>& wellState,
const int reportStepIdx,
const int phasePos,
const bool injector)
{
Scalar rate = 0.0;
@@ -128,9 +133,6 @@ namespace {
}
return rate;
}
} // namespace Anonymous
namespace Opm {
template<class Scalar>
void WellGroupHelpers<Scalar>::
@@ -47,6 +47,15 @@ template<class Scalar>
class WellGroupHelpers
{
public:
static Scalar sumWellPhaseRates(bool res_rates,
const Opm::Group& group,
const Opm::Schedule& schedule,
const Opm::WellState<Scalar>& wellState,
const int reportStepIdx,
const int phasePos,
const bool injector);
static void setCmodeGroup(const Group& group,
const Schedule& schedule,
const SummaryState& summaryState,