mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
restart flow
This commit is contained in:
parent
2c9a727844
commit
399b4f11c4
@ -79,6 +79,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
@ -583,7 +584,8 @@ namespace Opm
|
||||
SimulatorTimer simtimer;
|
||||
|
||||
// initialize variables
|
||||
simtimer.init(timeMap);
|
||||
const auto initConfig = eclipse_state_->getInitConfig();
|
||||
simtimer.init(timeMap, initConfig->getRestartInitiated(), (size_t)initConfig->getRestartStep());
|
||||
|
||||
|
||||
|
||||
|
@ -81,6 +81,12 @@ namespace Opm
|
||||
{
|
||||
WellState prev_well_state;
|
||||
|
||||
|
||||
if (output_writer_.isRestart()) {
|
||||
// This is a restart, populate WellState and ReservoirState state objects from restart file
|
||||
output_writer_.initFromRestartFile(props_.phaseUsage(), props_.permeability(), grid_, state, prev_well_state);
|
||||
}
|
||||
|
||||
// Create timers and file for writing timing info.
|
||||
Opm::time::StopWatch solver_timer;
|
||||
double stime = 0.0;
|
||||
@ -144,6 +150,7 @@ namespace Opm
|
||||
// write simulation state at the report stage
|
||||
output_writer_.writeTimeStep( timer, state, well_state );
|
||||
|
||||
|
||||
// Max oil saturation (for VPPARS), hysteresis update.
|
||||
props_.updateSatOilMax(state.saturation());
|
||||
props_.updateSatHyst(state.saturation(), allcells_);
|
||||
|
@ -30,6 +30,9 @@
|
||||
#include <opm/autodiff/GridHelpers.hpp>
|
||||
#include <opm/autodiff/BackupRestore.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
@ -280,7 +283,12 @@ namespace Opm
|
||||
}
|
||||
// ECL output
|
||||
if ( eclWriter_ ) {
|
||||
eclWriter_->writeTimeStep(timer, state, wellState, substep );
|
||||
const auto initConfig = eclipseState_->getInitConfig();
|
||||
if (initConfig->getRestartInitiated() && ((initConfig->getRestartStep()) == (timer.currentStepNum()))) {
|
||||
std::cout << "Skipping restart write in start of step " << timer.currentStepNum() << std::endl;
|
||||
} else {
|
||||
eclWriter_->writeTimeStep(timer, state, wellState, substep );
|
||||
}
|
||||
}
|
||||
|
||||
// write backup file
|
||||
@ -393,4 +401,10 @@ namespace Opm
|
||||
std::cerr << "Warning: Couldn't open restore file '" << filename << "'" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BlackoilOutputWriter::isRestart() const {
|
||||
const auto initconfig = eclipseState_->getInitConfig();
|
||||
return initconfig->getRestartInitiated();
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/utility/DataMap.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/core/io/eclipse/EclipseReader.hpp>
|
||||
#include <opm/core/utility/miscUtilities.hpp>
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
|
||||
@ -35,6 +36,10 @@
|
||||
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@ -194,6 +199,7 @@ namespace Opm
|
||||
/** \brief Wrapper class for VTK, Matlab, and ECL output. */
|
||||
class BlackoilOutputWriter : public OutputWriter
|
||||
{
|
||||
|
||||
public:
|
||||
// constructor creating different sub writers
|
||||
template <class Grid>
|
||||
@ -209,7 +215,7 @@ namespace Opm
|
||||
/** \copydoc Opm::OutputWriter::writeTimeStep */
|
||||
void writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
const SimulatorState& reservoirState,
|
||||
const WellState& wellState,
|
||||
const Opm::WellState& wellState,
|
||||
bool substep = false);
|
||||
|
||||
/** \brief return output directory */
|
||||
@ -224,6 +230,16 @@ namespace Opm
|
||||
const std::string& filename,
|
||||
const int desiredReportStep);
|
||||
|
||||
|
||||
template <class Grid>
|
||||
void initFromRestartFile(const PhaseUsage& phaseusage,
|
||||
const double* permeability,
|
||||
const Grid& grid,
|
||||
SimulatorState& simulatorstate,
|
||||
WellStateFullyImplicitBlackoil& wellstate);
|
||||
|
||||
bool isRestart() const;
|
||||
|
||||
protected:
|
||||
const bool output_;
|
||||
std::unique_ptr< ParallelDebugOutputInterface > parallelOutput_;
|
||||
@ -238,6 +254,7 @@ namespace Opm
|
||||
std::unique_ptr< OutputWriter > vtkWriter_;
|
||||
std::unique_ptr< OutputWriter > matlabWriter_;
|
||||
std::unique_ptr< EclipseWriter > eclWriter_;
|
||||
EclipseStateConstPtr eclipseState_;
|
||||
};
|
||||
|
||||
|
||||
@ -269,7 +286,8 @@ namespace Opm
|
||||
new EclipseWriter(param, eclipseState, phaseUsage,
|
||||
parallelOutput_->numCells(),
|
||||
parallelOutput_->globalCell() )
|
||||
: 0 )
|
||||
: 0 ),
|
||||
eclipseState_(eclipseState)
|
||||
{
|
||||
// For output.
|
||||
if (output_ && parallelOutput_->isIORank() ) {
|
||||
@ -289,5 +307,32 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class Grid>
|
||||
inline void
|
||||
BlackoilOutputWriter::
|
||||
initFromRestartFile( const PhaseUsage& phaseusage,
|
||||
const double* permeability,
|
||||
const Grid& grid,
|
||||
SimulatorState& simulatorstate,
|
||||
WellStateFullyImplicitBlackoil& wellstate)
|
||||
{
|
||||
WellsManager wellsmanager(eclipseState_,
|
||||
eclipseState_->getInitConfig()->getRestartStep(),
|
||||
Opm::UgGridHelpers::numCells(grid),
|
||||
Opm::UgGridHelpers::globalCell(grid),
|
||||
Opm::UgGridHelpers::cartDims(grid),
|
||||
Opm::UgGridHelpers::dimensions(grid),
|
||||
Opm::UgGridHelpers::cell2Faces(grid),
|
||||
Opm::UgGridHelpers::beginFaceCentroids(grid),
|
||||
permeability);
|
||||
|
||||
const Wells* wells = wellsmanager.c_wells();
|
||||
wellstate.resize(wells, simulatorstate); //Resize for restart step
|
||||
Opm::init_from_restart_file(eclipseState_, Opm::UgGridHelpers::numCells(grid), phaseusage, simulatorstate, wellstate);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -169,6 +169,13 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
template <class State>
|
||||
void resize(const Wells* wells, const State& state) {
|
||||
const WellStateFullyImplicitBlackoil dummy_state; //Init with an empty previous state only resizes
|
||||
init(wells, state, dummy_state) ;
|
||||
}
|
||||
|
||||
|
||||
/// One rate per phase and well connection.
|
||||
std::vector<double>& perfPhaseRates() { return perfphaserates_; }
|
||||
const std::vector<double>& perfPhaseRates() const { return perfphaserates_; }
|
||||
|
Loading…
Reference in New Issue
Block a user