Use Action::State object to keep track of actions being run

This commit is contained in:
Joakim Hove 2020-06-16 14:09:49 +02:00
parent f54245f1ca
commit dd1591f1a2
23 changed files with 313 additions and 254 deletions

View File

@ -24,6 +24,11 @@ class ParseContext;
class Parser;
class Python;
class SummaryState;
namespace Action {
class State;
}
class msim {
public:
@ -37,12 +42,12 @@ public:
void well_rate(const std::string& well, data::Rates::opt rate, std::function<well_rate_function> func);
void solution(const std::string& field, std::function<solution_function> func);
void run(Schedule& schedule, EclipseIO& io, bool report_only);
void post_step(Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step);
void post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step);
private:
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const;
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const;
void output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const;
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const;
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const;
void output(Action::State& action_state, SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const;
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const;
EclipseState state;

View File

@ -29,6 +29,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
@ -44,18 +45,19 @@ void msim::run(Schedule& schedule, EclipseIO& io, bool report_only) {
const double week = 7 * 86400;
data::Solution sol;
SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime()));
Action::State action_state;
Python python;
io.writeInitial();
for (size_t report_step = 1; report_step < schedule.size(); report_step++) {
data::Wells well_data;
if (report_only)
run_step(schedule, st, sol, well_data, report_step, io);
run_step(schedule, action_state, st, sol, well_data, report_step, io);
else {
double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1));
run_step(schedule, st, sol, well_data, report_step, time_step, io);
run_step(schedule, action_state, st, sol, well_data, report_step, time_step, io);
}
post_step(schedule, st, sol, well_data, report_step);
post_step(schedule, action_state, st, sol, well_data, report_step);
const auto& exit_status = schedule.exitStatus();
if (exit_status.has_value())
return;
@ -67,7 +69,7 @@ UDAValue msim::uda_val() {
}
void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, size_t report_step) {
void msim::post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, size_t report_step) {
const auto& actions = schedule.actions(report_step);
if (actions.empty())
return;
@ -75,8 +77,8 @@ void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* so
Action::Context context( st );
auto sim_time = schedule.simTime(report_step);
for (const auto& action : actions.pending(sim_time)) {
auto result = action->eval(sim_time, context);
for (const auto& action : actions.pending(action_state, sim_time)) {
auto result = action->eval(context);
if (result)
schedule.applyAction(report_step, *action, result);
}
@ -87,12 +89,12 @@ void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* so
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const {
this->run_step(schedule, st, sol, well_data, report_step, schedule.stepLength(report_step - 1), io);
void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const {
this->run_step(schedule, action_state, st, sol, well_data, report_step, schedule.stepLength(report_step - 1), io);
}
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const {
void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const {
double start_time = schedule.seconds(report_step - 1);
double end_time = schedule.seconds(report_step);
double seconds_elapsed = start_time;
@ -117,7 +119,8 @@ void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution&
group_data,
{});
this->output(st,
this->output(action_state,
st,
report_step,
(seconds_elapsed < end_time),
seconds_elapsed,
@ -129,9 +132,10 @@ void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution&
void msim::output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const {
void msim::output(Action::State& action_state, SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const {
RestartValue value(sol, well_data);
io.writeTimeStep(st,
io.writeTimeStep(action_state,
st,
report_step,
substep,
seconds_elapsed,

View File

@ -41,6 +41,10 @@ namespace Opm {
class Schedule;
class UDQInput;
class UDQActive;
namespace Action {
class State;
}
} // Opm
@ -52,10 +56,11 @@ class AggregateActionxData
public:
explicit AggregateActionxData(const std::vector<int>& actDims);
void captureDeclaredActionxData( const Opm::Schedule& sched,
const Opm::SummaryState& st,
const std::vector<int>& actDims,
const std::size_t simStep);
void captureDeclaredActionxData( const Opm::Schedule& sched,
const Opm::Action::State& action_state,
const Opm::SummaryState& st,
const std::vector<int>& actDims,
const std::size_t simStep);
const std::vector<int>& getIACT() const
{

View File

@ -33,6 +33,9 @@ namespace Opm {
class Schedule;
class SummaryState;
class UnitSystem;
namespace Action {
class State;
}
} // Opm
namespace Opm { namespace data {
@ -40,17 +43,18 @@ namespace Opm { namespace data {
}} // Opm::data
namespace Opm { namespace RestartIO { namespace Helpers {
class AggregateWellData
{
public:
explicit AggregateWellData(const std::vector<int>& inteHead);
void captureDeclaredWellData(const Schedule& sched,
const UnitSystem& units,
const std::size_t sim_step,
const ::Opm::SummaryState& smry,
const std::vector<int>& inteHead);
void captureDeclaredWellData(const Schedule& sched,
const UnitSystem& units,
const std::size_t sim_step,
const ::Opm::Action::State& action_state,
const ::Opm::SummaryState& smry,
const std::vector<int>& inteHead);
void captureDynamicWellData(const Opm::Schedule& sched,
const std::size_t sim_step,
@ -81,8 +85,8 @@ namespace Opm { namespace RestartIO { namespace Helpers {
return this->zWell_.data();
}
private:
/// Aggregate 'IWEL' array (Integer) for all wells.
WindowedArray<int> iWell_;

View File

@ -45,7 +45,7 @@ class EclipseState;
class Schedule;
class SummaryConfig;
class SummaryState;
namespace Action { class State; }
/*!
* \brief A class to write the reservoir state and the well state of a
* blackoil simulation to disk using the Eclipse binary format.
@ -174,7 +174,8 @@ public:
* hardcoded static map misc_units in Summary.cpp.
*/
void writeTimeStep( const SummaryState& st,
void writeTimeStep( const Action::State& action_state,
const SummaryState& st,
int report_step,
bool isSubstep,
double seconds_elapsed,
@ -220,7 +221,7 @@ public:
missing, if the bool is false missing keywords will be ignored
(there will *not* be an empty vector in the return value).
*/
RestartValue loadRestart(SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys = {}) const;
RestartValue loadRestart(Action::State& action_state, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys = {}) const;
const out::Summary& summary();
EclipseIO( const EclipseIO& ) = delete;

View File

@ -46,6 +46,12 @@ namespace Opm { namespace EclIO { namespace OutputStream {
}}}
namespace Opm { namespace Action {
class State;
}}
/*
The two free functions RestartIO::save() and RestartIO::load() can
be used to save and load reservoir and well state from restart
@ -76,12 +82,14 @@ namespace Opm { namespace RestartIO {
const EclipseState& es,
const EclipseGrid& grid,
const Schedule& schedule,
const Action::State& action_state,
const SummaryState& sumState,
bool write_double = false);
RestartValue load(const std::string& filename,
int report_step,
Action::State& action_state,
SummaryState& summary_state,
const std::vector<RestartKey>& solution_keys,
const EclipseState& es,

View File

@ -36,6 +36,7 @@ namespace Opm {
class DeckKeyword;
namespace Action {
class State;
/*
The ActionX class internalizes the ACTIONX keyword. This keyword represents a
@ -71,8 +72,8 @@ public:
static ActionX serializeObject();
void addKeyword(const DeckKeyword& kw);
bool ready(std::time_t sim_time) const;
Action::Result eval(std::time_t sim_time, const Action::Context& context) const;
bool ready(const State& state, std::time_t sim_time) const;
Action::Result eval(const Action::Context& context) const;
std::string name() const { return this->m_name; }
@ -105,8 +106,6 @@ public:
serializer.vector(keywords);
condition.serializeOp(serializer);
serializer.vector(m_conditions);
serializer(run_count);
serializer(last_run);
}
private:
@ -119,8 +118,6 @@ private:
std::vector<DeckKeyword> keywords;
Action::AST condition;
std::vector<Condition> m_conditions;
mutable size_t run_count = 0;
mutable std::time_t last_run = 0;
};
}

View File

@ -31,6 +31,8 @@
namespace Opm {
namespace Action {
class State;
/*
The Actions class is a container of ACTIONX keywords. The main functionality
is to provide a list of ACTIONX keywords which are ready to be evaluated.
@ -48,10 +50,10 @@ public:
bool empty() const;
void add(const ActionX& action);
void add(const PyAction& pyaction);
bool ready(std::time_t sim_time) const;
bool ready(const State& state, std::time_t sim_time) const;
const ActionX& get(const std::string& name) const;
const ActionX& get(std::size_t index) const;
std::vector<const ActionX *> pending(std::time_t sim_time) const;
std::vector<const ActionX *> pending(const State& state, std::time_t sim_time) const;
std::vector<const PyAction *> pending_python() const;
std::vector<ActionX>::const_iterator begin() const;

View File

@ -480,17 +480,18 @@ const std::map<cmp_enum, int> cmpToIndex = {
}
Opm::Action::Result
act_res(const Opm::Schedule& sched, const Opm::SummaryState& smry, const std::size_t sim_step, std::vector<Opm::Action::ActionX>::const_iterator act_x) {
act_res(const Opm::Schedule& sched, const Opm::Action::State& action_state, const Opm::SummaryState& smry, const std::size_t sim_step, std::vector<Opm::Action::ActionX>::const_iterator act_x) {
auto sim_time = sched.simTime(sim_step);
if (act_x->ready(sim_time)) {
if (act_x->ready(action_state, sim_time)) {
Opm::Action::Context context(smry);
return act_x->eval(sim_time, context);
return act_x->eval(context);
} else
return Opm::Action::Result(false);
}
template <class SACNArray>
void staticContrib(std::vector<Opm::Action::ActionX>::const_iterator actx_it,
const Opm::Action::State& action_state,
const Opm::SummaryState& st,
const Opm::Schedule& sched,
const std::size_t simStep,
@ -500,7 +501,7 @@ const std::map<cmp_enum, int> cmpToIndex = {
int noEPZacn = 16;
double undef_high_val = 1.0E+20;
const auto& wells = sched.getWells(simStep);
const auto ar = sACN::act_res(sched, st, simStep, actx_it);
const auto ar = sACN::act_res(sched, action_state, st, simStep, actx_it);
// write out the schedule Actionx conditions
const auto& actx_cond = actx_it->conditions();
for (const auto& z_data : actx_cond) {
@ -627,10 +628,11 @@ AggregateActionxData(const std::vector<int>& actDims)
void
Opm::RestartIO::Helpers::AggregateActionxData::
captureDeclaredActionxData( const Opm::Schedule& sched,
const Opm::SummaryState& st,
const std::vector<int>& actDims,
const std::size_t simStep)
captureDeclaredActionxData( const Opm::Schedule& sched,
const Opm::Action::State& action_state,
const Opm::SummaryState& st,
const std::vector<int>& actDims,
const std::size_t simStep)
{
const auto& acts = sched.actions(simStep);
std::size_t act_ind = 0;
@ -667,7 +669,7 @@ captureDeclaredActionxData( const Opm::Schedule& sched,
{
auto s_acn = this->sACN_[act_ind];
sACN::staticContrib(actx_it, st, sched, simStep, s_acn);
sACN::staticContrib(actx_it, action_state, st, sched, simStep, s_acn);
}
act_ind +=1;

View File

@ -38,6 +38,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <algorithm>
#include <cassert>
@ -807,13 +808,13 @@ namespace {
}
std::vector<std::pair<std::string, Opm::Action::Result>>
act_res_stat(const Opm::Schedule& sched, const Opm::SummaryState& smry, const std::size_t sim_step) {
act_res_stat(const Opm::Schedule& sched, const Opm::Action::State& action_state, const Opm::SummaryState& smry, const std::size_t sim_step) {
std::vector<std::pair<std::string, Opm::Action::Result>> results;
const auto& acts = sched.actions(sim_step);
Opm::Action::Context context(smry);
auto sim_time = sched.simTime(sim_step);
for (const auto& action : acts.pending(sim_time)) {
auto result = action->eval(sim_time, context);
for (const auto& action : acts.pending(action_state, sim_time)) {
auto result = action->eval(context);
if (result)
results.emplace_back( action->name(), std::move(result) );
}
@ -854,6 +855,7 @@ Opm::RestartIO::Helpers::AggregateWellData::
captureDeclaredWellData(const Schedule& sched,
const UnitSystem& units,
const std::size_t sim_step,
const ::Opm::Action::State& action_state,
const ::Opm::SummaryState& smry,
const std::vector<int>& inteHead)
{
@ -894,7 +896,7 @@ captureDeclaredWellData(const Schedule& sched,
});
{
const auto actResStat = ZWell::act_res_stat(sched, smry, sim_step);
const auto actResStat = ZWell::act_res_stat(sched, action_state, smry, sim_step);
// Static contributions to ZWEL array.
wellLoop(wells,
[&actResStat, this](const Well& well, const std::size_t wellID) -> void

View File

@ -187,7 +187,8 @@ void EclipseIO::writeInitial( data::Solution simProps, std::map<std::string, std
}
// implementation of the writeTimeStep method
void EclipseIO::writeTimeStep(const SummaryState& st,
void EclipseIO::writeTimeStep(const Action::State& action_state,
const SummaryState& st,
int report_step,
bool isSubstep,
double secs_elapsed,
@ -237,7 +238,7 @@ void EclipseIO::writeTimeStep(const SummaryState& st,
};
RestartIO::save(rstFile, report_step, secs_elapsed, value,
es, grid, schedule, st, write_double);
es, grid, schedule, action_state, st, write_double);
}
// RFT file written only if requested and never for substeps.
@ -275,7 +276,7 @@ void EclipseIO::writeTimeStep(const SummaryState& st,
}
RestartValue EclipseIO::loadRestart(SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys) const {
RestartValue EclipseIO::loadRestart(Action::State& action_state, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys) const {
const auto& es = this->impl->es;
const auto& grid = this->impl->grid;
const auto& schedule = this->impl->schedule;
@ -286,7 +287,7 @@ RestartValue EclipseIO::loadRestart(SummaryState& summary_state, const std::vect
report_step,
false );
return RestartIO::load(filename, report_step, summary_state, solution_keys,
return RestartIO::load(filename, report_step, action_state, summary_state, solution_keys,
es, grid, schedule, extra_keys);
}

View File

@ -1441,6 +1441,7 @@ namespace Opm { namespace RestartIO {
RestartValue
load(const std::string& filename,
int report_step,
Action::State& /* action_state */,
SummaryState& summary_state,
const std::vector<RestartKey>& solution_keys,
const EclipseState& es,

View File

@ -319,6 +319,7 @@ namespace {
const int sim_step,
const EclipseState& es,
const Schedule& schedule,
const Action::State& action_state,
const SummaryState& sum_state,
EclIO::OutputStream::Restart& rstFile)
{
@ -332,7 +333,7 @@ namespace {
const auto actDims = Opm::RestartIO::Helpers::createActionxDims(es.runspec(), schedule, simStep);
auto actionxData = Opm::RestartIO::Helpers::AggregateActionxData(actDims);
actionxData.captureDeclaredActionxData(schedule, sum_state, actDims, simStep);
actionxData.captureDeclaredActionxData(schedule, action_state, sum_state, actDims, simStep);
if (actDims[0] >= 1) {
rstFile.write("IACT", actionxData.getIACT());
@ -353,12 +354,13 @@ namespace {
const Schedule& schedule,
const std::vector<std::string>& well_names,
const data::Wells& wells,
const Opm::Action::State& action_state,
const Opm::SummaryState& sumState,
const std::vector<int>& ih,
EclIO::OutputStream::Restart& rstFile)
{
auto wellData = Helpers::AggregateWellData(ih);
wellData.captureDeclaredWellData(schedule, units, sim_step, sumState, ih);
wellData.captureDeclaredWellData(schedule, units, sim_step, action_state, sumState, ih);
wellData.captureDynamicWellData(schedule, sim_step,
wells, sumState);
@ -396,6 +398,7 @@ namespace {
const EclipseGrid& grid,
const Schedule& schedule,
const data::WellRates& wellSol,
const Opm::Action::State& action_state,
const Opm::SummaryState& sumState,
const std::vector<int>& inteHD,
EclIO::OutputStream::Restart& rstFile)
@ -420,7 +423,7 @@ namespace {
writeWell(sim_step, ecl_compatible_rst,
phases, units, grid, schedule, wells,
wellSol, sumState, inteHD, rstFile);
wellSol, action_state, sumState, inteHD, rstFile);
}
}
@ -651,6 +654,7 @@ void save(EclIO::OutputStream::Restart& rstFile,
const EclipseState& es,
const EclipseGrid& grid,
const Schedule& schedule,
const Action::State& action_state,
const SummaryState& sumState,
bool write_double)
{
@ -675,11 +679,11 @@ void save(EclIO::OutputStream::Restart& rstFile,
if (report_step > 0) {
writeDynamicData(sim_step, ecl_compatible_rst, es.runspec().phases(),
units, grid, schedule, value.wells, sumState,
units, grid, schedule, value.wells, action_state, sumState,
inteHD, rstFile);
}
writeActionx(report_step, sim_step, es, schedule, sumState, rstFile);
writeActionx(report_step, sim_step, es, schedule, action_state, sumState, rstFile);
writeSolution(value, schedule, sumState, report_step, sim_step,
ecl_compatible_rst, write_double, inteHD, rstFile);

View File

@ -24,6 +24,7 @@
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include "ActionParser.hpp"
@ -96,8 +97,6 @@ ActionX ActionX::serializeObject()
cond.cmp = Condition::Comparator::GREATER_EQUAL;
cond.cmp_string = "test3";
result.m_conditions = {cond};
result.run_count = 4;
result.last_run = 5;
return result;
}
@ -109,18 +108,8 @@ void ActionX::addKeyword(const DeckKeyword& kw) {
Action::Result ActionX::eval(std::time_t sim_time, const Action::Context& context) const {
if (!this->ready(sim_time))
return Action::Result(false);
auto result = this->condition.eval(context);
if (result) {
this->run_count += 1;
this->last_run = sim_time;
}
return result;
Action::Result ActionX::eval(const Action::Context& context) const {
return this->condition.eval(context);
}
@ -132,7 +121,7 @@ bool ActionX::ready(const State& state, std::time_t sim_time) const {
if (sim_time < this->start_time())
return false;
if (this->run_count == 0)
if (run_count == 0)
return true;
if (this->min_wait() <= 0)
@ -202,9 +191,7 @@ bool ActionX::operator==(const ActionX& data) const {
this->id() == data.id() &&
this->keywords == data.keywords &&
this->condition == data.condition &&
this->conditions() == data.conditions() &&
this->run_count == data.run_count &&
this->last_run == data.last_run;
this->conditions() == data.conditions();
}
}

View File

@ -92,9 +92,9 @@ int Actions::max_input_lines() const {
}
bool Actions::ready(std::time_t sim_time) const {
bool Actions::ready(const State& state, std::time_t sim_time) const {
for (const auto& action : this->actions) {
if (action.ready(sim_time))
if (action.ready(state, sim_time))
return true;
}
return false;
@ -111,10 +111,10 @@ std::vector<const PyAction *> Actions::pending_python() const {
}
std::vector<const ActionX *> Actions::pending(std::time_t sim_time) const {
std::vector<const ActionX *> Actions::pending(const State& state, std::time_t sim_time) const {
std::vector<const ActionX *> action_vector;
for (const auto& action : this->actions) {
if (action.ready(sim_time))
if (action.ready(state, sim_time))
action_vector.push_back( &action );
}
return action_vector;

View File

@ -180,18 +180,19 @@ BOOST_AUTO_TEST_CASE(TestActions) {
config.add(py_action2);
}
const Opm::Action::ActionX& action2 = config.get("NAME");
Opm::Action::State action_state;
// The action2 instance has an empty condition, so it will never evaluate to true.
BOOST_CHECK(action2.ready( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 7, 1 })) ));
BOOST_CHECK(!action2.ready( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 6, 1 })) ));
BOOST_CHECK(!action2.eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 6, 1 })), context));
BOOST_CHECK(action2.ready( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 7, 1 })) ));
BOOST_CHECK(!action2.ready( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 6, 1 })) ));
BOOST_CHECK(!action2.eval(context));
auto pending = config.pending( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) );
auto pending = config.pending( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) );
BOOST_CHECK_EQUAL( pending.size(), 2);
for (auto& ptr : pending) {
BOOST_CHECK( ptr->ready( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) ));
BOOST_CHECK( !ptr->eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })), context));
BOOST_CHECK( ptr->ready( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) ));
BOOST_CHECK( !ptr->eval( context));
}
BOOST_CHECK(!action2.eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })), context));
BOOST_CHECK(!action2.eval(context));
const auto& python_actions = config.pending_python();

View File

@ -9,6 +9,7 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/output/eclipse/AggregateUDQData.hpp>
#include <opm/output/eclipse/AggregateActionxData.hpp>
#include <opm/output/eclipse/WriteRestartHelpers.hpp>
@ -36,10 +37,10 @@
#include <vector>
namespace {
Opm::Deck first_sim(std::string fname) {
return Opm::Parser{}.parseFile(fname);
}
return Opm::Parser{}.parseFile(fname);
}
}
Opm::SummaryState sum_state_TEST1()
@ -58,18 +59,18 @@ Opm::SummaryState sum_state_TEST1()
state.update_group_var("UPPER", "GWPR", 36.);
state.update_group_var("LOWER", "GWPR", 37.);
state.update_group_var("TEST", "GWPR", 73.);
state.update_group_var("UPPER", "GGPR", 460.);
state.update_group_var("LOWER", "GGPR", 461.);
state.update_group_var("TEST", "GGPR", 821.);
state.update_group_var("TEST", "GMWPR", 4);
state.update("FWPR", 73.);
state.update("FMWPR", 4);
return state;
}
@ -91,7 +92,7 @@ struct SimulationCase
Opm::Schedule sched;
};
BOOST_AUTO_TEST_SUITE(Aggregate_Actionx)
@ -100,10 +101,11 @@ BOOST_AUTO_TEST_SUITE(Aggregate_Actionx)
BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
{
const auto simCase = SimulationCase{first_sim("UDQ_ACTIONX_TEST1.DATA")};
Opm::EclipseState es = simCase.es;
Opm::Runspec rspec = es.runspec();
Opm::SummaryState st = sum_state_TEST1();
Opm::Action::State action_state;
Opm::Schedule sched = simCase.sched;
Opm::EclipseGrid grid = simCase.grid;
const auto& ioConfig = es.getIOConfig();
@ -111,7 +113,7 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
// Report Step 1: 2008-10-10 --> 2011-01-20
const auto rptStep = std::size_t{1};
const auto rptStep = std::size_t{1};
std::string outputDir = "./";
std::string baseName = "UDQ_ACTIONX_TEST1";
Opm::EclIO::OutputStream::Restart rstFile {
@ -126,25 +128,25 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
createInteHead(es, grid, sched, secs_elapsed,
rptStep, rptStep, rptStep);
//set dummy value for next_step_size
//set dummy value for next_step_size
const double next_step_size= 0.1;
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep,
secs_elapsed, next_step_size);
const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep,
secs_elapsed, next_step_size);
const auto udqDims = Opm::RestartIO::Helpers::createUdqDims(sched, rptStep, ih);
auto udqData = Opm::RestartIO::Helpers::AggregateUDQData(udqDims);
udqData.captureDeclaredUDQData(sched, rptStep, st, ih);
const auto actDims = Opm::RestartIO::Helpers::createActionxDims(rspec, sched, rptStep);
auto actionxData = Opm::RestartIO::Helpers::AggregateActionxData(actDims);
actionxData.captureDeclaredActionxData(sched, st, actDims, rptStep);
actionxData.captureDeclaredActionxData(sched, action_state, st, actDims, rptStep);
{
/*
Check of InteHEAD and DoubHEAD data for UDQ variables
INTEHEAD
INTEHEAD
Intehead[156] - The number of ACTIONS
Intehead[157] - The max number of lines of schedule data including ENDACTIO keyword for any ACTION
@ -154,23 +156,23 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
const auto rptStep_1 = std::size_t{0};
const auto ih_1 = Opm::RestartIO::Helpers::createInteHead(es, grid, sched,
secs_elapsed, rptStep, rptStep_1 + 1, rptStep_1);
BOOST_CHECK_EQUAL(ih_1[156] , 2);
BOOST_CHECK_EQUAL(ih_1[157] , 7);
BOOST_CHECK_EQUAL(ih_1[156] , 2);
BOOST_CHECK_EQUAL(ih_1[157] , 7);
const auto rptStep_2 = std::size_t{1};
const auto ih_2 = Opm::RestartIO::Helpers::createInteHead(es, grid, sched,
secs_elapsed, rptStep, rptStep_2 + 1, rptStep_2);
BOOST_CHECK_EQUAL(ih_2[156] , 3);
BOOST_CHECK_EQUAL(ih_2[157] , 10);
BOOST_CHECK_EQUAL(ih_2[156] , 3);
BOOST_CHECK_EQUAL(ih_2[157] , 10);
const auto rptStep_3 = std::size_t{2};
const auto ih_3 = Opm::RestartIO::Helpers::createInteHead(es, grid, sched,
secs_elapsed, rptStep, rptStep_3 + 1, rptStep_3);
BOOST_CHECK_EQUAL(ih_3[156] , 3);
BOOST_CHECK_EQUAL(ih_3[157] , 10);
BOOST_CHECK_EQUAL(ih_3[156] , 3);
BOOST_CHECK_EQUAL(ih_3[157] , 10);
}
@ -188,26 +190,26 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
//item [7]: is unknown, (=0)
//item [8]: The number of times the action is triggered
*/
const auto& iAct = actionxData.getIACT();
auto start = 0*actDims[1];
BOOST_CHECK_EQUAL(iAct[start + 0] , 0);
BOOST_CHECK_EQUAL(iAct[start + 1] , 10);
BOOST_CHECK_EQUAL(iAct[start + 2] , 1);
BOOST_CHECK_EQUAL(iAct[start + 0] , 0);
BOOST_CHECK_EQUAL(iAct[start + 1] , 10);
BOOST_CHECK_EQUAL(iAct[start + 2] , 1);
BOOST_CHECK_EQUAL(iAct[start + 3] , 7);
BOOST_CHECK_EQUAL(iAct[start + 4] , 0);
BOOST_CHECK_EQUAL(iAct[start + 5] , 10);
BOOST_CHECK_EQUAL(iAct[start + 6] , 0);
BOOST_CHECK_EQUAL(iAct[start + 7] , 0);
BOOST_CHECK_EQUAL(iAct[start + 8] , 3);
start = 1*actDims[1];
BOOST_CHECK_EQUAL(iAct[start + 0] , 0);
BOOST_CHECK_EQUAL(iAct[start + 1] , 7);
BOOST_CHECK_EQUAL(iAct[start + 2] , 1);
BOOST_CHECK_EQUAL(iAct[start + 1] , 7);
BOOST_CHECK_EQUAL(iAct[start + 2] , 1);
BOOST_CHECK_EQUAL(iAct[start + 3] , 7);
BOOST_CHECK_EQUAL(iAct[start + 4] , 0);
BOOST_CHECK_EQUAL(iAct[start + 5] , 11);
@ -216,9 +218,9 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(iAct[start + 8] , 3);
start = 2*actDims[1];
BOOST_CHECK_EQUAL(iAct[start + 0] , 0);
BOOST_CHECK_EQUAL(iAct[start + 1] , 4);
BOOST_CHECK_EQUAL(iAct[start + 2] , 1);
BOOST_CHECK_EQUAL(iAct[start + 0] , 0);
BOOST_CHECK_EQUAL(iAct[start + 1] , 4);
BOOST_CHECK_EQUAL(iAct[start + 2] , 1);
BOOST_CHECK_EQUAL(iAct[start + 3] , 7);
BOOST_CHECK_EQUAL(iAct[start + 4] , 0);
BOOST_CHECK_EQUAL(iAct[start + 5] , 13);
@ -227,159 +229,159 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(iAct[start + 8] , 3);
}
{
/*
ZACT
--length 4 times 8-chars pr ACTIONX keyword
Name of action 4 times 8 chars (up to 8 chars for name)
*/
const auto& zAct = actionxData.getZACT();
auto start = 0*actDims[3];
BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT01 ");
BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT01 ");
start = 1*actDims[3];
BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT02 ");
BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT02 ");
start = 2*actDims[3];
BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT03 ");
BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT03 ");
}
{
/*
ZLACT
-- length = ACTDIMS_item3*(max-over-action of number of lines of data pr ACTION)
*/
const auto& zLact = actionxData.getZLACT();
//First action
auto start_a = 0*actDims[4];
auto start = start_a + 0*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
start = start_a + 1*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '");
BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '");
BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 ");
BOOST_CHECK_EQUAL(zLact[start + 2].c_str() , "0 0 / ");
start = start_a + 2*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ ");
start = start_a + 3*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
//Second action
start_a = 1*actDims[4];
start = start_a + 0*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
start = start_a + 1*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '");
BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '");
BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 ");
BOOST_CHECK_EQUAL(zLact[start + 2].c_str() , "0 0 / ");
start = start_a + 2*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ ");
start = start_a + 3*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN ");
start = start_a + 4*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " 'OPL0");
BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "1' 'OPEN");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " 'OPL0");
BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "1' 'OPEN");
BOOST_CHECK_EQUAL(zLact[start + 2].c_str() , "' / ");
start = start_a + 5*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ ");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ ");
start = start_a + 6*actDims[8];
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "ENDACTIO");
BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "ENDACTIO");
}
{
/*
ZACN
//(Max number of conditions pr ACTIONX) * ((max no characters pr line = 104) / (8 - characters pr string)(104/8 = 13)
*/
const auto& zAcn = actionxData.getZACN();
//First action
auto start_a = 0*actDims[5];
auto start = start_a + 0*13;
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
start = start_a + 1*13;
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WUPR3 ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WUPR3 ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OP* ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 5].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OP* ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 5].c_str() , " ");
start = start_a + 2*13;
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
//Second action
start_a = 1*actDims[5];
start = start_a + 0*13;
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
start = start_a + 1*13;
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WGPR ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , "GGPR ");
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WGPR ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , "GGPR ");
BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OPL02 ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OPL02 ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 5].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 6].c_str() , "LOWER ");
BOOST_CHECK_EQUAL(zAcn[start + 6].c_str() , "LOWER ");
start = start_a + 2*13;
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " ");
BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " ");
}
{
/*
IACN
26*Max number of conditions pr ACTIONX
26*Max number of conditions pr ACTIONX
*/
const auto& iAcn = actionxData.getIACN();
auto start_a = 0*actDims[6];
auto start = start_a + 0*26;
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 4] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 5] , 0);
@ -395,11 +397,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(iAcn[start + 15] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 16] , 1);
BOOST_CHECK_EQUAL(iAcn[start + 17] , 0);
start = start_a + 1*26;
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 4] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 5] , 0);
@ -418,9 +420,9 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
start_a = 1*actDims[6];
start = start_a + 0*26;
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 4] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 5] , 0);
@ -436,11 +438,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(iAcn[start + 15] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 16] , 1);
BOOST_CHECK_EQUAL(iAcn[start + 17] , 0);
start = start_a + 1*26;
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 4] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 5] , 0);
@ -456,11 +458,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(iAcn[start + 15] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 16] , 1);
BOOST_CHECK_EQUAL(iAcn[start + 17] , 0);
start = start_a + 2*26;
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 2] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 4] , 0);
BOOST_CHECK_EQUAL(iAcn[start + 5] , 0);
@ -479,23 +481,23 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
}
{
/*
SACN
26*Max number of conditions pr ACTIONX
26*Max number of conditions pr ACTIONX
*/
const auto& sAcn = actionxData.getSACN();
auto start_a = 0*actDims[6];
auto start = start_a + 0*16;
BOOST_CHECK_EQUAL(sAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 2] , 45);
BOOST_CHECK_EQUAL(sAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 2] , 45);
BOOST_CHECK_EQUAL(sAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 4] , 4);
BOOST_CHECK_EQUAL(sAcn[start + 5] , 45);
@ -509,11 +511,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(sAcn[start + 13] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 14] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 15] , 0);
start = start_a + 1*16;
BOOST_CHECK_EQUAL(sAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 2] , 46);
BOOST_CHECK_EQUAL(sAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 2] , 46);
BOOST_CHECK_EQUAL(sAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 4] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 5] , 46);
@ -527,11 +529,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(sAcn[start + 13] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 14] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 15] , 0);
start = start_a + 2*16;
BOOST_CHECK_EQUAL(sAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 2] , 10);
BOOST_CHECK_EQUAL(sAcn[start + 0] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 1] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 2] , 10);
BOOST_CHECK_EQUAL(sAcn[start + 3] , 0);
BOOST_CHECK_EQUAL(sAcn[start + 4] , 1.E+20);
BOOST_CHECK_EQUAL(sAcn[start + 5] , 1.E+20);
@ -547,7 +549,7 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data)
BOOST_CHECK_EQUAL(sAcn[start + 15] , 0);
}
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -25,6 +25,7 @@
#include <opm/output/eclipse/AggregateWellData.hpp>
#include <opm/output/eclipse/AggregateConnectionData.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/output/eclipse/VectorItems/intehead.hpp>
#include <opm/output/eclipse/VectorItems/well.hpp>
@ -40,6 +41,7 @@
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <exception>
#include <stdexcept>
@ -574,7 +576,7 @@ BOOST_AUTO_TEST_CASE (Constructor)
BOOST_AUTO_TEST_CASE (Declared_Well_Data)
{
const auto simCase = SimulationCase{first_sim()};
Opm::Action::State action_state;
// Report Step 1: 2008-10-10 --> 2011-01-20
const auto rptStep = std::size_t{1};
@ -587,7 +589,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data)
const auto smry = sim_state();
auto awd = Opm::RestartIO::Helpers::AggregateWellData{ih.value};
awd.captureDeclaredWellData(simCase.sched,
simCase.es.getUnits(), rptStep, smry, ih.value);
simCase.es.getUnits(), rptStep, action_state, smry, ih.value);
// IWEL (OP_1)
{
@ -1060,6 +1062,7 @@ BOOST_AUTO_TEST_CASE(WELL_POD) {
const auto sim_step = rptStep - 1;
Opm::SummaryState sumState(std::chrono::system_clock::now());
const auto xw = well_rates_1();
Opm::Action::State action_state;
const auto ih = Opm::RestartIO::Helpers::createInteHead(simCase.es,
simCase.grid,
@ -1070,7 +1073,7 @@ BOOST_AUTO_TEST_CASE(WELL_POD) {
sim_step);
auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih);
wellData.captureDeclaredWellData(simCase.sched, units, sim_step, sumState, ih);
wellData.captureDeclaredWellData(simCase.sched, units, sim_step, action_state, sumState, ih);
wellData.captureDynamicWellData(simCase.sched, sim_step, xw , sumState);
auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih);

View File

@ -35,6 +35,7 @@
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/io/eclipse/EclFile.hpp>
#include <opm/io/eclipse/EGrid.hpp>
@ -320,9 +321,11 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
sol.insert("KRO", measure::identity , std::vector<double>(3*3*3 , i), TargetType::RESTART_AUXILIARY);
sol.insert("KRG", measure::identity , std::vector<double>(3*3*3 , i*10), TargetType::RESTART_AUXILIARY);
Action::State action_state;
RestartValue restart_value(sol, wells);
auto first_step = ecl_util_make_date( 10 + i, 11, 2008 );
eclWriter.writeTimeStep( st,
eclWriter.writeTimeStep( action_state,
st,
i,
false,
first_step - start_time,

View File

@ -37,6 +37,7 @@
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
@ -274,6 +275,7 @@ BOOST_AUTO_TEST_CASE(test_RFT)
const auto step_time = timeStamp(::Opm::EclIO::ERft::RftDate{ 2008, 10, 10 });
SummaryState st(std::chrono::system_clock::now());
Action::State action_state;
data::Rates r1, r2;
r1.set( data::Rates::opt::wat, 4.11 );
@ -306,7 +308,8 @@ BOOST_AUTO_TEST_CASE(test_RFT)
RestartValue restart_value(std::move(solution), std::move(wells));
eclipseWriter.writeTimeStep( st,
eclipseWriter.writeTimeStep( action_state,
st,
2,
false,
step_time - start_time,
@ -390,6 +393,7 @@ BOOST_AUTO_TEST_CASE(test_RFT2)
Schedule schedule(deck, eclipseState, python);
SummaryConfig summary_config( deck, schedule, eclipseState.getTableManager( ));
SummaryState st(std::chrono::system_clock::now());
Action::State action_state;
const auto start_time = schedule.posixStartTime();
const auto& time_map = schedule.getTimeMap( );
@ -430,7 +434,8 @@ BOOST_AUTO_TEST_CASE(test_RFT2)
RestartValue restart_value(std::move(solution), std::move(wells));
eclipseWriter.writeTimeStep( st,
eclipseWriter.writeTimeStep( action_state,
st,
step,
false,
step_time - start_time,

View File

@ -38,6 +38,7 @@
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Utility/Functional.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/io/eclipse/OutputStream.hpp>
#include <opm/io/eclipse/EclIOdata.hpp>
@ -361,7 +362,7 @@ struct Setup {
};
RestartValue first_sim(const Setup& setup, SummaryState& st, bool write_double) {
RestartValue first_sim(const Setup& setup, Action::State& action_state, SummaryState& st, bool write_double) {
EclipseIO eclWriter( setup.es, setup.grid, setup.schedule, setup.summary_config);
auto num_cells = setup.grid.getNumActive( );
int report_step = 1;
@ -372,7 +373,8 @@ RestartValue first_sim(const Setup& setup, SummaryState& st, bool write_double)
auto wells = mkWells();
RestartValue restart_value(sol, wells);
eclWriter.writeTimeStep( st,
eclWriter.writeTimeStep( action_state,
st,
report_step,
false,
std::difftime(first_step, start_time),
@ -382,9 +384,9 @@ RestartValue first_sim(const Setup& setup, SummaryState& st, bool write_double)
return restart_value;
}
RestartValue second_sim(const Setup& setup, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys) {
RestartValue second_sim(const Setup& setup, Action::State& action_state, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys) {
EclipseIO writer(setup.es, setup.grid, setup.schedule, setup.summary_config);
return writer.loadRestart( summary_state, solution_keys );
return writer.loadRestart( action_state, summary_state, solution_keys );
}
@ -422,14 +424,15 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) {
Setup base_setup("BASE_SIM.DATA");
SummaryState st(std::chrono::system_clock::now());
auto state1 = first_sim( base_setup , st, false );
Action::State action_state;
auto state1 = first_sim( base_setup , action_state, st, false );
Setup restart_setup("RESTART_SIM.DATA");
auto state2 = second_sim( restart_setup , st , keys );
auto state2 = second_sim( restart_setup , action_state, st , keys );
compare(state1, state2 , keys);
BOOST_CHECK_THROW( second_sim( restart_setup, st, {{"SOIL", UnitSystem::measure::pressure}} ) , std::runtime_error );
BOOST_CHECK_THROW( second_sim( restart_setup, st, {{"SOIL", UnitSystem::measure::pressure, true}}) , std::runtime_error );
BOOST_CHECK_THROW( second_sim( restart_setup, action_state, st, {{"SOIL", UnitSystem::measure::pressure}} ) , std::runtime_error );
BOOST_CHECK_THROW( second_sim( restart_setup, action_state, st, {{"SOIL", UnitSystem::measure::pressure, true}}) , std::runtime_error );
}
@ -446,6 +449,7 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
auto cells = mkSolution( num_cells );
auto wells = mkWells();
auto sumState = sim_state();
Action::State action_state;
{
RestartValue restart_value(cells, wells);
@ -467,6 +471,7 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
base_setup.es,
base_setup.grid,
base_setup.schedule,
action_state,
sumState,
true);
}
@ -495,6 +500,7 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
base_setup.es,
base_setup.grid,
base_setup.schedule,
action_state,
sumState,
true);
}
@ -552,11 +558,12 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData_double) {
test_area.copyIn("BASE_SIM.DATA");
Setup base_setup("BASE_SIM.DATA");
SummaryState st(std::chrono::system_clock::now());
Action::State action_state;
auto state1 = first_sim( base_setup , st, true);
auto state1 = first_sim( base_setup , action_state, st, true);
Setup restart_setup("RESTART_SIM.DATA");
auto state2 = second_sim( restart_setup, st, solution_keys );
auto state2 = second_sim( restart_setup, action_state, st, solution_keys );
compare_equal( state1 , state2 , solution_keys);
}
@ -573,6 +580,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) {
auto cells = mkSolution( num_cells );
auto wells = mkWells();
Opm::SummaryState sumState(std::chrono::system_clock::now());
Opm::Action::State action_state;
const auto seqnum = 1;
auto rstFile = OS::Restart {
@ -586,6 +594,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) {
setup.es,
setup.grid ,
setup.schedule,
action_state,
sumState),
std::runtime_error);
}
@ -620,6 +629,7 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) {
test_area.copyIn("RESTART_SIM.DATA");
Setup setup("BASE_SIM.DATA");
{
Action::State action_state;
auto num_cells = setup.grid.getNumActive( );
auto cells = mkSolution( num_cells );
auto wells = mkWells();
@ -646,6 +656,7 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) {
setup.es,
setup.grid,
setup.schedule,
action_state,
sumState);
}
@ -661,10 +672,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) {
BOOST_CHECK_CLOSE( units.from_si( UnitSystem::measure::pressure, 3), ex[3], 0.00001);
}
BOOST_CHECK_THROW( RestartIO::load( rstFile , 1 , st, {}, setup.es, setup.grid , setup.schedule,
BOOST_CHECK_THROW( RestartIO::load( rstFile , 1 , action_state, st, {}, setup.es, setup.grid , setup.schedule,
{{"NOT-THIS", UnitSystem::measure::identity, true}}) , std::runtime_error );
{
const auto rst_value = RestartIO::load(rstFile , 1 , st,
const auto rst_value = RestartIO::load(rstFile , 1 , action_state, st,
/* solution_keys = */ {
RestartKey("SWAT", UnitSystem::measure::identity),
RestartKey("NO" , UnitSystem::measure::identity, false)
@ -720,6 +731,7 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
restart_value.addExtra("THRESHPR", UnitSystem::measure::pressure, {0,1});
const auto sumState = sim_state();
Action::State action_state;
/* THPRES data has wrong size in extra container. */
{
@ -735,6 +747,7 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
base_setup.es,
base_setup.grid,
base_setup.schedule,
action_state,
sumState),
std::runtime_error);
}
@ -756,7 +769,9 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
restart_value2,
base_setup.es,
base_setup.grid,
base_setup.schedule, sumState);
base_setup.schedule,
action_state,
sumState);
}
{
@ -808,16 +823,18 @@ BOOST_AUTO_TEST_CASE(Restore_Cumulatives)
const auto rset = OS::ResultSet{ wa.currentWorkingDirectory(), "FILE" };
const auto seqnum = 1;
{
Action::State action_state;
auto rstFile = OS::Restart {
rset, seqnum, OS::Formatted{ false }, OS::Unified{ true }
};
RestartIO::save(rstFile, seqnum, 100, restart_value,
setup.es, setup.grid, setup.schedule, sumState);
setup.es, setup.grid, setup.schedule, action_state, sumState);
}
Action::State action_state;
SummaryState rstSumState(std::chrono::system_clock::now());
RestartIO::load(OS::outputFileName(rset, "UNRST"), seqnum, rstSumState,
RestartIO::load(OS::outputFileName(rset, "UNRST"), seqnum, action_state, rstSumState,
/* solution_keys = */ {
RestartKey("SWAT", UnitSystem::measure::identity),
},

View File

@ -36,6 +36,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/io/eclipse/EclFile.hpp>
@ -206,6 +207,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
Opm::EclipseIO eclipseWriter( es, grid , schedule, summary_config);
int countTimeStep = schedule.getTimeMap().numTimesteps();
Opm::SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime()));
Opm::Action::State action_state;
Opm::data::Solution solution;
solution.insert( "PRESSURE", Opm::UnitSystem::measure::pressure , std::vector< double >( num_cells, 1 ) , Opm::data::TargetType::RESTART_SOLUTION);
@ -215,7 +217,8 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
for(int timestep = 0; timestep <= countTimeStep; ++timestep) {
eclipseWriter.writeTimeStep( st,
eclipseWriter.writeTimeStep( action_state,
st,
timestep,
false,
schedule.seconds(timestep),

View File

@ -40,6 +40,7 @@
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/io/eclipse/rst/connection.hpp>
#include <opm/io/eclipse/rst/header.hpp>
@ -260,6 +261,7 @@ BOOST_AUTO_TEST_CASE(State_test) {
const auto rptStep = std::size_t{4};
const auto sim_step = rptStep - 1;
Opm::SummaryState sumState(std::chrono::system_clock::now());
Opm::Action::State action_state;
const auto ih = Opm::RestartIO::Helpers::createInteHead(simCase.es,
simCase.grid,
@ -277,7 +279,7 @@ BOOST_AUTO_TEST_CASE(State_test) {
0, 0);
auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih);
wellData.captureDeclaredWellData(simCase.sched, units, sim_step, sumState, ih);
wellData.captureDeclaredWellData(simCase.sched, units, sim_step, action_state, sumState, ih);
wellData.captureDynamicWellData(simCase.sched, sim_step, {} , sumState);
auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih);