Update to match revised extra data interface from opm-output.

This commit is contained in:
Atgeirr Flø Rasmussen
2017-03-01 09:50:32 +01:00
parent 1175c389b0
commit 429baf082c
4 changed files with 37 additions and 23 deletions

View File

@@ -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();
}

View File

@@ -132,7 +132,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.

View File

@@ -203,6 +203,7 @@ namespace Opm
const SimulationDataContainer state_;
const WellStateFullyImplicitBlackoil wellState_;
data::Solution simProps_;
std::map<std::string, std::vector<double>> extraData_;
const bool substep_;
explicit WriterCall( BlackoilOutputWriter& writer,
@@ -210,12 +211,14 @@ namespace Opm
const SimulationDataContainer& state,
const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps,
const std::map<std::string, std::vector<double>>& extraData,
bool substep )
: writer_( writer ),
timer_( timer.clone() ),
state_( state ),
wellState_( wellState ),
simProps_( simProps ),
extraData_( extraData ),
substep_( substep )
{
}
@@ -224,7 +227,7 @@ namespace Opm
void run ()
{
// write data
writer_.writeTimeStepSerial( *timer_, state_, wellState_, simProps_, substep_ );
writer_.writeTimeStepSerial( *timer_, state_, wellState_, simProps_, extraData_, substep_ );
}
};
}
@@ -238,6 +241,7 @@ namespace Opm
const SimulatorTimerInterface& timer,
const SimulationDataContainer& localState,
const WellStateFullyImplicitBlackoil& localWellState,
const std::map<std::string, std::vector<double>>& extraData,
bool substep)
{
data::Solution localCellData{};
@@ -246,7 +250,7 @@ namespace Opm
localCellData = simToSolution(localState, restart_double_si_, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
}
writeTimeStepWithCellProperties(timer, localState, localCellData ,
localWellState, substep);
localWellState, extraData, substep);
}
@@ -260,6 +264,7 @@ namespace Opm
const SimulationDataContainer& localState,
const data::Solution& localCellData,
const WellStateFullyImplicitBlackoil& localWellState,
const std::map<std::string, std::vector<double>>& extraData,
bool substep)
{
// VTK output (is parallel if grid is parallel)
@@ -281,6 +286,7 @@ namespace Opm
isIORank = parallelOutput_->collectToIORank( localState, localWellState,
localCellData,
wellStateStepNumber );
// Note that at this point the extraData are assumed to be global, i.e. identical across all processes.
}
const data::Solution& cellData = ( parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalCellData() : localCellData;
@@ -294,12 +300,12 @@ namespace Opm
{
if( asyncOutput_ ) {
// dispatch the write call to the extra thread
asyncOutput_->dispatch( detail::WriterCall( *this, timer, state, wellState, cellData, substep ) );
asyncOutput_->dispatch( detail::WriterCall( *this, timer, state, wellState, cellData, extraData, substep ) );
}
else {
// just write the data to disk
try {
writeTimeStepSerial( timer, state, wellState, cellData, substep );
writeTimeStepSerial( timer, state, wellState, cellData, extraData, substep );
} catch (std::runtime_error& msg) {
err = 1;
emsg = msg.what();
@@ -329,6 +335,7 @@ namespace Opm
const SimulationDataContainer& state,
const WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps,
const std::map<std::string, std::vector<double>>& extraData,
bool substep)
{
// Matlab output
@@ -349,6 +356,7 @@ namespace Opm
timer.simulationTimeElapsed(),
simProps,
wellState.report(phaseUsage_),
extraData,
restart_double_si_);
}
}
@@ -417,7 +425,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 "

View File

@@ -50,6 +50,8 @@
#include <iomanip>
#include <fstream>
#include <thread>
#include <map>
#include <set>
#include <boost/filesystem.hpp>
@@ -201,7 +203,7 @@ namespace Opm
/// Extra data to read/write for OPM restarting
struct ExtraData
{
double suggested_step;
double suggested_step = -1.0;
};
@@ -239,13 +241,14 @@ 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.
* CellData in simProps to the file as well as the extraData.
*/
void writeTimeStepWithCellProperties(
const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState,
const data::Solution& cellData,
const Opm::WellStateFullyImplicitBlackoil& wellState,
const std::map<std::string, std::vector<double>>& extraData,
bool substep = false);
/*!
@@ -257,6 +260,7 @@ namespace Opm
const SimulatorTimerInterface& timer,
const SimulationDataContainer& reservoirState,
const Opm::WellStateFullyImplicitBlackoil& wellState,
const std::map<std::string, std::vector<double>>& extraData,
bool substep = false);
/*!
@@ -268,6 +272,7 @@ namespace Opm
const SimulationDataContainer& reservoirState,
const Opm::WellStateFullyImplicitBlackoil& wellState,
const data::Solution& simProps,
const std::map<std::string, std::vector<double>>& extraData,
bool substep);
/** \brief return output directory */
@@ -421,8 +426,8 @@ namespace Opm
{"SGAS" , UnitSystem::measure::identity},
{"TEMP" , UnitSystem::measure::temperature},
{"RS" , UnitSystem::measure::gas_oil_ratio},
{"RV" , UnitSystem::measure::oil_gas_ratio},
{"OPMEXTRA" , UnitSystem::measure::identity}};
{"RV" , UnitSystem::measure::oil_gas_ratio}};
std::set<std::string> extra_keys {"OPMEXTRA"};
if (restart_double_si_) {
// Avoid any unit conversions, treat restart input as SI units.
@@ -452,15 +457,18 @@ namespace Opm
const Wells* wells = wellsmanager.c_wells();
wellstate.resize(wells, simulatorstate, phaseUsage ); //Resize for restart step
auto state = eclIO_->loadRestart(solution_keys);
auto restart_values = eclIO_->loadRestart(solution_keys, extra_keys);
solutionToSim( state.first, phaseUsage, simulatorstate );
wellsToState( state.second, phaseUsage, wellstate );
solutionToSim( restart_values.solution, phaseUsage, simulatorstate );
wellsToState( restart_values.wells, phaseUsage, wellstate );
if (state.first.has( "OPMEXTRA" ) ) {
std::vector<double> opmextra = state.first.data( "OPMEXTRA" );
const auto opmextra_iter = restart_values.extra.find("OPMEXTRA");
if (opmextra_iter != restart_values.extra.end()) {
std::vector<double> opmextra = opmextra_iter->second;
assert(opmextra.size() == 1);
extra.suggested_step = opmextra[0];
} else {
OPM_THROW(std::runtime_error, "Cannot restart, restart data is missing OPMEXTRA field.");
}
}
@@ -934,6 +942,7 @@ namespace Opm
const SummaryConfig& summaryConfig = eclipseState_.getSummaryConfig();
const int reportStepNum = timer.reportStepNum();
bool logMessages = output_ && parallelOutput_->isIORank();
std::map<std::string, std::vector<double>> extraData;
if( output_ )
{
@@ -952,16 +961,13 @@ namespace Opm
// sd will be invalid after getRestartData has been called
}
detail::getSummaryData( localCellData, phaseUsage_, physicalModel, summaryConfig );
// Hack: add suggested next timestep.
assert(!localCellData.empty());
localCellData.insert("OPMEXTRA",
UnitSystem::measure::identity,
std::vector<double>(1, nextstep),
data::TargetType::RESTART_SOLUTION);
// Add suggested next timestep to extra data.
extraData["OPMEXTRA"] = std::vector<double>(1, nextstep);
}
writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, substep);
writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, extraData, substep);
}
}
#endif