From 7c2f01996a9a343f289f73e160224b26880d1f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 24 Jan 2024 11:53:11 +0100 Subject: [PATCH] Add cpr_trueimpesanalytic option for LinearSolver parameter. --- opm/simulators/linalg/FlowLinearSolverParameters.hpp | 2 +- opm/simulators/linalg/ISTLSolverEbos.hpp | 2 +- opm/simulators/linalg/setupPropertyTree.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/opm/simulators/linalg/FlowLinearSolverParameters.hpp b/opm/simulators/linalg/FlowLinearSolverParameters.hpp index 1e93b22a1..f1529ad6f 100644 --- a/opm/simulators/linalg/FlowLinearSolverParameters.hpp +++ b/opm/simulators/linalg/FlowLinearSolverParameters.hpp @@ -307,7 +307,7 @@ namespace Opm EWOMS_REGISTER_PARAM(TypeTag, bool, UseGmres, "Use GMRES as the linear solver"); EWOMS_REGISTER_PARAM(TypeTag, bool, LinearSolverIgnoreConvergenceFailure, "Continue with the simulation like nothing happened after the linear solver did not converge"); EWOMS_REGISTER_PARAM(TypeTag, bool, ScaleLinearSystem, "Scale linear system according to equation scale and primary variable types"); - EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolver, "Configuration of solver. Valid options are: ilu0 (default), dilu, cprw, cpr (an alias for cprw), cpr_quasiimpes, cpr_trueimpes, amg or hybrid (experimental). Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'"); + EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolver, "Configuration of solver. Valid options are: ilu0 (default), dilu, cprw, cpr (an alias for cprw), cpr_quasiimpes, cpr_trueimpes, cpr_trueimpesanalytic, amg or hybrid (experimental). Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'"); EWOMS_REGISTER_PARAM(TypeTag, bool, LinearSolverPrintJsonDefinition, "Write the JSON definition of the linear solver setup to the DBG file."); EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse preconditioner setup. Valid options are 0: recreate the preconditioner for every linear solve, 1: recreate once every timestep, 2: recreate if last linear solve took more than 10 iterations, 3: never recreate, 4: recreated every CprReuseInterval"); EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseInterval, "Reuse preconditioner interval. Used when CprReuseSetup is set to 4, then the preconditioner will be fully recreated instead of reused every N linear solve, where N is this parameter."); diff --git a/opm/simulators/linalg/ISTLSolverEbos.hpp b/opm/simulators/linalg/ISTLSolverEbos.hpp index 6b72ef351..6d6653f96 100644 --- a/opm/simulators/linalg/ISTLSolverEbos.hpp +++ b/opm/simulators/linalg/ISTLSolverEbos.hpp @@ -585,7 +585,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, OPM_THROW(std::invalid_argument, "Weights type " + weightsType + "not implemented for cpr." - " Please use quasiimpes or trueimpes."); + " Please use quasiimpes, trueimpes or trueimpesanalytic."); } } return weightsCalculator; diff --git a/opm/simulators/linalg/setupPropertyTree.cpp b/opm/simulators/linalg/setupPropertyTree.cpp index 2c6b4a83d..170d18990 100644 --- a/opm/simulators/linalg/setupPropertyTree.cpp +++ b/opm/simulators/linalg/setupPropertyTree.cpp @@ -63,7 +63,7 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters } // Use CPR configuration. - if ((conf == "cpr_trueimpes") || (conf == "cpr_quasiimpes")) { + if ((conf == "cpr_trueimpes") || (conf == "cpr_quasiimpes") || (conf == "cpr_trueimpesanalytic")) { if (!linearSolverMaxIterSet) { // Use our own default unless it was explicitly overridden by user. p.linear_solver_maxiter_ = 20; @@ -115,7 +115,7 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters // No valid configuration option found. OPM_THROW(std::invalid_argument, conf + " is not a valid setting for --linear-solver-configuration." - " Please use ilu0, dilu, cpr, cpr_trueimpes, cpr_quasiimpes or isai"); + " Please use ilu0, dilu, cpr, cprw, cpr_trueimpes, cpr_quasiimpes, cpr_trueimpesanalytic or isai"); } std::string getSolverString(const FlowLinearSolverParameters& p) @@ -186,8 +186,10 @@ setupCPR(const std::string& conf, const FlowLinearSolverParameters& p) prm.put("preconditioner.type", "cpr"s); if (conf == "cpr_quasiimpes") { prm.put("preconditioner.weight_type", "quasiimpes"s); - } else { + } else if (conf == "cpr_trueimpes") { prm.put("preconditioner.weight_type", "trueimpes"s); + } else { + prm.put("preconditioner.weight_type", "trueimpesanalytic"s); } prm.put("preconditioner.finesmoother.type", "ParOverILU0"s); prm.put("preconditioner.finesmoother.relaxation", 1.0);