From 2d0701c1e81d350ec57d6fadbb009c7b5878840a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 6 Jun 2017 11:42:51 +0200 Subject: [PATCH] Include possibility for arbitrary summary data. This adapts to the upstream API change in opm-data, and adds a proof-of-concept dummy TCPU field. --- opm/autodiff/SimulatorBase_impl.hpp | 2 +- ...FullyImplicitBlackoilMultiSegment_impl.hpp | 2 +- .../SimulatorFullyImplicitBlackoilOutput.cpp | 31 ++++++++++++------- .../SimulatorFullyImplicitBlackoilOutput.hpp | 22 ++++++++----- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index cdf83a937..cf80351c2 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -191,7 +191,7 @@ namespace Opm // 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, {} ); + output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state, {}, {} ); report.output_write_time += perfTimer.stop(); } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp index b22c7dc65..3536259f8 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp @@ -145,7 +145,7 @@ namespace Opm if (timer.initialStep()) { // 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, {} ); + output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state, {}, {} ); } // Max oil saturation (for VPPARS), hysteresis update. diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp index 51124528e..e09303dc2 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp @@ -185,7 +185,8 @@ namespace Opm const SimulationDataContainer state_; const WellStateFullyImplicitBlackoil wellState_; data::Solution simProps_; - std::map> extraData_; + std::map miscSummaryData_; + std::map> extraRestartData_; const bool substep_; explicit WriterCall( BlackoilOutputWriter& writer, @@ -193,14 +194,16 @@ namespace Opm const SimulationDataContainer& state, const WellStateFullyImplicitBlackoil& wellState, const data::Solution& simProps, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep ) : writer_( writer ), timer_( timer.clone() ), state_( state ), wellState_( wellState ), simProps_( simProps ), - extraData_( extraData ), + miscSummaryData_( miscSummaryData ), + extraRestartData_( extraRestartData ), substep_( substep ) { } @@ -209,7 +212,7 @@ namespace Opm void run () { // write data - writer_.writeTimeStepSerial( *timer_, state_, wellState_, simProps_, extraData_, substep_ ); + writer_.writeTimeStepSerial( *timer_, state_, wellState_, simProps_, miscSummaryData_, extraRestartData_, substep_ ); } }; } @@ -223,7 +226,8 @@ namespace Opm const SimulatorTimerInterface& timer, const SimulationDataContainer& localState, const WellStateFullyImplicitBlackoil& localWellState, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep) { data::Solution localCellData{}; @@ -232,7 +236,7 @@ namespace Opm localCellData = simToSolution(localState, restart_double_si_, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...); } writeTimeStepWithCellProperties(timer, localState, localCellData , - localWellState, extraData, substep); + localWellState, miscSummaryData, extraRestartData, substep); } @@ -246,7 +250,8 @@ namespace Opm const SimulationDataContainer& localState, const data::Solution& localCellData, const WellStateFullyImplicitBlackoil& localWellState, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep) { // VTK output (is parallel if grid is parallel) @@ -282,12 +287,12 @@ namespace Opm { if( asyncOutput_ ) { // dispatch the write call to the extra thread - asyncOutput_->dispatch( detail::WriterCall( *this, timer, state, wellState, cellData, extraData, substep ) ); + asyncOutput_->dispatch( detail::WriterCall( *this, timer, state, wellState, cellData, miscSummaryData, extraRestartData, substep ) ); } else { // just write the data to disk try { - writeTimeStepSerial( timer, state, wellState, cellData, extraData, substep ); + writeTimeStepSerial( timer, state, wellState, cellData, miscSummaryData, extraRestartData, substep ); } catch (std::runtime_error& msg) { err = 1; emsg = msg.what(); @@ -317,7 +322,8 @@ namespace Opm const SimulationDataContainer& state, const WellStateFullyImplicitBlackoil& wellState, const data::Solution& simProps, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep) { // Matlab output @@ -338,7 +344,8 @@ namespace Opm timer.simulationTimeElapsed(), simProps, wellState.report(phaseUsage_), - extraData, + miscSummaryData, + extraRestartData, restart_double_si_); } } @@ -407,7 +414,7 @@ namespace Opm // No per cell data is written for restore steps, but will be // for subsequent steps, when we have started simulating - writeTimeStepWithoutCellProperties( timer, state, wellState, {} ); + writeTimeStepWithoutCellProperties( timer, state, wellState, {}, {}); // some output std::cout << "Restored step " << timer.reportStepNum() << " at day " diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index f637db318..f7401b98d 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -235,14 +235,15 @@ namespace Opm /*! * \brief Write a blackoil reservoir state to disk for later inspection with * visualization tools like ResInsight. This function will write all - * CellData in simProps to the file as well as the extraData. + * CellData in simProps to the file as well as the extraRestartData. */ void writeTimeStepWithCellProperties( const SimulatorTimerInterface& timer, const SimulationDataContainer& reservoirState, const data::Solution& cellData, const Opm::WellStateFullyImplicitBlackoil& wellState, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep = false); /*! @@ -254,7 +255,8 @@ namespace Opm const SimulatorTimerInterface& timer, const SimulationDataContainer& reservoirState, const Opm::WellStateFullyImplicitBlackoil& wellState, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep = false); /*! @@ -266,7 +268,8 @@ namespace Opm const SimulationDataContainer& reservoirState, const Opm::WellStateFullyImplicitBlackoil& wellState, const data::Solution& simProps, - const std::map>& extraData, + const std::map& miscSummaryData, + const std::map>& extraRestartData, bool substep); /** \brief return output directory */ @@ -994,7 +997,8 @@ namespace Opm const SummaryConfig& summaryConfig = eclipseState_.getSummaryConfig(); const int reportStepNum = timer.reportStepNum(); bool logMessages = output_ && parallelOutput_->isIORank(); - std::map> extraData; + std::map> extraRestartData; + std::map miscSummaryData; if( output_ ) { @@ -1016,10 +1020,14 @@ namespace Opm assert(!localCellData.empty()); // Add suggested next timestep to extra data. - extraData["OPMEXTRA"] = std::vector(1, nextstep); + extraRestartData["OPMEXTRA"] = std::vector(1, nextstep); + + // @@@ HACK @@@ + // Add TCPU + miscSummaryData["TCPU"] = 100.0; } - writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, extraData, substep); + writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, miscSummaryData, extraRestartData, substep); } } #endif