Merge pull request #2139 from joakim-hove/actionx-required-summary-variables
ACTIONX: Determine required summary keywords
This commit is contained in:
commit
9c6c07c294
@ -1,6 +1,8 @@
|
||||
#ifndef ASTNODE_HPP
|
||||
#define ASTNODE_HPP
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
|
||||
|
||||
#include "ActionValue.hpp"
|
||||
@ -27,6 +29,7 @@ public:
|
||||
void add_child(const ASTNode& child);
|
||||
size_t size() const;
|
||||
std::string func;
|
||||
void required_summary(std::unordered_set<std::string>& required_summary) const;
|
||||
|
||||
bool operator==(const ASTNode& data) const;
|
||||
|
||||
|
@ -21,9 +21,10 @@
|
||||
#ifndef ActionAST_HPP
|
||||
#define ActionAST_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp>
|
||||
|
||||
@ -56,6 +57,7 @@ public:
|
||||
{
|
||||
serializer(condition);
|
||||
}
|
||||
void required_summary(std::unordered_set<std::string>& required_summary) const;
|
||||
|
||||
private:
|
||||
/*
|
||||
|
@ -21,9 +21,10 @@
|
||||
#ifndef ActionX_HPP_
|
||||
#define ActionX_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp>
|
||||
@ -75,7 +76,7 @@ public:
|
||||
bool ready(const State& state, std::time_t sim_time) const;
|
||||
Action::Result eval(const Action::Context& context) const;
|
||||
|
||||
|
||||
void required_summary(std::unordered_set<std::string>& required_summary) const;
|
||||
std::string name() const { return this->m_name; }
|
||||
size_t max_run() const { return this->m_max_run; }
|
||||
double min_wait() const { return this->m_min_wait; }
|
||||
|
@ -78,6 +78,7 @@ namespace Opm {
|
||||
static std::time_t mkdate(int year, int month, int day);
|
||||
static std::time_t mkdatetime(int year, int month, int day, int hour, int minute, int second);
|
||||
static const std::map<std::string, int>& eclipseMonthIndices();
|
||||
static bool valid_month(const std::string& month_name);
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Units/Units.hpp>
|
||||
@ -3168,12 +3169,15 @@ std::vector<Opm::EclIO::SummaryNode> make_default_nodes(const std::string& keywo
|
||||
|
||||
|
||||
void Opm::out::Summary::SummaryImplementation::configureUDQ(const SummaryConfig& summary_config, const Schedule& sched) {
|
||||
const std::unordered_set<std::string> time_vectors = {"TIME", "DAY", "MONTH", "YEAR", "YEARS"};
|
||||
const std::unordered_set<std::string> time_vectors = {"TIME", "DAY", "MONTH", "YEAR", "YEARS", "MNTH"};
|
||||
auto nodes = std::vector<Opm::EclIO::SummaryNode> {};
|
||||
std::unordered_set<std::string> summary_keys;
|
||||
for (const auto& udq_ptr : sched.udqConfigList())
|
||||
udq_ptr->required_summary(summary_keys);
|
||||
|
||||
for (const auto& action : sched.actions(sched.size() - 1))
|
||||
action.required_summary(summary_keys);
|
||||
|
||||
for (const auto& key : summary_keys) {
|
||||
const auto& default_nodes = make_default_nodes(key, sched);
|
||||
for (const auto& def_node : default_nodes)
|
||||
@ -3205,6 +3209,12 @@ void Opm::out::Summary::SummaryImplementation::configureUDQ(const SummaryConfig&
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.is_user_defined())
|
||||
continue;
|
||||
|
||||
if (TimeMap::valid_month(node.keyword))
|
||||
continue;
|
||||
|
||||
throw std::logic_error(fmt::format("Evaluation function for: {} not found ", node.keyword));
|
||||
}
|
||||
}
|
||||
|
@ -169,5 +169,13 @@ bool ASTNode::operator==(const ASTNode& data) const {
|
||||
children == data.children;
|
||||
}
|
||||
|
||||
void ASTNode::required_summary(std::unordered_set<std::string>& required_summary) const {
|
||||
if (this->type == TokenType::ecl_expr)
|
||||
required_summary.insert( this->func );
|
||||
|
||||
for (const auto& node : this->children)
|
||||
node.required_summary(required_summary);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ bool AST::operator==(const AST& data) const {
|
||||
return !condition || (*condition == *data.condition);
|
||||
}
|
||||
|
||||
void AST::required_summary(std::unordered_set<std::string>& required_summary) const {
|
||||
this->condition->required_summary(required_summary);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -194,5 +194,10 @@ bool ActionX::operator==(const ActionX& data) const {
|
||||
this->conditions() == data.conditions();
|
||||
}
|
||||
|
||||
|
||||
void ActionX::required_summary(std::unordered_set<std::string>& required_summary) const {
|
||||
this->condition.required_summary(required_summary);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -246,6 +246,11 @@ struct TimeMapContext {
|
||||
}
|
||||
|
||||
|
||||
bool TimeMap::valid_month(const std::string& month_name) {
|
||||
return (month_indices.count(month_name) != 0);
|
||||
}
|
||||
|
||||
|
||||
std::time_t TimeMap::timeFromEclipse(const DeckRecord &dateRecord) {
|
||||
const auto &dayItem = dateRecord.getItem(0);
|
||||
const auto &monthItem = dateRecord.getItem(1);
|
||||
|
@ -1043,6 +1043,11 @@ TSTEP
|
||||
const auto& glo = sched.glo(0);
|
||||
BOOST_CHECK(!glo.has_group("PLAT-A"));
|
||||
}
|
||||
std::unordered_set<std::string> required_summary;
|
||||
action1.required_summary(required_summary);
|
||||
BOOST_CHECK_EQUAL( required_summary.count("WWCT"), 1);
|
||||
BOOST_CHECK_EQUAL( required_summary.count("FPR"), 1);
|
||||
|
||||
|
||||
Action::Result action_result(true);
|
||||
sched.applyAction(0, action1, action_result);
|
||||
@ -1094,6 +1099,9 @@ TSTEP
|
||||
const auto& well = sched.getWell("PROD1", 0);
|
||||
BOOST_CHECK_EQUAL( well.getWellPIScalingFactor(1.0), 1.0);
|
||||
}
|
||||
std::unordered_set<std::string> required_summary;
|
||||
action1.required_summary(required_summary);
|
||||
BOOST_CHECK_EQUAL( required_summary.count("WWCT"), 1);
|
||||
|
||||
Action::Result action_result(true);
|
||||
sched.applyAction(0, action1, action_result);
|
||||
|
@ -815,4 +815,8 @@ TSTEP
|
||||
BOOST_CHECK_NO_THROW( Opm::TimeMap(deck2, restart) );
|
||||
BOOST_CHECK_NO_THROW( Opm::TimeMap(deck3, restart) );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap(deck4, restart) , std::exception);
|
||||
|
||||
|
||||
BOOST_CHECK(Opm::TimeMap::valid_month("MAR"));
|
||||
BOOST_CHECK(!Opm::TimeMap::valid_month("Tulleogtøys"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user