mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Update to match revised extra data interface from opm-output.
This commit is contained in:
@@ -191,7 +191,7 @@ namespace Opm
|
|||||||
|
|
||||||
// No per cell data is written for initial step, but will be
|
// No per cell data is written for initial step, but will be
|
||||||
// for subsequent steps, when we have started simulating
|
// 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();
|
report.output_write_time += perfTimer.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace Opm
|
|||||||
if (timer.initialStep()) {
|
if (timer.initialStep()) {
|
||||||
// No per cell data is written for initial step, but will be
|
// No per cell data is written for initial step, but will be
|
||||||
// for subsequent steps, when we have started simulating
|
// 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.
|
// Max oil saturation (for VPPARS), hysteresis update.
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ namespace Opm
|
|||||||
const SimulationDataContainer state_;
|
const SimulationDataContainer state_;
|
||||||
const WellStateFullyImplicitBlackoil wellState_;
|
const WellStateFullyImplicitBlackoil wellState_;
|
||||||
data::Solution simProps_;
|
data::Solution simProps_;
|
||||||
|
std::map<std::string, std::vector<double>> extraData_;
|
||||||
const bool substep_;
|
const bool substep_;
|
||||||
|
|
||||||
explicit WriterCall( BlackoilOutputWriter& writer,
|
explicit WriterCall( BlackoilOutputWriter& writer,
|
||||||
@@ -210,12 +211,14 @@ namespace Opm
|
|||||||
const SimulationDataContainer& state,
|
const SimulationDataContainer& state,
|
||||||
const WellStateFullyImplicitBlackoil& wellState,
|
const WellStateFullyImplicitBlackoil& wellState,
|
||||||
const data::Solution& simProps,
|
const data::Solution& simProps,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep )
|
bool substep )
|
||||||
: writer_( writer ),
|
: writer_( writer ),
|
||||||
timer_( timer.clone() ),
|
timer_( timer.clone() ),
|
||||||
state_( state ),
|
state_( state ),
|
||||||
wellState_( wellState ),
|
wellState_( wellState ),
|
||||||
simProps_( simProps ),
|
simProps_( simProps ),
|
||||||
|
extraData_( extraData ),
|
||||||
substep_( substep )
|
substep_( substep )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -224,7 +227,7 @@ namespace Opm
|
|||||||
void run ()
|
void run ()
|
||||||
{
|
{
|
||||||
// write data
|
// 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 SimulatorTimerInterface& timer,
|
||||||
const SimulationDataContainer& localState,
|
const SimulationDataContainer& localState,
|
||||||
const WellStateFullyImplicitBlackoil& localWellState,
|
const WellStateFullyImplicitBlackoil& localWellState,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep)
|
bool substep)
|
||||||
{
|
{
|
||||||
data::Solution localCellData{};
|
data::Solution localCellData{};
|
||||||
@@ -246,7 +250,7 @@ namespace Opm
|
|||||||
localCellData = simToSolution(localState, restart_double_si_, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
|
localCellData = simToSolution(localState, restart_double_si_, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
|
||||||
}
|
}
|
||||||
writeTimeStepWithCellProperties(timer, localState, localCellData ,
|
writeTimeStepWithCellProperties(timer, localState, localCellData ,
|
||||||
localWellState, substep);
|
localWellState, extraData, substep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -260,6 +264,7 @@ namespace Opm
|
|||||||
const SimulationDataContainer& localState,
|
const SimulationDataContainer& localState,
|
||||||
const data::Solution& localCellData,
|
const data::Solution& localCellData,
|
||||||
const WellStateFullyImplicitBlackoil& localWellState,
|
const WellStateFullyImplicitBlackoil& localWellState,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep)
|
bool substep)
|
||||||
{
|
{
|
||||||
// VTK output (is parallel if grid is parallel)
|
// VTK output (is parallel if grid is parallel)
|
||||||
@@ -281,6 +286,7 @@ namespace Opm
|
|||||||
isIORank = parallelOutput_->collectToIORank( localState, localWellState,
|
isIORank = parallelOutput_->collectToIORank( localState, localWellState,
|
||||||
localCellData,
|
localCellData,
|
||||||
wellStateStepNumber );
|
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;
|
const data::Solution& cellData = ( parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalCellData() : localCellData;
|
||||||
@@ -294,12 +300,12 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
if( asyncOutput_ ) {
|
if( asyncOutput_ ) {
|
||||||
// dispatch the write call to the extra thread
|
// 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 {
|
else {
|
||||||
// just write the data to disk
|
// just write the data to disk
|
||||||
try {
|
try {
|
||||||
writeTimeStepSerial( timer, state, wellState, cellData, substep );
|
writeTimeStepSerial( timer, state, wellState, cellData, extraData, substep );
|
||||||
} catch (std::runtime_error& msg) {
|
} catch (std::runtime_error& msg) {
|
||||||
err = 1;
|
err = 1;
|
||||||
emsg = msg.what();
|
emsg = msg.what();
|
||||||
@@ -329,6 +335,7 @@ namespace Opm
|
|||||||
const SimulationDataContainer& state,
|
const SimulationDataContainer& state,
|
||||||
const WellStateFullyImplicitBlackoil& wellState,
|
const WellStateFullyImplicitBlackoil& wellState,
|
||||||
const data::Solution& simProps,
|
const data::Solution& simProps,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep)
|
bool substep)
|
||||||
{
|
{
|
||||||
// Matlab output
|
// Matlab output
|
||||||
@@ -349,6 +356,7 @@ namespace Opm
|
|||||||
timer.simulationTimeElapsed(),
|
timer.simulationTimeElapsed(),
|
||||||
simProps,
|
simProps,
|
||||||
wellState.report(phaseUsage_),
|
wellState.report(phaseUsage_),
|
||||||
|
extraData,
|
||||||
restart_double_si_);
|
restart_double_si_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,7 +425,7 @@ namespace Opm
|
|||||||
|
|
||||||
// No per cell data is written for restore steps, but will be
|
// No per cell data is written for restore steps, but will be
|
||||||
// for subsequent steps, when we have started simulating
|
// for subsequent steps, when we have started simulating
|
||||||
writeTimeStepWithoutCellProperties( timer, state, wellState );
|
writeTimeStepWithoutCellProperties( timer, state, wellState, {} );
|
||||||
|
|
||||||
// some output
|
// some output
|
||||||
std::cout << "Restored step " << timer.reportStepNum() << " at day "
|
std::cout << "Restored step " << timer.reportStepNum() << " at day "
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
@@ -201,7 +203,7 @@ namespace Opm
|
|||||||
/// Extra data to read/write for OPM restarting
|
/// Extra data to read/write for OPM restarting
|
||||||
struct ExtraData
|
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
|
* \brief Write a blackoil reservoir state to disk for later inspection with
|
||||||
* visualization tools like ResInsight. This function will write all
|
* 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(
|
void writeTimeStepWithCellProperties(
|
||||||
const SimulatorTimerInterface& timer,
|
const SimulatorTimerInterface& timer,
|
||||||
const SimulationDataContainer& reservoirState,
|
const SimulationDataContainer& reservoirState,
|
||||||
const data::Solution& cellData,
|
const data::Solution& cellData,
|
||||||
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep = false);
|
bool substep = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -257,6 +260,7 @@ namespace Opm
|
|||||||
const SimulatorTimerInterface& timer,
|
const SimulatorTimerInterface& timer,
|
||||||
const SimulationDataContainer& reservoirState,
|
const SimulationDataContainer& reservoirState,
|
||||||
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep = false);
|
bool substep = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -268,6 +272,7 @@ namespace Opm
|
|||||||
const SimulationDataContainer& reservoirState,
|
const SimulationDataContainer& reservoirState,
|
||||||
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
const Opm::WellStateFullyImplicitBlackoil& wellState,
|
||||||
const data::Solution& simProps,
|
const data::Solution& simProps,
|
||||||
|
const std::map<std::string, std::vector<double>>& extraData,
|
||||||
bool substep);
|
bool substep);
|
||||||
|
|
||||||
/** \brief return output directory */
|
/** \brief return output directory */
|
||||||
@@ -421,8 +426,8 @@ namespace Opm
|
|||||||
{"SGAS" , UnitSystem::measure::identity},
|
{"SGAS" , UnitSystem::measure::identity},
|
||||||
{"TEMP" , UnitSystem::measure::temperature},
|
{"TEMP" , UnitSystem::measure::temperature},
|
||||||
{"RS" , UnitSystem::measure::gas_oil_ratio},
|
{"RS" , UnitSystem::measure::gas_oil_ratio},
|
||||||
{"RV" , UnitSystem::measure::oil_gas_ratio},
|
{"RV" , UnitSystem::measure::oil_gas_ratio}};
|
||||||
{"OPMEXTRA" , UnitSystem::measure::identity}};
|
std::set<std::string> extra_keys {"OPMEXTRA"};
|
||||||
|
|
||||||
if (restart_double_si_) {
|
if (restart_double_si_) {
|
||||||
// Avoid any unit conversions, treat restart input as SI units.
|
// Avoid any unit conversions, treat restart input as SI units.
|
||||||
@@ -452,15 +457,18 @@ namespace Opm
|
|||||||
|
|
||||||
const Wells* wells = wellsmanager.c_wells();
|
const Wells* wells = wellsmanager.c_wells();
|
||||||
wellstate.resize(wells, simulatorstate, phaseUsage ); //Resize for restart step
|
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 );
|
solutionToSim( restart_values.solution, phaseUsage, simulatorstate );
|
||||||
wellsToState( state.second, phaseUsage, wellstate );
|
wellsToState( restart_values.wells, phaseUsage, wellstate );
|
||||||
|
|
||||||
if (state.first.has( "OPMEXTRA" ) ) {
|
const auto opmextra_iter = restart_values.extra.find("OPMEXTRA");
|
||||||
std::vector<double> opmextra = state.first.data( "OPMEXTRA" );
|
if (opmextra_iter != restart_values.extra.end()) {
|
||||||
|
std::vector<double> opmextra = opmextra_iter->second;
|
||||||
assert(opmextra.size() == 1);
|
assert(opmextra.size() == 1);
|
||||||
extra.suggested_step = opmextra[0];
|
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 SummaryConfig& summaryConfig = eclipseState_.getSummaryConfig();
|
||||||
const int reportStepNum = timer.reportStepNum();
|
const int reportStepNum = timer.reportStepNum();
|
||||||
bool logMessages = output_ && parallelOutput_->isIORank();
|
bool logMessages = output_ && parallelOutput_->isIORank();
|
||||||
|
std::map<std::string, std::vector<double>> extraData;
|
||||||
|
|
||||||
if( output_ )
|
if( output_ )
|
||||||
{
|
{
|
||||||
@@ -952,16 +961,13 @@ namespace Opm
|
|||||||
// sd will be invalid after getRestartData has been called
|
// sd will be invalid after getRestartData has been called
|
||||||
}
|
}
|
||||||
detail::getSummaryData( localCellData, phaseUsage_, physicalModel, summaryConfig );
|
detail::getSummaryData( localCellData, phaseUsage_, physicalModel, summaryConfig );
|
||||||
|
|
||||||
// Hack: add suggested next timestep.
|
|
||||||
assert(!localCellData.empty());
|
assert(!localCellData.empty());
|
||||||
localCellData.insert("OPMEXTRA",
|
|
||||||
UnitSystem::measure::identity,
|
// Add suggested next timestep to extra data.
|
||||||
std::vector<double>(1, nextstep),
|
extraData["OPMEXTRA"] = std::vector<double>(1, nextstep);
|
||||||
data::TargetType::RESTART_SOLUTION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, substep);
|
writeTimeStepWithCellProperties(timer, localState, localCellData, localWellState, extraData, substep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user