From a949d5a73638b3107ef28c2e383846fde43060b7 Mon Sep 17 00:00:00 2001 From: chflo Date: Sun, 2 Aug 2015 22:26:45 +0200 Subject: [PATCH] OPM-218: Write restart files at same interval as eclipse --- opm/core/io/OutputWriter.cpp | 5 +++-- opm/core/io/OutputWriter.hpp | 3 ++- opm/core/io/eclipse/EclipseWriter.cpp | 6 ++++-- opm/core/io/eclipse/EclipseWriter.hpp | 2 +- opm/core/simulator/AdaptiveTimeStepping_impl.hpp | 3 ++- opm/core/simulator/SimulatorOutput.cpp | 2 +- tests/test_EclipseWriteRFTHandler.cpp | 2 +- tests/test_EclipseWriter.cpp | 2 +- tests/test_readWriteWellStateData.cpp | 2 +- tests/test_writenumwells.cpp | 2 +- 10 files changed, 17 insertions(+), 12 deletions(-) diff --git a/opm/core/io/OutputWriter.cpp b/opm/core/io/OutputWriter.cpp index 1431ad46..a0208463 100644 --- a/opm/core/io/OutputWriter.cpp +++ b/opm/core/io/OutputWriter.cpp @@ -34,9 +34,10 @@ struct MultiWriter : public OutputWriter { virtual void writeTimeStep(const SimulatorTimerInterface& timer, const SimulatorState& reservoirState, - const WellState& wellState) { + const WellState& wellState, + bool isSubstep) { for (it_t it = writers_->begin (); it != writers_->end(); ++it) { - (*it)->writeTimeStep (timer, reservoirState, wellState); + (*it)->writeTimeStep (timer, reservoirState, wellState, isSubstep); } } diff --git a/opm/core/io/OutputWriter.hpp b/opm/core/io/OutputWriter.hpp index 27f4dd3b..8ae51577 100644 --- a/opm/core/io/OutputWriter.hpp +++ b/opm/core/io/OutputWriter.hpp @@ -88,7 +88,8 @@ public: */ virtual void writeTimeStep(const SimulatorTimerInterface& timer, const SimulatorState& reservoirState, - const WellState& wellState) = 0; + const WellState& wellState, + bool isSubstep) = 0; /*! * Create a suitable set of output formats based on configuration. diff --git a/opm/core/io/eclipse/EclipseWriter.cpp b/opm/core/io/eclipse/EclipseWriter.cpp index 1af7422c..762deaf5 100644 --- a/opm/core/io/eclipse/EclipseWriter.cpp +++ b/opm/core/io/eclipse/EclipseWriter.cpp @@ -1219,8 +1219,10 @@ void EclipseWriter::writeInit(const SimulatorTimerInterface &timer) // implementation of the writeTimeStep method void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer, const SimulatorState& reservoirState, - const WellState& wellState) + const WellState& wellState, + bool isSubstep) { + // if we don't want to write anything, this method becomes a // no-op... if (!enableOutput_) { @@ -1258,7 +1260,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer, // Write restart file - if(ioConfig->getWriteRestartFile(timer.reportStepNum())) + if(!isSubstep && ioConfig->getWriteRestartFile(timer.reportStepNum())) { const size_t ncwmax = eclipseState_->getSchedule()->getMaxNumCompletionsForWells(timer.reportStepNum()); const size_t numWells = eclipseState_->getSchedule()->numWells(timer.reportStepNum()); diff --git a/opm/core/io/eclipse/EclipseWriter.hpp b/opm/core/io/eclipse/EclipseWriter.hpp index f87eb9d7..a3063184 100644 --- a/opm/core/io/eclipse/EclipseWriter.hpp +++ b/opm/core/io/eclipse/EclipseWriter.hpp @@ -98,7 +98,7 @@ public: */ virtual void writeTimeStep(const SimulatorTimerInterface& timer, const SimulatorState& reservoirState, - const WellState& wellState); + const WellState& wellState, bool isSubstep ); static int eclipseWellTypeMask(WellType wellType, WellInjector::TypeEnum injectorType); diff --git a/opm/core/simulator/AdaptiveTimeStepping_impl.hpp b/opm/core/simulator/AdaptiveTimeStepping_impl.hpp index 4e252e80..950a975b 100644 --- a/opm/core/simulator/AdaptiveTimeStepping_impl.hpp +++ b/opm/core/simulator/AdaptiveTimeStepping_impl.hpp @@ -180,7 +180,8 @@ namespace Opm { // write data if outputWriter was provided if( outputWriter ) { - outputWriter->writeTimeStep( substepTimer, state, well_state ); + bool substep = true; + outputWriter->writeTimeStep( substepTimer, state, well_state, substep); } // set new time step length diff --git a/opm/core/simulator/SimulatorOutput.cpp b/opm/core/simulator/SimulatorOutput.cpp index 40606c30..b2f83b02 100644 --- a/opm/core/simulator/SimulatorOutput.cpp +++ b/opm/core/simulator/SimulatorOutput.cpp @@ -88,7 +88,7 @@ SimulatorOutputBase::writeOutput () { // relay the request to the handlers (setup in the constructor // from parameters) - writer_->writeTimeStep (*timer_, *reservoirState_, *wellState_); + writer_->writeTimeStep (*timer_, *reservoirState_, *wellState_ , false); // advance to the next reporting time ++next_; diff --git a/tests/test_EclipseWriteRFTHandler.cpp b/tests/test_EclipseWriteRFTHandler.cpp index d557574a..6c59d6ce 100755 --- a/tests/test_EclipseWriteRFTHandler.cpp +++ b/tests/test_EclipseWriteRFTHandler.cpp @@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(test_EclipseWriterRFTHandler) for (; simulatorTimer->currentStepNum() < simulatorTimer->numSteps(); ++ (*simulatorTimer)) { std::shared_ptr blackoilState2 = createBlackoilState(simulatorTimer->currentStepNum(),ourFineGridManagerPtr); std::shared_ptr wellState = createWellState(blackoilState2); - eclipseWriter->writeTimeStep(*simulatorTimer, *blackoilState2, *wellState); + eclipseWriter->writeTimeStep(*simulatorTimer, *blackoilState2, *wellState, false); } std::string cwd(test_work_area_get_cwd(test_area.get())); diff --git a/tests/test_EclipseWriter.cpp b/tests/test_EclipseWriter.cpp index 611f3dba..431dab53 100644 --- a/tests/test_EclipseWriter.cpp +++ b/tests/test_EclipseWriter.cpp @@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriterIntegration) for (; simTimer->currentStepNum() < simTimer->numSteps(); ++ (*simTimer)) { createBlackoilState(simTimer->currentStepNum()); createWellState(simTimer->currentStepNum()); - eclWriter->writeTimeStep(*simTimer, *blackoilState, *wellState); + eclWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false); checkRestartFile(simTimer->currentStepNum()); checkSummaryFile(simTimer->currentStepNum()); } diff --git a/tests/test_readWriteWellStateData.cpp b/tests/test_readWriteWellStateData.cpp index 5400c188..f63a55c2 100644 --- a/tests/test_readWriteWellStateData.cpp +++ b/tests/test_readWriteWellStateData.cpp @@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) setValuesInWellState(wellState); simTimer->setCurrentStepNum(1); - eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState); + eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState , false); const char * test_area_path = test_work_area_get_cwd(test_area); std::string slash = "/"; diff --git a/tests/test_writenumwells.cpp b/tests/test_writenumwells.cpp index 05743cd3..1049169d 100644 --- a/tests/test_writenumwells.cpp +++ b/tests/test_writenumwells.cpp @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) for(int timestep=0; timestep <= countTimeStep; ++timestep){ simTimer->setCurrentStepNum(timestep); - eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState); + eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false); } verifyWellState(eclipse_restart_filename, eclipseState->getEclipseGrid(), eclipseState->getSchedule());