3#include <dune/istl/solver.hh>
5#include <amdis/linearalgebra/LinearSolverInterface.hpp>
6#include <amdis/linearalgebra/istl/ISTLSolverCreator.hpp>
7#include <amdis/linearalgebra/istl/Preconditioners.hpp>
8#include <amdis/linearalgebra/istl/Solvers.hpp>
9#include <amdis/linearalgebra/istl/Traits.hpp>
14 template <
class Mat,
class VecX,
class VecY = VecX>
16 :
public LinearSolverInterface<Mat,VecX,VecY>
18 using Traits = SolverTraits<Mat,VecX,VecY>;
19 using Map = CreatorMap<tag::solver<Traits>>;
20 using Creator = ISTLSolverCreatorBase<Traits>;
23 LinearSolver(std::string
const& name, std::string
const& prefix)
24 : solverCreator_(dynamic_cast<Creator*>(Map::get(name, prefix)))
26 assert(solverCreator_ !=
nullptr);
27 solverCreator_->init(prefix);
30 void init(Mat
const& A)
override
32 assert(solverCreator_ !=
nullptr);
33 solver_ = solverCreator_->createSolver(A.matrix(), A.comm());
42 void apply(VecX& x, VecY
const& b, Dune::InverseOperatorResult& stat)
override
45 auto rhs = b.vector();
46 solver_->apply(x.vector(), rhs, stat);
51 std::shared_ptr<typename Traits::Solver> solver_;
Base class for solver creators,.
Definition: ISTLSolverCreator.hpp:56
void apply(VecX &x, VecY const &b, Dune::InverseOperatorResult &stat) override
Implements Dune::InverseOperator::apply()
Definition: LinearSolver.hpp:42
void init(Mat const &A) override
Prepare the solve (and preconditioner), e.g. make a factorization of the matrix, or extract its diago...
Definition: LinearSolver.hpp:30
void finish() override
Cleanup the solver, e.g. free the previously created factorization.
Definition: LinearSolver.hpp:36