mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4565 from hnil/reduced_linearsolver_option
Reduced linearsolver option
This commit is contained in:
commit
dcdb9413b4
@ -45,6 +45,12 @@ template<class TypeTag, class MyTypeTag>
|
|||||||
struct LinearSolverReduction {
|
struct LinearSolverReduction {
|
||||||
using type = UndefinedProperty;
|
using type = UndefinedProperty;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class TypeTag, class MyTypeTag>
|
||||||
|
struct RelaxedLinearSolverReduction {
|
||||||
|
using type = UndefinedProperty;
|
||||||
|
};
|
||||||
|
|
||||||
template<class TypeTag, class MyTypeTag>
|
template<class TypeTag, class MyTypeTag>
|
||||||
struct IluRelaxation {
|
struct IluRelaxation {
|
||||||
using type = UndefinedProperty;
|
using type = UndefinedProperty;
|
||||||
@ -126,6 +132,11 @@ struct LinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams> {
|
|||||||
static constexpr type value = 1e-2;
|
static constexpr type value = 1e-2;
|
||||||
};
|
};
|
||||||
template<class TypeTag>
|
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> {
|
struct IluRelaxation<TypeTag, TTag::FlowIstlSolverParams> {
|
||||||
using type = GetPropType<TypeTag, Scalar>;
|
using type = GetPropType<TypeTag, Scalar>;
|
||||||
static constexpr type value = 0.9;
|
static constexpr type value = 0.9;
|
||||||
@ -217,6 +228,7 @@ namespace Opm
|
|||||||
struct FlowLinearSolverParameters
|
struct FlowLinearSolverParameters
|
||||||
{
|
{
|
||||||
double linear_solver_reduction_;
|
double linear_solver_reduction_;
|
||||||
|
double relaxed_linear_solver_reduction_;
|
||||||
double ilu_relaxation_;
|
double ilu_relaxation_;
|
||||||
int linear_solver_maxiter_;
|
int linear_solver_maxiter_;
|
||||||
int linear_solver_restart_;
|
int linear_solver_restart_;
|
||||||
@ -242,6 +254,7 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
// TODO: these parameters have undocumented non-trivial dependencies
|
// TODO: these parameters have undocumented non-trivial dependencies
|
||||||
linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, LinearSolverReduction);
|
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);
|
ilu_relaxation_ = EWOMS_GET_PARAM(TypeTag, double, IluRelaxation);
|
||||||
linear_solver_maxiter_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverMaxIter);
|
linear_solver_maxiter_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverMaxIter);
|
||||||
linear_solver_restart_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverRestart);
|
linear_solver_restart_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverRestart);
|
||||||
@ -271,7 +284,8 @@ namespace Opm
|
|||||||
template <class TypeTag>
|
template <class TypeTag>
|
||||||
static void registerParameters()
|
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, 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, 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");
|
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;
|
newton_use_gmres_ = false;
|
||||||
linear_solver_reduction_ = 1e-2;
|
linear_solver_reduction_ = 1e-2;
|
||||||
|
relaxed_linear_solver_reduction_ = 1e-2;
|
||||||
linear_solver_maxiter_ = 150;
|
linear_solver_maxiter_ = 150;
|
||||||
linear_solver_restart_ = 40;
|
linear_solver_restart_ = 40;
|
||||||
linear_solver_verbosity_ = 0;
|
linear_solver_verbosity_ = 0;
|
||||||
|
@ -434,9 +434,17 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
|||||||
// store number of iterations
|
// store number of iterations
|
||||||
iterations_ = result.iterations;
|
iterations_ = result.iterations;
|
||||||
converged_ = result.converged;
|
converged_ = result.converged;
|
||||||
|
if(!converged_){
|
||||||
|
if(result.reduction < parameters_.relaxed_linear_solver_reduction_){
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<< "Full linear solver tolerance not achived. The reduction is:" << result.reduction
|
||||||
|
<< " after " << result.iterations << " iterations ";
|
||||||
|
OpmLog::warning(ss.str());
|
||||||
|
converged_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check for failure of linear solver.
|
// Check for failure of linear solver.
|
||||||
if (!parameters_.ignoreConvergenceFailure_ && !result.converged) {
|
if (!parameters_.ignoreConvergenceFailure_ && !converged_) {
|
||||||
const std::string msg("Convergence failure for linear solver.");
|
const std::string msg("Convergence failure for linear solver.");
|
||||||
OPM_THROW_NOLOG(NumericalProblem, msg);
|
OPM_THROW_NOLOG(NumericalProblem, msg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user