Save THPRES values to restart file

This commit is contained in:
Joakim Hove 2018-04-28 13:31:27 +02:00
parent 91139efa27
commit 324a4ad307
3 changed files with 44 additions and 38 deletions

View File

@ -846,6 +846,11 @@ public:
Scalar thresholdPressure(unsigned elem1Idx, unsigned elem2Idx) const Scalar thresholdPressure(unsigned elem1Idx, unsigned elem2Idx) const
{ return thresholdPressures_.thresholdPressure(elem1Idx, elem2Idx); } { return thresholdPressures_.thresholdPressure(elem1Idx, elem2Idx); }
const EclThresholdPressure<TypeTag>& thresholdPressure() const {
return thresholdPressures_;
}
/*! /*!
* \copydoc FvBaseMultiPhaseProblem::porosity * \copydoc FvBaseMultiPhaseProblem::porosity
*/ */

View File

@ -157,6 +157,11 @@ public:
return thpres_[equilRegion1Idx*numEquilRegions_ + equilRegion2Idx]; return thpres_[equilRegion1Idx*numEquilRegions_ + equilRegion2Idx];
} }
const std::vector<Scalar>& data() const {
return thpres_;
}
private: private:
// compute the defaults of the threshold pressures using the initial condition // compute the defaults of the threshold pressures using the initial condition
void computeDefaultThresholdPressures_() void computeDefaultThresholdPressures_()

View File

