6#include <boost/numeric/itl/itl.hpp>
7#include <boost/numeric/mtl/mtl.hpp>
10#include <amdis/Environment.hpp>
11#include <amdis/linearalgebra/LinearSolverInterface.hpp>
12#include <amdis/linearalgebra/mtl/Preconditioners.hpp>
22 template <
class M,
class X,
class Y,
class ITLSolver>
29 using FloatType =
typename M::value_type;
34 std::unique_ptr<LinearSolverInterface<M,X,Y>>
37 return std::make_unique<Self>(prefix);
55 void init(M
const& A)
override
68 void apply(X& x, Y
const& b, Dune::InverseOperatorResult& stat)
override
73 FloatType r0 = two_norm(b - (*A_)*x);
74 itl::cyclic_iteration<FloatType> iter(r0, maxIter_, rTol_, aTol_, printCycle_);
78 [[maybe_unused]]
int error = itlSolver_(*A_, x, b, *P_, iter);
80 stat.iterations = iter.iterations();
81 stat.converged = iter.is_converged();
82 stat.reduction = iter.relresid();
83 stat.elapsed = t.elapsed();
91 std::string preconName =
"default";
96 P_ = creator->createWithString(prefix +
"->precon");
101 ITLSolver itlSolver_;
107 std::shared_ptr<PreconBase> P_;
110 M
const* A_ =
nullptr;
116 FloatType rTol_ = 1.e-6;
119 std::size_t maxIter_ = 1000;
122 std::size_t printCycle_ = 100;
Interface for creators with name.
Definition: CreatorInterface.hpp:44
A CreatorMap is used to construct objects, which types depends on key words determined at run time....
Definition: CreatorMap.hpp:30
static int infoLevel()
Return the info level for messages in info()
Definition: Environment.cpp:63
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
Wrapper class for different MTL4 itl-solvers. These solvers are parametrized by Matrix and Vector.
Definition: KrylovRunner.hpp:25
KrylovRunner(std::string const &prefix)
Constructor.
Definition: KrylovRunner.hpp:43
void init(M const &A) override
Implementation of LinearSolverInterface::init()
Definition: KrylovRunner.hpp:55
void apply(X &x, Y const &b, Dune::InverseOperatorResult &stat) override
Implementation of LinearSolverInterface::apply()
Definition: KrylovRunner.hpp:68
void finish() override
Implementation of LinearSolverInterface::finish()
Definition: KrylovRunner.hpp:62
void createPrecon(std::string const &prefix)
Create left/right preconditioners from parameters given in the init-file.
Definition: KrylovRunner.hpp:88
Definition: LinearSolverInterface.hpp:9
Interface for Preconditioner y = M*x.
Definition: PreconditionerInterface.hpp:10
Definition: KrylovRunner.hpp:33
std::unique_ptr< LinearSolverInterface< M, X, Y > > createWithString(std::string prefix) final
Must be implemented by sub classes of CreatorInterfaceName. Creates a new instance of the sub class o...
Definition: KrylovRunner.hpp:35