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);
}
restartTimeStepSize_ = restartValues.getExtra("OPMEXTRA")[0];
if (restartTimeStepSize_ <= 0)
restartTimeStepSize_ = std::numeric_limits<double>::max();
// initialize the well model from restart values
simulator_.problem().wellModel().initFromRestartFile(restartValues);

View File

@ -601,7 +601,9 @@ public:
// update maximum water saturation and minimum pressure
// 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()) {
this->model().linearizer().updateBoundaryConditionData();
@ -1871,7 +1873,7 @@ private:
Implementation& asImp_()
{ return *static_cast<Implementation *>(this); }
protected:
void updateExplicitQuantities_(int episodeIdx, int timeStepSize)
void updateExplicitQuantities_(int episodeIdx, int timeStepSize, const bool first_step_after_restart = false)
{
OPM_TIMEBLOCK(updateExplicitQuantities);
const bool invalidateFromMaxWaterSat = updateMaxWaterSaturation_();
@ -1883,7 +1885,7 @@ protected:
// 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
bool invalidateIntensiveQuantities
@ -2209,9 +2211,8 @@ protected:
const auto& schedule = simulator.vanguard().schedule();
const auto& eclState = simulator.vanguard().eclState();
const auto& initconfig = eclState.getInitConfig();
const int restart_step = initconfig.getRestartStep();
{
int restart_step = initconfig.getRestartStep();
simulator.setTime(schedule.seconds(restart_step));
simulator.startNextEpisode(simulator.startTime() + simulator.time(),
@ -2245,6 +2246,9 @@ protected:
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) {
auto& elemFluidState = initialFluidStates_[elemIdx];
elemFluidState.setPvtRegionIndex(pvtRegionIndex(elemIdx));
@ -2886,7 +2890,7 @@ private:
BCData<int> bcindex_;
bool nonTrivialBoundaryConditions_ = false;
bool explicitRockCompaction_ = false;
bool first_step_ = true;
ModuleParams moduleParams_;

View File

@ -195,6 +195,8 @@ public:
{
init(timer);
// 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);
// Main simulation loop.
while (!timer.done()) {