Add restart I/O of suggested timestep length.

This commit is contained in:
Atgeirr Flø Rasmussen
2017-02-24 14:52:12 +01:00
parent 650f863785
commit ffaa48295a
3 changed files with 43 additions and 8 deletions

View File

@@ -144,9 +144,10 @@ public:
{
WellState prev_well_state;
ExtraData extra;
if (output_writer_.isRestart()) {
// This is a restart, populate WellState and ReservoirState state objects from restart file
output_writer_.initFromRestartFile(props_.phaseUsage(), grid(), state, prev_well_state);
output_writer_.initFromRestartFile(props_.phaseUsage(), grid(), state, prev_well_state, extra);
initHydroCarbonState(state, props_.phaseUsage(), Opm::UgGridHelpers::numCells(grid()), has_disgas_, has_vapoil_);
}
@@ -170,6 +171,10 @@ public:
} else {
adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) );
}
if (output_writer_.isRestart()) {
adaptiveTimeStepping->setSuggestedNextStep(extra.suggested_step);
}
}
std::string restorefilename = param_.getDefault("restorefile", std::string("") );
@@ -354,7 +359,8 @@ public:
// write simulation state at the report stage
Dune::Timer perfTimer;
perfTimer.start();
output_writer_.writeTimeStep( timer, state, well_state, solver->model() );
const double nextstep = adaptiveTimeStepping ? adaptiveTimeStepping->suggestedNextStep() : -1.0;
output_writer_.writeTimeStep( timer, state, well_state, solver->model(), false, nextstep );
report.output_write_time += perfTimer.stop();
prev_well_state = well_state;

View File

@@ -197,6 +197,13 @@ namespace Opm
const Grid& grid_;
};
struct ExtraData
{
double suggested_step;
};
/** \brief Wrapper class for VTK, Matlab, and ECL output. */
class BlackoilOutputWriter
{
@@ -224,7 +231,8 @@ namespace Opm
const SimulationDataContainer& reservoirState,
const Opm::WellStateFullyImplicitBlackoil& wellState,
const Model& physicalModel,
bool substep = false);
bool substep = false,
const double nextstep = -1.0);
/*!
@@ -280,11 +288,12 @@ namespace Opm
const int desiredReportStep);
template <class Grid, class WellStateFullyImplicitBlackOel>
template <class Grid, class WellState>
void initFromRestartFile(const PhaseUsage& phaseUsage,
const Grid& grid,
SimulationDataContainer& simulatorstate,
WellStateFullyImplicitBlackOel& wellstate);
WellState& wellstate,
ExtraData& extra);
bool isRestart() const;
@@ -401,14 +410,16 @@ namespace Opm
initFromRestartFile( const PhaseUsage& phaseUsage,
const Grid& grid,
SimulationDataContainer& simulatorstate,
WellState& wellstate)
WellState& wellstate,
ExtraData& extra )
{
std::map<std::string, UnitSystem::measure> 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}};
{"RV" , UnitSystem::measure::oil_gas_ratio},
{"OPMEXTRA" , UnitSystem::measure::identity}};
// gives a dummy dynamic_list_econ_limited
DynamicListEconLimited dummy_list_econ_limited;
@@ -435,6 +446,12 @@ namespace Opm
solutionToSim( state.first, phaseUsage, simulatorstate );
wellsToState( state.second, phaseUsage, wellstate );
if (state.first.has( "OPMEXTRA" ) ) {
std::vector<double> opmextra = state.first.data( "OPMEXTRA" );
assert(opmextra.size() == 1);
extra.suggested_step = opmextra[0];
}
}
@@ -899,7 +916,8 @@ namespace Opm
const SimulationDataContainer& localState,
const WellStateFullyImplicitBlackoil& localWellState,
const Model& physicalModel,
bool substep)
bool substep,
const double nextstep)
{
data::Solution localCellData{};
const RestartConfig& restartConfig = eclipseState_.getRestartConfig();
@@ -924,6 +942,13 @@ namespace Opm
// sd will be invalid after getRestartData has been called
}
detail::getSummaryData( localCellData, phaseUsage_, physicalModel, summaryConfig );
// Hack: add suggested next timestep.
assert(!localCellData.empty());
localCellData.insert("OPMEXTRA",
UnitSystem::measure::identity,
std::vector<double>(1, nextstep),
data::TargetType::RESTART_SOLUTION);
}
writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, substep);

View File

@@ -84,6 +84,10 @@ namespace Opm {
Output& outputWriter,
const std::vector<int>* fipnum = nullptr);
double suggestedNextStep() const { return suggested_next_timestep_; }
void setSuggestedNextStep(const double x) { suggested_next_timestep_ = x; }
protected:
template <class Solver, class State, class WellState, class Output>
SimulatorReport stepImpl( const SimulatorTimer& timer,