Add data::GroupValues member to RestartValue
This commit is contained in:
parent
1019187a4e
commit
305b2a166a
@ -14,6 +14,7 @@
|
||||
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
|
||||
|
||||
|
||||
@ -42,13 +43,13 @@ 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, Action::State& action_state, 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, data::GroupValues& group_data, size_t report_step);
|
||||
private:
|
||||
|
||||
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;
|
||||
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_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, data::GroupValues& group_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, const data::GroupValues& group_data, EclipseIO& io) const;
|
||||
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, double seconds_elapsed, double time_step) const;
|
||||
|
||||
EclipseState state;
|
||||
std::map<std::string, std::map<data::Rates::opt, std::function<well_rate_function>>> well_rates;
|
||||
|
@ -51,13 +51,14 @@ void msim::run(Schedule& schedule, EclipseIO& io, bool report_only) {
|
||||
io.writeInitial();
|
||||
for (size_t report_step = 1; report_step < schedule.size(); report_step++) {
|
||||
data::Wells well_data;
|
||||
data::GroupValues group_data;
|
||||
if (report_only)
|
||||
run_step(schedule, action_state, st, sol, well_data, report_step, io);
|
||||
run_step(schedule, action_state, st, sol, well_data, group_data, report_step, io);
|
||||
else {
|
||||
double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1));
|
||||
run_step(schedule, action_state, st, sol, well_data, report_step, time_step, io);
|
||||
run_step(schedule, action_state, st, sol, well_data, group_data, report_step, time_step, io);
|
||||
}
|
||||
post_step(schedule, action_state, st, sol, well_data, report_step);
|
||||
post_step(schedule, action_state, st, sol, well_data, group_data, report_step);
|
||||
const auto& exit_status = schedule.exitStatus();
|
||||
if (exit_status.has_value())
|
||||
return;
|
||||
@ -69,7 +70,7 @@ UDAValue msim::uda_val() {
|
||||
}
|
||||
|
||||
|
||||
void msim::post_step(Schedule& schedule, Action::State& action_state, 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 */, data::GroupValues& /* group_data */, size_t report_step) {
|
||||
const auto& actions = schedule.actions(report_step);
|
||||
if (actions.empty())
|
||||
return;
|
||||
@ -89,12 +90,12 @@ void msim::post_step(Schedule& schedule, Action::State& action_state, SummarySta
|
||||
|
||||
|
||||
|
||||
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, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, EclipseIO& io) const {
|
||||
this->run_step(schedule, action_state, st, sol, well_data, group_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, 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, data::GroupValues& group_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;
|
||||
@ -104,9 +105,7 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, Summa
|
||||
if ((seconds_elapsed + time_step) > end_time)
|
||||
time_step = end_time - seconds_elapsed;
|
||||
|
||||
this->simulate(schedule, st, sol, well_data, report_step, seconds_elapsed, time_step);
|
||||
|
||||
Opm::data::GroupValues group_data;
|
||||
this->simulate(schedule, st, sol, well_data, group_data, report_step, seconds_elapsed, time_step);
|
||||
|
||||
seconds_elapsed += time_step;
|
||||
|
||||
@ -126,14 +125,15 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, Summa
|
||||
seconds_elapsed,
|
||||
sol,
|
||||
well_data,
|
||||
group_data,
|
||||
io);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
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, const data::GroupValues& group_data, EclipseIO& io) const {
|
||||
RestartValue value(sol, well_data, group_data);
|
||||
io.writeTimeStep(action_state,
|
||||
st,
|
||||
report_step,
|
||||
@ -143,7 +143,7 @@ void msim::output(Action::State& action_state, SummaryState& st, size_t report_s
|
||||
}
|
||||
|
||||
|
||||
void msim::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 {
|
||||
void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& /* group_data */, size_t report_step, double seconds_elapsed, double time_step) const {
|
||||
for (const auto& sol_pair : this->solutions) {
|
||||
auto func = sol_pair.second;
|
||||
func(this->state, schedule, sol, report_step, seconds_elapsed + time_step);
|
||||
|
@ -42,6 +42,13 @@ namespace Opm { namespace data {
|
||||
template <class MessageBufferType>
|
||||
void read(MessageBufferType& buffer);
|
||||
|
||||
bool operator==(const GroupConstraints& other) const
|
||||
{
|
||||
return this->currentProdConstraint == other.currentProdConstraint &&
|
||||
this->currentGasInjectionConstraint == other.currentGasInjectionConstraint &&
|
||||
this->currentWaterInjectionConstraint == other.currentWaterInjectionConstraint;
|
||||
}
|
||||
|
||||
inline GroupConstraints& set(Opm::Group::ProductionCMode cpc,
|
||||
Opm::Group::InjectionCMode cgic,
|
||||
Opm::Group::InjectionCMode cwic);
|
||||
@ -63,6 +70,11 @@ namespace Opm { namespace data {
|
||||
{
|
||||
this->currentControl.read(buffer);
|
||||
}
|
||||
|
||||
bool operator==(const GroupData& other) const
|
||||
{
|
||||
return this->currentControl == other.currentControl;
|
||||
}
|
||||
};
|
||||
|
||||
class GroupValues : public std::map<std::string, GroupData> {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <opm/output/data/Aquifer.hpp>
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -70,10 +71,11 @@ namespace Opm {
|
||||
using ExtraVector = std::vector<std::pair<RestartKey, std::vector<double>>>;
|
||||
data::Solution solution;
|
||||
data::Wells wells;
|
||||
data::GroupValues groups;
|
||||
ExtraVector extra;
|
||||
std::vector<data::AquiferData> aquifer;
|
||||
|
||||
RestartValue(data::Solution sol, data::Wells wells_arg);
|
||||
RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupValues groups_arg);
|
||||
|
||||
RestartValue() {}
|
||||
|
||||
@ -89,6 +91,7 @@ namespace Opm {
|
||||
{
|
||||
return solution == val2.solution &&
|
||||
wells == val2.wells &&
|
||||
groups == val2.groups &&
|
||||
extra == val2.extra;
|
||||
}
|
||||
};
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <opm/output/data/Cells.hpp>
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
|
||||
#include <opm/output/eclipse/VectorItems/aquifer.hpp>
|
||||
#include <opm/output/eclipse/VectorItems/connection.hpp>
|
||||
@ -1561,8 +1562,9 @@ namespace Opm { namespace RestartIO {
|
||||
auto xw = rst_view->hasKeyword<double>("OPM_XWEL")
|
||||
? restore_wells_opm(es, grid, schedule, *rst_view)
|
||||
: restore_wells_ecl(es, grid, schedule, rst_view);
|
||||
data::GroupValues xg;
|
||||
|
||||
auto rst_value = RestartValue{ std::move(xr), std::move(xw) };
|
||||
auto rst_value = RestartValue{ std::move(xr), std::move(xw) , std::move(xg)};
|
||||
|
||||
if (! extra_keys.empty()) {
|
||||
restoreExtra(extra_keys, es.getUnits(), *rst_view, rst_value);
|
||||
|
@ -32,9 +32,10 @@ namespace Opm {
|
||||
|
||||
|
||||
|
||||
RestartValue::RestartValue(data::Solution sol, data::Wells wells_arg) :
|
||||
RestartValue::RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupValues groups_arg) :
|
||||
solution(std::move(sol)),
|
||||
wells(std::move(wells_arg))
|
||||
wells(std::move(wells_arg)),
|
||||
groups(std::move(groups_arg))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -315,6 +315,7 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
||||
eclWriter.writeInitial( eGridProps , int_data );
|
||||
|
||||
data::Wells wells;
|
||||
data::GroupValues groups;
|
||||
|
||||
for( int i = first; i < last; ++i ) {
|
||||
data::Solution sol = createBlackoilState( i, 3 * 3 * 3 );
|
||||
@ -322,7 +323,7 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) {
|
||||
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);
|
||||
RestartValue restart_value(sol, wells, groups);
|
||||
auto first_step = ecl_util_make_date( 10 + i, 11, 2008 );
|
||||
eclWriter.writeTimeStep( action_state,
|
||||
st,
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
#include <opm/output/eclipse/InteHEAD.hpp>
|
||||
#include <opm/output/eclipse/WriteRFT.hpp>
|
||||
@ -299,6 +300,7 @@ BOOST_AUTO_TEST_CASE(test_RFT)
|
||||
|
||||
Opm::data::Solution solution = createBlackoilState(2, numCells);
|
||||
Opm::data::Wells wells;
|
||||
Opm::data::GroupValues groups;
|
||||
|
||||
using SegRes = decltype(wells["w"].segments);
|
||||
using Ctrl = decltype(wells["w"].current_control);
|
||||
@ -306,7 +308,7 @@ BOOST_AUTO_TEST_CASE(test_RFT)
|
||||
wells["OP_1"] = { std::move(r1), 1.0, 1.1, 3.1, 1, std::move(well1_comps), SegRes{}, Ctrl{} };
|
||||
wells["OP_2"] = { std::move(r2), 1.0, 1.1, 3.2, 1, std::move(well2_comps), SegRes{}, Ctrl{} };
|
||||
|
||||
RestartValue restart_value(std::move(solution), std::move(wells));
|
||||
RestartValue restart_value(std::move(solution), std::move(wells), std::move(groups));
|
||||
|
||||
eclipseWriter.writeTimeStep( action_state,
|
||||
st,
|
||||
@ -432,7 +434,7 @@ BOOST_AUTO_TEST_CASE(test_RFT2)
|
||||
wells["OP_1"] = { std::move(r1), 1.0, 1.1, 3.1, 1, std::move(well1_comps), SegRes{}, Ctrl{} };
|
||||
wells["OP_2"] = { std::move(r2), 1.0, 1.1, 3.2, 1, std::move(well2_comps), SegRes{}, Ctrl{} };
|
||||
|
||||
RestartValue restart_value(std::move(solution), std::move(wells));
|
||||
RestartValue restart_value(std::move(solution), std::move(wells), data::GroupValues());
|
||||
|
||||
eclipseWriter.writeTimeStep( action_state,
|
||||
st,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/data/Cells.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/Eqldims.hpp>
|
||||
@ -135,6 +136,9 @@ std::ostream& operator<<( std::ostream& stream,
|
||||
|
||||
}
|
||||
|
||||
data::GroupValues mkGroups() {
|
||||
return {};
|
||||
}
|
||||
|
||||
data::Wells mkWells() {
|
||||
data::Rates r1, r2, rc1, rc2, rc3;
|
||||
@ -389,8 +393,9 @@ RestartValue first_sim(const Setup& setup, Action::State& action_state, SummaryS
|
||||
|
||||
auto sol = mkSolution( num_cells );
|
||||
auto wells = mkWells();
|
||||
auto groups = mkGroups();
|
||||
const auto& udq = setup.schedule.getUDQConfig(report_step);
|
||||
RestartValue restart_value(sol, wells);
|
||||
RestartValue restart_value(sol, wells, groups);
|
||||
|
||||
init_st(st);
|
||||
udq.eval(st);
|
||||
@ -469,10 +474,11 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) {
|
||||
auto num_cells = base_setup.grid.getNumActive( );
|
||||
auto cells = mkSolution( num_cells );
|
||||
auto wells = mkWells();
|
||||
auto groups = mkGroups();
|
||||
auto sumState = sim_state();
|
||||
Action::State action_state;
|
||||
{
|
||||
RestartValue restart_value(cells, wells);
|
||||
RestartValue restart_value(cells, wells, groups);
|
||||
|
||||
io_config.setEclCompatibleRST( false );
|
||||
restart_value.addExtra("EXTRA", UnitSystem::measure::pressure, {10,1,2,3});
|
||||
@ -600,6 +606,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) {
|
||||
auto num_cells = setup.grid.getNumActive( ) + 1;
|
||||
auto cells = mkSolution( num_cells );
|
||||
auto wells = mkWells();
|
||||
auto groups = mkGroups();
|
||||
Opm::SummaryState sumState(std::chrono::system_clock::now());
|
||||
Opm::Action::State action_state;
|
||||
|
||||
@ -611,7 +618,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) {
|
||||
|
||||
BOOST_CHECK_THROW( RestartIO::save(rstFile, seqnum,
|
||||
100,
|
||||
RestartValue(cells, wells),
|
||||
RestartValue(cells, wells, groups),
|
||||
setup.es,
|
||||
setup.grid ,
|
||||
setup.schedule,
|
||||
@ -627,7 +634,8 @@ BOOST_AUTO_TEST_CASE(ExtraData_KEYS) {
|
||||
auto num_cells = setup.grid.getNumActive( );
|
||||
auto cells = mkSolution( num_cells );
|
||||
auto wells = mkWells();
|
||||
RestartValue restart_value(cells, wells);
|
||||
auto groups = mkGroups();
|
||||
RestartValue restart_value(cells, wells, groups);
|
||||
|
||||
BOOST_CHECK_THROW( restart_value.addExtra("TOO-LONG-KEY", {0,1,2}), std::runtime_error);
|
||||
|
||||
@ -654,9 +662,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) {
|
||||
auto num_cells = setup.grid.getNumActive( );
|
||||
auto cells = mkSolution( num_cells );
|
||||
auto wells = mkWells();
|
||||
auto groups = mkGroups();
|
||||
const auto& units = setup.es.getUnits();
|
||||
{
|
||||
RestartValue restart_value(cells, wells);
|
||||
RestartValue restart_value(cells, wells, groups);
|
||||
SummaryState st(std::chrono::system_clock::now());
|
||||
const auto sumState = sim_state();
|
||||
|
||||
@ -732,10 +741,11 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) {
|
||||
auto num_cells = base_setup.grid.getNumActive( );
|
||||
auto cells = mkSolution( num_cells );
|
||||
auto wells = mkWells();
|
||||
auto groups = mkGroups();
|
||||
const auto outputDir = test_area.currentWorkingDirectory();
|
||||
{
|
||||
RestartValue restart_value(cells, wells);
|
||||
RestartValue restart_value2(cells, wells);
|
||||
RestartValue restart_value(cells, wells, groups);
|
||||
RestartValue restart_value2(cells, wells, groups);
|
||||
|
||||
/* Missing THPRES data in extra container. */
|
||||
/* Because it proved to difficult to update the legacy simulators
|
||||
@ -835,7 +845,8 @@ BOOST_AUTO_TEST_CASE(Restore_Cumulatives)
|
||||
|
||||
const auto restart_value = RestartValue {
|
||||
mkSolution(setup.grid.getNumActive()),
|
||||
mkWells()
|
||||
mkWells(),
|
||||
mkGroups()
|
||||
};
|
||||
const auto sumState = sim_state();
|
||||
|
||||
|
@ -214,6 +214,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
|
||||
solution.insert( "SWAT" , Opm::UnitSystem::measure::identity , std::vector< double >( num_cells, 1 ) , Opm::data::TargetType::RESTART_SOLUTION);
|
||||
solution.insert( "SGAS" , Opm::UnitSystem::measure::identity , std::vector< double >( num_cells, 1 ) , Opm::data::TargetType::RESTART_SOLUTION);
|
||||
Opm::data::Wells wells;
|
||||
Opm::data::GroupValues groups;
|
||||
|
||||
for(int timestep = 0; timestep <= countTimeStep; ++timestep) {
|
||||
|
||||
@ -222,7 +223,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
|
||||
timestep,
|
||||
false,
|
||||
schedule.seconds(timestep),
|
||||
Opm::RestartValue(solution, wells));
|
||||
Opm::RestartValue(solution, wells, groups));
|
||||
}
|
||||
|
||||
for (int i=1; i <=4; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user