Commit aa94c825 authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Let FixedStepLinearSolver inherit from IterativeSolver

This includes it into the regular dynamic-polymorphism class
tree of dune-solvers.
parent 2784897f
......@@ -7,6 +7,7 @@
#include <dune/solvers/common/defaultbitvector.hh>
#include <dune/solvers/common/resize.hh>
#include <dune/solvers/solvers/iterativesolver.hh>
......@@ -19,8 +20,9 @@ namespace TNNMG {
* \tparam Matrix Matrix type of the linear system
* \tparam Vector Vector type of the linear system
*/
template<class Matrix, class Vector, class Step>
template <class Matrix, class Vector, class Step>
class FixedStepLinearSolver
: public IterativeSolver<Vector, Solvers::DefaultBitVector_t<Vector>>
{
using BitVector = Dune::Solvers::DefaultBitVector_t<Vector>;
......@@ -31,10 +33,18 @@ public:
* \param noOfSteps The number of steps to take
*/
FixedStepLinearSolver(const std::shared_ptr<Step> step, unsigned int noOfSteps=1)
: step_(step),
: IterativeSolver<Vector, BitVector>(-1, // tolerance
noOfSteps,
NumProc::QUIET),
step_(step),
noOfSteps_(noOfSteps)
{}
virtual void preprocess()
{
step_->preprocess();
}
/** \brief Solve */
void operator()(Vector& x, const Matrix& m, const Vector& r)
{
......@@ -46,6 +56,13 @@ public:
step_->iterate();
}
/** \brief Solve */
virtual void solve()
{
for (unsigned int i=0; i<noOfSteps_; i++)
step_->iterate();
}
private:
std::shared_ptr<Step> step_;
unsigned int noOfSteps_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment