diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 4c8fed7b8..ca4e1ce5b 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -1900,79 +1900,60 @@ namespace { const std::vector cond = phaseCondition(); - double CNVW = 0.; - double CNVO = 0.; - double CNVG = 0.; + 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.}; + Eigen::Array B; + Eigen::Array R; + Eigen::Array tempV; - double RW_sum = 0.; - double RO_sum = 0.; - double RG_sum = 0.; - - double BW_avg = 0.; - double BO_avg = 0.; - double BG_avg = 0.; - - if (active_[Water]) { - const int pos = pu.phase_pos[Water]; - const ADB& tempBW = rq_[pos].b; - V BW = 1./tempBW.value(); - V RW = residual_.material_balance_eq[Water].value(); - BW_avg = BW.sum()/nc; - const V tempV = RW.abs()/pv; - - CNVW = BW_avg * dt * tempV.maxCoeff(); - RW_sum = RW.sum(); + for(int idx=0; idx maxResidualAllowed() || - std::isnan(mass_balance_residual_oil) || mass_balance_residual_oil > maxResidualAllowed() || - std::isnan(mass_balance_residual_gas) || mass_balance_residual_gas > maxResidualAllowed() || - std::isnan(CNVW) || CNVW > maxResidualAllowed() || - std::isnan(CNVO) || CNVO > maxResidualAllowed() || - std::isnan(CNVG) || CNVG > maxResidualAllowed() || + if( std::isnan(mass_balance_residual[Water]) || mass_balance_residual[Water] > maxResidualAllowed() || + std::isnan(mass_balance_residual[Oil]) || mass_balance_residual[Oil] > maxResidualAllowed() || + std::isnan(mass_balance_residual[Gas]) || mass_balance_residual[Gas] > maxResidualAllowed() || + std::isnan(CNV[Water]) || CNV[Water] > maxResidualAllowed() || + std::isnan(CNV[Oil]) || CNV[Oil] > maxResidualAllowed() || + std::isnan(CNV[Gas]) || CNV[Gas] > maxResidualAllowed() || std::isnan(residualWellFlux) || residualWellFlux > maxResidualAllowed() || std::isnan(residualWell) || residualWell > maxResidualAllowed() ) { @@ -1985,12 +1966,12 @@ namespace { const std::streamsize oprec = std::cout.precision(3); const std::ios::fmtflags oflags = std::cout.setf(std::ios::scientific); std::cout << std::setw(4) << iteration - << std::setw(11) << mass_balance_residual_water - << std::setw(11) << mass_balance_residual_oil - << std::setw(11) << mass_balance_residual_gas - << std::setw(11) << CNVW - << std::setw(11) << CNVO - << std::setw(11) << CNVG + << std::setw(11) << mass_balance_residual[Water] + << std::setw(11) << mass_balance_residual[Oil] + << std::setw(11) << mass_balance_residual[Gas] + << std::setw(11) << CNV[Water] + << std::setw(11) << CNV[Oil] + << std::setw(11) << CNV[Gas] << std::setw(11) << residualWellFlux << std::setw(11) << residualWell << std::endl;