From 080d224926e9f5e338da0d9ff49648a5a7e5a92f Mon Sep 17 00:00:00 2001 From: Linus Seelinger <S.Linus@gmx.de> Date: Fri, 21 Jul 2017 14:37:32 +0200 Subject: [PATCH] Only support float and double as field types for CG condition estimate --- dune/istl/solvers.hh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dune/istl/solvers.hh b/dune/istl/solvers.hh index 08b2860f1..5206a2951 100644 --- a/dune/istl/solvers.hh +++ b/dune/istl/solvers.hh @@ -261,22 +261,34 @@ namespace Dune { \copydetails IterativeSolver::IterativeSolver(LinearOperator<X,Y>&, Preconditioner<X,Y>&, real_type, int, int) \param condition_estimate Whether to calculate an estimate of the condition number. The estimate is given in the InverseOperatorResult returned by apply(). + This is only supported for float and double field types. */ CGSolver (LinearOperator<X,X>& op, Preconditioner<X,X>& prec, real_type reduction, int maxit, int verbose, bool condition_estimate) : IterativeSolver<X,X>(op, prec, reduction, maxit, verbose), condition_estimate_(condition_estimate) - {} + { + if (condition_estimate && !(std::is_same<field_type,float>::value || std::is_same<field_type,double>::value)) { + condition_estimate_ = false; + std::cerr << "WARNING: Condition estimate was disabled. It is only available for double and float field types!" << std::endl; + } + } /*! \brief Constructor to initialize a CG solver. \copydetails IterativeSolver::IterativeSolver(LinearOperator<X,Y>&, ScalarProduct<X>&, Preconditioner<X,Y>&, real_type, int, int) \param condition_estimate Whether to calculate an estimate of the condition number. The estimate is given in the InverseOperatorResult returned by apply(). + This is only supported for float and double field types. */ CGSolver (LinearOperator<X,X>& op, ScalarProduct<X>& sp, Preconditioner<X,X>& prec, real_type reduction, int maxit, int verbose, bool condition_estimate) : IterativeSolver<X,X>(op, sp, prec, reduction, maxit, verbose), condition_estimate_(condition_estimate) - {} + { + if (condition_estimate && !(std::is_same<field_type,float>::value || std::is_same<field_type,double>::value)) { + condition_estimate_ = false; + std::cerr << "WARNING: Condition estimate was disabled. It is only available for double and float field types!" << std::endl; + } + } /*! -- GitLab