From b67388e6f061f760558574ae20cd53de66692fdc Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 18 Jan 2023 21:42:31 +0100 Subject: [PATCH] Use cpr if requested in RUNSPEC section of data file. Can be overwritten using command line parameter `--linear-solver=...`. --- opm/simulators/linalg/FlowLinearSolverParameters.hpp | 10 ++++++++-- opm/simulators/linalg/ISTLSolverEbos.hpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/opm/simulators/linalg/FlowLinearSolverParameters.hpp b/opm/simulators/linalg/FlowLinearSolverParameters.hpp index b4d11e32e..5201c9c71 100644 --- a/opm/simulators/linalg/FlowLinearSolverParameters.hpp +++ b/opm/simulators/linalg/FlowLinearSolverParameters.hpp @@ -238,7 +238,7 @@ namespace Opm bool opencl_ilu_parallel_; template - void init() + void init(bool cprRequestedInDataFile) { // TODO: these parameters have undocumented non-trivial dependencies linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, LinearSolverReduction); @@ -255,7 +255,13 @@ namespace Opm scale_linear_system_ = EWOMS_GET_PARAM(TypeTag, bool, ScaleLinearSystem); cpr_reuse_setup_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseSetup); cpr_reuse_interval_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseInterval); - linsolver_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolver); + + if (!EWOMS_PARAM_IS_SET(TypeTag, int, LinearSolverMaxIter) && cprRequestedInDataFile) { + linsolver_ = "cpr"; + } else { + linsolver_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolver); + } + accelerator_mode_ = EWOMS_GET_PARAM(TypeTag, std::string, AcceleratorMode); bda_device_id_ = EWOMS_GET_PARAM(TypeTag, int, BdaDeviceId); opencl_platform_id_ = EWOMS_GET_PARAM(TypeTag, int, OpenclPlatformId); diff --git a/opm/simulators/linalg/ISTLSolverEbos.hpp b/opm/simulators/linalg/ISTLSolverEbos.hpp index 878702f3c..2ad2a8c37 100644 --- a/opm/simulators/linalg/ISTLSolverEbos.hpp +++ b/opm/simulators/linalg/ISTLSolverEbos.hpp @@ -241,7 +241,7 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, #if HAVE_MPI comm_.reset( new CommunicationType( simulator_.vanguard().grid().comm() ) ); #endif - parameters_.template init(); + parameters_.template init(simulator_.vanguard().eclState().getSimulationConfig().useCPR()); prm_ = setupPropertyTree(parameters_, EWOMS_PARAM_IS_SET(TypeTag, int, LinearSolverMaxIter), EWOMS_PARAM_IS_SET(TypeTag, double, LinearSolverReduction));