Skip to content
Snippets Groups Projects
Commit 6eb61e07 authored by Max Kahnt's avatar Max Kahnt
Browse files

Allow custom ignore type in cgstep.

parent 9184389a
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -3,13 +3,13 @@
#include <dune/solvers/common/canignore.hh>
template <class MatrixType, class VectorType>
void CGStep<MatrixType, VectorType>::check() const
template <class MatrixType, class VectorType, class Ignore>
void CGStep<MatrixType, VectorType, Ignore>::check() const
{
}
template <class MatrixType, class VectorType>
void CGStep<MatrixType, VectorType>::preprocess()
template <class MatrixType, class VectorType, class Ignore>
void CGStep<MatrixType, VectorType, Ignore>::preprocess()
{
// Compute the residual (r starts out as the rhs)
this->mat_->mmv(*x_,r_);
......@@ -19,7 +19,7 @@ void CGStep<MatrixType, VectorType>::preprocess()
r_[i] = 0;
if (preconditioner_) {
using CanIgnore_t = CanIgnore<DefaultBitVector_t<VectorType>>;
using CanIgnore_t = CanIgnore<Ignore>;
CanIgnore_t *asCanIgnore = dynamic_cast<CanIgnore_t*>(preconditioner_);
if (asCanIgnore != nullptr and this->hasIgnore())
asCanIgnore->setIgnore(this->ignore());
......@@ -32,8 +32,8 @@ void CGStep<MatrixType, VectorType>::preprocess()
r_squared_old_ = p_*r_;
}
template <class MatrixType, class VectorType>
void CGStep<MatrixType, VectorType>::iterate()
template <class MatrixType, class VectorType, class Ignore>
void CGStep<MatrixType, VectorType, Ignore>::iterate()
{
// Avoid divide-by-zero. If r_squared was zero, we're done anyway.
if (r_squared_old_ <= 0)
......
......@@ -4,16 +4,18 @@
#define DUNE_SOLVERS_ITERATIONSTEPS_CGSTEP_HH
#include <dune/solvers/common/preconditioner.hh>
#include <dune/solvers/common/defaultbitvector.hh>
#include <dune/solvers/iterationsteps/lineariterationstep.hh>
namespace Dune {
namespace Solvers {
//! A conjugate gradient solver
template <class MatrixType, class VectorType>
class CGStep : public LinearIterationStep<MatrixType,VectorType>
template <class MatrixType, class VectorType, class Ignore = DefaultBitVector_t<VectorType>>
class CGStep : public LinearIterationStep<MatrixType,VectorType,Ignore>
{
using Base = LinearIterationStep<MatrixType,VectorType>;
using Base = LinearIterationStep<MatrixType,VectorType,Ignore>;
using Preconditioner = Dune::Solvers::Preconditioner<MatrixType, VectorType, Ignore>;
public:
CGStep()
......@@ -30,7 +32,7 @@ namespace Dune {
CGStep(const MatrixType& matrix,
VectorType& x,
const VectorType& rhs,
Preconditioner<MatrixType, VectorType>& preconditioner)
Preconditioner& preconditioner)
: Base(matrix,x), p_(rhs.size()), r_(rhs),
preconditioner_(&preconditioner)
{}
......@@ -54,7 +56,7 @@ namespace Dune {
VectorType r_; // residual
using Base::x_;
double r_squared_old_;
Preconditioner<MatrixType, VectorType>* preconditioner_;
Preconditioner* preconditioner_;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment