mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-25 10:40:21 -06:00
Use RestartValue when saving eclipse output
This commit is contained in:
parent
483e04c5da
commit
c76898d0c9
@ -40,6 +40,7 @@
|
||||
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
|
||||
@ -124,8 +125,8 @@ namespace Opm
|
||||
WellState& wellstate,
|
||||
ExtraData& extra) {
|
||||
|
||||
std::map<std::string, bool> extra_keys {
|
||||
{"OPMEXTRA" , false}
|
||||
std::vector<RestartKey> extra_keys = {
|
||||
{"OPMEXTRA" , Opm::UnitSystem::measure::identity, false}
|
||||
};
|
||||
|
||||
// gives a dummy dynamic_list_econ_limited
|
||||
@ -150,7 +151,7 @@ namespace Opm
|
||||
|
||||
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);
|
||||
|
||||
const int nw = wells->number_of_wells;
|
||||
@ -159,9 +160,8 @@ namespace Opm
|
||||
wellsToState( restart_values.wells, phaseUsage_, wellstate );
|
||||
}
|
||||
|
||||
const auto opmextra_iter = restart_values.extra.find("OPMEXTRA");
|
||||
if (opmextra_iter != restart_values.extra.end()) {
|
||||
std::vector<double> opmextra = opmextra_iter->second;
|
||||
if (restart_values.hasExtra("OPMEXTRA")) {
|
||||
std::vector<double> opmextra = restart_values.getExtra("OPMEXTRA");
|
||||
assert(opmextra.size() == 1);
|
||||
extra.suggested_step = opmextra[0];
|
||||
} else {
|
||||
|
@ -131,11 +131,11 @@ data::Solution simToSolution( const SimulationDataContainer& reservoir,
|
||||
|
||||
|
||||
|
||||
void solutionToSim( const data::Solution& sol,
|
||||
const std::map<std::string,std::vector<double> >& /* extra */,
|
||||
void solutionToSim( const RestartValue& restart_value,
|
||||
PhaseUsage phases,
|
||||
SimulationDataContainer& state ) {
|
||||
|
||||
const auto& sol = restart_value.solution;
|
||||
const auto stride = phases.num_phases;
|
||||
|
||||
if( sol.has( "SWAT" ) ) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef 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/Wells.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
@ -59,8 +60,7 @@ namespace Opm {
|
||||
/// Copies the following fields from sol into state (all conditionally):
|
||||
/// PRESSURE, TEMP, SWAT, SGAS, RS, RV, SSOL
|
||||
/// Also handles extra data such as hysteresis parameters, SOMAX, etc.
|
||||
void solutionToSim( const data::Solution& sol,
|
||||
const std::map<std::string,std::vector<double> >& extra,
|
||||
void solutionToSim( const RestartValue& restart_value,
|
||||
PhaseUsage phases,
|
||||
SimulationDataContainer& state );
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <unordered_set>
|
||||
|
||||
#include <opm/common/data/SimulationDataContainer.hpp>
|
||||
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
|
||||
#include <opm/grid/UnstructuredGrid.h>
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/autodiff/Compat.hpp>
|
||||
#include <opm/core/wells/DynamicListEconLimited.hpp>
|
||||
|
||||
@ -645,8 +646,8 @@ namespace Opm
|
||||
if( isIORank() )
|
||||
{
|
||||
// copy values from globalCellData to globalReservoirState
|
||||
const std::map<std::string, std::vector<double> > no_extra_data;
|
||||
solutionToSim(*globalCellData_, no_extra_data, phaseUsage_, *globalReservoirState_);
|
||||
RestartValue restart_value(*globalCellData_, {});
|
||||
solutionToSim(restart_value, phaseUsage_, *globalReservoirState_);
|
||||
}
|
||||
return isIORank();
|
||||
}
|
||||
|
@ -24,7 +24,9 @@
|
||||
#include <opm/common/data/SimulationDataContainer.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/data/Cells.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/core/utility/DataMap.hpp>
|
||||
#include <opm/autodiff/Compat.hpp>
|
||||
@ -181,7 +183,7 @@ namespace Opm
|
||||
const WellStateFullyImplicitBlackoil wellState_;
|
||||
data::Solution simProps_;
|
||||
std::map<std::string, double> miscSummaryData_;
|
||||
std::map<std::string, std::vector<double>> extraRestartData_;
|
||||
RestartValue::ExtraVector extraRestartData_;
|
||||
const bool substep_;
|
||||
|
||||
explicit WriterCall( BlackoilOutputWriter& writer,
|
||||
@ -190,7 +192,7 @@ namespace Opm
|
||||
const WellStateFullyImplicitBlackoil& wellState,
|
||||
const data::Solution& simProps,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep)
|
||||
: writer_( writer ),
|
||||
timer_( timer.clone() ),
|
||||
@ -222,7 +224,7 @@ namespace Opm
|
||||
const SimulationDataContainer& localState,
|
||||
const WellStateFullyImplicitBlackoil& localWellState,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep)
|
||||
{
|
||||
data::Solution localCellData{};
|
||||
@ -246,7 +248,7 @@ namespace Opm
|
||||
const data::Solution& localCellData,
|
||||
const WellStateFullyImplicitBlackoil& localWellState,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep)
|
||||
{
|
||||
// VTK output (is parallel if grid is parallel)
|
||||
@ -318,7 +320,7 @@ namespace Opm
|
||||
const WellStateFullyImplicitBlackoil& wellState,
|
||||
const data::Solution& simProps,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep)
|
||||
{
|
||||
// Matlab output
|
||||
@ -335,15 +337,21 @@ namespace Opm
|
||||
} else {
|
||||
// ... insert "extra" data (KR, VISC, ...)
|
||||
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,
|
||||
substep,
|
||||
timer.simulationTimeElapsed(),
|
||||
simProps,
|
||||
wellState.report(phaseUsage_, globalCellIdxMap_),
|
||||
restart_value,
|
||||
miscSummaryData,
|
||||
{}, //regionData
|
||||
{}, //blockData
|
||||
extraRestartData,
|
||||
restart_double_si_);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ namespace Opm
|
||||
const data::Solution& cellData,
|
||||
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep = false);
|
||||
|
||||
/*!
|
||||
@ -261,7 +261,7 @@ namespace Opm
|
||||
const SimulationDataContainer& reservoirState,
|
||||
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep = false);
|
||||
|
||||
/*!
|
||||
@ -274,7 +274,7 @@ namespace Opm
|
||||
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
||||
const data::Solution& simProps,
|
||||
const std::map<std::string, double>& miscSummaryData,
|
||||
const std::map<std::string, std::vector<double>>& extraRestartData,
|
||||
const RestartValue::ExtraVector& extraRestartData,
|
||||
bool substep );
|
||||
|
||||
/** \brief return output directory */
|
||||
@ -412,26 +412,26 @@ namespace Opm
|
||||
WellState& wellstate,
|
||||
ExtraData& extra )
|
||||
{
|
||||
std::map<std::string, RestartKey> solution_keys {{"PRESSURE" , RestartKey(UnitSystem::measure::pressure)},
|
||||
{"SWAT" , RestartKey(UnitSystem::measure::identity)},
|
||||
{"SGAS" , RestartKey(UnitSystem::measure::identity)},
|
||||
{"TEMP" , RestartKey(UnitSystem::measure::temperature)},
|
||||
{"RS" , RestartKey(UnitSystem::measure::gas_oil_ratio)},
|
||||
{"RV" , RestartKey(UnitSystem::measure::oil_gas_ratio)},
|
||||
{"SOMAX", {UnitSystem::measure::identity, false}},
|
||||
{"PCSWM_OW", {UnitSystem::measure::identity, false}},
|
||||
{"KRNSW_OW", {UnitSystem::measure::identity, false}},
|
||||
{"PCSWM_GO", {UnitSystem::measure::identity, false}},
|
||||
{"KRNSW_GO", {UnitSystem::measure::identity, false}}};
|
||||
std::vector<RestartKey> solution_keys = {{"PRESSURE" , UnitSystem::measure::pressure},
|
||||
{"SWAT" , UnitSystem::measure::identity},
|
||||
{"SGAS" , UnitSystem::measure::identity},
|
||||
{"TEMP" , UnitSystem::measure::temperature},
|
||||
{"RS" , UnitSystem::measure::gas_oil_ratio},
|
||||
{"RV" , UnitSystem::measure::oil_gas_ratio},
|
||||
{"SOMAX", UnitSystem::measure::identity, false},
|
||||
{"PCSWM_OW", UnitSystem::measure::identity, false},
|
||||
{"KRNSW_OW", UnitSystem::measure::identity, false},
|
||||
{"PCSWM_GO", UnitSystem::measure::identity, false},
|
||||
{"KRNSW_GO", UnitSystem::measure::identity, false}};
|
||||
|
||||
std::map<std::string, bool> extra_keys {
|
||||
{"OPMEXTRA" , false}
|
||||
std::vector<RestartKey> extra_keys {
|
||||
{"OPMEXTRA" , UnitSystem::measure::identity, false}
|
||||
};
|
||||
|
||||
if (restart_double_si_) {
|
||||
// Avoid any unit conversions, treat restart input as SI units.
|
||||
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
|
||||
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 );
|
||||
|
||||
const auto opmextra_iter = restart_values.extra.find("OPMEXTRA");
|
||||
if (opmextra_iter != restart_values.extra.end()) {
|
||||
std::vector<double> opmextra = opmextra_iter->second;
|
||||
if (restart_values.hasExtra("OPMEXTRA")) {
|
||||
const std::vector<double>& opmextra = restart_values.getExtra("OPMEXTRA");
|
||||
assert(opmextra.size() == 1);
|
||||
extra.suggested_step = opmextra[0];
|
||||
} else {
|
||||
@ -1003,7 +1002,7 @@ namespace Opm
|
||||
const RestartConfig& restartConfig = eclipseState_.getRestartConfig();
|
||||
const int reportStepNum = timer.reportStepNum();
|
||||
bool logMessages = output_ && parallelOutput_->isIORank();
|
||||
std::map<std::string, std::vector<double>> extraRestartData;
|
||||
RestartValue::ExtraVector extraRestartData;
|
||||
std::map<std::string, double> miscSummaryData;
|
||||
|
||||
if( output_ )
|
||||
@ -1026,7 +1025,7 @@ namespace Opm
|
||||
assert(!localCellData.empty());
|
||||
|
||||
// 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.
|
||||
const double totalSolverTime = simulatorReport.solver_time;
|
||||
|
Loading…
Reference in New Issue
Block a user