Merge pull request #3568 from bska/fix-udq-assign-well-level
Don't Run ASSIGN on Every Report Step
This commit is contained in:
@@ -127,7 +127,8 @@ void msim::run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solut
|
||||
/* initial_inplace = */ {},
|
||||
/* inplace = */ {});
|
||||
|
||||
this->schedule.getUDQConfig( report_step ).eval(report_step, schedule.wellMatcher(report_step), this->st, udq_state);
|
||||
this->schedule.getUDQConfig(report_step)
|
||||
.eval(report_step, this->schedule, schedule.wellMatcher(report_step), this->st, udq_state);
|
||||
|
||||
this->output(wtest_state,
|
||||
udq_state,
|
||||
|
||||
@@ -40,9 +40,10 @@
|
||||
namespace Opm {
|
||||
|
||||
class DeckRecord;
|
||||
class KeywordLocation;
|
||||
class Schedule;
|
||||
class SummaryState;
|
||||
class UDQState;
|
||||
class KeywordLocation;
|
||||
class WellMatcher;
|
||||
|
||||
} // namespace Opm
|
||||
@@ -73,8 +74,8 @@ namespace Opm {
|
||||
void add_assign(const std::string& quantity, const std::unordered_set<std::string>& selector, double value, std::size_t report_step);
|
||||
void add_define(const std::string& quantity, const KeywordLocation& location, const std::vector<std::string>& expression, std::size_t report_step);
|
||||
|
||||
void eval_assign(std::size_t report_step, const WellMatcher& wm, SummaryState& st, UDQState& udq_state) const;
|
||||
void eval(std::size_t report_step, const WellMatcher& wm, SummaryState& st, UDQState& udq_state) const;
|
||||
void eval_assign(std::size_t report_step, const Schedule& sched, const WellMatcher& wm, SummaryState& st, UDQState& udq_state) const;
|
||||
void eval(std::size_t report_step, const Schedule& sched, const WellMatcher& wm, SummaryState& st, UDQState& udq_state) const;
|
||||
const UDQDefine& define(const std::string& key) const;
|
||||
const UDQAssign& assign(const std::string& key) const;
|
||||
std::vector<UDQDefine> definitions() const;
|
||||
@@ -115,7 +116,7 @@ namespace Opm {
|
||||
private:
|
||||
void add_node(const std::string& quantity, UDQAction action);
|
||||
UDQAction action_type(const std::string& udq_key) const;
|
||||
void eval_assign(std::size_t report_step, SummaryState& st, UDQState& udq_state, UDQContext& context) const;
|
||||
void eval_assign(std::size_t report_step, const Schedule& sched, UDQState& udq_state, UDQContext& context) const;
|
||||
void eval_define(std::size_t report_step, UDQState& udq_state, UDQContext& context) const;
|
||||
|
||||
UDQParams udq_params;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
||||
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
||||
#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
|
||||
#include <opm/input/eclipse/Schedule/UDQ/UDQInput.hpp>
|
||||
@@ -440,20 +441,23 @@ namespace Opm {
|
||||
}
|
||||
|
||||
void UDQConfig::eval_assign(const std::size_t report_step,
|
||||
SummaryState& st,
|
||||
const Schedule& sched,
|
||||
UDQState& udq_state,
|
||||
UDQContext& context) const
|
||||
{
|
||||
const auto wells = sched.wellNames(report_step);
|
||||
const auto groups = sched.groupNames(report_step);
|
||||
|
||||
for (const auto& assign : this->assignments(UDQVarType::WELL_VAR)) {
|
||||
if (udq_state.assign(report_step, assign.keyword())) {
|
||||
auto ws = assign.eval(st.wells());
|
||||
if (udq_state.assign(assign.report_step(), assign.keyword())) {
|
||||
auto ws = assign.eval(wells);
|
||||
context.update_assign(report_step, assign.keyword(), ws);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& assign : this->assignments(UDQVarType::GROUP_VAR)) {
|
||||
if (udq_state.assign(report_step, assign.keyword())) {
|
||||
auto ws = assign.eval(st.groups());
|
||||
if (udq_state.assign(assign.report_step(), assign.keyword())) {
|
||||
auto ws = assign.eval(groups);
|
||||
context.update_assign(report_step, assign.keyword(), ws);
|
||||
}
|
||||
}
|
||||
@@ -505,22 +509,24 @@ namespace Opm {
|
||||
}
|
||||
|
||||
void UDQConfig::eval(const std::size_t report_step,
|
||||
const Schedule& sched,
|
||||
const WellMatcher& wm,
|
||||
SummaryState& st,
|
||||
UDQState& udq_state) const
|
||||
{
|
||||
UDQContext context(this->function_table(), wm, st, udq_state);
|
||||
this->eval_assign(report_step, st, udq_state, context);
|
||||
this->eval_assign(report_step, sched, udq_state, context);
|
||||
this->eval_define(report_step, udq_state, context);
|
||||
}
|
||||
|
||||
void UDQConfig::eval_assign(const std::size_t report_step,
|
||||
const Schedule& sched,
|
||||
const WellMatcher& wm,
|
||||
SummaryState& st,
|
||||
UDQState& udq_state) const
|
||||
{
|
||||
UDQContext context(this->function_table(), wm, st, udq_state);
|
||||
this->eval_assign(report_step, st, udq_state, context);
|
||||
this->eval_assign(report_step, sched, udq_state, context);
|
||||
}
|
||||
|
||||
void UDQConfig::required_summary(std::unordered_set<std::string>& summary_keys) const
|
||||
|
||||
@@ -1949,7 +1949,7 @@ UDQ
|
||||
SummaryState st(TimeService::now());
|
||||
auto undefined_value = udq.params().undefinedValue();
|
||||
UDQState udq_state(undefined_value);
|
||||
udq.eval(0, {}, st, udq_state);
|
||||
udq.eval(0, schedule, {}, st, udq_state);
|
||||
|
||||
BOOST_CHECK_EQUAL( st.get("FU_UADD"), 12); // 10 + 2
|
||||
|
||||
@@ -1975,7 +1975,7 @@ DEFINE FU_PAR2 FU_PAR3 /
|
||||
auto undefined_value = udq.params().undefinedValue();
|
||||
UDQState udq_state(undefined_value);
|
||||
st.update("FMWPR", 100);
|
||||
udq.eval(0, {}, st, udq_state);
|
||||
udq.eval(0, schedule, {}, st, udq_state);
|
||||
|
||||
BOOST_CHECK_EQUAL(st.get("FU_PAR2"), 100);
|
||||
}
|
||||
@@ -1993,7 +1993,7 @@ DEFINE FU_PAR3 FU_PAR2 + 1/
|
||||
SummaryState st(TimeService::now());
|
||||
auto undefined_value = udq.params().undefinedValue();
|
||||
UDQState udq_state(undefined_value);
|
||||
udq.eval(0, {}, st, udq_state);
|
||||
udq.eval(0, schedule, {}, st, udq_state);
|
||||
|
||||
BOOST_CHECK_EQUAL(st.get("FU_PAR2"), undefined_value);
|
||||
BOOST_CHECK_EQUAL(st.get("FU_PAR3"), undefined_value);
|
||||
@@ -2103,7 +2103,7 @@ DEFINE WUGASRA 750000 - WGLIR '*' /
|
||||
|
||||
NameOrder wo({"W1", "W2", "W3"});
|
||||
WellMatcher wm(wo);
|
||||
udq.eval(0, wm, st, udq_state);
|
||||
udq.eval(0, schedule, wm, st, udq_state);
|
||||
{
|
||||
std::unordered_set<std::string> required_keys;
|
||||
udq.required_summary(required_keys);
|
||||
@@ -2307,7 +2307,7 @@ DEFINE FU_VAR91 GOPR TEST /
|
||||
st.update_well_var("W3", "WGLIR", 3);
|
||||
st.update_group_var("TEST", "GOPR", 1);
|
||||
|
||||
udq.eval(0, {}, st, udq_state);
|
||||
udq.eval(0, schedule, {}, st, udq_state);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDQ_KEY_ERROR) {
|
||||
@@ -2326,7 +2326,7 @@ UDQ
|
||||
UDQState udq_state(undefined_value);
|
||||
SummaryState st(TimeService::now());
|
||||
|
||||
BOOST_CHECK_THROW(udq.eval(0, {}, st, udq_state), std::exception);
|
||||
BOOST_CHECK_THROW(udq.eval(0, schedule, {}, st, udq_state), std::exception);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDQ_ASSIGN) {
|
||||
@@ -2351,7 +2351,7 @@ UDQ
|
||||
BOOST_CHECK(required_keys.empty());
|
||||
}
|
||||
|
||||
udq.eval(0, {}, st, udq_state);
|
||||
udq.eval(0, schedule, {}, st, udq_state);
|
||||
BOOST_CHECK_EQUAL(st.get("FU_VAR1"), 10);
|
||||
}
|
||||
|
||||
@@ -2392,7 +2392,7 @@ TSTEP
|
||||
// Counting: 1,2,3,4,5
|
||||
for (std::size_t report_step = 0; report_step < 5; report_step++) {
|
||||
const auto& udq = schedule.getUDQConfig(report_step);
|
||||
udq.eval(report_step, schedule.wellMatcher(report_step), st, udq_state);
|
||||
udq.eval(report_step, schedule, schedule.wellMatcher(report_step), st, udq_state);
|
||||
auto fu_var1 = st.get("FU_VAR1");
|
||||
BOOST_CHECK_EQUAL(fu_var1, report_step + 1);
|
||||
}
|
||||
@@ -2400,7 +2400,7 @@ TSTEP
|
||||
// Reset to zero and count: 1,2,3,4,5
|
||||
for (std::size_t report_step = 5; report_step < 10; report_step++) {
|
||||
const auto& udq = schedule.getUDQConfig(report_step);
|
||||
udq.eval(report_step, schedule.wellMatcher(report_step), st, udq_state);
|
||||
udq.eval(report_step, schedule, schedule.wellMatcher(report_step), st, udq_state);
|
||||
auto fu_var1 = st.get("FU_VAR1");
|
||||
BOOST_CHECK_EQUAL(fu_var1, report_step - 4);
|
||||
}
|
||||
@@ -2408,7 +2408,7 @@ TSTEP
|
||||
// Reset to zero and stay there.
|
||||
for (std::size_t report_step = 10; report_step < 15; report_step++) {
|
||||
const auto& udq = schedule.getUDQConfig(report_step);
|
||||
udq.eval(report_step, schedule.wellMatcher(report_step),st, udq_state);
|
||||
udq.eval(report_step, schedule, schedule.wellMatcher(report_step),st, udq_state);
|
||||
auto fu_var1 = st.get("FU_VAR1");
|
||||
BOOST_CHECK_EQUAL(fu_var1, 0);
|
||||
}
|
||||
@@ -2459,7 +2459,7 @@ UDQ
|
||||
SummaryState st(TimeService::now());
|
||||
|
||||
const auto& udq = schedule.getUDQConfig(0);
|
||||
udq.eval(0, {}, st, udq_state);
|
||||
udq.eval(0, schedule, {}, st, udq_state);
|
||||
auto fu_var1 = st.get("FU_VAR1");
|
||||
auto fu_var2 = st.get("FU_VAR2");
|
||||
auto fu_var3 = st.get("FU_VAR3");
|
||||
@@ -2504,7 +2504,7 @@ UDQ
|
||||
st.update_well_var("P3", "WOPR", 3);
|
||||
st.update_well_var("P4", "WOPR", 4);
|
||||
|
||||
udq.eval(0, schedule.wellMatcher(0), st, udq_state);
|
||||
udq.eval(0, schedule, schedule.wellMatcher(0), st, udq_state);
|
||||
auto fu_var1 = st.get("FU_VAR1");
|
||||
auto fu_var2 = st.get("FU_VAR2");
|
||||
auto fu_var3 = st.get("FU_VAR3");
|
||||
@@ -2530,7 +2530,7 @@ UDQ
|
||||
UDQState udq_state(0);
|
||||
SummaryState st(TimeService::now());
|
||||
const auto& udq = schedule.getUDQConfig(0);
|
||||
udq.eval(0, schedule.wellMatcher(0), st, udq_state);
|
||||
udq.eval(0, schedule, schedule.wellMatcher(0), st, udq_state);
|
||||
|
||||
auto fu_var1 = st.get("FU_VAR1");
|
||||
auto fu_var2 = st.get("FU_VAR2");
|
||||
|
||||
@@ -419,7 +419,11 @@ RestartValue first_sim(const Setup& setup, Action::State& action_state, SummaryS
|
||||
const auto& udq = setup.schedule.getUDQConfig(report_step);
|
||||
RestartValue restart_value(sol, wells, groups, {});
|
||||
|
||||
udq.eval(report_step, setup.schedule.wellMatcher(report_step), st, udq_state);
|
||||
udq.eval(report_step,
|
||||
setup.schedule,
|
||||
setup.schedule.wellMatcher(report_step),
|
||||
st, udq_state);
|
||||
|
||||
eclWriter.writeTimeStep( action_state,
|
||||
wtest_state,
|
||||
st,
|
||||
|
||||
Reference in New Issue
Block a user