Merge pull request #1322 from totto82/fixResetSolution

BUGFIX Update the solution variable in ebos
This commit is contained in:
Atgeirr Flø Rasmussen 2017-11-09 10:35:38 +01:00 committed by GitHub
commit e7a6e8f2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -185,11 +185,23 @@ namespace Opm {
/// \param[in] timer simulation timer
/// \param[in, out] reservoir_state reservoir state variables
/// \param[in, out] well_state well state variables
void prepareStep(const SimulatorTimerInterface& /*timer*/,
void prepareStep(const SimulatorTimerInterface& timer,
const ReservoirState& /*reservoir_state*/,
const WellState& /* well_state */)
{
// update the solution variables in ebos
// if the last time step failed we need to update the curent solution
// and recalculate the Intesive Quantities.
if ( timer.lastStepFailed() ) {
ebosSimulator_.model().solution( 0 /* timeIdx */ ) = ebosSimulator_.model().solution( 1 /* timeIdx */ );
ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0);
} else {
// set the initial solution.
ebosSimulator_.model().solution( 1 /* timeIdx */ ) = ebosSimulator_.model().solution( 0 /* timeIdx */ );
}
unsigned numDof = ebosSimulator_.model().numGridDof();
wasSwitched_.resize(numDof);
std::fill(wasSwitched_.begin(), wasSwitched_.end(), false);
@ -305,7 +317,7 @@ namespace Opm {
// Apply the update, with considering model-dependent limitations and
// chopping of the update.
updateState(x,iteration);
updateState(x);
report.update_time += perfTimer.stop();
}
@ -580,8 +592,7 @@ namespace Opm {
/// \param[in] dx updates to apply to primary variables
/// \param[in, out] reservoir_state reservoir state variables
/// \param[in, out] well_state well state variables
void updateState(const BVector& dx,
const int iterationIdx)
void updateState(const BVector& dx)
{
using namespace Opm::AutoDiffGrid;
@ -593,12 +604,6 @@ namespace Opm {
const auto& elemEndIt = gridView.template end</*codim=*/0>();
SolutionVector& solution = ebosSimulator_.model().solution( 0 /* timeIdx */ );
// Store the initial solution.
if( iterationIdx == 0 )
{
ebosSimulator_.model().solution( 1 /* timeIdx */ ) = solution;
}
for (auto elemIt = gridView.template begin</*codim=*/0>();
elemIt != elemEndIt;
++elemIt)
@ -1564,12 +1569,6 @@ namespace Opm {
{
ebosSimulator_.problem().beginTimeStep();
}
// if the last time step failed we need to update the solution varables in ebos
// and recalculate the Intesive Quantities.
if ( timer.lastStepFailed() && iterationIdx == 0 ) {
ebosSimulator_.model().solution( 0 /* timeIdx */ ) = ebosSimulator_.model().solution( 1 /* timeIdx */ );
ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0);
}
ebosSimulator_.problem().beginIteration();
ebosSimulator_.model().linearizer().linearize();