Skip to content
Snippets Groups Projects
Commit 27503a93 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

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]]
parent 5250ce18
No related branches found
No related tags found
No related merge requests found
...@@ -9,24 +9,24 @@ ...@@ -9,24 +9,24 @@
#include <dune/solvers/solvers/quadraticipopt.hh> #include <dune/solvers/solvers/quadraticipopt.hh>
#endif #endif
template <class OperatorType, class VectorType, class BitVectorType> template <class MatrixType, class VectorType, class BitVectorType>
VectorType MultigridStep<OperatorType, VectorType, BitVectorType>:: VectorType MultigridStep<MatrixType, VectorType, BitVectorType>::
getSol() getSol()
{ {
return this->x_[numLevels_-1]; return this->x_[numLevels_-1];
} }
template<class OperatorType, class VectorType, class BitVectorType> template<class MatrixType, class VectorType, class BitVectorType>
inline inline
const OperatorType* MultigridStep<OperatorType, VectorType, BitVectorType>:: const MatrixType* MultigridStep<MatrixType, VectorType, BitVectorType>::
getMatrix() getMatrix()
{ {
return this->mat_[this->mat_.size()-1]; return this->mat_[this->mat_.size()-1];
} }
template<class OperatorType, class VectorType, class BitVectorType> template<class MatrixType, class VectorType, class BitVectorType>
inline inline
void MultigridStep<OperatorType, VectorType, BitVectorType>:: void MultigridStep<MatrixType, VectorType, BitVectorType>::
setMGType(int mu, int nu1, int nu2) setMGType(int mu, int nu1, int nu2)
{ {
mu_ = mu; mu_ = mu;
...@@ -34,8 +34,8 @@ setMGType(int mu, int nu1, int nu2) ...@@ -34,8 +34,8 @@ setMGType(int mu, int nu1, int nu2)
nu2_ = nu2; nu2_ = nu2;
} }
template<class OperatorType, class VectorType, class BitVectorType> template<class MatrixType, class VectorType, class BitVectorType>
void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
{ {
if(preprocessCalled) if(preprocessCalled)
std::cout << "Warning: Preprocess has already been called without calling iterate afterwards!" << std::endl; std::cout << "Warning: Preprocess has already been called without calling iterate afterwards!" << std::endl;
...@@ -66,11 +66,11 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() ...@@ -66,11 +66,11 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess()
this->mat_[i] = NULL; 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 // Compute which entries are present in the (sparse) coarse grid stiffness
// matrices. // 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 // Set solution vector sizes for the lower levels
GenericVector::resize(this->x_[i],*this->mat_[i]); GenericVector::resize(this->x_[i],*this->mat_[i]);
...@@ -80,7 +80,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() ...@@ -80,7 +80,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess()
// Assemble the complete hierarchy of matrices // Assemble the complete hierarchy of matrices
// ///////////////////////////////////////////////////// // /////////////////////////////////////////////////////
for (i=this->mgTransfer_.size()-1; i>=0; i--) 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 // Setup dirichlet bitfields
...@@ -100,7 +100,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() ...@@ -100,7 +100,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess()
DUNE_THROW(SolverError, "We need a set of nodes to ignore"); DUNE_THROW(SolverError, "We need a set of nodes to ignore");
for (i=this->mgTransfer_.size()-1; i>=0; i--) 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 // Set up base solver
...@@ -119,7 +119,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess() ...@@ -119,7 +119,7 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess()
DuneSolversLoopSolver* loopBaseSolver = dynamic_cast<DuneSolversLoopSolver*> (this->basesolver_); DuneSolversLoopSolver* loopBaseSolver = dynamic_cast<DuneSolversLoopSolver*> (this->basesolver_);
typedef LinearIterationStep<OperatorType, VectorType> SmootherType; typedef LinearIterationStep<MatrixType, VectorType> SmootherType;
assert(dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)); assert(dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_));
dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->setProblem(*(this->mat_[0]), this->x_[0], this->rhs_[0]); 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() ...@@ -127,9 +127,9 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::preprocess()
} }
#ifdef HAVE_IPOPT #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]); ipoptBaseSolver->setProblem(*(this->mat_[0]), this->x_[0], this->rhs_[0]);
} }
...@@ -142,8 +142,8 @@ else { ...@@ -142,8 +142,8 @@ else {
template<class OperatorType, class VectorType, class BitVectorType> template<class MatrixType, class VectorType, class BitVectorType>
void MultigridStep<OperatorType, VectorType, BitVectorType>::nestedIteration() void MultigridStep<MatrixType, VectorType, BitVectorType>::nestedIteration()
{ {
for (level_ = 0; level_<numLevels_; level_++) { for (level_ = 0; level_<numLevels_; level_++) {
...@@ -158,22 +158,22 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::nestedIteration() ...@@ -158,22 +158,22 @@ void MultigridStep<OperatorType, VectorType, BitVectorType>::nestedIteration()
} }
template<class OperatorType, class VectorType, class BitVectorType> template<class MatrixType, class VectorType, class BitVectorType>
void MultigridStep<OperatorType, VectorType, BitVectorType>::postprocess() void MultigridStep<MatrixType, VectorType, BitVectorType>::postprocess()
{ {
} }
template<class OperatorType, class VectorType, class BitVectorType> template<class MatrixType, class VectorType, class BitVectorType>
void MultigridStep<OperatorType, VectorType, BitVectorType>::iterate() void MultigridStep<MatrixType, VectorType, BitVectorType>::iterate()
{ {
preprocessCalled = false; preprocessCalled = false;
int& level = this->level_; int& level = this->level_;
// Define references just for ease of notation // 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>& x = this->x_;
std::vector<VectorType>& rhs = this->rhs_; std::vector<VectorType>& rhs = this->rhs_;
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
/** \brief A linear multigrid step */ /** \brief A linear multigrid step */
template< template<
class OperatorType, class MatrixType,
class VectorType, class VectorType,
class BitVectorType = Dune::BitSetVector<VectorType::block_type::dimension> > 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; static const int blocksize = VectorType::block_type::dimension;
...@@ -30,15 +30,15 @@ ...@@ -30,15 +30,15 @@
preprocessCalled(false) preprocessCalled(false)
{} {}
MultigridStep(const OperatorType& mat, MultigridStep(const MatrixType& mat,
VectorType& x, VectorType& x,
VectorType& rhs, int numLevels, VectorType& rhs, int numLevels,
int mu, int nu1, int nu2, int mu, int nu1, int nu2,
LinearIterationStep<OperatorType, VectorType>* preSmoother, LinearIterationStep<MatrixType, VectorType>* preSmoother,
LinearIterationStep<OperatorType, VectorType>* postSmoother, LinearIterationStep<MatrixType, VectorType>* postSmoother,
Solver* baseSolver, Solver* baseSolver,
const BitVectorType* ignoreNodes) : const BitVectorType* ignoreNodes) :
LinearIterationStep<OperatorType, VectorType>(mat, x, rhs), LinearIterationStep<MatrixType, VectorType>(mat, x, rhs),
presmoother_(numLevels), postsmoother_(numLevels), presmoother_(numLevels), postsmoother_(numLevels),
mat_(numLevels), mat_(numLevels),
ignoreNodesHierarchy_(numLevels), ignoreNodesHierarchy_(numLevels),
...@@ -64,10 +64,10 @@ ...@@ -64,10 +64,10 @@
this->ignoreNodes_ = ignoreNodes; this->ignoreNodes_ = ignoreNodes;
} }
MultigridStep(const OperatorType& mat, MultigridStep(const MatrixType& mat,
VectorType& x, VectorType& x,
VectorType& rhs, int numLevels) : VectorType& rhs, int numLevels) :
LinearIterationStep<OperatorType, VectorType>(mat, x, rhs), LinearIterationStep<MatrixType, VectorType>(mat, x, rhs),
presmoother_(numLevels),postsmoother_(numLevels), presmoother_(numLevels),postsmoother_(numLevels),
basesolver_(0), basesolver_(0),
mat_(numLevels), mat_(numLevels),
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
} }
} }
virtual void setProblem(const OperatorType& mat, virtual void setProblem(const MatrixType& mat,
VectorType& x, VectorType& x,
VectorType& rhs, VectorType& rhs,
int numLevels) int numLevels)
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
rhs_.resize(numLevels); rhs_.resize(numLevels);
} }
virtual void setProblem(const OperatorType& mat, virtual void setProblem(const MatrixType& mat,
VectorType& x, VectorType& x,
VectorType& rhs) VectorType& rhs)
{ {
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
virtual VectorType getSol(); virtual VectorType getSol();
virtual const OperatorType* getMatrix(); virtual const MatrixType* getMatrix();
virtual int level() const {return level_;} virtual int level() const {return level_;}
...@@ -176,14 +176,14 @@ ...@@ -176,14 +176,14 @@
virtual void setMGType(int mu, int nu1, int nu2); virtual void setMGType(int mu, int nu1, int nu2);
/** \brief Set the smoother iteration step */ /** \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++) for (size_t i=0; i<presmoother_.size(); i++)
presmoother_[i] = postsmoother_[i] = smoother; presmoother_[i] = postsmoother_[i] = smoother;
} }
/** \brief Set pre- and post smoothers individually */ /** \brief Set pre- and post smoothers individually */
virtual void setSmoother(LinearIterationStep<OperatorType, VectorType>* preSmoother, virtual void setSmoother(LinearIterationStep<MatrixType, VectorType>* preSmoother,
LinearIterationStep<OperatorType, VectorType>* postSmoother) { LinearIterationStep<MatrixType, VectorType>* postSmoother) {
for (size_t i=0; i<presmoother_.size(); i++) { for (size_t i=0; i<presmoother_.size(); i++) {
presmoother_[i] = preSmoother; presmoother_[i] = preSmoother;
postsmoother_[i] = postSmoother; postsmoother_[i] = postSmoother;
...@@ -191,17 +191,17 @@ ...@@ -191,17 +191,17 @@
} }
/** \brief Set the smoother iteration step for a particular level */ /** \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) { int level) {
presmoother_[level] = postsmoother_[level] = smoother; presmoother_[level] = postsmoother_[level] = smoother;
} }
protected: protected:
/** \brief The presmoothers, one for each level */ /** \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 */ /** \brief The postsmoothers, one for each level */
std::vector<LinearIterationStep<OperatorType, VectorType>*> postsmoother_; std::vector<LinearIterationStep<MatrixType, VectorType>*> postsmoother_;
public: public:
/** \brief The base solver */ /** \brief The base solver */
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
public: public:
//! The linear operators on each level //! The linear operators on each level
std::vector<const OperatorType*> mat_; std::vector<const MatrixType*> mat_;
protected: protected:
//! Flags specifying the dirichlet nodes on each level //! Flags specifying the dirichlet nodes on each level
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
std::vector<VectorType> rhs_; std::vector<VectorType> rhs_;
//protected: //protected:
std::vector<MultigridTransfer<VectorType, BitVectorType, OperatorType>* > mgTransfer_; std::vector<MultigridTransfer<VectorType, BitVectorType, MatrixType>* > mgTransfer_;
protected: protected:
bool preprocessCalled; bool preprocessCalled;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment