mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add SI/double preserving feature to restart I/O.
The parameter "restart_double_si" (defaults to false) will when true cause the RESTART_SOLUTION data (only) to be read/written with measure equal to measure::identity, thereby suppressing unit conversions. Also, the output layer will be told to output all (not just RESTART_SOLUTION but also RESTART_AUXILIARY) restart data as doubles.
This commit is contained in:
@@ -75,10 +75,18 @@ std::vector< double >& stripe( const std::vector< double >& v,
|
||||
|
||||
|
||||
data::Solution simToSolution( const SimulationDataContainer& reservoir,
|
||||
const bool use_si_units,
|
||||
PhaseUsage phases ) {
|
||||
|
||||
// Set up unit system to use to suppress conversion if use_si_units is true.
|
||||
const UnitSystem::measure press_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::pressure;
|
||||
const UnitSystem::measure temp_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::temperature;
|
||||
const UnitSystem::measure rs_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::gas_oil_ratio;
|
||||
const UnitSystem::measure rv_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::oil_gas_ratio;
|
||||
|
||||
data::Solution sol;
|
||||
sol.insert( "PRESSURE", UnitSystem::measure::pressure, reservoir.pressure() , data::TargetType::RESTART_SOLUTION);
|
||||
sol.insert( "TEMP" , UnitSystem::measure::temperature, reservoir.temperature() , data::TargetType::RESTART_SOLUTION );
|
||||
sol.insert( "PRESSURE", press_unit, reservoir.pressure() , data::TargetType::RESTART_SOLUTION);
|
||||
sol.insert( "TEMP" , temp_unit, reservoir.temperature() , data::TargetType::RESTART_SOLUTION );
|
||||
|
||||
const auto ph = reservoir.numPhases();
|
||||
const auto& sat = reservoir.saturation();
|
||||
@@ -95,11 +103,11 @@ data::Solution simToSolution( const SimulationDataContainer& reservoir,
|
||||
}
|
||||
|
||||
if( reservoir.hasCellData( BlackoilState::GASOILRATIO ) ) {
|
||||
sol.insert( "RS", UnitSystem::measure::gas_oil_ratio, reservoir.getCellData( BlackoilState::GASOILRATIO ) , data::TargetType::RESTART_SOLUTION );
|
||||
sol.insert( "RS", rs_unit, reservoir.getCellData( BlackoilState::GASOILRATIO ) , data::TargetType::RESTART_SOLUTION );
|
||||
}
|
||||
|
||||
if( reservoir.hasCellData( BlackoilState::RV ) ) {
|
||||
sol.insert( "RV", UnitSystem::measure::oil_gas_ratio, reservoir.getCellData( BlackoilState::RV ) , data::TargetType::RESTART_SOLUTION );
|
||||
sol.insert( "RV", rv_unit, reservoir.getCellData( BlackoilState::RV ) , data::TargetType::RESTART_SOLUTION );
|
||||
}
|
||||
|
||||
if (reservoir.hasCellData( BlackoilSolventState::SSOL)) {
|
||||
|
||||
@@ -51,7 +51,10 @@ namespace Opm {
|
||||
/// Returns Solution with the following fields:
|
||||
/// PRESSURE, TEMP (unconditionally)
|
||||
/// SWAT, SGAS, RS, RV, SSOL (if appropriate fields present in input)
|
||||
/// If use_si_units is true, the fields will have the measure UnitSystem::measure::identity,
|
||||
/// and therefore *not* be converted to customary units (depending on family) upon output.
|
||||
data::Solution simToSolution( const SimulationDataContainer& reservoir,
|
||||
const bool use_si_units,
|
||||
PhaseUsage phases );
|
||||
|
||||
/// Copies the following fields from sol into state (all conditionally):
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Opm
|
||||
data::Solution localCellData{};
|
||||
if( output_ )
|
||||
{
|
||||
localCellData = simToSolution(localState, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
|
||||
localCellData = simToSolution(localState, restart_double_si_, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
|
||||
}
|
||||
writeTimeStepWithCellProperties(timer, localState, localCellData ,
|
||||
localWellState, substep);
|
||||
@@ -348,7 +348,8 @@ namespace Opm
|
||||
substep,
|
||||
timer.simulationTimeElapsed(),
|
||||
simProps,
|
||||
wellState.report(phaseUsage_));
|
||||
wellState.report(phaseUsage_),
|
||||
restart_double_si_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,6 +307,7 @@ namespace Opm
|
||||
// Parameters for output.
|
||||
const std::string outputDir_;
|
||||
const int output_interval_;
|
||||
const bool restart_double_si_;
|
||||
|
||||
int lastBackupReportStep_;
|
||||
|
||||
@@ -338,6 +339,7 @@ namespace Opm
|
||||
parallelOutput_( output_ ? new ParallelDebugOutput< Grid >( grid, eclipseState, phaseUsage.num_phases, phaseUsage ) : 0 ),
|
||||
outputDir_( output_ ? param.getDefault("output_dir", std::string("output")) : "." ),
|
||||
output_interval_( output_ ? param.getDefault("output_interval", 1): 0 ),
|
||||
restart_double_si_( output_ ? param.getDefault("restart_double_si", false) : false ),
|
||||
lastBackupReportStep_( -1 ),
|
||||
phaseUsage_( phaseUsage ),
|
||||
eclipseState_(eclipseState),
|
||||
@@ -415,13 +417,20 @@ namespace Opm
|
||||
ExtraData& extra )
|
||||
{
|
||||
std::map<std::string, UnitSystem::measure> solution_keys {{"PRESSURE" , UnitSystem::measure::pressure},
|
||||
{"SWAT" , UnitSystem::measure::identity},
|
||||
{"SGAS" , UnitSystem::measure::identity},
|
||||
{"TEMP" , UnitSystem::measure::temperature},
|
||||
{"RS" , UnitSystem::measure::gas_oil_ratio},
|
||||
{"RV" , UnitSystem::measure::oil_gas_ratio},
|
||||
{"SWAT" , UnitSystem::measure::identity},
|
||||
{"SGAS" , UnitSystem::measure::identity},
|
||||
{"TEMP" , UnitSystem::measure::temperature},
|
||||
{"RS" , UnitSystem::measure::gas_oil_ratio},
|
||||
{"RV" , UnitSystem::measure::oil_gas_ratio},
|
||||
{"OPMEXTRA" , UnitSystem::measure::identity}};
|
||||
|
||||
if (restart_double_si_) {
|
||||
// Avoid any unit conversions, treat restart input as SI units.
|
||||
for (auto& elem : solution_keys) {
|
||||
elem.second = UnitSystem::measure::identity;
|
||||
}
|
||||
}
|
||||
|
||||
// gives a dummy dynamic_list_econ_limited
|
||||
DynamicListEconLimited dummy_list_econ_limited;
|
||||
WellsManager wellsmanager(eclipseState_,
|
||||
@@ -936,7 +945,7 @@ namespace Opm
|
||||
SimulationDataContainer sd =
|
||||
detail::convertToSimulationDataContainer( physicalModel.getSimulatorData(), localState, phaseUsage_ );
|
||||
|
||||
localCellData = simToSolution( sd, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
|
||||
localCellData = simToSolution( sd, restart_double_si_, phaseUsage_); // Get "normal" data (SWAT, PRESSURE, ...);
|
||||
|
||||
detail::getRestartData( localCellData, std::move(sd), phaseUsage_, physicalModel,
|
||||
restartConfig, reportStepNum, logMessages );
|
||||
|
||||
Reference in New Issue
Block a user