@ -37,8 +37,11 @@
#if HAVE_ECL_OUTPUT #if HAVE_ECL_OUTPUT
#include <opm/output/eclipse/EclipseIO.hpp> #include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#endif #endif
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/grid/GridHelpers.hpp> #include <opm/grid/GridHelpers.hpp>
#include <opm/material/common/Valgrind.hpp> #include <opm/material/common/Valgrind.hpp>
@ -146,9 +149,10 @@ public:
*/ */
void writeOutput(Opm::data::Wells& localWellData, Scalar curTime, bool isSubStep, Scalar totalSolverTime, Scalar nextStepSize) void writeOutput(Opm::data::Wells& localWellData, Scalar curTime, bool isSubStep, Scalar totalSolverTime, Scalar nextStepSize)
{ {
#if !HAVE_ECL_OUTPUT
throw std::runtime_error("Eclipse output support not available in opm-common, unable to write ECL output!"); #if !HAVE_ECL_INPUT
#else throw std::runtime_error("Unit support not available in opm-common.");
#endif
int episodeIdx = simulator_.episodeIndex() + 1; int episodeIdx = simulator_.episodeIndex() + 1;
const auto& gridView = simulator_.vanguard().gridView(); const auto& gridView = simulator_.vanguard().gridView();
@ -185,11 +189,8 @@ public:
// write output on I/O rank // write output on I/O rank
if (collectToIORank_.isIORank()) { if (collectToIORank_.isIORank()) {
std::map<std::string, std::vector<double>> extraRestartData; const auto& eclState = simulator_.vanguard().eclState();
const auto& simConfig = eclState.getSimulationConfig();
// Add suggested next timestep to extra data.
if (!isSubStep)
extraRestartData["OPMEXTRA"] = std::vector<double>(1, nextStepSize);
// Add TCPU // Add TCPU
if (totalSolverTime != 0.0) if (totalSolverTime != 0.0)
@ -198,23 +199,29 @@ public:
bool enableDoublePrecisionOutput = EWOMS_GET_PARAM(TypeTag, bool, EclOutputDoublePrecision); bool enableDoublePrecisionOutput = EWOMS_GET_PARAM(TypeTag, bool, EclOutputDoublePrecision);
const Opm::data::Solution& cellData = collectToIORank_.isParallel() ? collectToIORank_.globalCellData() : localCellData; const Opm::data::Solution& cellData = collectToIORank_.isParallel() ? collectToIORank_.globalCellData() : localCellData;
const Opm::data::Wells& wellData = collectToIORank_.isParallel() ? collectToIORank_.globalWellData() : localWellData; const Opm::data::Wells& wellData = collectToIORank_.isParallel() ? collectToIORank_.globalWellData() : localWellData;
Opm::RestartValue restartValue(cellData, wellData);
const std::map<std::pair<std::string, int>, double>& blockData const std::map<std::pair<std::string, int>, double>& blockData
= collectToIORank_.isParallel() = collectToIORank_.isParallel()
? collectToIORank_.globalBlockData() ? collectToIORank_.globalBlockData()
: eclOutputModule_.getBlockData(); : eclOutputModule_.getBlockData();
// Add suggested next timestep to extra data.
if (!isSubStep)
restartValue.addExtra("OPMEXTRA", std::vector<double>(1, nextStepSize));
if (simConfig.hasThresholdPressure())
restartValue.addExtra("THPRES", Opm::UnitSystem::measure::pressure, simulator_.problem().thresholdPressure().data());
// first, create a tasklet to write the data for the current time step to disk // first, create a tasklet to write the data for the current time step to disk
auto eclWriteTasklet = std::make_shared<EclWriteTasklet>(*eclIO_, auto eclWriteTasklet = std::make_shared<EclWriteTasklet>(*eclIO_,
episodeIdx, episodeIdx,
isSubStep, isSubStep,
curTime, curTime,
cellData, restartValue,
wellData,
miscSummaryData, miscSummaryData,
regionData, regionData,
blockData, blockData,
extraRestartData,
enableDoublePrecisionOutput); enableDoublePrecisionOutput);
// then, make sure that the previous I/O request has been completed and the // then, make sure that the previous I/O request has been completed and the
@ -224,27 +231,24 @@ public:
// finally, start a new output writing job // finally, start a new output writing job
taskletRunner_->dispatch(eclWriteTasklet); taskletRunner_->dispatch(eclWriteTasklet);
} }
#endif
} }
void restartBegin() void restartBegin()
{ {
bool enableHysteresis = simulator_.problem().materialLawManager()->enableHysteresis(); bool enableHysteresis = simulator_.problem().materialLawManager()->enableHysteresis();
std::map<std::string, Opm::RestartKey> solution_keys {{"PRESSURE" , Opm::RestartKey(Opm::UnitSystem::measure::pressure)}, std::vector<Opm::RestartKey> solution_keys {{"PRESSURE" , Opm::UnitSystem::measure::pressure},
{"SWAT" , Opm::RestartKey(Opm::UnitSystem::measure::identity, FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx))}, {"SWAT" , Opm::UnitSystem::measure::identity, static_cast<bool>(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx))},
{"SGAS" , Opm::RestartKey(Opm::UnitSystem::measure::identity, FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx))}, {"SGAS" , Opm::UnitSystem::measure::identity, static_cast<bool>(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx))},
{"TEMP" , Opm::RestartKey(Opm::UnitSystem::measure::temperature)}, // always required for now {"TEMP" , Opm::UnitSystem::measure::temperature}, // always required for now
{"RS" , Opm::RestartKey(Opm::UnitSystem::measure::gas_oil_ratio, FluidSystem::enableDissolvedGas())}, {"RS" , Opm::UnitSystem::measure::gas_oil_ratio, FluidSystem::enableDissolvedGas()},
{"RV" , Opm::RestartKey(Opm::UnitSystem::measure::oil_gas_ratio, FluidSystem::enableVaporizedOil())}, {"RV" , Opm::UnitSystem::measure::oil_gas_ratio, FluidSystem::enableVaporizedOil()},
{"SOMAX", {Opm::UnitSystem::measure::identity, simulator_.problem().vapparsActive()}}, {"SOMAX", Opm::UnitSystem::measure::identity, simulator_.problem().vapparsActive()},
{"PCSWM_OW", {Opm::UnitSystem::measure::identity, enableHysteresis}}, {"PCSWM_OW", Opm::UnitSystem::measure::identity, enableHysteresis},
{"KRNSW_OW", {Opm::UnitSystem::measure::identity, enableHysteresis}}, {"KRNSW_OW", Opm::UnitSystem::measure::identity, enableHysteresis},
{"PCSWM_GO", {Opm::UnitSystem::measure::identity, enableHysteresis}}, {"PCSWM_GO", Opm::UnitSystem::measure::identity, enableHysteresis},
{"KRNSW_GO", {Opm::UnitSystem::measure::identity, enableHysteresis}}}; {"KRNSW_GO", Opm::UnitSystem::measure::identity, enableHysteresis}};
std::map<std::string, bool> extra_keys { std::vector<Opm::RestartKey> extra_keys = {{"OPMEXTRA", Opm::UnitSystem::measure::identity, false}};
{"OPMEXTRA" , false}
};
unsigned episodeIdx = simulator_.episodeIndex(); unsigned episodeIdx = simulator_.episodeIndex();
const auto& gridView = simulator_.vanguard().gridView(); const auto& gridView = simulator_.vanguard().gridView();
@ -413,35 +417,29 @@ private:
int episodeIdx_; int episodeIdx_;
bool isSubStep_; bool isSubStep_;
double secondsElapsed_; double secondsElapsed_;
Opm::data::Solution cellData_; Opm::RestartValue restartValue_;
Opm::data::Wells wellData_;
std::map<std::string, double> singleSummaryValues_; std::map<std::string, double> singleSummaryValues_;
std::map<std::string, std::vector<double>> regionSummaryValues_; std::map<std::string, std::vector<double>> regionSummaryValues_;
std::map<std::pair<std::string, int>, double> blockSummaryValues_; std::map<std::pair<std::string, int>, double> blockSummaryValues_;
std::map<std::string, std::vector<double>> extraRestartData_;
bool writeDoublePrecision_; bool writeDoublePrecision_;
explicit EclWriteTasklet(Opm::EclipseIO& eclIO, explicit EclWriteTasklet(Opm::EclipseIO& eclIO,
int episodeIdx, int episodeIdx,
bool isSubStep, bool isSubStep,
double secondsElapsed, double secondsElapsed,
Opm::data::Solution cellData, Opm::RestartValue restartValue,
Opm::data::Wells wellData,
const std::map<std::string, double>& singleSummaryValues, const std::map<std::string, double>& singleSummaryValues,
const std::map<std::string, std::vector<double>>& regionSummaryValues, const std::map<std::string, std::vector<double>>& regionSummaryValues,
const std::map<std::pair<std::string, int>, double>& blockSummaryValues, const std::map<std::pair<std::string, int>, double>& blockSummaryValues,
const std::map<std::string, std::vector<double>>& extraRestartData,
bool writeDoublePrecision) bool writeDoublePrecision)
: eclIO_(eclIO) : eclIO_(eclIO)
, episodeIdx_(episodeIdx) , episodeIdx_(episodeIdx)
, isSubStep_(isSubStep) , isSubStep_(isSubStep)
, secondsElapsed_(secondsElapsed) , secondsElapsed_(secondsElapsed)
, cellData_(cellData) , restartValue_(restartValue)
, wellData_(wellData)
, singleSummaryValues_(singleSummaryValues) , singleSummaryValues_(singleSummaryValues)
, regionSummaryValues_(regionSummaryValues) , regionSummaryValues_(regionSummaryValues)
, blockSummaryValues_(blockSummaryValues) , blockSummaryValues_(blockSummaryValues)
, extraRestartData_(extraRestartData)
, writeDoublePrecision_(writeDoublePrecision) , writeDoublePrecision_(writeDoublePrecision)
{ } { }
@ -451,12 +449,10 @@ private:
eclIO_.writeTimeStep(episodeIdx_, eclIO_.writeTimeStep(episodeIdx_,
isSubStep_, isSubStep_,
secondsElapsed_, secondsElapsed_,
cellData_, restartValue_,
wellData_,
singleSummaryValues_, singleSummaryValues_,
regionSummaryValues_, regionSummaryValues_,
blockSummaryValues_, blockSummaryValues_,
extraRestartData_,
writeDoublePrecision_); writeDoublePrecision_);
} }
}; };