Merge pull request #729 from atgeirr/refine-nonlinear-solver-interface

Refine nonlinear solver interface
This commit is contained in:
Atgeirr Flø Rasmussen 2016-06-17 12:37:15 +02:00 committed by GitHub
commit 6dfd5ec63d
2 changed files with 45 additions and 5 deletions

View File

@ -76,15 +76,32 @@ namespace Opm {
/// Take a single forward step, after which the states will be modified
/// according to the physical model.
/// \param[in] dt time step size
/// \param[in] reservoir_state reservoir state variables
/// \param[in] well_state well state variables
/// \return number of linear iterations used
/// \param[in] dt time step size
/// \param[in, out] reservoir_state reservoir state variables
/// \param[in, out] well_state well state variables
/// \return number of linear iterations used
int
step(const double dt,
ReservoirState& reservoir_state,
WellState& well_state);
/// Take a single forward step, after which the states will be modified
/// according to the physical model. This version allows for the
/// states passed as in/out arguments to be different from the initial
/// states.
/// \param[in] dt time step size
/// \param[in] initial_reservoir_state reservoir state variables at start of timestep
/// \param[in] initial_well_state well state variables at start of timestep
/// \param[in, out] reservoir_state reservoir state variables
/// \param[in, out] well_state well state variables
/// \return number of linear iterations used
int
step(const double dt,
const ReservoirState& initial_reservoir_state,
const WellState& initial_well_state,
ReservoirState& reservoir_state,
WellState& well_state);
/// Number of nonlinear solver iterations used in all calls to step().
unsigned int nonlinearIterations() const;
@ -100,6 +117,9 @@ namespace Opm {
/// Reference to physical model.
const PhysicalModel& model() const;
/// Mutable reference to physical model.
PhysicalModel& model();
/// Detect oscillation or stagnation in a given residual history.
void detectOscillations(const std::vector<std::vector<double>>& residual_history,
const int it, bool& oscillate, bool& stagnate) const;

View File

@ -60,6 +60,12 @@ namespace Opm
return *model_;
}
template <class PhysicalModel>
PhysicalModel& NonlinearSolver<PhysicalModel>::model()
{
return *model_;
}
template <class PhysicalModel>
unsigned int NonlinearSolver<PhysicalModel>::nonlinearIterationsLastStep() const
{
@ -79,9 +85,23 @@ namespace Opm
step(const double dt,
ReservoirState& reservoir_state,
WellState& well_state)
{
return step(dt, reservoir_state, well_state, reservoir_state, well_state);
}
template <class PhysicalModel>
int
NonlinearSolver<PhysicalModel>::
step(const double dt,
const ReservoirState& initial_reservoir_state,
const WellState& initial_well_state,
ReservoirState& reservoir_state,
WellState& well_state)
{
// Do model-specific once-per-step calculations.
model_->prepareStep(dt, reservoir_state, well_state);
model_->prepareStep(dt, initial_reservoir_state, initial_well_state);
int iteration = 0;