diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 0d4a39bc1..a3053803c 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -28,6 +28,8 @@ #include #include +#include + struct UnstructuredGrid; struct Wells; @@ -351,6 +353,16 @@ namespace Opm { /// residual mass balance (tol_cnv). bool getConvergence(const double dt, const int iteration); + /// Compute the reduction within the convergence check. + void + convergenceReduction(const Eigen::Array& B, + const Eigen::Array& tempV, + const Eigen::Array& R, + std::array& B_avg, + std::array& maxCoeff, + std::array& R_sum, + int nc) const; + void detectNewtonOscillations(const std::vector>& residual_history, const int it, const double relaxRelTol, bool& oscillate, bool& stagnate) const; diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index ca4e1ce5b..b1df7ccaa 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -1885,6 +1885,30 @@ namespace { return; } + template + void + FullyImplicitBlackoilSolver::convergenceReduction(const Eigen::Array& B, + const Eigen::Array& tempV, + const Eigen::Array& R, + std::array& R_sum, + std::array& maxCoeff, + std::array& B_avg, + int nc) const + { + const Opm::PhaseUsage& pu = fluid_.phaseUsage(); + // Do the global reductions + for(int idx=0; idx bool FullyImplicitBlackoilSolver::getConvergence(const double dt, const int iteration) @@ -1900,11 +1924,11 @@ namespace { const std::vector cond = phaseCondition(); - double CNV[MaxNumPhases] = {0., 0., 0.}; - double R_sum[MaxNumPhases] = {0., 0., 0.}; - double B_avg[MaxNumPhases] = {0., 0., 0.}; - double maxCoeff[MaxNumPhases] = {0., 0., 0.}; - double mass_balance_residual[MaxNumPhases] = {0., 0., 0.}; + std::array CNV = {{0., 0., 0.}}; + std::array R_sum = {{0., 0., 0.}}; + std::array B_avg = {{0., 0., 0.}}; + std::array maxCoeff = {{0., 0., 0.}}; + std::array mass_balance_residual = {{0., 0., 0.}}; Eigen::Array B; Eigen::Array R; Eigen::Array tempV; @@ -1919,17 +1943,8 @@ namespace { tempV.col(pu.phase_pos[idx]) = R.col(pu.phase_pos[idx]).abs()/pv; } } - // Do the global reductions - for(int idx=0; idx