mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-21 16:57:25 -06:00
sync restart
This commit is contained in:
parent
1544f84fb4
commit
f83e99c6aa
@ -39,6 +39,8 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/material/common/Exceptions.hpp>
|
||||
|
||||
@ -613,6 +615,11 @@ public:
|
||||
reportStepIdx);
|
||||
}
|
||||
|
||||
void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){
|
||||
// not implemented
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
bool wellTopologyChanged_(const Opm::EclipseState& eclState OPM_UNUSED,
|
||||
const Opm::Schedule& schedule,
|
||||
|
@ -418,16 +418,7 @@ public:
|
||||
eclOutputModule_.allocBuffers(numElements, restartStepIdx, /*isSubStep=*/false, /*log=*/false);
|
||||
|
||||
{
|
||||
/*
|
||||
When running a restarted simulation the restart file is loaded
|
||||
twice, first here as part of the state initialization and then
|
||||
subsequently in the Simulator::run() method. The global
|
||||
SummaryState instance is accumulates total variables like FOPT, if
|
||||
the same instance is used twice when loading the restart file, the
|
||||
cumulatives will be counted doubly, we therefor use a temporary
|
||||
SummaryState instance in this call to loadRestart().
|
||||
*/
|
||||
Opm::SummaryState summaryState(std::chrono::system_clock::from_time_t(simulator_.vanguard().schedule().getStartTime()));
|
||||
Opm::SummaryState& summaryState = simulator_.vanguard().summaryState();
|
||||
auto restartValues = eclIO_->loadRestart(summaryState, solutionKeys, extraKeys);
|
||||
|
||||
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
|
||||
@ -442,6 +433,9 @@ public:
|
||||
thpres.setFromRestart(thpresValues);
|
||||
}
|
||||
restartTimeStepSize_ = restartValues.getExtra("OPMEXTRA")[0];
|
||||
|
||||
// initialize the well model from restart values
|
||||
simulator_.problem().wellModel().initFromRestartFile(restartValues);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,18 +134,6 @@ public:
|
||||
|
||||
ebosSimulator_.setEpisodeIndex(-1);
|
||||
|
||||
// handle restarts
|
||||
std::unique_ptr<RestartValue> restartValues;
|
||||
if (isRestart()) {
|
||||
Opm::SummaryState& summaryState = ebosSimulator_.vanguard().summaryState();
|
||||
std::vector<RestartKey> extraKeys = {
|
||||
{"OPMEXTRA" , Opm::UnitSystem::measure::identity, false}
|
||||
};
|
||||
|
||||
std::vector<RestartKey> solutionKeys = {};
|
||||
restartValues.reset(new RestartValue(ebosSimulator_.problem().eclIO().loadRestart(summaryState, solutionKeys, extraKeys)));
|
||||
}
|
||||
|
||||
// Create timers and file for writing timing info.
|
||||
Opm::time::StopWatch solverTimer;
|
||||
Opm::time::StopWatch totalTimer;
|
||||
@ -164,46 +152,16 @@ public:
|
||||
adaptiveTimeStepping.reset(new TimeStepper(terminalOutput_));
|
||||
}
|
||||
|
||||
double suggestedStepSize = -1.0;
|
||||
if (isRestart()) {
|
||||
// This is a restart, determine the time step size from the restart data
|
||||
if (restartValues->hasExtra("OPMEXTRA")) {
|
||||
std::vector<double> opmextra = restartValues->getExtra("OPMEXTRA");
|
||||
assert(opmextra.size() == 1);
|
||||
suggestedStepSize = opmextra[0];
|
||||
}
|
||||
else {
|
||||
OpmLog::warning("Restart data is missing OPMEXTRA field, restart run may deviate from original run.");
|
||||
suggestedStepSize = -1.0;
|
||||
}
|
||||
|
||||
if (suggestedStepSize > 0.0) {
|
||||
adaptiveTimeStepping->setSuggestedNextStep(suggestedStepSize);
|
||||
}
|
||||
// For restarts the ebosSimulator may have gotten some information
|
||||
// about the next timestep size from the OPMEXTRA field
|
||||
adaptiveTimeStepping->setSuggestedNextStep(ebosSimulator_.timeStepSize());
|
||||
}
|
||||
}
|
||||
|
||||
SimulatorReport report;
|
||||
SimulatorReport stepReport;
|
||||
|
||||
if (isRestart()) {
|
||||
// Set the start time of the simulation
|
||||
const auto& schedule = ebosSimulator_.vanguard().schedule();
|
||||
const auto& eclState = ebosSimulator_.vanguard().eclState();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
const auto& initconfig = eclState.getInitConfig();
|
||||
int episodeIdx = initconfig.getRestartStep() - 1;
|
||||
|
||||
ebosSimulator_.setStartTime(timeMap.getStartTime(/*timeStepIdx=*/0));
|
||||
ebosSimulator_.setTime(timeMap.getTimePassedUntil(episodeIdx));
|
||||
|
||||
ebosSimulator_.startNextEpisode(ebosSimulator_.startTime() + ebosSimulator_.time(),
|
||||
timeMap.getTimeStepLength(episodeIdx));
|
||||
ebosSimulator_.setEpisodeIndex(episodeIdx);
|
||||
wellModel_().beginEpisode();
|
||||
wellModel_().initFromRestartFile(*restartValues);
|
||||
}
|
||||
|
||||
// Main simulation loop.
|
||||
while (!timer.done()) {
|
||||
// Report timestep.
|
||||
|
@ -493,6 +493,8 @@ namespace Opm {
|
||||
|
||||
const Wells* wells = wellsmanager.c_wells();
|
||||
|
||||
wells_ecl_ = schedule().getWells2(report_step);
|
||||
|
||||
const int nw = wells->number_of_wells;
|
||||
if (nw > 0) {
|
||||
const auto phaseUsage = phaseUsageFromDeck(eclState());
|
||||
|
Loading…
Reference in New Issue
Block a user