mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
sync restart
This commit is contained in:
@@ -39,6 +39,8 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||||
|
#include <opm/output/eclipse/RestartValue.hpp>
|
||||||
|
|
||||||
#include <opm/output/data/Wells.hpp>
|
#include <opm/output/data/Wells.hpp>
|
||||||
#include <opm/material/common/Exceptions.hpp>
|
#include <opm/material/common/Exceptions.hpp>
|
||||||
|
|
||||||
@@ -613,6 +615,11 @@ public:
|
|||||||
reportStepIdx);
|
reportStepIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){
|
||||||
|
// not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool wellTopologyChanged_(const Opm::EclipseState& eclState OPM_UNUSED,
|
bool wellTopologyChanged_(const Opm::EclipseState& eclState OPM_UNUSED,
|
||||||
const Opm::Schedule& schedule,
|
const Opm::Schedule& schedule,
|
||||||
|
|||||||
@@ -418,16 +418,7 @@ public:
|
|||||||
eclOutputModule_.allocBuffers(numElements, restartStepIdx, /*isSubStep=*/false, /*log=*/false);
|
eclOutputModule_.allocBuffers(numElements, restartStepIdx, /*isSubStep=*/false, /*log=*/false);
|
||||||
|
|
||||||
{
|
{
|
||||||
/*
|
Opm::SummaryState& summaryState = simulator_.vanguard().summaryState();
|
||||||
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()));
|
|
||||||
auto restartValues = eclIO_->loadRestart(summaryState, solutionKeys, extraKeys);
|
auto restartValues = eclIO_->loadRestart(summaryState, solutionKeys, extraKeys);
|
||||||
|
|
||||||
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
|
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
|
||||||
@@ -442,6 +433,9 @@ public:
|
|||||||
thpres.setFromRestart(thpresValues);
|
thpres.setFromRestart(thpresValues);
|
||||||
}
|
}
|
||||||
restartTimeStepSize_ = restartValues.getExtra("OPMEXTRA")[0];
|
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);
|
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.
|
// Create timers and file for writing timing info.
|
||||||
Opm::time::StopWatch solverTimer;
|
Opm::time::StopWatch solverTimer;
|
||||||
Opm::time::StopWatch totalTimer;
|
Opm::time::StopWatch totalTimer;
|
||||||
@@ -164,46 +152,16 @@ public:
|
|||||||
adaptiveTimeStepping.reset(new TimeStepper(terminalOutput_));
|
adaptiveTimeStepping.reset(new TimeStepper(terminalOutput_));
|
||||||
}
|
}
|
||||||
|
|
||||||
double suggestedStepSize = -1.0;
|
|
||||||
if (isRestart()) {
|
if (isRestart()) {
|
||||||
// This is a restart, determine the time step size from the restart data
|
// For restarts the ebosSimulator may have gotten some information
|
||||||
if (restartValues->hasExtra("OPMEXTRA")) {
|
// about the next timestep size from the OPMEXTRA field
|
||||||
std::vector<double> opmextra = restartValues->getExtra("OPMEXTRA");
|
adaptiveTimeStepping->setSuggestedNextStep(ebosSimulator_.timeStepSize());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulatorReport report;
|
SimulatorReport report;
|
||||||
SimulatorReport stepReport;
|
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.
|
// Main simulation loop.
|
||||||
while (!timer.done()) {
|
while (!timer.done()) {
|
||||||
// Report timestep.
|
// Report timestep.
|
||||||
|
|||||||
@@ -493,6 +493,8 @@ namespace Opm {
|
|||||||
|
|
||||||
const Wells* wells = wellsmanager.c_wells();
|
const Wells* wells = wellsmanager.c_wells();
|
||||||
|
|
||||||
|
wells_ecl_ = schedule().getWells2(report_step);
|
||||||
|
|
||||||
const int nw = wells->number_of_wells;
|
const int nw = wells->number_of_wells;
|
||||||
if (nw > 0) {
|
if (nw > 0) {
|
||||||
const auto phaseUsage = phaseUsageFromDeck(eclState());
|
const auto phaseUsage = phaseUsageFromDeck(eclState());
|
||||||
|
|||||||
Reference in New Issue
Block a user