Merge pull request #2363 from joakim-hove/action-wells-specified

Make sure action results contain well for fully specified condition
This commit is contained in:
Joakim Hove
2021-03-17 13:44:09 +01:00
committed by GitHub
4 changed files with 58 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ namespace Action {
class Value {
public:
explicit Value(double value);
Value(const std::string& wname, double value);
Value() = default;
Result eval_cmp(TokenType op, const Value& rhs) const;

View File

@@ -133,7 +133,13 @@ Action::Value ASTNode::value(const Action::Context& context) const {
std::string arg_key = this->arg_list[0];
for (size_t index = 1; index < this->arg_list.size(); index++)
arg_key += ":" + this->arg_list[index];
return Action::Value(context.get(this->func, arg_key));
auto scalar_value = context.get(this->func, arg_key);
if (this->func_type == FuncType::well)
return Action::Value(this->arg_list[0], scalar_value);
else
return Action::Value(scalar_value);
}
}
}

View File

@@ -81,6 +81,9 @@ Value::Value(double value) :
is_scalar(true)
{ }
Value::Value(const std::string& wname, double value) {
this->add_well(wname, value);
}
double Value::scalar() const {
if (!this->is_scalar)

View File

@@ -1287,3 +1287,50 @@ ENDACTIO
}
}
BOOST_AUTO_TEST_CASE(MatchingWellsSpecified1) {
Action::AST ast({"WBHP", "P1", "<", "200"});
auto st = SummaryState{ TimeService::now() };
Opm::WListManager wlm;
st.update_well_var("P1", "WBHP", 150);
Opm::Action::Context context(st, wlm);
auto result = ast.eval(context);
BOOST_CHECK(result);
BOOST_CHECK(result.wells() == std::vector<std::string>{"P1"});
}
BOOST_AUTO_TEST_CASE(MatchingWellsSpecified2) {
const auto deck_string = std::string{ R"(
SCHEDULE
WELSPECS
'P1' 'OP' 1 1 3.33 'OIL' 7*/
/
ACTIONX
INJECTION 10 /
WBHP P1 < 200.0 /
/
WELOPEN
'WI1' 'OPEN' 5* /
/
ENDACTIO
)"};
auto st = SummaryState{ TimeService::now() };
Schedule sched = make_schedule(deck_string);
Opm::WListManager wlm;
st.update_well_var("P1", "WBHP", 150);
Opm::Action::Context context(st, wlm);
const auto& action = sched[0].actions.get().get("INJECTION");
auto result = action.eval(context);
BOOST_CHECK(result);
BOOST_CHECK(result.wells() == std::vector<std::string>{"P1"});
}