Merge pull request #769 from blattms/fix-step-used-by-parallel-io

Fix step number used by parallel io and OutputWriter::writeTimeStep
This commit is contained in:
Atgeirr Flø Rasmussen 2016-09-07 14:09:56 +02:00 committed by GitHub
commit 4d2d004c43
2 changed files with 16 additions and 7 deletions

View File

@ -45,10 +45,12 @@ namespace Opm
public: public:
virtual ~ParallelDebugOutputInterface() {} virtual ~ParallelDebugOutputInterface() {}
// gather solution to rank 0 for EclipseWriter //! \brief gather solution to rank 0 for EclipseWriter
//! \param localWellState The well state
//! \param wellStateStepNumber The step number of the well state.
virtual bool collectToIORank( const SimulationDataContainer& localReservoirState, virtual bool collectToIORank( const SimulationDataContainer& localReservoirState,
const WellState& localWellState, const WellState& localWellState,
const int reportStep ) = 0; const int wellStateStepNumber ) = 0;
virtual const SimulationDataContainer& globalReservoirState() const = 0 ; virtual const SimulationDataContainer& globalReservoirState() const = 0 ;
virtual const WellState& globalWellState() const = 0 ; virtual const WellState& globalWellState() const = 0 ;
@ -77,7 +79,7 @@ namespace Opm
// gather solution to rank 0 for EclipseWriter // gather solution to rank 0 for EclipseWriter
virtual bool collectToIORank( const SimulationDataContainer& localReservoirState, virtual bool collectToIORank( const SimulationDataContainer& localReservoirState,
const WellState& localWellState, const WellState& localWellState,
const int /* reportStep */) const int /* wellStateStepNumber */)
{ {
globalState_ = &localReservoirState; globalState_ = &localReservoirState;
wellState_ = &localWellState; wellState_ = &localWellState;
@ -521,7 +523,7 @@ namespace Opm
// gather solution to rank 0 for EclipseWriter // gather solution to rank 0 for EclipseWriter
bool collectToIORank( const SimulationDataContainer& localReservoirState, bool collectToIORank( const SimulationDataContainer& localReservoirState,
const WellState& localWellState, const WellState& localWellState,
const int reportStep ) const int wellStateStepNumber )
{ {
if( isIORank() ) if( isIORank() )
{ {
@ -532,7 +534,7 @@ namespace Opm
const DynamicListEconLimited dynamic_list_econ_limited; const DynamicListEconLimited dynamic_list_econ_limited;
// Create wells and well state. // Create wells and well state.
WellsManager wells_manager(eclipseState_, WellsManager wells_manager(eclipseState_,
reportStep, wellStateStepNumber,
Opm::UgGridHelpers::numCells( globalGrid ), Opm::UgGridHelpers::numCells( globalGrid ),
Opm::UgGridHelpers::globalCell( globalGrid ), Opm::UgGridHelpers::globalCell( globalGrid ),
Opm::UgGridHelpers::cartDims( globalGrid ), Opm::UgGridHelpers::cartDims( globalGrid ),

View File

@ -295,8 +295,15 @@ namespace Opm
bool isIORank = output_ ; bool isIORank = output_ ;
if( parallelOutput_ && parallelOutput_->isParallel() ) if( parallelOutput_ && parallelOutput_->isParallel() )
{ {
// If this is not the initial write and no substep, then the well
// state used in the computation is actually the one of the last
// step. We need that well state for the gathering. Otherwise
// It an exception with a message like "global state does not
// contain well ..." might be thrown.
int wellStateStepNumber = ( ! substep && timer.reportStepNum() > 0) ?
(timer.reportStepNum() - 1) : timer.reportStepNum();
// collect all solutions to I/O rank // collect all solutions to I/O rank
isIORank = parallelOutput_->collectToIORank( localState, localWellState, timer.reportStepNum() ); isIORank = parallelOutput_->collectToIORank( localState, localWellState, wellStateStepNumber );
} }
const SimulationDataContainer& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState; const SimulationDataContainer& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState;
@ -361,7 +368,7 @@ namespace Opm
*/ */
eclWriter_->writeTimeStep(timer.currentStepNum(), eclWriter_->writeTimeStep(timer.reportStepNum(),
substep, substep,
timer.simulationTimeElapsed(), timer.simulationTimeElapsed(),
simToSolution( state, phaseUsage_ ), simToSolution( state, phaseUsage_ ),