Merge pull request #5537 from vkip/drsdt_restart

Avoid updating max Rs first step after restart.
This commit is contained in:
Bård Skaflestad 2024-08-29 10:56:29 +02:00 committed by GitHub
commit d8c30f8758
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -574,6 +574,8 @@ public:
thpres.setFromRestart(thpresValues); thpres.setFromRestart(thpresValues);
} }
restartTimeStepSize_ = restartValues.getExtra("OPMEXTRA")[0]; restartTimeStepSize_ = restartValues.getExtra("OPMEXTRA")[0];
if (restartTimeStepSize_ <= 0)
restartTimeStepSize_ = std::numeric_limits<double>::max();
// initialize the well model from restart values // initialize the well model from restart values
simulator_.problem().wellModel().initFromRestartFile(restartValues); simulator_.problem().wellModel().initFromRestartFile(restartValues);

View File

@ -601,7 +601,9 @@ public:
// update maximum water saturation and minimum pressure // update maximum water saturation and minimum pressure
// used when ROCKCOMP is activated // used when ROCKCOMP is activated
asImp_().updateExplicitQuantities_(episodeIdx, timeStepSize); // Do not update max RS first step after a restart
asImp_().updateExplicitQuantities_(episodeIdx, timeStepSize, first_step_ && (episodeIdx > 0));
first_step_ = false;
if (nonTrivialBoundaryConditions()) { if (nonTrivialBoundaryConditions()) {
this->model().linearizer().updateBoundaryConditionData(); this->model().linearizer().updateBoundaryConditionData();
@ -1871,7 +1873,7 @@ private:
Implementation& asImp_() Implementation& asImp_()
{ return *static_cast<Implementation *>(this); } { return *static_cast<Implementation *>(this); }
protected: protected:
void updateExplicitQuantities_(int episodeIdx, int timeStepSize) void updateExplicitQuantities_(int episodeIdx, int timeStepSize, const bool first_step_after_restart = false)
{ {
OPM_TIMEBLOCK(updateExplicitQuantities); OPM_TIMEBLOCK(updateExplicitQuantities);
const bool invalidateFromMaxWaterSat = updateMaxWaterSaturation_(); const bool invalidateFromMaxWaterSat = updateMaxWaterSaturation_();
@ -1883,7 +1885,7 @@ protected:
// deal with DRSDT and DRVDT // deal with DRSDT and DRVDT
const bool invalidateDRDT = this->asImp_().updateCompositionChangeLimits_(); const bool invalidateDRDT = !first_step_after_restart && this->asImp_().updateCompositionChangeLimits_();
// the derivatives may have change // the derivatives may have change
bool invalidateIntensiveQuantities bool invalidateIntensiveQuantities
@ -2209,9 +2211,8 @@ protected:
const auto& schedule = simulator.vanguard().schedule(); const auto& schedule = simulator.vanguard().schedule();
const auto& eclState = simulator.vanguard().eclState(); const auto& eclState = simulator.vanguard().eclState();
const auto& initconfig = eclState.getInitConfig(); const auto& initconfig = eclState.getInitConfig();
const int restart_step = initconfig.getRestartStep();
{ {
int restart_step = initconfig.getRestartStep();
simulator.setTime(schedule.seconds(restart_step)); simulator.setTime(schedule.seconds(restart_step));
simulator.startNextEpisode(simulator.startTime() + simulator.time(), simulator.startNextEpisode(simulator.startTime() + simulator.time(),
@ -2245,6 +2246,9 @@ protected:
this->micp_.resize(numElems); this->micp_.resize(numElems);
} }
// Initialize mixing controls before trying to set any lastRx valuesx
this->mixControls_.init(numElems, restart_step, eclState.runspec().tabdims().getNumPVTTables());
for (std::size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) { for (std::size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) {
auto& elemFluidState = initialFluidStates_[elemIdx]; auto& elemFluidState = initialFluidStates_[elemIdx];
elemFluidState.setPvtRegionIndex(pvtRegionIndex(elemIdx)); elemFluidState.setPvtRegionIndex(pvtRegionIndex(elemIdx));
@ -2886,7 +2890,7 @@ private:
BCData<int> bcindex_; BCData<int> bcindex_;
bool nonTrivialBoundaryConditions_ = false; bool nonTrivialBoundaryConditions_ = false;
bool explicitRockCompaction_ = false; bool explicitRockCompaction_ = false;
bool first_step_ = true;
ModuleParams moduleParams_; ModuleParams moduleParams_;

View File

@ -195,6 +195,8 @@ public:
{ {
init(timer); init(timer);
// Make cache up to date. No need for updating it in elementCtx. // Make cache up to date. No need for updating it in elementCtx.
// NB! Need to be at the correct step in case of restart
simulator_.setEpisodeIndex(timer.currentStepNum());
simulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0); simulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
// Main simulation loop. // Main simulation loop.
while (!timer.done()) { while (!timer.done()) {