From 15aeac3f90d5d0e5df0f5ca033889c2a20fc91ca Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 8 Mar 2018 08:19:44 +0100 Subject: [PATCH] Add option for relaxed CNV tolerance Use a relaxed tolerance for individual cells (CNV) when iter > max_strict_iter. tolerance_cnv_relaxed_ is defauled to 1.0e9 This assure the same behaviour as current master, where CNV criterion is ignored when iter > max_strict_iter TODO: Test this with a stricter default ( <= 1.0) --- opm/autodiff/BlackoilModelEbos.hpp | 13 +++++++------ opm/autodiff/BlackoilModelParameters.cpp | 2 ++ opm/autodiff/BlackoilModelParameters.hpp | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 8ef241357..ec1824fb9 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -818,6 +818,7 @@ namespace Opm { const double dt = timer.currentStepLength(); const double tol_mb = param_.tolerance_mb_; const double tol_cnv = param_.tolerance_cnv_; + const double tol_cnv_relaxed = param_.tolerance_cnv_relaxed_; const int numComp = numEq; @@ -904,8 +905,11 @@ namespace Opm { { CNV[compIdx] = B_avg[compIdx] * dt * maxCoeff[compIdx]; mass_balance_residual[compIdx] = std::abs(B_avg[compIdx]*R_sum[compIdx]) * dt / pvSum; - converged_MB = converged_MB && (mass_balance_residual[compIdx] < tol_mb); - converged_CNV = converged_CNV && (CNV[compIdx] < tol_cnv); + converged_MB = converged_MB && (mass_balance_residual[compIdx] < tol_mb); + if (iteration < param_.max_strict_iter_) + converged_CNV = converged_CNV && (CNV[compIdx] < tol_cnv); + else + converged_CNV = converged_CNV && (CNV[compIdx] < tol_cnv_relaxed); residual_norms.push_back(CNV[compIdx]); } @@ -914,10 +918,7 @@ namespace Opm { bool converged = converged_MB && converged_Well; - // do not care about the cell based residual in the last two Newton - // iterations - if (iteration < param_.max_strict_iter_) - converged = converged && converged_CNV; + converged = converged && converged_CNV; if ( terminal_output_ ) { diff --git a/opm/autodiff/BlackoilModelParameters.cpp b/opm/autodiff/BlackoilModelParameters.cpp index be87aca67..39f62633f 100644 --- a/opm/autodiff/BlackoilModelParameters.cpp +++ b/opm/autodiff/BlackoilModelParameters.cpp @@ -48,6 +48,7 @@ namespace Opm max_residual_allowed_ = param.getDefault("max_residual_allowed", max_residual_allowed_); tolerance_mb_ = param.getDefault("tolerance_mb", tolerance_mb_); tolerance_cnv_ = param.getDefault("tolerance_cnv", tolerance_cnv_); + tolerance_cnv_relaxed_ = param.getDefault("tolerance_cnv_relaxed", tolerance_cnv_relaxed_); tolerance_wells_ = param.getDefault("tolerance_wells", tolerance_wells_ ); tolerance_well_control_ = param.getDefault("tolerance_well_control", tolerance_well_control_); max_welleq_iter_ = param.getDefault("max_welleq_iter", max_welleq_iter_); @@ -82,6 +83,7 @@ namespace Opm max_residual_allowed_ = 1e7; tolerance_mb_ = 1.0e-5; tolerance_cnv_ = 1.0e-2; + tolerance_cnv_relaxed_ = 1.0e9; tolerance_wells_ = 1.0e-4; tolerance_well_control_ = 1.0e-7; tolerance_pressure_ms_wells_ = unit::convert::from(0.01, unit::barsa); // 0.01 bar diff --git a/opm/autodiff/BlackoilModelParameters.hpp b/opm/autodiff/BlackoilModelParameters.hpp index 7b885a4c3..a0291de74 100644 --- a/opm/autodiff/BlackoilModelParameters.hpp +++ b/opm/autodiff/BlackoilModelParameters.hpp @@ -46,6 +46,8 @@ namespace Opm double tolerance_mb_; /// Local convergence tolerance (max of local saturation errors). double tolerance_cnv_; + /// Relaxed local convergence tolerance (used when iter >= max_strict_iter_). + double tolerance_cnv_relaxed_; /// Well convergence tolerance. double tolerance_wells_; /// Tolerance for the well control equations