- added a reduced tolerance for linear for the nonlinear solver to accept the result

This commit is contained in:
hnil 2023-03-28 11:43:00 +02:00
parent 88e5b235b8
commit 992edc1fec
2 changed files with 20 additions and 3 deletions

View File

@ -45,6 +45,12 @@ template<class TypeTag, class MyTypeTag>
struct LinearSolverReduction {
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag>
struct RelaxedLinearSolverReduction {
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag>
struct IluRelaxation {
using type = UndefinedProperty;
@ -126,6 +132,11 @@ struct LinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams> {
static constexpr type value = 1e-2;
};
template<class TypeTag>
struct RelaxedLinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1e-2;
};
template<class TypeTag>
struct IluRelaxation<TypeTag, TTag::FlowIstlSolverParams> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 0.9;
@ -217,6 +228,7 @@ namespace Opm
struct FlowLinearSolverParameters
{
double linear_solver_reduction_;
double relaxed_linear_solver_reduction_;
double ilu_relaxation_;
int linear_solver_maxiter_;
int linear_solver_restart_;
@ -242,6 +254,7 @@ namespace Opm
{
// TODO: these parameters have undocumented non-trivial dependencies
linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, LinearSolverReduction);
relaxed_linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, RelaxedLinearSolverReduction);
ilu_relaxation_ = EWOMS_GET_PARAM(TypeTag, double, IluRelaxation);
linear_solver_maxiter_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverMaxIter);
linear_solver_restart_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverRestart);
@ -271,7 +284,8 @@ namespace Opm
template <class TypeTag>
static void registerParameters()
{
EWOMS_REGISTER_PARAM(TypeTag, double, LinearSolverReduction, "The minimum reduction of the residual which the linear solver must achieve");
EWOMS_REGISTER_PARAM(TypeTag, double, LinearSolverReduction, "The minimum reduction of the residual which the linear solver must achieve should try to achive");
EWOMS_REGISTER_PARAM(TypeTag, double, RelaxedLinearSolverReduction, "The minimum reduction of the residual which the linear solver need to achieve for the solution to be accepted");
EWOMS_REGISTER_PARAM(TypeTag, double, IluRelaxation, "The relaxation factor of the linear solver's ILU preconditioner");
EWOMS_REGISTER_PARAM(TypeTag, int, LinearSolverMaxIter, "The maximum number of iterations of the linear solver");
EWOMS_REGISTER_PARAM(TypeTag, int, LinearSolverRestart, "The number of iterations after which GMRES is restarted");
@ -299,6 +313,7 @@ namespace Opm
{
newton_use_gmres_ = false;
linear_solver_reduction_ = 1e-2;
relaxed_linear_solver_reduction_ = 1e-2;
linear_solver_maxiter_ = 150;
linear_solver_restart_ = 40;
linear_solver_verbosity_ = 0;

View File

@ -434,9 +434,11 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
// store number of iterations
iterations_ = result.iterations;
converged_ = result.converged;
if(result.reduction < parameters_.relaxed_linear_solver_reduction_){
converged_ = true;
}
// Check for failure of linear solver.
if (!parameters_.ignoreConvergenceFailure_ && !result.converged) {
if (!parameters_.ignoreConvergenceFailure_ && !converged_) {
const std::string msg("Convergence failure for linear solver.");
OPM_THROW_NOLOG(NumericalProblem, msg);
}