From 3c1a1b4e74424651acf0d39173e47f5af8a036b8 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Tue, 17 Jan 2017 17:16:03 +0100 Subject: [PATCH] Clean up preprocess method using the new LinearSolver interface class Finally we get rid of the explicit solver names that were hard-coded in the MultigridStep::preprocess method! --- dune/solvers/iterationsteps/multigridstep.cc | 29 +++----------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/dune/solvers/iterationsteps/multigridstep.cc b/dune/solvers/iterationsteps/multigridstep.cc index 407421bf..f8025637 100644 --- a/dune/solvers/iterationsteps/multigridstep.cc +++ b/dune/solvers/iterationsteps/multigridstep.cc @@ -5,16 +5,9 @@ #include <dune/solvers/transferoperators/multigridtransfer.hh> #include <dune/solvers/solvers/loopsolver.hh> +#include <dune/solvers/solvers/linearsolver.hh> #include <dune/solvers/common/genericvectortools.hh> -#if HAVE_IPOPT -#include <dune/solvers/solvers/quadraticipopt.hh> -#endif - -#if HAVE_UMFPACK -#include <dune/solvers/solvers/umfpacksolver.hh> -#endif - //template<class MatrixType, class VectorType, class BitVectorType> //inline //const MatrixType* MultigridStep<MatrixType, VectorType, BitVectorType>:: @@ -164,26 +157,12 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess() dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->ignoreNodes_ = ignoreNodesHierarchy_[0]; } - // TODO: The following two #if-clauses do the exactly the same thing: they call setProblem - // However, we cannot write the code generically because there is no general abstraction - // for solvers that I can call 'setProblem' for. -#if HAVE_IPOPT - else if (typeid(*this->basesolver_) == typeid(QuadraticIPOptSolver<MatrixType,VectorType>)) { - - QuadraticIPOptSolver<MatrixType,VectorType>* ipoptBaseSolver = dynamic_cast<QuadraticIPOptSolver<MatrixType,VectorType>*> (this->basesolver_); - - ipoptBaseSolver->setProblem(*(this->matrixHierarchy_[0]), *this->xHierarchy_[0], this->rhsHierarchy_[0]); - } -#endif -#if HAVE_UMFPACK - else if (typeid(*this->basesolver_) == typeid(Dune::Solvers::UMFPackSolver<MatrixType,VectorType>)) { + else if (typeid(*this->basesolver_) == typeid(LinearSolver<MatrixType,VectorType>)) { - Dune::Solvers::UMFPackSolver<MatrixType,VectorType>* umfpackBaseSolver - = dynamic_cast<Dune::Solvers::UMFPackSolver<MatrixType,VectorType>*> (this->basesolver_); + LinearSolver<MatrixType,VectorType>* linearBaseSolver = dynamic_cast<LinearSolver<MatrixType,VectorType>*> (this->basesolver_); - umfpackBaseSolver->setProblem(*(this->matrixHierarchy_[0]), *this->xHierarchy_[0], this->rhsHierarchy_[0]); + linearBaseSolver->setProblem(*(this->matrixHierarchy_[0]), *this->xHierarchy_[0], this->rhsHierarchy_[0]); } -#endif else { DUNE_THROW(SolverError, "You can't use " << typeid(*this->basesolver_).name() << " as a base solver in a MultigridStep!"); -- GitLab