Commit 743c1abc authored by's avatar
Browse files

Use the dune-solvers-style API to call the linear solver

parent 65aaecf2
......@@ -10,6 +10,7 @@
#include "dune/solvers/iterationsteps/iterationstep.hh"
#include "dune/solvers/iterationsteps/lineariterationstep.hh"
#include <dune/solvers/solvers/iterativesolver.hh>
......@@ -23,7 +24,6 @@ namespace TNNMG {
* \tparam BV Bit-vector type for marking ignored components
template<class F, class BV, class Linearization,
class LinearSolver,
class DefectProjection,
class LineSearchSolver>
class TNNMGStep :
......@@ -36,6 +36,7 @@ public:
using Vector = typename F::Vector;
using BitVector = typename Base::BitVector;
using Functional = F;
using LinearSolver = Solvers::IterativeSolver<typename Linearization::ConstrainedVector, Solvers::DefaultBitVector_t<Vector> >;
/** \brief Constructor
* \param linearSolver This is a callback used to solve the constrained linearized system
......@@ -104,8 +105,30 @@ public:
auto emptyIgnore = ignore;
Solvers::resizeInitialize(emptyIgnore, constrainedCorrection_, false);
linearSolver_->step_->setProblem(A, constrainedCorrection_, r);
// Hand the linear problem to the linear solver.
// Currently we only support IterativeSolvers. The IterationStep member
// needs to be a LinearIterationStep, so we can give it the matrix.
using LinearIterationStepType = Solvers::LinearIterationStep<std::decay_t<decltype(A)>,
typename Linearization::ConstrainedVector,
decltype(emptyIgnore) >;
LinearIterationStepType* linearIterationStep;
auto iterativeSolver = std::dynamic_pointer_cast<Solvers::IterativeSolver<typename Linearization::ConstrainedVector> >(linearSolver_);
if (iterativeSolver)
linearIterationStep = dynamic_cast<LinearIterationStepType*>(iterativeSolver->iterationStep_);
} else
DUNE_THROW(Exception, "Linear solver has to be an IterativeSolver!");
if (linearIterationStep)
linearIterationStep->setProblem(A, constrainedCorrection_, r);
DUNE_THROW(Exception, "Linear solver does not accept matrices!");
Supports Markdown
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