Merge pull request #941 from blattms/read-write-perforation-rates-and-pressure

Read write perforation rates, pressure, phase reates, and control of wells.
This commit is contained in:
Atgeirr Flø Rasmussen 2016-11-22 11:16:19 +01:00 committed by GitHub
commit 621a72bb25
5 changed files with 90 additions and 42 deletions

View File

@ -55,13 +55,13 @@ namespace Opm
//! localReservoirState) //! localReservoirState)
//! \param wellStateStepNumber The step number of 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 WellStateFullyImplicitBlackoil& localWellState,
const data::Solution& localCellData, const data::Solution& localCellData,
const int wellStateStepNumber ) = 0; const int wellStateStepNumber ) = 0;
virtual const SimulationDataContainer& globalReservoirState() const = 0 ; virtual const SimulationDataContainer& globalReservoirState() const = 0 ;
virtual const data::Solution& globalCellData() const = 0 ; virtual const data::Solution& globalCellData() const = 0 ;
virtual const WellState& globalWellState() const = 0 ; virtual const WellStateFullyImplicitBlackoil& globalWellState() const = 0 ;
virtual bool isIORank() const = 0; virtual bool isIORank() const = 0;
virtual bool isParallel() const = 0; virtual bool isParallel() const = 0;
virtual int numCells() const = 0 ; virtual int numCells() const = 0 ;
@ -74,9 +74,9 @@ namespace Opm
protected: protected:
const GridImpl& grid_; const GridImpl& grid_;
const SimulationDataContainer* globalState_; const SimulationDataContainer* globalState_;
const WellState* wellState_; const WellStateFullyImplicitBlackoil* wellState_;
const data::Solution* globalCellData_; const data::Solution* globalCellData_;
public: public:
ParallelDebugOutput ( const GridImpl& grid, ParallelDebugOutput ( const GridImpl& grid,
@ -88,7 +88,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 WellStateFullyImplicitBlackoil& localWellState,
const data::Solution& localCellData, const data::Solution& localCellData,
const int /* wellStateStepNumber */) const int /* wellStateStepNumber */)
{ {
@ -103,7 +103,7 @@ namespace Opm
{ {
return *globalCellData_; return *globalCellData_;
} }
virtual const WellState& globalWellState() const { return *wellState_; } virtual const WellStateFullyImplicitBlackoil& globalWellState() const { return *wellState_; }
virtual bool isIORank () const { return true; } virtual bool isIORank () const { return true; }
virtual bool isParallel () const { return false; } virtual bool isParallel () const { return false; }
virtual int numCells() const { return grid_.number_of_cells; } virtual int numCells() const { return grid_.number_of_cells; }
@ -341,8 +341,8 @@ namespace Opm
SimulationDataContainer& globalState_; SimulationDataContainer& globalState_;
const data::Solution& localCellData_; const data::Solution& localCellData_;
data::Solution& globalCellData_; data::Solution& globalCellData_;
const WellState& localWellState_; const WellStateFullyImplicitBlackoil& localWellState_;
WellState& globalWellState_; WellStateFullyImplicitBlackoil& globalWellState_;
const IndexMapType& localIndexMap_; const IndexMapType& localIndexMap_;
const IndexMapStorageType& indexMaps_; const IndexMapStorageType& indexMaps_;
@ -351,8 +351,8 @@ namespace Opm
SimulationDataContainer& globalState, SimulationDataContainer& globalState,
const data::Solution& localCellData, const data::Solution& localCellData,
data::Solution& globalCellData, data::Solution& globalCellData,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
WellState& globalWellState, WellStateFullyImplicitBlackoil& globalWellState,
const IndexMapType& localIndexMap, const IndexMapType& localIndexMap,
const IndexMapStorageType& indexMaps, const IndexMapStorageType& indexMaps,
const bool isIORank ) const bool isIORank )
@ -522,8 +522,32 @@ namespace Opm
for( int np=0; np<localWellState_.numPhases(); ++np ) for( int np=0; np<localWellState_.numPhases(); ++np )
buffer.write( localWellState_.wellRates()[ wellRateIdx + np ] ); buffer.write( localWellState_.wellRates()[ wellRateIdx + np ] );
// TODO: perfRates and perfPress, need to figure out the index // Write well control
// mapping there. buffer.write(localWellState_.currentControls()[ wellIdx ]);
// Write perfRates and perfPress. No need to figure out the index
// mapping there as the ordering of the perforations should
// be the same for global and local state.
const int end_con = it->second[1] + it->second[2];
for( int con = it->second[1]; con < end_con; ++con )
{
buffer.write( localWellState_.perfRates()[ con ] );
}
for( int con = it->second[1]; con < end_con; ++con )
{
buffer.write( localWellState_.perfPress()[ con ] );
}
// Write perfPhaseRate
const int np = localWellState_.perfPhaseRates().size() /
localWellState_.perfRates().size();
for( int con = it->second[1]*np; con < end_con*np; ++con )
{
buffer.write( localWellState_.perfPhaseRates()[ con ] );
}
} }
} }
@ -552,15 +576,39 @@ namespace Opm
for( int np=0; np<globalWellState_.numPhases(); ++np ) for( int np=0; np<globalWellState_.numPhases(); ++np )
buffer.read( globalWellState_.wellRates()[ wellRateIdx + np ] ); buffer.read( globalWellState_.wellRates()[ wellRateIdx + np ] );
// TODO: perfRates and perfPress, need to figure out the index // Write well control
// mapping there. buffer.read(globalWellState_.currentControls()[ wellIdx ]);
// Read perfRates and perfPress. No need to figure out the index
// mapping there as the ordering of the perforations should
// be the same for global and local state.
const int end_con = it->second[1] + it->second[2];
for( int con = it->second[1]; con < end_con; ++con )
{
buffer.read( globalWellState_.perfRates()[ con ] );
}
for( int con = it->second[1]; con < end_con; ++con )
{
buffer.read( globalWellState_.perfPress()[ con ] );
}
// Read perfPhaseRate
const int np = globalWellState_.perfPhaseRates().size() /
globalWellState_.perfRates().size();
for( int con = it->second[1]*np; con < end_con*np; ++con )
{
buffer.read( globalWellState_.perfPhaseRates()[ con ] );
}
} }
} }
}; };
// 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 WellStateFullyImplicitBlackoil& localWellState,
const data::Solution& localCellData, const data::Solution& localCellData,
const int wellStateStepNumber ) const int wellStateStepNumber )
{ {
@ -623,7 +671,7 @@ namespace Opm
return *globalCellData_; return *globalCellData_;
} }
const WellState& globalWellState() const { return globalWellState_; } const WellStateFullyImplicitBlackoil& globalWellState() const { return globalWellState_; }
bool isIORank() const bool isIORank() const
{ {

View File

@ -201,14 +201,14 @@ namespace Opm
BlackoilOutputWriter& writer_; BlackoilOutputWriter& writer_;
std::unique_ptr< SimulatorTimerInterface > timer_; std::unique_ptr< SimulatorTimerInterface > timer_;
const SimulationDataContainer state_; const SimulationDataContainer state_;
const WellState wellState_; const WellStateFullyImplicitBlackoil wellState_;
data::Solution simProps_; data::Solution simProps_;
const bool substep_; const bool substep_;
explicit WriterCall( BlackoilOutputWriter& writer, explicit WriterCall( BlackoilOutputWriter& writer,
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& state, const SimulationDataContainer& state,
const WellState& wellState, const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
bool substep ) bool substep )
: writer_( writer ), : writer_( writer ),
@ -237,7 +237,7 @@ namespace Opm
writeTimeStepWithoutCellProperties( writeTimeStepWithoutCellProperties(
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
bool substep) bool substep)
{ {
data::Solution localCellData{}; data::Solution localCellData{};
@ -259,7 +259,7 @@ namespace Opm
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const data::Solution& localCellData, const data::Solution& localCellData,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
bool substep) bool substep)
{ {
// VTK output (is parallel if grid is parallel) // VTK output (is parallel if grid is parallel)
@ -285,7 +285,7 @@ namespace Opm
const data::Solution& cellData = ( parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalCellData() : localCellData; const data::Solution& cellData = ( parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalCellData() : localCellData;
const SimulationDataContainer& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState; const SimulationDataContainer& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState;
const WellState& wellState = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalWellState() : localWellState; const WellStateFullyImplicitBlackoil& wellState = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalWellState() : localWellState;
// serial output is only done on I/O rank // serial output is only done on I/O rank
if( isIORank ) if( isIORank )
@ -307,7 +307,7 @@ namespace Opm
BlackoilOutputWriter:: BlackoilOutputWriter::
writeTimeStepSerial(const SimulatorTimerInterface& timer, writeTimeStepSerial(const SimulatorTimerInterface& timer,
const SimulationDataContainer& state, const SimulationDataContainer& state,
const WellState& wellState, const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
bool substep) bool substep)
{ {

View File

@ -148,7 +148,7 @@ namespace Opm
virtual void writeTimeStep(const SimulatorTimerInterface& timer, virtual void writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& state, const SimulationDataContainer& state,
const WellState&, const WellStateFullyImplicitBlackoil&,
bool /*substep*/ = false) = 0; bool /*substep*/ = false) = 0;
protected: protected:
const std::string outputDir_; const std::string outputDir_;
@ -165,7 +165,7 @@ namespace Opm
void writeTimeStep(const SimulatorTimerInterface& timer, void writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& state, const SimulationDataContainer& state,
const WellState&, const WellStateFullyImplicitBlackoil&,
bool /*substep*/ = false) override bool /*substep*/ = false) override
{ {
outputStateVtk(grid_, state, timer.currentStepNum(), outputDir_); outputStateVtk(grid_, state, timer.currentStepNum(), outputDir_);
@ -187,7 +187,7 @@ namespace Opm
void writeTimeStep(const SimulatorTimerInterface& timer, void writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const WellState& wellState, const WellStateFullyImplicitBlackoil& wellState,
bool /*substep*/ = false) override bool /*substep*/ = false) override
{ {
outputStateMatlab(grid_, reservoirState, timer.currentStepNum(), outputDir_); outputStateMatlab(grid_, reservoirState, timer.currentStepNum(), outputDir_);
@ -224,7 +224,7 @@ namespace Opm
template<class Model> template<class Model>
void writeTimeStep(const SimulatorTimerInterface& timer, void writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const Model& physicalModel, const Model& physicalModel,
bool substep = false); bool substep = false);
@ -238,7 +238,7 @@ namespace Opm
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const data::Solution& cellData, const data::Solution& cellData,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
bool substep = false); bool substep = false);
/*! /*!
@ -249,7 +249,7 @@ namespace Opm
void writeTimeStepWithoutCellProperties( void writeTimeStepWithoutCellProperties(
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
bool substep = false); bool substep = false);
/*! /*!
@ -259,7 +259,7 @@ namespace Opm
*/ */
void writeTimeStepSerial(const SimulatorTimerInterface& timer, void writeTimeStepSerial(const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
bool substep); bool substep);
@ -781,7 +781,7 @@ namespace Opm
BlackoilOutputWriter:: BlackoilOutputWriter::
writeTimeStep(const SimulatorTimerInterface& timer, writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
const Model& physicalModel, const Model& physicalModel,
bool substep) bool substep)
{ {

View File

@ -61,14 +61,14 @@ namespace Opm
BlackoilOutputWriterEbos& writer_; BlackoilOutputWriterEbos& writer_;
std::unique_ptr< SimulatorTimerInterface > timer_; std::unique_ptr< SimulatorTimerInterface > timer_;
const SimulationDataContainer state_; const SimulationDataContainer state_;
const WellState wellState_; const WellStateFullyImplicitBlackoil wellState_;
data::Solution simProps_; data::Solution simProps_;
const bool substep_; const bool substep_;
explicit WriterCallEbos( BlackoilOutputWriterEbos& writer, explicit WriterCallEbos( BlackoilOutputWriterEbos& writer,
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& state, const SimulationDataContainer& state,
const WellState& wellState, const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
bool substep ) bool substep )
: writer_( writer ), : writer_( writer ),
@ -94,7 +94,7 @@ namespace Opm
writeTimeStepWithoutCellProperties( writeTimeStepWithoutCellProperties(
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
bool substep) bool substep)
{ {
data::Solution noCellProperties; data::Solution noCellProperties;
@ -110,7 +110,7 @@ namespace Opm
writeTimeStepWithCellProperties( writeTimeStepWithCellProperties(
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
const data::Solution& sol, const data::Solution& sol,
bool substep) bool substep)
{ {
@ -129,7 +129,7 @@ namespace Opm
} }
const SimulationDataContainer& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState; const SimulationDataContainer& state = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalReservoirState() : localState;
const WellState& wellState = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalWellState() : localWellState; const WellStateFullyImplicitBlackoil& wellState = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalWellState() : localWellState;
// serial output is only done on I/O rank // serial output is only done on I/O rank
if( isIORank ) if( isIORank )
@ -151,7 +151,7 @@ namespace Opm
BlackoilOutputWriterEbos:: BlackoilOutputWriterEbos::
writeTimeStepSerial(const SimulatorTimerInterface& timer, writeTimeStepSerial(const SimulatorTimerInterface& timer,
const SimulationDataContainer& state, const SimulationDataContainer& state,
const WellState& wellState, const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& sol, const data::Solution& sol,
bool substep) bool substep)
{ {

View File

@ -83,7 +83,7 @@ namespace Opm
template<class Model> template<class Model>
void writeTimeStep(const SimulatorTimerInterface& timer, void writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const Model& physicalModel, const Model& physicalModel,
bool substep = false); bool substep = false);
@ -96,7 +96,7 @@ namespace Opm
void writeTimeStepWithCellProperties( void writeTimeStepWithCellProperties(
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const data::Solution& sol, const data::Solution& sol,
bool substep = false); bool substep = false);
@ -108,7 +108,7 @@ namespace Opm
void writeTimeStepWithoutCellProperties( void writeTimeStepWithoutCellProperties(
const SimulatorTimerInterface& timer, const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
bool substep = false); bool substep = false);
/*! /*!
@ -118,7 +118,7 @@ namespace Opm
*/ */
void writeTimeStepSerial(const SimulatorTimerInterface& timer, void writeTimeStepSerial(const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState, const SimulationDataContainer& reservoirState,
const Opm::WellState& wellState, const Opm::WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps, const data::Solution& simProps,
bool substep); bool substep);
@ -684,7 +684,7 @@ namespace Opm
BlackoilOutputWriterEbos:: BlackoilOutputWriterEbos::
writeTimeStep(const SimulatorTimerInterface& timer, writeTimeStep(const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState, const SimulationDataContainer& localState,
const WellState& localWellState, const WellStateFullyImplicitBlackoil& localWellState,
const Model& physicalModel, const Model& physicalModel,
bool substep) bool substep)
{ {