diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 0d4a39bc1..dc9a1b978 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -272,7 +272,11 @@ namespace Opm { double residualNorm() const; - std::vector residuals() const; + /// \brief Compute the residual norms of the mass balance for each phase, + /// the well flux, and the well equation. + /// \return a vector that contains for each phase the norm of the mass balance + /// and afterwards the norm of the residual of the well flux and the well equation. + std::vector computeResidualNorms() const; ADB fluidViscosity(const int phase, diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 4c8fed7b8..c8bfeb297 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -281,7 +281,9 @@ namespace { computeWellConnectionPressures(state, xw); } - std::vector> residual_history; + // For each iteration we store in a vector the norms of the residual of + // the mass balance for each active phase, the well flux and the well equations + std::vector> residual_norms_history; assemble(pvdt, x, xw); @@ -289,7 +291,7 @@ namespace { bool converged = false; double omega = 1.; - residual_history.push_back(residuals()); + residual_norms_history.push_back(computeResidualNorms()); int it = 0; converged = getConvergence(dt,it); @@ -308,7 +310,7 @@ namespace { // store number of linear iterations used linearIterations += linsolver_.iterations(); - detectNewtonOscillations(residual_history, it, relaxRelTol(), isOscillate, isStagnate); + detectNewtonOscillations(residual_norms_history, it, relaxRelTol(), isOscillate, isStagnate); if (isOscillate) { omega -= relaxIncrement(); @@ -322,7 +324,7 @@ namespace { assemble(pvdt, x, xw); - residual_history.push_back(residuals()); + residual_norms_history.push_back(computeResidualNorms()); // increase iteration counter ++it; @@ -1783,9 +1785,9 @@ namespace { template std::vector - FullyImplicitBlackoilSolver::residuals() const + FullyImplicitBlackoilSolver::computeResidualNorms() const { - std::vector residual; + std::vector residualNorms; std::vector::const_iterator massBalanceIt = residual_.material_balance_eq.begin(); const std::vector::const_iterator endMassBalanceIt = residual_.material_balance_eq.end(); @@ -1796,7 +1798,7 @@ namespace { OPM_THROW(Opm::NumericalProblem, "Encountered a non-finite residual"); } - residual.push_back(massBalanceResid); + residualNorms.push_back(massBalanceResid); } // the following residuals are not used in the oscillation detection now @@ -1805,16 +1807,16 @@ namespace { OPM_THROW(Opm::NumericalProblem, "Encountered a non-finite residual"); } - residual.push_back(wellFluxResid); + residualNorms.push_back(wellFluxResid); const double wellResid = infinityNorm( residual_.well_eq ); if (!std::isfinite(wellResid)) { OPM_THROW(Opm::NumericalProblem, "Encountered a non-finite residual"); } - residual.push_back(wellResid); + residualNorms.push_back(wellResid); - return residual; + return residualNorms; } template