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

Remove the numLevels_ data member.

Because it is obsolete now that the number of levels
is officially inferred from the number of transfer operators.

[[Imported from SVN: r7641]]
parent 554dddf7
No related branches found
No related tags found
No related merge requests found
......@@ -58,9 +58,7 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
std::cout << "Warning: Preprocess has already been called without calling iterate afterwards!" << std::endl;
preprocessCalled = true;
numLevels_ = mgTransfer_.size() + 1;
this->level_ = this->numLevels_-1;
this->level_ = numLevels()-1;
// //////////////////////////////////////////////////////////
// Check that transfer operators have been supplied
......@@ -72,17 +70,17 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
// //////////////////////////////////////////////////////////
// Resize hierarchy containers to current numLevels_
// Resize hierarchy containers to current number of levels
// and set fine level data where needed.
// //////////////////////////////////////////////////////////
for (int i=0; i<int(ignoreNodesHierarchy_.size())-1; i++)
if (ignoreNodesHierarchy_[i])
delete(ignoreNodesHierarchy_[i]);
xHierarchy_.resize(numLevels_);
rhsHierarchy_.resize(numLevels_);
matrixHierarchy_.resize(numLevels_);
ignoreNodesHierarchy_.resize(numLevels_);
xHierarchy_.resize(numLevels());
rhsHierarchy_.resize(numLevels());
matrixHierarchy_.resize(numLevels());
ignoreNodesHierarchy_.resize(numLevels());
for (int i=0; i<int(matrixHierarchy_.size())-1; i++)
{
......@@ -95,11 +93,11 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
xHierarchy_.back() = Dune::stackobject_to_shared_ptr(*(this->x_));
rhsHierarchy_.back() = *(this->rhs_);
presmoother_.resize(numLevels_);
postsmoother_.resize(numLevels_);
presmoother_.resize(numLevels());
postsmoother_.resize(numLevels());
typename SmootherCache::iterator end=levelWiseSmoothers_.end();
for (size_t i=0; i<numLevels_; ++i)
for (size_t i=0; i<numLevels(); ++i)
{
typename SmootherCache::iterator levelSmoother = levelWiseSmoothers_.find(i);
if (levelSmoother != end)
......@@ -114,7 +112,7 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
// /////////////////////////////////////////////////////
// Assemble the complete hierarchy of matrices
// /////////////////////////////////////////////////////
for (int i=this->numLevels_-2; i>=0; i--)
for (int i=this->numLevels()-2; i>=0; i--)
{
this->matrixHierarchy_[i] = Dune::shared_ptr<MatrixType>(new MatrixType);
this->xHierarchy_[i] = Dune::shared_ptr<VectorType>(new VectorType);
......@@ -135,8 +133,8 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
// /////////////////////////////////////////////////////
if (this->ignoreNodes_!=0)
{
ignoreNodesHierarchy_[this->numLevels_-1] = const_cast<BitVectorType*>(this->ignoreNodes_);
for (int i=this->numLevels_-2; i>=0; --i)
ignoreNodesHierarchy_[numLevels()-1] = const_cast<BitVectorType*>(this->ignoreNodes_);
for (int i=numLevels()-2; i>=0; --i)
{
ignoreNodesHierarchy_[i] = new BitVectorType();
this->mgTransfer_[i]->restrictToFathers(*ignoreNodesHierarchy_[i+1], *ignoreNodesHierarchy_[i]);
......@@ -186,7 +184,7 @@ else {
template<class MatrixType, class VectorType, class BitVectorType>
void MultigridStep<MatrixType, VectorType, BitVectorType>::nestedIteration()
{
for (level_ = 0; level_<numLevels_; level_++)
for (level_ = 0; level_<numLevels(); level_++)
{
iterate();
......
......@@ -26,7 +26,6 @@
presmoother_(0),
postsmoother_(0),
basesolver_(0),
numLevels_(0),
ignoreNodesHierarchy_(0),
preprocessCalled(false)
{}
......@@ -48,7 +47,6 @@
rhsHierarchy_(numLevels),
preprocessCalled(false)
{
numLevels_ = numLevels;
level_ = numLevels-1;
mu_ = mu;
......@@ -98,7 +96,6 @@
rhsHierarchy_(numLevels),
preprocessCalled(false)
{
numLevels_ = numLevels;
level_ = numLevels-1;
}
......@@ -136,7 +133,7 @@
VectorType& x,
const VectorType& rhs)
{
level_ = numLevels_-1;
level_ = numLevels()-1;
LinearIterationStep<MatrixType, VectorType, BitVectorType>::setProblem(mat,x,rhs);
// Preprocess must be called again, to create the new matrix hierarchy
......@@ -145,7 +142,7 @@
void setRhs(const VectorType& rhs)
{
level_ = numLevels_-1;
level_ = numLevels()-1;
this->rhs_ = &rhs;
rhsHierarchy_.back() = rhs;
}
......@@ -248,9 +245,6 @@
//! Variable used to store the current level
int level_;
//! The total number of levels of the underlying grid
int numLevels_;
//! The linear operators on each level
std::vector<Dune::shared_ptr<const MatrixType> > matrixHierarchy_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment