Merge pull request #964 from totto82/reuse_cache2

Reuse cache revisited
This commit is contained in:
Atgeirr Flø Rasmussen
2016-12-20 14:46:00 +01:00
committed by GitHub
2 changed files with 13 additions and 20 deletions

View File

@@ -191,7 +191,6 @@ namespace Opm {
, current_relaxation_(1.0)
, dx_old_(AutoDiffGrid::numCells(grid_))
, isBeginReportStep_(false)
, invalidateIntensiveQuantitiesCache_(true)
{
const double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_));
const std::vector<double> pv(geo_.poreVolume().data(), geo_.poreVolume().data() + geo_.poreVolume().size());
@@ -270,9 +269,6 @@ namespace Opm {
dx_old_ = 0.0;
}
// reset intensive quantities cache useless other options are set
// further down
invalidateIntensiveQuantitiesCache_ = true;
report.total_linearizations = 1;
try {
@@ -288,12 +284,11 @@ namespace Opm {
std::vector<double> residual_norms;
perfTimer.reset();
perfTimer.start();
report.converged = getConvergence(timer, iteration,residual_norms);
// the step is not considered converged until at least minIter iterations is done
report.converged = getConvergence(timer, iteration,residual_norms) && iteration > nonlinear_solver.minIter();
report.update_time += perfTimer.stop();
residual_norms_history_.push_back(residual_norms);
bool must_solve = iteration < nonlinear_solver.minIter() || !report.converged;
if (must_solve) {
if (!report.converged) {
perfTimer.reset();
perfTimer.start();
report.total_newton_iterations = 1;
@@ -341,14 +336,13 @@ namespace Opm {
// chopping of the update.
updateState(x,reservoir_state);
wellModel().updateWellState(xw, well_state);
// if the solution is updated the solution needs to be comunicated to ebos
// and the cachedIntensiveQuantities needs to be updated.
convertInput( iteration, reservoir_state, ebosSimulator_ );
ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0);
report.update_time += perfTimer.stop();
}
else {
// if the solution is not updated, we do not need to recalculate the
// intensive quantities in the next iteration.
assert(report.converged);
invalidateIntensiveQuantitiesCache_ = false ;
}
return report;
}
@@ -1453,8 +1447,6 @@ namespace Opm {
const int iterationIdx,
const ReservoirState& reservoirState)
{
convertInput( iterationIdx, reservoirState, ebosSimulator_ );
ebosSimulator_.startNextEpisode( timer.currentStepLength() );
ebosSimulator_.setEpisodeIndex( timer.reportStepNum() );
ebosSimulator_.setTimeStepIndex( timer.reportStepNum() );
@@ -1482,8 +1474,10 @@ namespace Opm {
{
ebosSimulator_.problem().beginTimeStep();
}
// if the last step failed we want to recalculate the IntesiveQuantities.
if ( invalidateIntensiveQuantitiesCache_ ) {
// if the last time step failed we need to update the solution varables in ebos
// and recalculate the IntesiveQuantities.
if ( timer.lastStepFailed() && iterationIdx == 0 ) {
convertInput( iterationIdx, reservoirState, ebosSimulator_ );
ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0);
}
@@ -1512,7 +1506,6 @@ namespace Opm {
public:
bool isBeginReportStep_;
bool invalidateIntensiveQuantitiesCache_;
};
} // namespace Opm

View File

@@ -147,7 +147,7 @@ namespace Opm
converged = report.converged;
iteration += 1;
} while ( (!converged && (iteration <= maxIter())) || (iteration < minIter()));
} while ( (!converged && (iteration <= maxIter())) || (iteration <= minIter()));
if (!converged) {
if (model_->terminalOutputEnabled()) {