mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #335 from totto82/fix_thpress_init
WIP Fix thpress restart
This commit is contained in:
commit
be881c6b00
@ -446,9 +446,6 @@ public:
|
|||||||
// create the ECL writer
|
// create the ECL writer
|
||||||
eclWriter_.reset(new EclWriterType(simulator));
|
eclWriter_.reset(new EclWriterType(simulator));
|
||||||
|
|
||||||
// Loading the solution from a restart file is done recursively, we need this
|
|
||||||
// bool variable to signal the stop condition.
|
|
||||||
restartApplied = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -519,10 +516,21 @@ public:
|
|||||||
readMaterialParameters_();
|
readMaterialParameters_();
|
||||||
readThermalParameters_();
|
readThermalParameters_();
|
||||||
transmissibilities_.finishInit();
|
transmissibilities_.finishInit();
|
||||||
readInitialCondition_();
|
|
||||||
|
|
||||||
// Set the start time of the simulation
|
const auto& eclState = simulator.vanguard().eclState();
|
||||||
|
const auto& initconfig = eclState.getInitConfig();
|
||||||
const auto& timeMap = simulator.vanguard().schedule().getTimeMap();
|
const auto& timeMap = simulator.vanguard().schedule().getTimeMap();
|
||||||
|
if(initconfig.restartRequested()) {
|
||||||
|
// Set the start time of the simulation
|
||||||
|
simulator.setStartTime( timeMap.getStartTime(/*timeStepIdx=*/initconfig.getRestartStep()) );
|
||||||
|
simulator.setEpisodeIndex(initconfig.getRestartStep());
|
||||||
|
simulator.setEpisodeLength(0.0);
|
||||||
|
simulator.setTimeStepSize(0.0);
|
||||||
|
|
||||||
|
readEclRestartSolution_();
|
||||||
|
} else {
|
||||||
|
readInitialCondition_();
|
||||||
|
// Set the start time of the simulation
|
||||||
simulator.setStartTime( timeMap.getStartTime(/*timeStepIdx=*/0) );
|
simulator.setStartTime( timeMap.getStartTime(/*timeStepIdx=*/0) );
|
||||||
|
|
||||||
// We want the episode index to be the same as the report step index to make
|
// We want the episode index to be the same as the report step index to make
|
||||||
@ -532,6 +540,7 @@ public:
|
|||||||
simulator.setEpisodeIndex(-1);
|
simulator.setEpisodeIndex(-1);
|
||||||
simulator.setEpisodeLength(0.0);
|
simulator.setEpisodeLength(0.0);
|
||||||
simulator.setTimeStepSize(0.0);
|
simulator.setTimeStepSize(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
updatePffDofData_();
|
updatePffDofData_();
|
||||||
|
|
||||||
@ -1228,23 +1237,11 @@ public:
|
|||||||
wellManager_.init(this->simulator().vanguard().eclState(), this->simulator().vanguard().schedule());
|
wellManager_.init(this->simulator().vanguard().eclState(), this->simulator().vanguard().schedule());
|
||||||
}
|
}
|
||||||
|
|
||||||
// The initialSolutionApplied is called recursively by readEclRestartSolution_().
|
|
||||||
if (restartApplied)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// let the object for threshold pressures initialize itself. this is done only at
|
// let the object for threshold pressures initialize itself. this is done only at
|
||||||
// this point, because determining the threshold pressures may require to access
|
// this point, because determining the threshold pressures may require to access
|
||||||
// the initial solution.
|
// the initial solution.
|
||||||
thresholdPressures_.finishInit();
|
thresholdPressures_.finishInit();
|
||||||
|
|
||||||
const auto& eclState = this->simulator().vanguard().eclState();
|
|
||||||
const auto& initconfig = eclState.getInitConfig();
|
|
||||||
if(initconfig.restartRequested()) {
|
|
||||||
restartApplied = true;
|
|
||||||
this->simulator().setEpisodeIndex(initconfig.getRestartStep());
|
|
||||||
readEclRestartSolution_();
|
|
||||||
}
|
|
||||||
|
|
||||||
// release the memory of the EQUIL grid since it's no longer needed after this point
|
// release the memory of the EQUIL grid since it's no longer needed after this point
|
||||||
this->simulator().vanguard().releaseEquilGrid();
|
this->simulator().vanguard().releaseEquilGrid();
|
||||||
|
|
||||||
@ -1707,6 +1704,7 @@ private:
|
|||||||
|
|
||||||
for (size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) {
|
for (size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) {
|
||||||
auto& elemFluidState = initialFluidStates_[elemIdx];
|
auto& elemFluidState = initialFluidStates_[elemIdx];
|
||||||
|
elemFluidState.setPvtRegionIndex(pvtRegionIndex(elemIdx));
|
||||||
eclWriter_->eclOutputModule().initHysteresisParams(this->simulator(), elemIdx);
|
eclWriter_->eclOutputModule().initHysteresisParams(this->simulator(), elemIdx);
|
||||||
eclWriter_->eclOutputModule().assignToFluidState(elemFluidState, elemIdx);
|
eclWriter_->eclOutputModule().assignToFluidState(elemFluidState, elemIdx);
|
||||||
if (enableSolvent)
|
if (enableSolvent)
|
||||||
@ -1714,7 +1712,6 @@ private:
|
|||||||
if (enablePolymer)
|
if (enablePolymer)
|
||||||
polymerConcentration_[elemIdx] = eclWriter_->eclOutputModule().getPolymerConcentration(elemIdx);
|
polymerConcentration_[elemIdx] = eclWriter_->eclOutputModule().getPolymerConcentration(elemIdx);
|
||||||
}
|
}
|
||||||
this->model().applyInitialSolution();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void readExplicitInitialCondition_()
|
void readExplicitInitialCondition_()
|
||||||
@ -2072,8 +2069,6 @@ private:
|
|||||||
|
|
||||||
PffGridVector<GridView, Stencil, PffDofData_, DofMapper> pffDofData_;
|
PffGridVector<GridView, Stencil, PffDofData_, DofMapper> pffDofData_;
|
||||||
|
|
||||||
bool restartApplied;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace Ewoms
|
} // namespace Ewoms
|
||||||
|
|
||||||
|
@ -116,15 +116,6 @@ public:
|
|||||||
if (!enableThresholdPressure_)
|
if (!enableThresholdPressure_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
|
||||||
If this is a restart run the ThresholdPressure object will be active,
|
|
||||||
but it will *not* be properly initialized with numerical values. The
|
|
||||||
values must instead come from the THPRES vector in the restart file.
|
|
||||||
*/
|
|
||||||
if (simConfig.getThresholdPressure().restart())
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
numEquilRegions_ = eclState.getTableManager().getEqldims().getNumEquilRegions();
|
numEquilRegions_ = eclState.getTableManager().getEqldims().getNumEquilRegions();
|
||||||
if (numEquilRegions_ > 0xff) {
|
if (numEquilRegions_ > 0xff) {
|
||||||
// make sure that the index of an equilibration region can be stored in a
|
// make sure that the index of an equilibration region can be stored in a
|
||||||
@ -132,10 +123,6 @@ public:
|
|||||||
throw std::runtime_error("The maximum number of supported equilibration regions is 255!");
|
throw std::runtime_error("The maximum number of supported equilibration regions is 255!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate the array which specifies the threshold pressures
|
|
||||||
thpres_.resize(numEquilRegions_*numEquilRegions_, 0.0);
|
|
||||||
thpresDefault_.resize(numEquilRegions_*numEquilRegions_, 0.0);
|
|
||||||
|
|
||||||
// internalize the data specified using the EQLNUM keyword
|
// internalize the data specified using the EQLNUM keyword
|
||||||
const std::vector<int>& equilRegionData =
|
const std::vector<int>& equilRegionData =
|
||||||
eclState.get3DProperties().getIntGridProperty("EQLNUM").getData();
|
eclState.get3DProperties().getIntGridProperty("EQLNUM").getData();
|
||||||
@ -147,6 +134,18 @@ public:
|
|||||||
elemEquilRegion_[elemIdx] = equilRegionData[cartElemIdx] - 1;
|
elemEquilRegion_[elemIdx] = equilRegionData[cartElemIdx] - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If this is a restart run the ThresholdPressure object will be active,
|
||||||
|
but it will *not* be properly initialized with numerical values. The
|
||||||
|
values must instead come from the THPRES vector in the restart file.
|
||||||
|
*/
|
||||||
|
if (simConfig.getThresholdPressure().restart())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// allocate the array which specifies the threshold pressures
|
||||||
|
thpres_.resize(numEquilRegions_*numEquilRegions_, 0.0);
|
||||||
|
thpresDefault_.resize(numEquilRegions_*numEquilRegions_, 0.0);
|
||||||
|
|
||||||
computeDefaultThresholdPressures_();
|
computeDefaultThresholdPressures_();
|
||||||
applyExplicitThresholdPressures_();
|
applyExplicitThresholdPressures_();
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,9 @@ public:
|
|||||||
{"KRNSW_GO", Opm::UnitSystem::measure::identity, enableHysteresis}
|
{"KRNSW_GO", Opm::UnitSystem::measure::identity, enableHysteresis}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Opm::RestartKey> extraKeys = {{"OPMEXTRA", Opm::UnitSystem::measure::identity, false}};
|
const auto& inputThpres = eclState().getSimulationConfig().getThresholdPressure();
|
||||||
|
std::vector<Opm::RestartKey> extraKeys = {{"OPMEXTRA", Opm::UnitSystem::measure::identity, false},
|
||||||
|
{"THPRES", Opm::UnitSystem::measure::pressure, inputThpres.active()}};
|
||||||
|
|
||||||
unsigned episodeIdx = simulator_.episodeIndex();
|
unsigned episodeIdx = simulator_.episodeIndex();
|
||||||
const auto& gridView = simulator_.vanguard().gridView();
|
const auto& gridView = simulator_.vanguard().gridView();
|
||||||
@ -265,7 +267,6 @@ public:
|
|||||||
unsigned globalIdx = collectToIORank_.localIdxToGlobalIdx(elemIdx);
|
unsigned globalIdx = collectToIORank_.localIdxToGlobalIdx(elemIdx);
|
||||||
eclOutputModule_.setRestart(restartValues.solution, elemIdx, globalIdx);
|
eclOutputModule_.setRestart(restartValues.solution, elemIdx, globalIdx);
|
||||||
}
|
}
|
||||||
const auto& inputThpres = eclState().getSimulationConfig().getThresholdPressure();
|
|
||||||
if (inputThpres.active()) {
|
if (inputThpres.active()) {
|
||||||
Simulator& mutableSimulator = const_cast<Simulator&>(simulator_);
|
Simulator& mutableSimulator = const_cast<Simulator&>(simulator_);
|
||||||
auto& thpres = mutableSimulator.problem().thresholdPressure();
|
auto& thpres = mutableSimulator.problem().thresholdPressure();
|
||||||
|
Loading…
Reference in New Issue
Block a user