diff --git a/dune/solvers/iterationsteps/multigridstep.cc b/dune/solvers/iterationsteps/multigridstep.cc index 1d14abfe8ad60bf867c3c44b820464556d3a5bc7..8183d7c182d43cbcfe3d1fe1ac3acf9b9d08ae05 100644 --- a/dune/solvers/iterationsteps/multigridstep.cc +++ b/dune/solvers/iterationsteps/multigridstep.cc @@ -138,6 +138,8 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess() // Set up base solver // ///////////////////////////////////////////// + using SmootherType = LinearIterationStep<MatrixType, VectorType, BitVectorType>; + using LinearSolverType = LinearSolver<MatrixType, VectorType, BitVectorType>; if (basesolver_) { // If the base solver can ignore dofs give it the ignoreNodes field @@ -150,16 +152,15 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess() DuneSolversLoopSolver* loopBaseSolver = dynamic_cast<DuneSolversLoopSolver*> (this->basesolver_.get()); - typedef LinearIterationStep<MatrixType, VectorType> SmootherType; assert(dynamic_cast<SmootherType*>(&loopBaseSolver->getIterationStep())); dynamic_cast<SmootherType*>(&loopBaseSolver->getIterationStep())->setProblem(*(this->matrixHierarchy_[0]), *this->xHierarchy_[0], this->rhsHierarchy_[0]); dynamic_cast<SmootherType*>(&loopBaseSolver->getIterationStep())->setIgnore(*ignoreNodesHierarchy_[0]); } - else if (dynamic_cast<LinearSolver<MatrixType, VectorType>*>(this->basesolver_.get())) { + else if (dynamic_cast<LinearSolverType*>(this->basesolver_.get())) { - LinearSolver<MatrixType,VectorType>* linearBaseSolver = dynamic_cast<LinearSolver<MatrixType,VectorType>*> (this->basesolver_.get()); + LinearSolverType* linearBaseSolver = dynamic_cast<LinearSolverType*> (this->basesolver_.get()); linearBaseSolver->setProblem(*(this->matrixHierarchy_[0]), *this->xHierarchy_[0], this->rhsHierarchy_[0]); } diff --git a/dune/solvers/iterationsteps/multigridstep.hh b/dune/solvers/iterationsteps/multigridstep.hh index 6f00dbfdba9c9c95a68c38c672216bbfe4807829..d079d9d56c34804f13a484049f2700083052a332 100644 --- a/dune/solvers/iterationsteps/multigridstep.hh +++ b/dune/solvers/iterationsteps/multigridstep.hh @@ -28,6 +28,7 @@ namespace Dune { static const int blocksize = VectorType::block_type::dimension; public: + using LinearStepType = LinearIterationStep<MatrixType, VectorType, BitVectorType>; MultigridStep() : presmoother_(0), @@ -41,11 +42,11 @@ namespace Dune { VectorType& x, const VectorType& rhs, int mu, int nu1, int nu2, - LinearIterationStep<MatrixType, VectorType>* preSmoother, - LinearIterationStep<MatrixType, VectorType>* postSmoother, + LinearStepType* preSmoother, + LinearStepType* postSmoother, Solver* baseSolver, const BitVectorType* ignoreNodes) : - LinearIterationStep<MatrixType, VectorType>(mat, x, rhs), + LinearStepType(mat, x, rhs), preprocessCalled(false) { mu_ = mu; @@ -62,7 +63,7 @@ namespace Dune { MultigridStep(const MatrixType& mat, VectorType& x, const VectorType& rhs) : - LinearIterationStep<MatrixType, VectorType>(mat, x, rhs), + LinearStepType(mat, x, rhs), basesolver_(0), preprocessCalled(false) {} @@ -143,7 +144,7 @@ namespace Dune { virtual void setMGType(int mu, int nu1, int nu2); /** \brief Set the smoother iteration step */ - virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* smoother) + virtual void setSmoother(LinearStepType* smoother) { presmootherDefault_ = postsmootherDefault_ = Dune::stackobject_to_shared_ptr(*smoother); @@ -151,7 +152,7 @@ namespace Dune { } /** \brief Set the smoother iteration step from a smart pointer*/ - virtual void setSmoother(std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > smoother) + virtual void setSmoother(std::shared_ptr<LinearStepType> smoother) { presmootherDefault_ = postsmootherDefault_ = smoother; @@ -159,8 +160,8 @@ namespace Dune { } /** \brief Set pre- and post smoothers individually */ - virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* preSmoother, - LinearIterationStep<MatrixType, VectorType>* postSmoother) + virtual void setSmoother(LinearStepType* preSmoother, + LinearStepType* postSmoother) { presmootherDefault_ = Dune::stackobject_to_shared_ptr(*preSmoother); postsmootherDefault_ = Dune::stackobject_to_shared_ptr(*postSmoother); @@ -169,13 +170,13 @@ namespace Dune { } /** \brief Set the smoother iteration step for a particular level */ - virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* smoother, std::size_t level) + virtual void setSmoother(LinearStepType* smoother, std::size_t level) { levelWiseSmoothers_[level] = Dune::stackobject_to_shared_ptr(*smoother); } /** \brief Set the smoother iteration step for a particular level, from a smart pointer */ - virtual void setSmoother(std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > smoother, std::size_t level) + virtual void setSmoother(std::shared_ptr<LinearStepType> smoother, std::size_t level) { levelWiseSmoothers_[level] = smoother; } @@ -189,10 +190,10 @@ namespace Dune { protected: /** \brief The presmoothers, one for each level */ - std::vector<std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > > presmoother_; + std::vector<std::shared_ptr<LinearStepType> > presmoother_; /** \brief The postsmoothers, one for each level */ - std::vector<std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > > postsmoother_; + std::vector<std::shared_ptr<LinearStepType> > postsmoother_; /** \brief The base solver */ std::shared_ptr<Solver> basesolver_; @@ -230,9 +231,9 @@ namespace Dune { protected: - std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > presmootherDefault_; - std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > postsmootherDefault_; - typedef std::map<std::size_t, std::shared_ptr<LinearIterationStep<MatrixType, VectorType> > > SmootherCache; + std::shared_ptr<LinearStepType> presmootherDefault_; + std::shared_ptr<LinearStepType> postsmootherDefault_; + typedef std::map<std::size_t, std::shared_ptr<LinearStepType> > SmootherCache; SmootherCache levelWiseSmoothers_; bool preprocessCalled;