Merge pull request #1839 from joakim-hove/eval-udq

Eval udq
This commit is contained in:
Bård Skaflestad 2020-06-24 14:15:27 +02:00 committed by GitHub
commit 2876751fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 34 deletions

View File

@ -38,6 +38,7 @@ namespace Opm {
class DeckRecord;
class Deck;
class SummaryState;
class UDQConfig {
public:
UDQConfig() = default;
@ -55,6 +56,7 @@ namespace Opm {
void add_assign(const std::string& quantity, const std::vector<std::string>& selector, double value);
void add_define(const std::string& quantity, const std::vector<std::string>& expression);
void eval(SummaryState& st) const;
std::vector<UDQDefine> definitions() const;
std::vector<UDQDefine> definitions(UDQVarType var_type) const;
std::vector<UDQInput> input() const;

View File

@ -1379,38 +1379,6 @@ bool need_wells(const Opm::EclIO::SummaryNode& node) {
throw std::runtime_error("Unhandled summary node category in need_wells");
}
void eval_udq(const Opm::Schedule& schedule, std::size_t sim_step, Opm::SummaryState& st)
{
using namespace Opm;
const UDQConfig& udq = schedule.getUDQConfig(sim_step);
const auto& func_table = udq.function_table();
UDQContext context(func_table, st);
for (const auto& assign : udq.assignments(UDQVarType::WELL_VAR)) {
auto ws = assign.eval(st.wells());
st.update_udq(ws);
}
for (const auto& def : udq.definitions(UDQVarType::WELL_VAR)) {
auto ws = def.eval(context);
st.update_udq(ws);
}
for (const auto& assign : udq.assignments(UDQVarType::GROUP_VAR)) {
auto ws = assign.eval(st.groups());
st.update_udq(ws);
}
for (const auto& def : udq.definitions(UDQVarType::GROUP_VAR)) {
auto ws = def.eval(context);
st.update_udq(ws);
}
for (const auto& def : udq.definitions(UDQVarType::FIELD_VAR)) {
auto field_udq = def.eval(context);
st.update_udq(field_udq);
}
}
void updateValue(const Opm::EclIO::SummaryNode& node, const double value, Opm::SummaryState& st)
{
@ -2668,8 +2636,8 @@ void Summary::eval(SummaryState& st,
well_solution, group_solution, single_values,
region_values, block_values, st);
eval_udq(schedule, sim_step, st);
const auto& udq = schedule.getUDQConfig(sim_step);
udq.eval(st);
st.update_elapsed(duration);
}

View File

@ -18,6 +18,7 @@
*/
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
@ -288,6 +289,34 @@ namespace Opm {
this->type_count == data.type_count;
}
void UDQConfig::eval(SummaryState& st) const {
const auto& func_table = this->function_table();
UDQContext context(func_table, st);
for (const auto& assign : this->assignments(UDQVarType::WELL_VAR)) {
auto ws = assign.eval(st.wells());
st.update_udq(ws);
}
for (const auto& def : this->definitions(UDQVarType::WELL_VAR)) {
auto ws = def.eval(context);
st.update_udq(ws);
}
for (const auto& assign : this->assignments(UDQVarType::GROUP_VAR)) {
auto ws = assign.eval(st.groups());
st.update_udq(ws);
}
for (const auto& def : this->definitions(UDQVarType::GROUP_VAR)) {
auto ws = def.eval(context);
st.update_udq(ws);
}
for (const auto& def : this->definitions(UDQVarType::FIELD_VAR)) {
auto field_udq = def.eval(context);
st.update_udq(field_udq);
}
}
}