ParallelDebugOutput: initialize wells with current report step number.

This commit is contained in:
Robert Kloefkorn
2015-10-27 16:11:38 +01:00
parent 8e5c9b77ea
commit e30688fb85
2 changed files with 39 additions and 8 deletions

View File

@@ -43,7 +43,8 @@ namespace Opm
// gather solution to rank 0 for EclipseWriter // gather solution to rank 0 for EclipseWriter
virtual bool collectToIORank( const SimulatorState& localReservoirState, virtual bool collectToIORank( const SimulatorState& localReservoirState,
const WellState& localWellState ) = 0; const WellState& localWellState,
const int reportStep ) = 0;
virtual const SimulatorState& globalReservoirState() const = 0 ; virtual const SimulatorState& globalReservoirState() const = 0 ;
virtual const WellState& globalWellState() const = 0 ; virtual const WellState& globalWellState() const = 0 ;
@@ -71,7 +72,8 @@ namespace Opm
// gather solution to rank 0 for EclipseWriter // gather solution to rank 0 for EclipseWriter
virtual bool collectToIORank( const SimulatorState& localReservoirState, virtual bool collectToIORank( const SimulatorState& localReservoirState,
const WellState& localWellState ) const WellState& localWellState,
const int reportStep )
{ {
globalState_ = &localReservoirState; globalState_ = &localReservoirState;
wellState_ = &localWellState; wellState_ = &localWellState;
@@ -222,7 +224,10 @@ namespace Opm
Opm::EclipseStateConstPtr eclipseState, Opm::EclipseStateConstPtr eclipseState,
const int numPhases, const int numPhases,
const double* permeability ) const double* permeability )
: toIORankComm_( otherGrid.comm() ), : grid_(),
eclipseState_( eclipseState ),
permeability_( permeability ),
toIORankComm_( otherGrid.comm() ),
isIORank_( otherGrid.comm().rank() == ioRank ) isIORank_( otherGrid.comm().rank() == ioRank )
{ {
const CollectiveCommunication& comm = otherGrid.comm(); const CollectiveCommunication& comm = otherGrid.comm();
@@ -232,13 +237,15 @@ namespace Opm
// the I/O rank receives from all other ranks // the I/O rank receives from all other ranks
if( isIORank() ) if( isIORank() )
{ {
Dune::CpGrid globalGrid( otherGrid ); // copy grid
globalGrid.switchToGlobalView(); grid_.reset( new Dune::CpGrid(otherGrid ) );
grid_->switchToGlobalView();
Dune::CpGrid& globalGrid = *grid_;
// initialize global state with correct sizes // initialize global state with correct sizes
globalReservoirState_.init( globalGrid.numCells(), globalGrid.numFaces(), numPhases ); globalReservoirState_.init( globalGrid.numCells(), globalGrid.numFaces(), numPhases );
// TODO init well state
/*
// Create wells and well state. // Create wells and well state.
WellsManager wells_manager(eclipseState, WellsManager wells_manager(eclipseState,
0, 0,
@@ -253,6 +260,7 @@ namespace Opm
const Wells* wells = wells_manager.c_wells(); const Wells* wells = wells_manager.c_wells();
globalWellState_.init(wells, globalReservoirState_, globalWellState_ ); globalWellState_.init(wells, globalReservoirState_, globalWellState_ );
*/
// copy global cartesian index // copy global cartesian index
globalIndex_ = globalGrid.globalCell(); globalIndex_ = globalGrid.globalCell();
@@ -526,8 +534,28 @@ namespace Opm
// gather solution to rank 0 for EclipseWriter // gather solution to rank 0 for EclipseWriter
bool collectToIORank( const SimulatorState& localReservoirState, bool collectToIORank( const SimulatorState& localReservoirState,
const WellState& localWellState ) const WellState& localWellState,
const int reportStep )
{ {
if( isIORank() )
{
Dune::CpGrid& globalGrid = *grid_;
// Create wells and well state.
WellsManager wells_manager(eclipseState_,
reportStep,
Opm::UgGridHelpers::numCells( globalGrid ),
Opm::UgGridHelpers::globalCell( globalGrid ),
Opm::UgGridHelpers::cartDims( globalGrid ),
Opm::UgGridHelpers::dimensions( globalGrid ),
Opm::UgGridHelpers::cell2Faces( globalGrid ),
Opm::UgGridHelpers::beginFaceCentroids( globalGrid ),
permeability_,
false);
const Wells* wells = wells_manager.c_wells();
globalWellState_.init(wells, globalReservoirState_, globalWellState_ );
}
PackUnPackSimulatorState packUnpack( localReservoirState, globalReservoirState_, PackUnPackSimulatorState packUnpack( localReservoirState, globalReservoirState_,
localWellState, globalWellState_, localWellState, globalWellState_,
localIndexMap_, indexMaps_, isIORank() ); localIndexMap_, indexMaps_, isIORank() );
@@ -562,6 +590,9 @@ namespace Opm
} }
protected: protected:
std::unique_ptr< Dune::CpGrid > grid_;
Opm::EclipseStateConstPtr eclipseState_;
const double* permeability_;
P2PCommunicatorType toIORankComm_; P2PCommunicatorType toIORankComm_;
IndexMapType globalIndex_; IndexMapType globalIndex_;
IndexMapType localIndexMap_; IndexMapType localIndexMap_;

View File

@@ -265,7 +265,7 @@ namespace Opm
if( parallelOutput_ && parallelOutput_->isParallel() ) if( parallelOutput_ && parallelOutput_->isParallel() )
{ {
// collect all solutions to I/O rank // collect all solutions to I/O rank
isIORank = parallelOutput_->collectToIORank( localState, localWellState ); isIORank = parallelOutput_->collectToIORank( localState, localWellState, timer.reportStepNum() );
} }
const SimulatorState& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState; const SimulatorState& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState;