Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • lisa_julia.nebel_at_tu-dresden.de/dune-solvers
  • patrick.jaap_at_tu-dresden.de/dune-solvers
  • burchardt_at_igpm.rwth-aachen.de/dune-solvers
  • agnumpde/dune-solvers
4 results
Select Git revision
Show changes
Commits on Source (1)
......@@ -4,6 +4,9 @@
#define DUNE_SOLVERS_COMMON_CANIGNORE_HH
#include <cassert>
#include <memory>
#include <dune/solvers/common/wrapownshare.hh>
/** \brief Abstract base class for solvers and iterationsteps that are
* able to ignore degrees of freedom described by a bit field.
......@@ -18,35 +21,33 @@ public:
/**
* \brief Default constructor
*/
CanIgnore()
: ignoreNodes_(nullptr)
{}
CanIgnore() = default;
/**
* \brief Constructor from bit vector
*
* This class stores a non-owning pointer to the bit vector.
*/
CanIgnore(const BitVector& i)
: ignoreNodes_(&i)
{}
/**
* \brief Destructor
*
* Does NOT delete the bitfield!
* This class
* - stores a non-owning pointer to references
* - moves and owns r-values
* - shares shared_ptrs
*/
~CanIgnore()
template<typename BV>
CanIgnore(BV&& i)
: ignoreNodes_(Dune::Solvers::wrap_own_share<const BitVector>(std::forward<BV>(i)))
{}
/**
* \brief Set bit vector
*
* This class stores a non-owning pointer to the bit vector.
* If i is...
* - an l-value, a non-owning references is stored
* - an r-value, the value is moved and owned
* - a shared_ptr, i is shared.
*/
void setIgnore(const BitVector& i)
template<typename BV>
void setIgnore(BV&& i)
{
ignoreNodes_ = &i;
ignoreNodes_ = Dune::Solvers::wrap_own_share<const BitVector>(std::forward<BV>(i));
}
/**
......@@ -68,7 +69,7 @@ public:
/**
* \brief A flag for each degree of freedom stating whether the dof should be ignored by the solver
*/
const BitVectorType* ignoreNodes_;
std::shared_ptr<const BitVector> ignoreNodes_;
};
......
......@@ -165,7 +165,7 @@ void MonotoneMGStep<MatrixType, VectorType>::iterate()
presmoother->setProblem(*(mat[level]), *x[level], rhs[level]);
presmoother->obstacles_ = obstacles[level].get();
presmoother->hasObstacle_ = hasObstacleHierarchy_[level].get();
presmoother->ignoreNodes_ = this->ignoreNodesHierarchy_[level];
presmoother->setIgnore(*this->ignoreNodesHierarchy_[level]);
for (int i=0; i<this->nu1_; i++)
presmoother->iterate();
......@@ -285,7 +285,7 @@ void MonotoneMGStep<MatrixType, VectorType>::iterate()
postsmoother->setProblem(*(mat[level]), *x[level], rhs[level]);
postsmoother->obstacles_ = obstacles[level].get();
postsmoother->hasObstacle_ = hasObstacleHierarchy_[level].get();
postsmoother->ignoreNodes_ = this->ignoreNodesHierarchy_[level];
postsmoother->setIgnore(*this->ignoreNodesHierarchy_[level]);
for (int i=0; i<this->nu2_; i++)
postsmoother->iterate();
......
......@@ -138,7 +138,7 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
// /////////////////////////////////////////////////////
if (this->ignoreNodes_!=0)
{
ignoreNodesHierarchy_[numLevels()-1] = const_cast<BitVectorType*>(this->ignoreNodes_);
ignoreNodesHierarchy_[numLevels()-1] = const_cast<BitVectorType*>(&(*this->ignoreNodes_));
for (int i=numLevels()-2; i>=0; --i)
{
ignoreNodesHierarchy_[i] = new BitVectorType();
......@@ -226,7 +226,7 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::iterate()
// Presmoothing
presmoother_[level]->setProblem(*(this->matrixHierarchy_[level]), *x[level], rhs[level]);
presmoother_[level]->ignoreNodes_ = ignoreNodesHierarchy_[level];
presmoother_[level]->setIgnore(*ignoreNodesHierarchy_[level]);
for (int i=0; i<this->nu1_; i++)
presmoother_[level]->iterate();
......@@ -269,7 +269,7 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::iterate()
// Postsmoothing
postsmoother_[level]->setProblem(*(mat[level]), *x[level], rhs[level]);
postsmoother_[level]->ignoreNodes_ = ignoreNodesHierarchy_[level];
postsmoother_[level]->setIgnore(*ignoreNodesHierarchy_[level]);
for (int i=0; i<this->nu2_; i++)
postsmoother_[level]->iterate();
......
......@@ -166,7 +166,7 @@ class ObstacleTNNMGStep
nonlinearSmoother_.obstacles_ = &obstacles_;
nonlinearSmoother_.hasObstacle_ = &hasObstacle_;
nonlinearSmoother_.ignoreNodes_ = ignoreNodes_;
nonlinearSmoother_.setIgnore(ignoreNodes_);
outStream_.str("");
outStream_ << " step size";
for(int j=0; j<blockSize; ++j)
......@@ -243,7 +243,7 @@ class ObstacleTNNMGStep
// apply linear multigrid to approximatively solve the truncated linear system
linearMGStep_.setProblem(truncatedMat, coarseCorrection_, truncatedResidual_);
linearMGStep_.ignoreNodes_ = ignoreNodes_;
linearMGStep_.setIgnore(ignoreNodes_);
linearMGStep_.preprocess();
for(int i=0; i<linearIterationSteps_; ++i)
linearMGStep_.iterate();
......