mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
BUGFIX Update the solution variable in ebos
Updating the solution variable in updateState() was conceptually wrong and lead to incorrect results if the linear solver failed before the updateState() method was called. i.e. in the first iteration.
This commit is contained in:
parent
c79dab27d5
commit
4bb5213f37
@ -203,7 +203,7 @@ namespace Opm {
|
|||||||
/// \param[in] timer simulation timer
|
/// \param[in] timer simulation timer
|
||||||
/// \param[in, out] reservoir_state reservoir state variables
|
/// \param[in, out] reservoir_state reservoir state variables
|
||||||
/// \param[in, out] well_state well 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 ReservoirState& /*reservoir_state*/,
|
||||||
const WellState& /* well_state */)
|
const WellState& /* well_state */)
|
||||||
{
|
{
|
||||||
@ -211,6 +211,18 @@ namespace Opm {
|
|||||||
updateRateConverter();
|
updateRateConverter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
unsigned numDof = ebosSimulator_.model().numGridDof();
|
||||||
wasSwitched_.resize(numDof);
|
wasSwitched_.resize(numDof);
|
||||||
std::fill(wasSwitched_.begin(), wasSwitched_.end(), false);
|
std::fill(wasSwitched_.begin(), wasSwitched_.end(), false);
|
||||||
@ -329,7 +341,7 @@ namespace Opm {
|
|||||||
|
|
||||||
// Apply the update, with considering model-dependent limitations and
|
// Apply the update, with considering model-dependent limitations and
|
||||||
// chopping of the update.
|
// chopping of the update.
|
||||||
updateState(x,iteration);
|
updateState(x);
|
||||||
|
|
||||||
report.update_time += perfTimer.stop();
|
report.update_time += perfTimer.stop();
|
||||||
}
|
}
|
||||||
@ -605,8 +617,7 @@ namespace Opm {
|
|||||||
/// \param[in] dx updates to apply to primary variables
|
/// \param[in] dx updates to apply to primary variables
|
||||||
/// \param[in, out] reservoir_state reservoir state variables
|
/// \param[in, out] reservoir_state reservoir state variables
|
||||||
/// \param[in, out] well_state well state variables
|
/// \param[in, out] well_state well state variables
|
||||||
void updateState(const BVector& dx,
|
void updateState(const BVector& dx)
|
||||||
const int iterationIdx)
|
|
||||||
{
|
{
|
||||||
using namespace Opm::AutoDiffGrid;
|
using namespace Opm::AutoDiffGrid;
|
||||||
|
|
||||||
@ -618,12 +629,6 @@ namespace Opm {
|
|||||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||||
SolutionVector& solution = ebosSimulator_.model().solution( 0 /* timeIdx */ );
|
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>();
|
for (auto elemIt = gridView.template begin</*codim=*/0>();
|
||||||
elemIt != elemEndIt;
|
elemIt != elemEndIt;
|
||||||
++elemIt)
|
++elemIt)
|
||||||
@ -1611,12 +1616,6 @@ namespace Opm {
|
|||||||
{
|
{
|
||||||
ebosSimulator_.problem().beginTimeStep();
|
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_.problem().beginIteration();
|
||||||
ebosSimulator_.model().linearizer().linearize();
|
ebosSimulator_.model().linearizer().linearize();
|
||||||
|
Loading…
Reference in New Issue
Block a user