Use RestartValue when saving eclipse output

This commit is contained in:
Joakim Hove
2018-04-28 20:20:46 +02:00
parent 483e04c5da
commit c76898d0c9
6 changed files with 52 additions and 44 deletions

View File

@@ -40,6 +40,7 @@
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp> #include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp> #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp> #include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
@@ -124,8 +125,8 @@ namespace Opm
WellState& wellstate, WellState& wellstate,
ExtraData& extra) { ExtraData& extra) {
std::map<std::string, bool> extra_keys { std::vector<RestartKey> extra_keys = {
{"OPMEXTRA" , false} {"OPMEXTRA" , Opm::UnitSystem::measure::identity, false}
}; };
// gives a dummy dynamic_list_econ_limited // gives a dummy dynamic_list_econ_limited
@@ -150,7 +151,7 @@ namespace Opm
const Wells* wells = wellsmanager.c_wells(); const Wells* wells = wellsmanager.c_wells();
std::map<std::string, RestartKey> solution_keys {}; std::vector<RestartKey> solution_keys = {};
auto restart_values = ebosSimulator_.problem().eclIO().loadRestart(solution_keys, extra_keys); auto restart_values = ebosSimulator_.problem().eclIO().loadRestart(solution_keys, extra_keys);
const int nw = wells->number_of_wells; const int nw = wells->number_of_wells;
@@ -159,9 +160,8 @@ namespace Opm
wellsToState( restart_values.wells, phaseUsage_, wellstate ); wellsToState( restart_values.wells, phaseUsage_, wellstate );
} }
const auto opmextra_iter = restart_values.extra.find("OPMEXTRA"); if (restart_values.hasExtra("OPMEXTRA")) {
if (opmextra_iter != restart_values.extra.end()) { std::vector<double> opmextra = restart_values.getExtra("OPMEXTRA");
std::vector<double> opmextra = opmextra_iter->second;
assert(opmextra.size() == 1); assert(opmextra.size() == 1);
extra.suggested_step = opmextra[0]; extra.suggested_step = opmextra[0];
} else { } else {

View File

@@ -131,11 +131,11 @@ data::Solution simToSolution( const SimulationDataContainer& reservoir,
void solutionToSim( const data::Solution& sol, void solutionToSim( const RestartValue& restart_value,
const std::map<std::string,std::vector<double> >& /* extra */,
PhaseUsage phases, PhaseUsage phases,
SimulationDataContainer& state ) { SimulationDataContainer& state ) {
const auto& sol = restart_value.solution;
const auto stride = phases.num_phases; const auto stride = phases.num_phases;
if( sol.has( "SWAT" ) ) { if( sol.has( "SWAT" ) ) {

View File

@@ -21,6 +21,7 @@
#ifndef OPM_SIMULATORS_COMPAT_HPP #ifndef OPM_SIMULATORS_COMPAT_HPP
#define OPM_SIMULATORS_COMPAT_HPP #define OPM_SIMULATORS_COMPAT_HPP
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/output/data/Solution.hpp> #include <opm/output/data/Solution.hpp>
#include <opm/output/data/Wells.hpp> #include <opm/output/data/Wells.hpp>
#include <opm/core/props/BlackoilPhases.hpp> #include <opm/core/props/BlackoilPhases.hpp>
@@ -59,8 +60,7 @@ namespace Opm {
/// Copies the following fields from sol into state (all conditionally): /// Copies the following fields from sol into state (all conditionally):
/// PRESSURE, TEMP, SWAT, SGAS, RS, RV, SSOL /// PRESSURE, TEMP, SWAT, SGAS, RS, RV, SSOL
/// Also handles extra data such as hysteresis parameters, SOMAX, etc. /// Also handles extra data such as hysteresis parameters, SOMAX, etc.
void solutionToSim( const data::Solution& sol, void solutionToSim( const RestartValue& restart_value,
const std::map<std::string,std::vector<double> >& extra,
PhaseUsage phases, PhaseUsage phases,
SimulationDataContainer& state ); SimulationDataContainer& state );

View File

@@ -22,7 +22,7 @@
#include <unordered_set> #include <unordered_set>
#include <opm/common/data/SimulationDataContainer.hpp> #include <opm/common/data/SimulationDataContainer.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/grid/UnstructuredGrid.h> #include <opm/grid/UnstructuredGrid.h>
#include <opm/core/simulator/WellState.hpp> #include <opm/core/simulator/WellState.hpp>
@@ -30,6 +30,7 @@
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp> #include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp> #include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/autodiff/Compat.hpp> #include <opm/autodiff/Compat.hpp>
#include <opm/core/wells/DynamicListEconLimited.hpp> #include <opm/core/wells/DynamicListEconLimited.hpp>
@@ -645,8 +646,8 @@ namespace Opm
if( isIORank() ) if( isIORank() )
{ {
// copy values from globalCellData to globalReservoirState // copy values from globalCellData to globalReservoirState
const std::map<std::string, std::vector<double> > no_extra_data; RestartValue restart_value(*globalCellData_, {});
solutionToSim(*globalCellData_, no_extra_data, phaseUsage_, *globalReservoirState_); solutionToSim(restart_value, phaseUsage_, *globalReservoirState_);
} }
return isIORank(); return isIORank();
} }

View File

@@ -24,7 +24,9 @@
#include <opm/common/data/SimulationDataContainer.hpp> #include <opm/common/data/SimulationDataContainer.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp> #include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/output/data/Cells.hpp> #include <opm/output/data/Cells.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/core/simulator/BlackoilState.hpp> #include <opm/core/simulator/BlackoilState.hpp>
#include <opm/core/utility/DataMap.hpp> #include <opm/core/utility/DataMap.hpp>
#include <opm/autodiff/Compat.hpp> #include <opm/autodiff/Compat.hpp>
@@ -181,7 +183,7 @@ namespace Opm
const WellStateFullyImplicitBlackoil wellState_; const WellStateFullyImplicitBlackoil wellState_;
data::Solution simProps_; data::Solution simProps_;
std::map<std::string, double> miscSummaryData_; std::map<std::string, double> miscSummaryData_;
std::map<std::string, std::vector<double>> extraRestartData_; RestartValue::ExtraVector extraRestartData_;
const bool substep_; const bool substep_;
explicit WriterCall( BlackoilOutputWriter& writer, explicit WriterCall( BlackoilOutputWriter& writer,
@@ -190,7 +192,7 @@ namespace Opm
const WellStateFullyImplicitBlackoil& wellState, const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep) bool substep)
: writer_( writer ), : writer_( writer ),
timer_( timer.clone() ), timer_( timer.clone() ),
@@ -222,7 +224,7 @@ namespace Opm
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const WellStateFullyImplicitBlackoil& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep) bool substep)
{ {
data::Solution localCellData{}; data::Solution localCellData{};
@@ -246,7 +248,7 @@ namespace Opm
const data::Solution& localCellData, const data::Solution& localCellData,
const WellStateFullyImplicitBlackoil& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep) bool substep)
{ {
// VTK output (is parallel if grid is parallel) // VTK output (is parallel if grid is parallel)
@@ -318,7 +320,7 @@ namespace Opm
const WellStateFullyImplicitBlackoil& wellState, const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep) bool substep)
{ {
// Matlab output // Matlab output
@@ -335,15 +337,21 @@ namespace Opm
} else { } else {
// ... insert "extra" data (KR, VISC, ...) // ... insert "extra" data (KR, VISC, ...)
const int reportStepForOutput = substep ? timer.reportStepNum() + 1 : timer.reportStepNum(); const int reportStepForOutput = substep ? timer.reportStepNum() + 1 : timer.reportStepNum();
RestartValue restart_value(simProps, wellState.report(phaseUsage_, globalCellIdxMap_));
for (const auto& extra_pair : extraRestartData) {
const RestartKey& restart_key = extra_pair.first;
const std::vector<double>& data = extra_pair.second;
restart_value.addExtra(restart_key.key, restart_key.dim, data);
}
// Here we should check if the THPRES option is active, and in that case
// add the THPRES values to the extra values object.
eclIO_->writeTimeStep(reportStepForOutput, eclIO_->writeTimeStep(reportStepForOutput,
substep, substep,
timer.simulationTimeElapsed(), timer.simulationTimeElapsed(),
simProps, restart_value,
wellState.report(phaseUsage_, globalCellIdxMap_),
miscSummaryData, miscSummaryData,
{}, //regionData {}, //regionData
{}, //blockData {}, //blockData
extraRestartData,
restart_double_si_); restart_double_si_);
} }
} }

View File

@@ -248,7 +248,7 @@ namespace Opm
const data::Solution& cellData, const data::Solution& cellData,
const Opm::WellStateFullyImplicitBlackoil& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep = false); bool substep = false);
/*! /*!
@@ -261,7 +261,7 @@ namespace Opm
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellStateFullyImplicitBlackoil& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep = false); bool substep = false);
/*! /*!
@@ -274,7 +274,7 @@ namespace Opm
const Opm::WellStateFullyImplicitBlackoil& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
const std::map<std::string, double>& miscSummaryData, const std::map<std::string, double>& miscSummaryData,
const std::map<std::string, std::vector<double>>& extraRestartData, const RestartValue::ExtraVector& extraRestartData,
bool substep ); bool substep );
/** \brief return output directory */ /** \brief return output directory */
@@ -412,26 +412,26 @@ namespace Opm
WellState& wellstate, WellState& wellstate,
ExtraData& extra ) ExtraData& extra )
{ {
std::map<std::string, RestartKey> solution_keys {{"PRESSURE" , RestartKey(UnitSystem::measure::pressure)}, std::vector<RestartKey> solution_keys = {{"PRESSURE" , UnitSystem::measure::pressure},
{"SWAT" , RestartKey(UnitSystem::measure::identity)}, {"SWAT" , UnitSystem::measure::identity},
{"SGAS" , RestartKey(UnitSystem::measure::identity)}, {"SGAS" , UnitSystem::measure::identity},
{"TEMP" , RestartKey(UnitSystem::measure::temperature)}, {"TEMP" , UnitSystem::measure::temperature},
{"RS" , RestartKey(UnitSystem::measure::gas_oil_ratio)}, {"RS" , UnitSystem::measure::gas_oil_ratio},
{"RV" , RestartKey(UnitSystem::measure::oil_gas_ratio)}, {"RV" , UnitSystem::measure::oil_gas_ratio},
{"SOMAX", {UnitSystem::measure::identity, false}}, {"SOMAX", UnitSystem::measure::identity, false},
{"PCSWM_OW", {UnitSystem::measure::identity, false}}, {"PCSWM_OW", UnitSystem::measure::identity, false},
{"KRNSW_OW", {UnitSystem::measure::identity, false}}, {"KRNSW_OW", UnitSystem::measure::identity, false},
{"PCSWM_GO", {UnitSystem::measure::identity, false}}, {"PCSWM_GO", UnitSystem::measure::identity, false},
{"KRNSW_GO", {UnitSystem::measure::identity, false}}}; {"KRNSW_GO", UnitSystem::measure::identity, false}};
std::map<std::string, bool> extra_keys { std::vector<RestartKey> extra_keys {
{"OPMEXTRA" , false} {"OPMEXTRA" , UnitSystem::measure::identity, false}
}; };
if (restart_double_si_) { if (restart_double_si_) {
// Avoid any unit conversions, treat restart input as SI units. // Avoid any unit conversions, treat restart input as SI units.
for (auto& elem : solution_keys) { for (auto& elem : solution_keys) {
elem.second = RestartKey(UnitSystem::measure::identity); elem.dim = UnitSystem::measure::identity;
} }
} }
@@ -462,12 +462,11 @@ namespace Opm
wellstate.resize(wells, simulatorstate, phaseUsage ); //Resize for restart step wellstate.resize(wells, simulatorstate, phaseUsage ); //Resize for restart step
auto restart_values = eclIO_->loadRestart(solution_keys, extra_keys); auto restart_values = eclIO_->loadRestart(solution_keys, extra_keys);
solutionToSim( restart_values.solution, restart_values.extra, phaseUsage, simulatorstate ); solutionToSim( restart_values, phaseUsage, simulatorstate );
wellsToState( restart_values.wells, phaseUsage, wellstate ); wellsToState( restart_values.wells, phaseUsage, wellstate );
const auto opmextra_iter = restart_values.extra.find("OPMEXTRA"); if (restart_values.hasExtra("OPMEXTRA")) {
if (opmextra_iter != restart_values.extra.end()) { const std::vector<double>& opmextra = restart_values.getExtra("OPMEXTRA");
std::vector<double> opmextra = opmextra_iter->second;
assert(opmextra.size() == 1); assert(opmextra.size() == 1);
extra.suggested_step = opmextra[0]; extra.suggested_step = opmextra[0];
} else { } else {
@@ -1003,7 +1002,7 @@ namespace Opm
const RestartConfig& restartConfig = eclipseState_.getRestartConfig(); const RestartConfig& restartConfig = eclipseState_.getRestartConfig();
const int reportStepNum = timer.reportStepNum(); const int reportStepNum = timer.reportStepNum();
bool logMessages = output_ && parallelOutput_->isIORank(); bool logMessages = output_ && parallelOutput_->isIORank();
std::map<std::string, std::vector<double>> extraRestartData; RestartValue::ExtraVector extraRestartData;
std::map<std::string, double> miscSummaryData; std::map<std::string, double> miscSummaryData;
if( output_ ) if( output_ )
@@ -1026,7 +1025,7 @@ namespace Opm
assert(!localCellData.empty()); assert(!localCellData.empty());
// Add suggested next timestep to extra data. // Add suggested next timestep to extra data.
extraRestartData["OPMEXTRA"] = std::vector<double>(1, nextstep); extraRestartData.push_back({{"OPMEXTRA", UnitSystem::measure::identity}, std::vector<double>(1, nextstep)});
// Add TCPU if simulatorReport is not defaulted. // Add TCPU if simulatorReport is not defaulted.
const double totalSolverTime = simulatorReport.solver_time; const double totalSolverTime = simulatorReport.solver_time;