diff --git a/dune/solvers/iterationsteps/blockgsstep.cc b/dune/solvers/iterationsteps/blockgsstep.cc index 95115222bab1c57e6b52a1406ecbf59807cb1cae..926445c24adec0d3a7aefbf22388824f2e276bc9 100644 --- a/dune/solvers/iterationsteps/blockgsstep.cc +++ b/dune/solvers/iterationsteps/blockgsstep.cc @@ -30,7 +30,7 @@ template<class MatrixType, class DiscFuncType, class BitVectorType> inline void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate() { - assert(this->ignoreNodes_ != NULL); + assert(this->ignoreNodes_ != nullptr); if (gs_type_ != Direction::BACKWARD) for (std::size_t i=0; i<this->x_->size(); i++) @@ -47,8 +47,8 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i) { const MatrixType& mat = *this->mat_; - size_t const count = (*this->ignoreNodes_)[i].count(); - if (count == BlockSize) + auto const &ignore_i = this->ignore()[i]; + if (ignore_i.all()) return; VectorBlock r; @@ -58,7 +58,7 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i) // Compute correction v = A_{i,i}^{-1} r[i] VectorBlock v; - if (count == 0) { + if (ignore_i.none()) { // No degree of freedom shall be ignored --> solve linear problem mat_ii.solve(v, r); } else { @@ -66,7 +66,7 @@ void BlockGSStep<MatrixType, DiscFuncType, BitVectorType>::iterate_step(int i) // are not touched typename MatrixType::block_type matRes; for (int j = 0; j < BlockSize; ++j) { - if ((*this->ignoreNodes_)[i][j]) { + if (ignore_i[j]) { r[j] = 0; for (int k = 0; k < BlockSize; ++k) diff --git a/dune/solvers/iterationsteps/blockgssteps.hh b/dune/solvers/iterationsteps/blockgssteps.hh index d05a37b911d3153b8570c468c14e3c4118eefed5..aa995c0957657b617af58b33a2033eaf01be2a49 100644 --- a/dune/solvers/iterationsteps/blockgssteps.hh +++ b/dune/solvers/iterationsteps/blockgssteps.hh @@ -60,7 +60,7 @@ template <class M, class V, class BitVector, class LocalSolver> void linearStep(LinearIterationStep<M, V, BitVector>& lis, LocalSolver&& localSolver, Direction direction = Direction::FORWARD) { - return linearStep(*lis.mat_, *lis.x_, *lis.rhs_, *lis.ignoreNodes_, + return linearStep(*lis.mat_, *lis.x_, *lis.rhs_, lis.ignore(), std::forward<LocalSolver>(localSolver), direction); } diff --git a/dune/solvers/iterationsteps/cgstep.cc b/dune/solvers/iterationsteps/cgstep.cc index a34354a31eb4342e3512858d2a15de7f30d9b8ae..4e00a3bb9fca0c9de51cbd3ca513f0897aa186fe 100644 --- a/dune/solvers/iterationsteps/cgstep.cc +++ b/dune/solvers/iterationsteps/cgstep.cc @@ -14,7 +14,7 @@ void CGStep<MatrixType, VectorType>::preprocess() // Compute the residual (r starts out as the rhs) matrix_->mmv(*x_,r_); for (size_t i=0; i < r_.size(); ++i) - if ((*this->ignoreNodes_)[i].any()) + if (this->ignore()[i].any()) r_[i] = 0; if (preconditioner_) { @@ -37,7 +37,7 @@ void CGStep<MatrixType, VectorType>::iterate() r_.axpy(-alpha, q); // r_1 = r_0 - alpha_0 Ap_0 for (size_t i=0; i < r_.size(); ++i) - if ((*this->ignoreNodes_)[i].any()) + if (this->ignore()[i].any()) r_[i] = 0; if (preconditioner_) diff --git a/dune/solvers/iterationsteps/iterationstep.hh b/dune/solvers/iterationsteps/iterationstep.hh index d2ce942d5dee3706842a48574ab35ed6920aa00a..94bf5963ac0fc88330a12949083709c5a93f2050 100644 --- a/dune/solvers/iterationsteps/iterationstep.hh +++ b/dune/solvers/iterationsteps/iterationstep.hh @@ -78,10 +78,6 @@ class IterationStep : virtual public NumProc, public CanIgnore<BitVectorType> //! The solution container VectorType* x_; - - - using CanIgnore<BitVectorType>::ignoreNodes_; - }; #endif diff --git a/dune/solvers/iterationsteps/linegsstep.cc b/dune/solvers/iterationsteps/linegsstep.cc index a3d0d6b87cdd978277782895ff7135d154375d09..aada568c86d0156375adb1d7c32349f7b39b13a0 100755 --- a/dune/solvers/iterationsteps/linegsstep.cc +++ b/dune/solvers/iterationsteps/linegsstep.cc @@ -29,7 +29,7 @@ void LineGSStep<MatrixType, DiscFuncType, BitVectorType >::iterate() DiscFuncType permuted_r_i(current_block_size); for (int k=0; k<current_block_size; k++) { - if ( (*this->ignoreNodes_)[blockStructure_[b_num][k]][0]) + if ( this->ignore()[blockStructure_[b_num][k]][0]) permuted_r_i[k] = 0.0; else this->residual( blockStructure_[b_num][k], permuted_r_i[k]); // get r[p(i+k)] @@ -49,7 +49,7 @@ void LineGSStep<MatrixType, DiscFuncType, BitVectorType >::iterate() for (int j=0; j<current_block_size; j++) { - if ( (*this->ignoreNodes_)[blockStructure_[b_num][j]][0] ) { + if ( this->ignore()[blockStructure_[b_num][j]][0] ) { // left off-diagonal: if (j>0) diff --git a/dune/solvers/iterationsteps/obstacletnnmgstep.hh b/dune/solvers/iterationsteps/obstacletnnmgstep.hh index 04d232e5615c50470733559daa0a7da9cbdcf03d..8f369cfb3e8a370ca08805e9f403b5d49b0e4c41 100644 --- a/dune/solvers/iterationsteps/obstacletnnmgstep.hh +++ b/dune/solvers/iterationsteps/obstacletnnmgstep.hh @@ -120,7 +120,7 @@ class ObstacleTNNMGStep linearPreSmoothingSteps_(3), linearPostSmoothingSteps_(3) { - ignoreNodes_ = &ignore; + this->setIgnore(ignore); } /** @@ -377,7 +377,7 @@ class ObstacleTNNMGStep transfer_[maxLevel-1]->galerkinRestrictSetOccupation(mat_, coarseMatrix[maxLevel-1]); transfer_[maxLevel-1]->galerkinRestrict(mat_, coarseMatrix[maxLevel-1]); transfer_[maxLevel-1]->restrict(rhs_, coarseRhs[maxLevel-1]); - transfer_[maxLevel-1]->restrictToFathers(*ignoreNodes_, coarseIgnore[maxLevel-1]); + transfer_[maxLevel-1]->restrictToFathers(this->ignore(), coarseIgnore[maxLevel-1]); obstacleRestrictor.restrict(obstacles_, coarseObstacle[maxLevel-1], hasObstacle_, hasObstacle_, *(transfer_[maxLevel-1]), critical); coarseSolution[maxLevel-1].resize(coarseMatrix[maxLevel-1].N()); for (int i = maxLevel-2; i>=0; --i) diff --git a/dune/solvers/iterationsteps/projectedblockgsstep.cc b/dune/solvers/iterationsteps/projectedblockgsstep.cc index 981c6b7b4d0c59d8379f06760ee77d6e0a4b91b5..83e28e0e3e1a86b63e38383ab3890f44cc744a8f 100644 --- a/dune/solvers/iterationsteps/projectedblockgsstep.cc +++ b/dune/solvers/iterationsteps/projectedblockgsstep.cc @@ -12,10 +12,9 @@ void ProjectedBlockGSStep<MatrixType, VectorType>::iterate() const MatrixType& mat = *this->mat_; for (size_t i=0; i<this->x_->size(); i++) { - auto ignoreCount = (*this->ignoreNodes_)[i].count(); - if (ignoreCount == BlockSize) + if (this->ignore()[i].all()) continue; - if (ignoreCount > 0) + if (this->ignore()[i].any()) DUNE_THROW(Dune::NotImplemented, "Individual blocks must be either ignored completely, or not at all"); diff --git a/dune/solvers/iterationsteps/projectedgradientstep.cc b/dune/solvers/iterationsteps/projectedgradientstep.cc index debdd8a8464c2d10a5f4828a5990c2dcaf2fa92b..1cff07b9247cb6e0137d3025693035df2b9af9f5 100644 --- a/dune/solvers/iterationsteps/projectedgradientstep.cc +++ b/dune/solvers/iterationsteps/projectedgradientstep.cc @@ -25,7 +25,7 @@ inline void ProjectedGradientStep<MatrixType, VectorType>::computeGeneralizedCP( for (size_t i=0; i<obstacles_->size(); i++) for (int j=0; j<blocksize; j++) { - if ((*this->ignoreNodes_)[i][j]) { + if (this->ignore()[i][j]) { projGrad[i][j]=0; continue; } diff --git a/dune/solvers/iterationsteps/projectedlinegsstep.cc b/dune/solvers/iterationsteps/projectedlinegsstep.cc index 6b806b2ba728ba0400af74fe1086fa1e04b27dae..dab1236f62aeb34bfcd89b4682f7c25d5808f947 100755 --- a/dune/solvers/iterationsteps/projectedlinegsstep.cc +++ b/dune/solvers/iterationsteps/projectedlinegsstep.cc @@ -43,7 +43,7 @@ solveLocalSystem(const Dune::BTDMatrix<typename MatrixType::block_type>& matrix, ProjectedBlockGSStep<LocalMatrixType, VectorType> nonlinearSmootherStep(matrix, x, rhsCopy); - nonlinearSmootherStep.ignoreNodes_ = &ignoreNodes; + nonlinearSmootherStep.setIgnore(ignoreNodes); nonlinearSmootherStep.hasObstacle_ = &hasObstacle; nonlinearSmootherStep.obstacles_ = &localObstacles; @@ -184,7 +184,7 @@ void ProjectedLineGSStep<MatrixType, VectorType, BitVectorType>::iterate() VectorType permuted_r_i(current_block_size); for (int k=0; k<current_block_size; k++) { - if ( (*this->ignoreNodes_)[this->blockStructure_[b_num][k]][0]) + if ( this->ignore()[this->blockStructure_[b_num][k]][0]) permuted_r_i[k] = 0.0; else this->residual( this->blockStructure_[b_num][k], permuted_r_i[k]); // get r[p(i+k)] @@ -204,7 +204,7 @@ void ProjectedLineGSStep<MatrixType, VectorType, BitVectorType>::iterate() for (int j=0; j<current_block_size; j++) { - if ( (*this->ignoreNodes_)[this->blockStructure_[b_num][j]][0] ) { + if ( this->ignore()[this->blockStructure_[b_num][j]][0] ) { // left off-diagonal: if (j>0) diff --git a/dune/solvers/iterationsteps/semidefiniteblockgsstep.hh b/dune/solvers/iterationsteps/semidefiniteblockgsstep.hh index fe6dbe44e15ea47abe9a84cb4c13be3071705fc7..2b9cbd1e733a3c25e8bbc93c7dacdc4828018ad5 100644 --- a/dune/solvers/iterationsteps/semidefiniteblockgsstep.hh +++ b/dune/solvers/iterationsteps/semidefiniteblockgsstep.hh @@ -119,7 +119,7 @@ public: virtual void iterate() { const MatrixType& mat = *(this->mat_); const VectorType& rhs = *(this->rhs_); - const BitVectorType& ignore = *(this->ignoreNodes_); + const BitVectorType& ignore = this->ignore(); VectorType& x = *(this->x_); for (size_t i=0; i<mat.N(); ++i) { diff --git a/dune/solvers/iterationsteps/truncatedblockgsstep.hh b/dune/solvers/iterationsteps/truncatedblockgsstep.hh index 42511d8575f3693f6532b116f6d7e6e7b4b5ce5e..bd9b1433a99896959c62f4411f01a10fe3a0304a 100644 --- a/dune/solvers/iterationsteps/truncatedblockgsstep.hh +++ b/dune/solvers/iterationsteps/truncatedblockgsstep.hh @@ -42,7 +42,7 @@ public: //! Perform one iteration virtual void iterate() { - TruncatedBlockGSStepNS::RecursiveGSStep<MatrixType::blocklevel>::apply(*this->mat_, *this->rhs_, *this->ignoreNodes_, *this->x_, innerLoops_); + TruncatedBlockGSStepNS::RecursiveGSStep<MatrixType::blocklevel>::apply(*this->mat_, *this->rhs_, this->ignore(), *this->x_, innerLoops_); } protected: @@ -166,7 +166,7 @@ public: const LowRankMatrixType& lowrank_mat = mat.lowRankMatrix(); const VectorType& rhs = *this->rhs_; VectorType& x = *this->x_; - const BitVectorType& ignore = *this->ignoreNodes_; + const BitVectorType& ignore = this->ignore(); // compute m*x once and only add/subtract single summands in the iterations later VectorType mx(lowrank_mat.lowRankFactor().N()); diff --git a/dune/solvers/iterationsteps/truncatedsaddlepointgsstep.hh b/dune/solvers/iterationsteps/truncatedsaddlepointgsstep.hh index b47d5922f9ccd016edf25e27eae7eea580de5b3f..2a299331525a24bd08879a3753143500e3eeecd6 100644 --- a/dune/solvers/iterationsteps/truncatedsaddlepointgsstep.hh +++ b/dune/solvers/iterationsteps/truncatedsaddlepointgsstep.hh @@ -31,7 +31,6 @@ public: { const MatrixType& mat = *this->mat_; const VectorType& rhs = *this->rhs_; - const BitVectorType& ignore = *this->ignoreNodes_; VectorType& x = *this->x_; typedef typename VectorType::block_type VectorBlock; diff --git a/dune/solvers/iterationsteps/trustregiongsstep.cc b/dune/solvers/iterationsteps/trustregiongsstep.cc index ef95d3cf0075a5e325f704e37143a2451f27194c..5bd9c1951c24c15676cac6e8a0658edd9b037d6d 100644 --- a/dune/solvers/iterationsteps/trustregiongsstep.cc +++ b/dune/solvers/iterationsteps/trustregiongsstep.cc @@ -13,10 +13,10 @@ void TrustRegionGSStep<MatrixType, VectorType>::iterate() // Dirichlet nodes in this block std::bitset<BlockSize> ignoreNodes(0); - if (this->ignoreNodes_) - ignoreNodes = (*this->ignoreNodes_)[i]; + if (this->ignoreNodes_ != nullptr) + ignoreNodes = this->ignore()[i]; - if (ignoreNodes.count() == BlockSize) + if (ignoreNodes.all()) continue; VectorBlock blockResidual; diff --git a/dune/solvers/solvers/trustregionsolver.cc b/dune/solvers/solvers/trustregionsolver.cc index 3f65815b8199387026fd6bf878e8f3e8f73123fb..6ed0930346db8613b563b107e4614d4e18db0fe4 100644 --- a/dune/solvers/solvers/trustregionsolver.cc +++ b/dune/solvers/solvers/trustregionsolver.cc @@ -53,7 +53,7 @@ void TrustRegionSolver<ProblemType,VectorType,MatrixType>::solve() VectorType gradient = problem_->f_; for (size_t j=0; j<gradient.size(); j++) for (int k=0; k<gradient[j].size(); k++) - if ((*mgStep->ignoreNodes_)[j][k]) + if (mgStep.ignore()[j][k]) gradient[j][k] = 0; if (this->verbosity_ == Solver::FULL) diff --git a/dune/solvers/solvers/umfpacksolver.hh b/dune/solvers/solvers/umfpacksolver.hh index 1c1becd675286229ae372210b6c83ce5069f472c..f2a36ac82cf11f88f18a37bcdb21a2f94a8d6f12 100644 --- a/dune/solvers/solvers/umfpacksolver.hh +++ b/dune/solvers/solvers/umfpacksolver.hh @@ -70,7 +70,7 @@ public: // We may use the original rhs, but ISTL modifies it, so we need a non-const type here VectorType mutableRhs = *rhs_; - if (not this->ignoreNodes_) + if (this->ignoreNodes_ == nullptr) { ///////////////////////////////////////////////////////////////// // Solve the system @@ -93,10 +93,10 @@ public: std::set<std::size_t> nonIgnoreRows; for (size_t i=0; i<matrix_->N(); i++) { - auto ignoreCount = (*this->ignoreNodes_)[i].count(); - if (ignoreCount==0) + auto const &ignore = this->ignore()[i]; + if (ignore.none()) nonIgnoreRows.insert(i); - else if (ignoreCount!=blocksize) + else if (not ignore.all()) DUNE_THROW(Dune::NotImplemented, "Individual blocks must be either ignored completely, or not at all"); } @@ -117,14 +117,14 @@ public: shortRowCount = 0; for (size_t i=0; i<matrix_->N(); i++) { - if ((*this->ignoreNodes_)[i][0]) + if (this->ignore()[i].all()) continue; auto cIt = (*matrix_)[i].begin(); auto cEndIt = (*matrix_)[i].end(); for (; cIt!=cEndIt; ++cIt) - if ((*this->ignoreNodes_)[cIt.index()][0]) + if (this->ignore()[cIt.index()].all()) cIt->mmv((*x_)[cIt.index()], shortRhs[shortRowCount]); shortRowCount++; diff --git a/dune/solvers/test/mmgtest.cc b/dune/solvers/test/mmgtest.cc index 3b534924ff53ee8485871fa9358ffcad887e19a8..56aec597d7e17f878d22d730325a60e418e54d8f 100644 --- a/dune/solvers/test/mmgtest.cc +++ b/dune/solvers/test/mmgtest.cc @@ -55,7 +55,7 @@ void solveObstacleProblemByMMGSolver(const GridType& grid, const MatrixType& mat mmgStep.setProblem(mat,x,rhs); mmgStep.setMGType(1, 3, 3); - mmgStep.ignoreNodes_ = &ignore; + mmgStep.setIgnore(ignore); mmgStep.basesolver_ = &baseSolver; mmgStep.setSmoother(&smoother); MandelObstacleRestrictor<VectorType> obsRestrictor;