diff --git a/opm/simulators/linalg/FlowLinearSolverParameters.hpp b/opm/simulators/linalg/FlowLinearSolverParameters.hpp index 3789ab091..4fdfa6df5 100644 --- a/opm/simulators/linalg/FlowLinearSolverParameters.hpp +++ b/opm/simulators/linalg/FlowLinearSolverParameters.hpp @@ -113,12 +113,10 @@ template struct CprReuseSetup { using type = UndefinedProperty; }; - template struct CprReuseInterval { using type = UndefinedProperty; }; - template struct Linsolver { using type = UndefinedProperty; @@ -143,7 +141,6 @@ template struct FpgaBitstream { using type = UndefinedProperty; }; - template struct LinearSolverReduction { using type = GetPropType; @@ -218,12 +215,10 @@ template struct CprReuseSetup { static constexpr int value = 3; }; - template struct CprReuseInterval { static constexpr int value = 10; }; - template struct Linsolver { static constexpr auto value = "ilu0"; @@ -275,9 +270,9 @@ namespace Opm std::string accelerator_mode_; int bda_device_id_; int opencl_platform_id_; - int cpr_max_ell_iter_ = 20; - int cpr_reuse_setup_ = 0; - int cpr_reuse_interval_ = 10; + int cpr_max_ell_iter_; + int cpr_reuse_setup_; + int cpr_reuse_interval_; std::string opencl_ilu_reorder_; std::string fpga_bitstream_; @@ -327,7 +322,7 @@ namespace Opm EWOMS_REGISTER_PARAM(TypeTag, bool, ScaleLinearSystem, "Scale linear system according to equation scale and primary variable types"); EWOMS_REGISTER_PARAM(TypeTag, int, CprMaxEllIter, "MaxIterations of the elliptic pressure part of the cpr solver"); 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, "Rese preconditioner interval. Used with CprReuseSetup 4"); + 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."); EWOMS_REGISTER_PARAM(TypeTag, std::string, Linsolver, "Configuration of solver. Valid options are: ilu0 (default), cpr (an alias for cpr_trueimpes), cpr_quasiimpes, cpr_trueimpes or amg. 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, AcceleratorMode, "Use GPU (cusparseSolver or openclSolver) or FPGA (fpgaSolver) as the linear solver, usage: '--accelerator-mode=[none|cusparse|opencl|fpga|amgcl]'"); EWOMS_REGISTER_PARAM(TypeTag, int, BdaDeviceId, "Choose device ID for cusparseSolver or openclSolver, use 'nvidia-smi' or 'clinfo' to determine valid IDs"); diff --git a/opm/simulators/linalg/ISTLSolverEbos.hpp b/opm/simulators/linalg/ISTLSolverEbos.hpp index 4a0ab5dce..c7101e575 100644 --- a/opm/simulators/linalg/ISTLSolverEbos.hpp +++ b/opm/simulators/linalg/ISTLSolverEbos.hpp @@ -456,13 +456,22 @@ namespace Opm return false; } if (this->parameters_.cpr_reuse_setup_ == 4) { - int step = this->parameters_.cpr_reuse_interval_; - bool create = ((calls_%step) == 0); + // Recreate solver every 'step' solve calls. + const int step = this->parameters_.cpr_reuse_interval_; + const bool create = ((calls_ % step) == 0); return create; } - // Otherwise, do not recreate solver. - assert(false); + // If here, we have an invalid parameter. + const bool on_io_rank = (simulator_.gridView().comm().rank() == 0); + std::string msg = "Invalid value: " + std::to_string(this->parameters_.cpr_reuse_setup_) + + " for --cpr-reuse-setup parameter, run with --help to see allowed values."; + if (on_io_rank) { + OpmLog::error(msg); + } + throw std::runtime_error(msg); + + // Never reached. return false; }