mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 20:24:48 -06:00
return IterationReport for assemble and solver well eq methods.
This commit is contained in:
parent
9bf934363c
commit
c6586d36c8
@ -198,10 +198,10 @@ namespace Opm {
|
||||
/// \param[in, out] well_state well state variables
|
||||
/// \param[in] initial_assembly pass true if this is the first call to assemble() in this timestep
|
||||
/// \return well iterations.
|
||||
void assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly,
|
||||
int& well_iters);
|
||||
IterationReport
|
||||
assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly);
|
||||
|
||||
/// \brief Compute the residual norms of the mass balance for each phase,
|
||||
/// the well flux, and the well equation.
|
||||
@ -376,12 +376,11 @@ namespace Opm {
|
||||
assembleMassBalanceEq(const SolutionState& state);
|
||||
|
||||
|
||||
bool
|
||||
IterationReport
|
||||
solveWellEq(const std::vector<ADB>& mob_perfcells,
|
||||
const std::vector<ADB>& b_perfcells,
|
||||
SolutionState& state,
|
||||
WellState& well_state,
|
||||
int& well_iters);
|
||||
WellState& well_state);
|
||||
|
||||
void
|
||||
addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s,
|
||||
|
@ -288,8 +288,7 @@ namespace detail {
|
||||
current_relaxation_ = 1.0;
|
||||
dx_old_ = V::Zero(sizeNonLinear());
|
||||
}
|
||||
int well_iters = 0;
|
||||
asImpl().assemble(reservoir_state, well_state, iteration == 0, well_iters);
|
||||
IterationReport iter_report = asImpl().assemble(reservoir_state, well_state, iteration == 0);
|
||||
residual_norms_history_.push_back(asImpl().computeResidualNorms());
|
||||
const bool converged = asImpl().getConvergence(dt, iteration);
|
||||
const bool must_solve = (iteration < nonlinear_solver.minIter()) || (!converged);
|
||||
@ -323,7 +322,7 @@ namespace detail {
|
||||
}
|
||||
const bool failed = false; // Not needed in this model.
|
||||
const int linear_iters = must_solve ? asImpl().linearIterationsLastSolve() : 0;
|
||||
return IterationReport{ failed, converged, linear_iters , well_iters};
|
||||
return IterationReport{ failed, converged, linear_iters , iter_report.well_iterations};
|
||||
}
|
||||
|
||||
|
||||
@ -728,12 +727,11 @@ namespace detail {
|
||||
|
||||
|
||||
template <class Grid, class WellModel, class Implementation>
|
||||
void
|
||||
IterationReport
|
||||
BlackoilModelBase<Grid, WellModel, Implementation>::
|
||||
assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly,
|
||||
int& well_iters)
|
||||
const bool initial_assembly)
|
||||
{
|
||||
using namespace Opm::AutoDiffGrid;
|
||||
|
||||
@ -777,9 +775,9 @@ namespace detail {
|
||||
asImpl().assembleMassBalanceEq(state);
|
||||
|
||||
// -------- Well equations ----------
|
||||
|
||||
IterationReport iter_report;
|
||||
if ( ! wellsActive() ) {
|
||||
return;
|
||||
return iter_report;
|
||||
}
|
||||
|
||||
std::vector<ADB> mob_perfcells;
|
||||
@ -787,7 +785,7 @@ namespace detail {
|
||||
asImpl().wellModel().extractWellPerfProperties(state, rq_, mob_perfcells, b_perfcells);
|
||||
if (param_.solve_welleq_initially_ && initial_assembly) {
|
||||
// solve the well equations as a pre-processing step
|
||||
asImpl().solveWellEq(mob_perfcells, b_perfcells, state, well_state, well_iters);
|
||||
iter_report = asImpl().solveWellEq(mob_perfcells, b_perfcells, state, well_state);
|
||||
}
|
||||
V aliveWells;
|
||||
std::vector<ADB> cq_s;
|
||||
@ -801,7 +799,8 @@ namespace detail {
|
||||
SolutionState state0 = state;
|
||||
asImpl().makeConstantState(state0);
|
||||
asImpl().wellModel().computeWellPotentials(mob_perfcells, b_perfcells, state0, well_state);
|
||||
}
|
||||
}
|
||||
return iter_report;
|
||||
}
|
||||
|
||||
|
||||
@ -972,13 +971,12 @@ namespace detail {
|
||||
|
||||
|
||||
template <class Grid, class WellModel, class Implementation>
|
||||
bool
|
||||
IterationReport
|
||||
BlackoilModelBase<Grid, WellModel, Implementation>::
|
||||
solveWellEq(const std::vector<ADB>& mob_perfcells,
|
||||
const std::vector<ADB>& b_perfcells,
|
||||
SolutionState& state,
|
||||
WellState& well_state,
|
||||
int& well_iters)
|
||||
WellState& well_state)
|
||||
{
|
||||
V aliveWells;
|
||||
const int np = wells().number_of_phases;
|
||||
@ -1043,7 +1041,6 @@ namespace detail {
|
||||
} while (it < 15);
|
||||
|
||||
if (converged) {
|
||||
well_iters = it;
|
||||
OpmLog::note("well converged iter: " + std::to_string(it));
|
||||
const int nw = wells().number_of_wells;
|
||||
{
|
||||
@ -1070,8 +1067,9 @@ namespace detail {
|
||||
if (!converged) {
|
||||
well_state = well_state0;
|
||||
}
|
||||
|
||||
return converged;
|
||||
const bool failed = false; // Not needed in this method.
|
||||
const int linear_iters = 0; // Not needed in this method
|
||||
return IterationReport{failed, converged, linear_iters, it};
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,10 +105,10 @@ namespace Opm {
|
||||
/// \param[in] reservoir_state reservoir state variables
|
||||
/// \param[in, out] well_state well state variables
|
||||
/// \param[in] initial_assembly pass true if this is the first call to assemble() in this timestep
|
||||
void assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly,
|
||||
int& well_iters);
|
||||
IterationReport
|
||||
assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly);
|
||||
|
||||
using Base::numPhases;
|
||||
using Base::numMaterials;
|
||||
@ -165,12 +165,11 @@ namespace Opm {
|
||||
|
||||
const MultisegmentWells::MultisegmentWellOps& msWellOps() const { return well_model_.wellOps(); }
|
||||
|
||||
bool
|
||||
IterationReport
|
||||
solveWellEq(const std::vector<ADB>& mob_perfcells,
|
||||
const std::vector<ADB>& b_perfcells,
|
||||
SolutionState& state,
|
||||
WellState& well_state,
|
||||
int& well_iters);
|
||||
WellState& well_state);
|
||||
|
||||
void
|
||||
makeConstantState(SolutionState& state) const;
|
||||
|
@ -126,12 +126,11 @@ namespace Opm {
|
||||
|
||||
|
||||
template <class Grid>
|
||||
void
|
||||
IterationReport
|
||||
BlackoilMultiSegmentModel<Grid>::
|
||||
assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly,
|
||||
int& well_iters)
|
||||
const bool initial_assembly)
|
||||
{
|
||||
using namespace Opm::AutoDiffGrid;
|
||||
|
||||
@ -183,9 +182,9 @@ namespace Opm {
|
||||
asImpl().assembleMassBalanceEq(state);
|
||||
|
||||
// -------- Well equations ----------
|
||||
|
||||
IterationReport iter_report;
|
||||
if ( ! wellsActive() ) {
|
||||
return;
|
||||
return iter_report;
|
||||
}
|
||||
|
||||
wellModel().computeSegmentFluidProperties(state);
|
||||
@ -198,7 +197,7 @@ namespace Opm {
|
||||
wellModel().extractWellPerfProperties(state, rq_, mob_perfcells, b_perfcells);
|
||||
if (param_.solve_welleq_initially_ && initial_assembly) {
|
||||
// solve the well equations as a pre-processing step
|
||||
asImpl().solveWellEq(mob_perfcells, b_perfcells, state, well_state, well_iters);
|
||||
iter_report = asImpl().solveWellEq(mob_perfcells, b_perfcells, state, well_state);
|
||||
}
|
||||
|
||||
// the perforation flux here are different
|
||||
@ -210,6 +209,7 @@ namespace Opm {
|
||||
wellModel().addWellFluxEq(cq_s, state, residual_);
|
||||
asImpl().addWellContributionToMassBalanceEq(cq_s, state, well_state);
|
||||
wellModel().addWellControlEq(state, well_state, aliveWells, residual_);
|
||||
return iter_report;
|
||||
}
|
||||
|
||||
|
||||
@ -217,15 +217,15 @@ namespace Opm {
|
||||
|
||||
|
||||
template <class Grid>
|
||||
bool BlackoilMultiSegmentModel<Grid>::solveWellEq(const std::vector<ADB>& mob_perfcells,
|
||||
const std::vector<ADB>& b_perfcells,
|
||||
SolutionState& state,
|
||||
WellState& well_state,
|
||||
int& well_iters)
|
||||
IterationReport
|
||||
BlackoilMultiSegmentModel<Grid>::solveWellEq(const std::vector<ADB>& mob_perfcells,
|
||||
const std::vector<ADB>& b_perfcells,
|
||||
SolutionState& state,
|
||||
WellState& well_state)
|
||||
{
|
||||
const bool converged = Base::solveWellEq(mob_perfcells, b_perfcells, state, well_state, well_iters);
|
||||
IterationReport iter_report = Base::solveWellEq(mob_perfcells, b_perfcells, state, well_state);
|
||||
|
||||
if (converged) {
|
||||
if (iter_report.converged) {
|
||||
// We must now update the state.segp and state.segqs members,
|
||||
// that the base version does not know about.
|
||||
const int np = numPhases();
|
||||
@ -254,7 +254,7 @@ namespace Opm {
|
||||
asImpl().computeWellConnectionPressures(state, well_state);
|
||||
}
|
||||
|
||||
return converged;
|
||||
return iter_report;
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,10 +120,10 @@ namespace Opm {
|
||||
/// \param[in] reservoir_state reservoir state variables
|
||||
/// \param[in, out] well_state well state variables
|
||||
/// \param[in] initial_assembly pass true if this is the first call to assemble() in this timestep
|
||||
void assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly,
|
||||
int& well_iters);
|
||||
IterationReport
|
||||
assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -489,11 +489,10 @@ namespace Opm {
|
||||
|
||||
|
||||
template <class Grid>
|
||||
void
|
||||
IterationReport
|
||||
BlackoilPolymerModel<Grid>::assemble(const ReservoirState& reservoir_state,
|
||||
WellState& well_state,
|
||||
const bool initial_assembly,
|
||||
int& well_iters)
|
||||
const bool initial_assembly)
|
||||
{
|
||||
using namespace Opm::AutoDiffGrid;
|
||||
|
||||
@ -527,10 +526,10 @@ namespace Opm {
|
||||
|
||||
// -------- Mass balance equations --------
|
||||
assembleMassBalanceEq(state);
|
||||
|
||||
IterationReport iter_report;
|
||||
// -------- Well equations ----------
|
||||
if ( ! wellsActive() ) {
|
||||
return;
|
||||
return iter_report;
|
||||
}
|
||||
|
||||
std::vector<ADB> mob_perfcells;
|
||||
@ -538,7 +537,7 @@ namespace Opm {
|
||||
wellModel().extractWellPerfProperties(state, rq_, mob_perfcells, b_perfcells);
|
||||
if (param_.solve_welleq_initially_ && initial_assembly) {
|
||||
// solve the well equations as a pre-processing step
|
||||
Base::solveWellEq(mob_perfcells, b_perfcells, state, well_state, well_iters);
|
||||
Base::solveWellEq(mob_perfcells, b_perfcells, state, well_state);
|
||||
}
|
||||
|
||||
V aliveWells;
|
||||
|
Loading…
Reference in New Issue
Block a user