From 27503a938f20cb1c58c46179ef24cffebe28e7e9 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Fri, 3 Dec 2010 14:26:19 +0000 Subject: [PATCH] Rename template parameter OperatorType to MatrixType This is more precise about what it is. It also cleans up the doxygen inheritance diagram. [[Imported from SVN: r3567]] --- dune/solvers/iterationsteps/multigridstep.cc | 44 ++++++++++---------- dune/solvers/iterationsteps/multigridstep.hh | 38 ++++++++--------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/dune/solvers/iterationsteps/multigridstep.cc b/dune/solvers/iterationsteps/multigridstep.cc index 87840d96..4953fddd 100644 --- a/dune/solvers/iterationsteps/multigridstep.cc +++ b/dune/solvers/iterationsteps/multigridstep.cc @@ -9,24 +9,24 @@ #include <dune/solvers/solvers/quadraticipopt.hh> #endif -template <class OperatorType, class VectorType, class BitVectorType> -VectorType MultigridStep<OperatorType, VectorType, BitVectorType>:: +template <class MatrixType, class VectorType, class BitVectorType> +VectorType MultigridStep<MatrixType, VectorType, BitVectorType>:: getSol() { return this->x_[numLevels_-1]; } -template<class OperatorType, class VectorType, class BitVectorType> +template<class MatrixType, class VectorType, class BitVectorType> inline -const OperatorType* MultigridStep<OperatorType, VectorType, BitVectorType>:: +const MatrixType* MultigridStep<MatrixType, VectorType, BitVectorType>:: getMatrix() { return this->mat_[this->mat_.size()-1]; } -template<class OperatorType, class VectorType, class BitVectorType> +template<class MatrixType, class VectorType, class BitVectorType> inline -void MultigridStep<OperatorType, VectorType, BitVectorType>:: +void MultigridStep<MatrixType, VectorType, BitVectorType>:: setMGType(int mu, int nu1, int nu2) { mu_ = mu; @@ -34,8 +34,8 @@ setMGType(int mu, int nu1, int nu2) nu2_ = nu2; } -template<class OperatorType, class VectorType, class BitVectorType> -void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() +template<class MatrixType, class VectorType, class BitVectorType> +void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess() { if(preprocessCalled) std::cout << "Warning: Preprocess has already been called without calling iterate afterwards!" << std::endl; @@ -66,11 +66,11 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() this->mat_[i] = NULL; } - this->mat_[i] = new OperatorType; + this->mat_[i] = new MatrixType; // Compute which entries are present in the (sparse) coarse grid stiffness // matrices. - this->mgTransfer_[i]->galerkinRestrictSetOccupation(*this->mat_[i+1], *(const_cast<OperatorType*>(this->mat_[i]))); + this->mgTransfer_[i]->galerkinRestrictSetOccupation(*this->mat_[i+1], *(const_cast<MatrixType*>(this->mat_[i]))); // Set solution vector sizes for the lower levels GenericVector::resize(this->x_[i],*this->mat_[i]); @@ -80,7 +80,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() // Assemble the complete hierarchy of matrices // ///////////////////////////////////////////////////// for (i=this->mgTransfer_.size()-1; i>=0; i--) - this->mgTransfer_[i]->galerkinRestrict(*this->mat_[i+1], *(const_cast<OperatorType*>(this->mat_[i]))); + this->mgTransfer_[i]->galerkinRestrict(*this->mat_[i+1], *(const_cast<MatrixType*>(this->mat_[i]))); // ///////////////////////////////////////////////////// // Setup dirichlet bitfields @@ -100,7 +100,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() DUNE_THROW(SolverError, "We need a set of nodes to ignore"); for (i=this->mgTransfer_.size()-1; i>=0; i--) - this->mgTransfer_[i]->galerkinRestrict(*this->mat_[i+1], *(const_cast<OperatorType*>(this->mat_[i]))); + this->mgTransfer_[i]->galerkinRestrict(*this->mat_[i+1], *(const_cast<MatrixType*>(this->mat_[i]))); // ///////////////////////////////////////////// // Set up base solver @@ -119,7 +119,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() DuneSolversLoopSolver* loopBaseSolver = dynamic_cast<DuneSolversLoopSolver*> (this->basesolver_); - typedef LinearIterationStep<OperatorType, VectorType> SmootherType; + typedef LinearIterationStep<MatrixType, VectorType> SmootherType; assert(dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)); dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->setProblem(*(this->mat_[0]), this->x_[0], this->rhs_[0]); @@ -127,9 +127,9 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() } #ifdef HAVE_IPOPT - else if (typeid(*this->basesolver_) == typeid(QuadraticIPOptSolver<OperatorType,VectorType>)) { + else if (typeid(*this->basesolver_) == typeid(QuadraticIPOptSolver<MatrixType,VectorType>)) { - QuadraticIPOptSolver<OperatorType,VectorType>* ipoptBaseSolver = dynamic_cast<QuadraticIPOptSolver<OperatorType,VectorType>*> (this->basesolver_); + QuadraticIPOptSolver<MatrixType,VectorType>* ipoptBaseSolver = dynamic_cast<QuadraticIPOptSolver<MatrixType,VectorType>*> (this->basesolver_); ipoptBaseSolver->setProblem(*(this->mat_[0]), this->x_[0], this->rhs_[0]); } @@ -142,8 +142,8 @@ else { -template<class OperatorType, class VectorType, class BitVectorType> -void MultigridStep<OperatorType, VectorType, BitVectorType>::nestedIteration() +template<class MatrixType, class VectorType, class BitVectorType> +void MultigridStep<MatrixType, VectorType, BitVectorType>::nestedIteration() { for (level_ = 0; level_<numLevels_; level_++) { @@ -158,22 +158,22 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::nestedIteration() } -template<class OperatorType, class VectorType, class BitVectorType> -void MultigridStep<OperatorType, VectorType, BitVectorType>::postprocess() +template<class MatrixType, class VectorType, class BitVectorType> +void MultigridStep<MatrixType, VectorType, BitVectorType>::postprocess() { } -template<class OperatorType, class VectorType, class BitVectorType> -void MultigridStep<OperatorType, VectorType, BitVectorType>::iterate() +template<class MatrixType, class VectorType, class BitVectorType> +void MultigridStep<MatrixType, VectorType, BitVectorType>::iterate() { preprocessCalled = false; int& level = this->level_; // Define references just for ease of notation - std::vector<const OperatorType*>& mat = this->mat_; + std::vector<const MatrixType*>& mat = this->mat_; std::vector<VectorType>& x = this->x_; std::vector<VectorType>& rhs = this->rhs_; diff --git a/dune/solvers/iterationsteps/multigridstep.hh b/dune/solvers/iterationsteps/multigridstep.hh index ac18ac10..5eebf0b8 100644 --- a/dune/solvers/iterationsteps/multigridstep.hh +++ b/dune/solvers/iterationsteps/multigridstep.hh @@ -11,10 +11,10 @@ /** \brief A linear multigrid step */ template< - class OperatorType, + class MatrixType, class VectorType, class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> > - class MultigridStep : public LinearIterationStep<OperatorType, VectorType, BitVectorType> + class MultigridStep : public LinearIterationStep<MatrixType, VectorType, BitVectorType> { static const int blocksize = VectorType::block_type::dimension; @@ -30,15 +30,15 @@ preprocessCalled(false) {} - MultigridStep(const OperatorType& mat, + MultigridStep(const MatrixType& mat, VectorType& x, VectorType& rhs, int numLevels, int mu, int nu1, int nu2, - LinearIterationStep<OperatorType, VectorType>* preSmoother, - LinearIterationStep<OperatorType, VectorType>* postSmoother, + LinearIterationStep<MatrixType, VectorType>* preSmoother, + LinearIterationStep<MatrixType, VectorType>* postSmoother, Solver* baseSolver, const BitVectorType* ignoreNodes) : - LinearIterationStep<OperatorType, VectorType>(mat, x, rhs), + LinearIterationStep<MatrixType, VectorType>(mat, x, rhs), presmoother_(numLevels), postsmoother_(numLevels), mat_(numLevels), ignoreNodesHierarchy_(numLevels), @@ -64,10 +64,10 @@ this->ignoreNodes_ = ignoreNodes; } - MultigridStep(const OperatorType& mat, + MultigridStep(const MatrixType& mat, VectorType& x, VectorType& rhs, int numLevels) : - LinearIterationStep<OperatorType, VectorType>(mat, x, rhs), + LinearIterationStep<MatrixType, VectorType>(mat, x, rhs), presmoother_(numLevels),postsmoother_(numLevels), basesolver_(0), mat_(numLevels), @@ -94,7 +94,7 @@ } } - virtual void setProblem(const OperatorType& mat, + virtual void setProblem(const MatrixType& mat, VectorType& x, VectorType& rhs, int numLevels) @@ -131,7 +131,7 @@ rhs_.resize(numLevels); } - virtual void setProblem(const OperatorType& mat, + virtual void setProblem(const MatrixType& mat, VectorType& x, VectorType& rhs) { @@ -163,7 +163,7 @@ virtual VectorType getSol(); - virtual const OperatorType* getMatrix(); + virtual const MatrixType* getMatrix(); virtual int level() const {return level_;} @@ -176,14 +176,14 @@ virtual void setMGType(int mu, int nu1, int nu2); /** \brief Set the smoother iteration step */ - virtual void setSmoother(LinearIterationStep<OperatorType, VectorType>* smoother) { + virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* smoother) { for (size_t i=0; i<presmoother_.size(); i++) presmoother_[i] = postsmoother_[i] = smoother; } /** \brief Set pre- and post smoothers individually */ - virtual void setSmoother(LinearIterationStep<OperatorType, VectorType>* preSmoother, - LinearIterationStep<OperatorType, VectorType>* postSmoother) { + virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* preSmoother, + LinearIterationStep<MatrixType, VectorType>* postSmoother) { for (size_t i=0; i<presmoother_.size(); i++) { presmoother_[i] = preSmoother; postsmoother_[i] = postSmoother; @@ -191,17 +191,17 @@ } /** \brief Set the smoother iteration step for a particular level */ - virtual void setSmoother(LinearIterationStep<OperatorType, VectorType>* smoother, + virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* smoother, int level) { presmoother_[level] = postsmoother_[level] = smoother; } protected: /** \brief The presmoothers, one for each level */ - std::vector<LinearIterationStep<OperatorType, VectorType>*> presmoother_; + std::vector<LinearIterationStep<MatrixType, VectorType>*> presmoother_; /** \brief The postsmoothers, one for each level */ - std::vector<LinearIterationStep<OperatorType, VectorType>*> postsmoother_; + std::vector<LinearIterationStep<MatrixType, VectorType>*> postsmoother_; public: /** \brief The base solver */ @@ -225,7 +225,7 @@ public: //! The linear operators on each level - std::vector<const OperatorType*> mat_; + std::vector<const MatrixType*> mat_; protected: //! Flags specifying the dirichlet nodes on each level @@ -237,7 +237,7 @@ std::vector<VectorType> rhs_; //protected: - std::vector<MultigridTransfer<VectorType, BitVectorType, OperatorType>* > mgTransfer_; + std::vector<MultigridTransfer<VectorType, BitVectorType, MatrixType>* > mgTransfer_; protected: bool preprocessCalled; -- GitLab