Skip to content
Snippets Groups Projects
Commit 3c1a1b4e authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

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!
parent ea6e36aa
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -5,16 +5,9 @@ ...@@ -5,16 +5,9 @@
#include <dune/solvers/transferoperators/multigridtransfer.hh> #include <dune/solvers/transferoperators/multigridtransfer.hh>
#include <dune/solvers/solvers/loopsolver.hh> #include <dune/solvers/solvers/loopsolver.hh>
#include <dune/solvers/solvers/linearsolver.hh>
#include <dune/solvers/common/genericvectortools.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> //template<class MatrixType, class VectorType, class BitVectorType>
//inline //inline
//const MatrixType* MultigridStep<MatrixType, VectorType, BitVectorType>:: //const MatrixType* MultigridStep<MatrixType, VectorType, BitVectorType>::
...@@ -164,26 +157,12 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess() ...@@ -164,26 +157,12 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->ignoreNodes_ = ignoreNodesHierarchy_[0]; dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->ignoreNodes_ = ignoreNodesHierarchy_[0];
} }
// TODO: The following two #if-clauses do the exactly the same thing: they call setProblem else if (typeid(*this->basesolver_) == typeid(LinearSolver<MatrixType,VectorType>)) {
// 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>)) {
Dune::Solvers::UMFPackSolver<MatrixType,VectorType>* umfpackBaseSolver LinearSolver<MatrixType,VectorType>* linearBaseSolver = dynamic_cast<LinearSolver<MatrixType,VectorType>*> (this->basesolver_);
= dynamic_cast<Dune::Solvers::UMFPackSolver<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 { else {
DUNE_THROW(SolverError, "You can't use " << typeid(*this->basesolver_).name() DUNE_THROW(SolverError, "You can't use " << typeid(*this->basesolver_).name()
<< " as a base solver in a MultigridStep!"); << " as a base solver in a MultigridStep!");
......
  • Contributor

    Oh, this is such an improvement.

  • oliver.sander_at_tu-dresden.de @oliver.sander_at_tu-dresden.de ·
    Author Maintainer

    To be honest, I've been wanting to do this for the last ten years... seriously.

  • Developer

    This fails for me if I try to use UMFPackSolver as a base solver in the multigridtest.cc :

    what(): SolverError [preprocess:/home/mi/lh1887/dune/dune-solvers/dune/solvers/iterationsteps/multigridstep.cc:168]: You can't use N4Dune7Solvers13UMFPackSolverINS_10BCRSMatrixINS_11FieldMatrixIdLi1ELi1EEESaIS4_EEENS_11BlockVectorINS_11FieldVectorIdLi1EEESaIS9_EEEEE as a base solver in a MultigridStep!

    Or is there anything wrong with

    auto basesolver = Dune::Solvers::UMFPackSolver<Matrix, Vector> (); mgStep.basesolver_ = &basesolver;

    I am willing to learn...

  • lh1887 @lh1887

    mentioned in commit d0e63490

    ·

    mentioned in commit d0e63490

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment