From 8a879147400d2a1930872da0195732fb83133e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 2 Sep 2020 11:45:33 +0200 Subject: [PATCH] Don't Repeatedly Calculate Same Guiderate Value Doing so works reduces the impact of the damping factor. --- .../eclipse/EclipseState/Schedule/Group/GuideRate.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp index 8955cc2ef..da2bb081f 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp @@ -252,14 +252,19 @@ void GuideRate::assign_grvalue(const std::string& wgname, const GuideRateModel& model, GuideRateValue&& value) { - using std::swap; - auto& v = this->values[wgname]; if (v == nullptr) { v = std::make_unique(); } - swap(v->prev, v->curr); + if (value.sim_time > v->curr.sim_time) { + // We've advanced in time since we previously calculated/stored this + // guiderate value. Push current value into the past and prepare to + // capture new value. + using std::swap; + + swap(v->prev, v->curr); + } v->curr = std::move(value);