diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index 523679184..961748868 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -157,24 +157,31 @@ public: std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt"; std::ofstream tstep_os(tstep_filename.c_str()); + const auto& schedule = eclState().getSchedule(); + // adaptive time stepping std::unique_ptr< AdaptiveTimeStepping > adaptiveTimeStepping; if( param_.getDefault("timestep.adaptive", true ) ) { - adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) ); + + if (param_.getDefault("use_TUNING", false)) { + adaptiveTimeStepping.reset( new AdaptiveTimeStepping( schedule.getTuning(), timer.currentStepNum(), param_, terminal_output_ ) ); + } else { + adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) ); + } } std::string restorefilename = param_.getDefault("restorefile", std::string("") ); if( ! restorefilename.empty() ) { // -1 means that we'll take the last report step that was written - //const int desiredRestoreStep = param_.getDefault("restorestep", int(-1) ); + const int desiredRestoreStep = param_.getDefault("restorestep", int(-1) ); - // output_writer_.restore( timer, - // state, - // prev_well_state, - // restorefilename, - // desiredRestoreStep ); + output_writer_.restore( timer, + state, + prev_well_state, + restorefilename, + desiredRestoreStep ); } bool is_well_potentials_computed = param_.getDefault("compute_well_potentials", false ); @@ -195,7 +202,6 @@ public: } } std::vector> OOIP; - // Main simulation loop. while (!timer.done()) { // Report timestep. @@ -221,7 +227,6 @@ public: is_parallel_run_, well_potentials, defunct_well_names_ ); - const Wells* wells = wells_manager.c_wells(); WellState well_state; well_state.init(wells, state, prev_well_state, props_.phaseUsage()); @@ -229,6 +234,18 @@ public: // give the polymer and surfactant simulators the chance to do their stuff handleAdditionalWellInflow(timer, wells_manager, well_state, wells); + // write the inital state at the report stage + if (timer.initialStep()) { + Dune::Timer perfTimer; + perfTimer.start(); + + // No per cell data is written for initial step, but will be + // for subsequent steps, when we have started simulating + output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state ); + + report.output_write_time += perfTimer.stop(); + } + // Compute reservoir volumes for RESV controls. computeRESV(timer.currentStepNum(), wells, state, well_state); @@ -239,29 +256,6 @@ public: auto solver = createSolver(well_model); - // write the inital state at the report stage - if (timer.initialStep()) { - Dune::Timer perfTimer; - perfTimer.start(); - - // make sure that the Intensive Quantities cache is up to date - const auto& gridManager = ebosSimulator_.gridManager(); - const auto& gridView = gridManager.gridView(); - auto elemIt = gridView.template begin<0>(); - auto elemEndIt = gridView.template end<0>(); - ElementContext elemCtx(ebosSimulator_); - for (; elemIt != elemEndIt; ++ elemIt) { - elemCtx.updatePrimaryStencil(*elemIt); - elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); - } - - // No per cell data is written for initial step, but will be - // for subsequent steps, when we have started simulating - output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state ); - - report.output_write_time += perfTimer.stop(); - } - // Compute orignal FIP; if (!ooip_computed) { OOIP = solver->computeFluidInPlace(fipnum); @@ -274,12 +268,10 @@ public: std::ostringstream step_msg; boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%d-%b-%Y"); step_msg.imbue(std::locale(std::locale::classic(), facet)); - step_msg << "\n" - << "Time step " << std::setw(4) <