From 3864afe8e2afac7332acd4301b23e2a27e846c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 11 Jun 2012 17:54:23 +0200 Subject: [PATCH] Constructor: Move common failure mode to end of if-else chain. While here, add a failure mode pertaining to solvers that are supported by the system but disabled at configure time. --- opm/core/linalg/LinearSolverFactory.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/opm/core/linalg/LinearSolverFactory.cpp b/opm/core/linalg/LinearSolverFactory.cpp index 6943b88cd..9b6d89095 100644 --- a/opm/core/linalg/LinearSolverFactory.cpp +++ b/opm/core/linalg/LinearSolverFactory.cpp @@ -55,20 +55,29 @@ namespace Opm LinearSolverFactory::LinearSolverFactory(const parameter::ParameterGroup& param) { - const std::string ls = param.getDefault("linsolver", "umfpack"); + const std::string ls = + param.getDefault("linsolver", "umfpack"); + if (ls == "umfpack") { #if HAVE_SUITESPARSE_UMFPACK_H solver_.reset(new LinearSolverUmfpack); -#else - THROW("Linear solver " << ls <<" is not available."); #endif - } else if (ls == "istl") { + } + + else if (ls == "istl") { #if HAVE_DUNE_ISTL solver_.reset(new LinearSolverIstl(param)); -#else - THROW("Linear solver " << ls <<" is not available."); #endif } + + else { + THROW("Linear solver " << ls << " is unknown."); + } + + if (! solver_) { + THROW("Linear solver " << ls << " is not enabled in " + "this configuration."); + } }