Merge pull request #769 from dr-robertk/PR/eclipsewriter-only-summary-in-substeps

Eclipsewriter: only write summary in substeps
This commit is contained in:
Bård Skaflestad 2015-03-10 12:32:00 +01:00
commit 91dc1ccc47
3 changed files with 119 additions and 113 deletions

View File

@ -105,7 +105,7 @@ namespace EclipseWriterDetails {
ecl_rft_node_type * ecl_rft_node = ecl_rft_node_alloc_new(well_name.c_str(), type.c_str(), recording_date, days); ecl_rft_node_type * ecl_rft_node = ecl_rft_node_alloc_new(well_name.c_str(), type.c_str(), recording_date, days);
CompletionSetConstPtr completionsSet = well->getCompletions(timestep); CompletionSetConstPtr completionsSet = well->getCompletions(timestep);
for (int index = 0; index < completionsSet->size(); ++index) { for (size_t index = 0; index < completionsSet->size(); ++index) {
CompletionConstPtr completion = completionsSet->get(index); CompletionConstPtr completion = completionsSet->get(index);
size_t i = (size_t)completion->getI(); size_t i = (size_t)completion->getI();
size_t j = (size_t)completion->getJ(); size_t j = (size_t)completion->getJ();
@ -131,7 +131,7 @@ namespace EclipseWriterDetails {
void EclipseWriteRFTHandler::initGlobalToActiveIndex(const int * compressedToCartesianCellIdx, size_t numCells, size_t cartesianSize) { void EclipseWriteRFTHandler::initGlobalToActiveIndex(const int * compressedToCartesianCellIdx, size_t numCells, size_t cartesianSize) {
globalToActiveIndex_.resize(cartesianSize, -1); globalToActiveIndex_.resize(cartesianSize, -1);
for (int active_index = 0; active_index < numCells; ++active_index) { for (size_t active_index = 0; active_index < numCells; ++active_index) {
//If compressedToCartesianCellIdx is NULL, assume no compressed to cartesian mapping, set global equal to active index //If compressedToCartesianCellIdx is NULL, assume no compressed to cartesian mapping, set global equal to active index
int global_index = (NULL != compressedToCartesianCellIdx) ? compressedToCartesianCellIdx[active_index] : active_index; int global_index = (NULL != compressedToCartesianCellIdx) ? compressedToCartesianCellIdx[active_index] : active_index;
globalToActiveIndex_[global_index] = active_index; globalToActiveIndex_[global_index] = active_index;

View File

@ -2,6 +2,7 @@
Copyright (c) 2013-2014 Andreas Lauser Copyright (c) 2013-2014 Andreas Lauser
Copyright (c) 2013 SINTEF ICT, Applied Mathematics. Copyright (c) 2013 SINTEF ICT, Applied Mathematics.
Copyright (c) 2013 Uni Research AS Copyright (c) 2013 Uni Research AS
Copyright (c) 2015 IRIS AS
This file is part of the Open Porous Media project (OPM). This file is part of the Open Porous Media project (OPM).
@ -1002,24 +1003,21 @@ int EclipseWriter::eclipseWellStatusMask(WellCommon::StatusEnum wellStatus)
/** /**
* Convert opm-core UnitType to eclipse format: ert_ecl_unit_enum * Convert opm-core UnitType to eclipse format: ert_ecl_unit_enum
*/ */
ert_ecl_unit_enum EclipseWriter::convertUnitTypeErtEclUnitEnum(UnitSystem::UnitType unit) ert_ecl_unit_enum
EclipseWriter::convertUnitTypeErtEclUnitEnum(UnitSystem::UnitType unit)
{ {
ert_ecl_unit_enum ecl_type;
switch (unit) { switch (unit) {
case(UnitSystem::UNIT_TYPE_METRIC): case UnitSystem::UNIT_TYPE_METRIC:
ecl_type = ERT_ECL_METRIC_UNITS; return ERT_ECL_METRIC_UNITS;
break;
case(UnitSystem::UNIT_TYPE_FIELD) :
ecl_type = ERT_ECL_FIELD_UNITS;
break;
case(UnitSystem::UNIT_TYPE_LAB):
ecl_type = ERT_ECL_LAB_UNITS;
break;
default:
break;
};
return ecl_type; case UnitSystem::UNIT_TYPE_FIELD:
return ERT_ECL_FIELD_UNITS;
case UnitSystem::UNIT_TYPE_LAB:
return ERT_ECL_LAB_UNITS;
}
throw std::invalid_argument("unhandled enum value");
} }
@ -1032,6 +1030,7 @@ void EclipseWriter::writeInit(const SimulatorTimerInterface &timer)
} }
writeStepIdx_ = 0; writeStepIdx_ = 0;
reportStepIdx_ = -1;
EclipseWriterDetails::Init fortio(outputDir_, baseName_, /*stepIdx=*/0); EclipseWriterDetails::Init fortio(outputDir_, baseName_, /*stepIdx=*/0);
fortio.writeHeader(numCells_, fortio.writeHeader(numCells_,
@ -1084,6 +1083,9 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
return; return;
} }
// only write solution when report step number has changed
if( reportStepIdx_ != timer.reportStepNum() )
{
const size_t ncwmax = eclipseState_->getSchedule()->getMaxNumCompletionsForWells(timer.reportStepNum()); const size_t ncwmax = eclipseState_->getSchedule()->getMaxNumCompletionsForWells(timer.reportStepNum());
const size_t numWells = eclipseState_->getSchedule()->numWells(timer.reportStepNum()); const size_t numWells = eclipseState_->getSchedule()->numWells(timer.reportStepNum());
std::vector<WellConstPtr> wells_ptr = eclipseState_->getSchedule()->getWells(timer.reportStepNum()); std::vector<WellConstPtr> wells_ptr = eclipseState_->getSchedule()->getWells(timer.reportStepNum());
@ -1092,7 +1094,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
std::vector<int> iwell_data( numWells * Opm::EclipseWriterDetails::Restart::NIWELZ , 0 ); std::vector<int> iwell_data( numWells * Opm::EclipseWriterDetails::Restart::NIWELZ , 0 );
std::vector<int> icon_data( numWells * ncwmax * Opm::EclipseWriterDetails::Restart::NICONZ , 0 ); std::vector<int> icon_data( numWells * ncwmax * Opm::EclipseWriterDetails::Restart::NICONZ , 0 );
EclipseWriterDetails::Restart restartHandle(outputDir_, baseName_, writeStepIdx_); EclipseWriterDetails::Restart restartHandle(outputDir_, baseName_, timer.reportStepNum());
for (size_t iwell = 0; iwell < wells_ptr.size(); ++iwell) { for (size_t iwell = 0; iwell < wells_ptr.size(); ++iwell) {
WellConstPtr well = wells_ptr[iwell]; WellConstPtr well = wells_ptr[iwell];
@ -1123,7 +1125,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
rsthead_data.sim_days = Opm::unit::convert::to(timer.simulationTimeElapsed(), Opm::unit::day); //data for doubhead rsthead_data.sim_days = Opm::unit::convert::to(timer.simulationTimeElapsed(), Opm::unit::day); //data for doubhead
restartHandle.writeHeader(timer, restartHandle.writeHeader(timer,
writeStepIdx_, timer.reportStepNum(),
&rsthead_data); &rsthead_data);
} }
@ -1200,7 +1202,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
saturation_water, saturation_water,
saturation_gas); saturation_gas);
} // end if( reportStepIdx_ != timer.reportStepNum() )
/* Summary variables (well reporting) */ /* Summary variables (well reporting) */
// TODO: instead of writing the header (smspec) every time, it should // TODO: instead of writing the header (smspec) every time, it should
@ -1217,6 +1219,8 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
summary_->writeTimeStep(writeStepIdx_, timer, wellState); summary_->writeTimeStep(writeStepIdx_, timer, wellState);
++writeStepIdx_; ++writeStepIdx_;
// store current report index
reportStepIdx_ = timer.reportStepNum();
} }
@ -1293,6 +1297,7 @@ void EclipseWriter::init(const parameter::ParameterGroup& params)
// set the index of the first time step written to 0... // set the index of the first time step written to 0...
writeStepIdx_ = 0; writeStepIdx_ = 0;
reportStepIdx_ = -1;
if (enableOutput_) { if (enableOutput_) {
// make sure that the output directory exists, if not try to create it // make sure that the output directory exists, if not try to create it

View File

@ -115,6 +115,7 @@ private:
bool enableOutput_; bool enableOutput_;
int outputInterval_; int outputInterval_;
int writeStepIdx_; int writeStepIdx_;
int reportStepIdx_;
std::string outputDir_; std::string outputDir_;
std::string baseName_; std::string baseName_;
PhaseUsage phaseUsage_; // active phases in the input deck PhaseUsage phaseUsage_; // active phases in the input deck