5#include <dune/istl/solver.hh>
7#include <amdis/CreatorMap.hpp>
8#include <amdis/Initfile.hpp>
9#include <amdis/Output.hpp>
10#include <amdis/linearalgebra/LinearSolverInterface.hpp>
11#include <amdis/linearalgebra/mtl/PreconditionerInterface.hpp>
20 template <
class M,
class X,
class Y>
33 return std::make_unique<Self>(std::move(prefix));
40 std::string solverName =
"default";
44 solver_ = solverCreator->createWithString(prefix +
"->solver");
48 void init(M
const& matrix)
override
51 solver_->init(matrix);
62 void solve(X
const& x, Y& y)
const override
64 test_exit_dbg(
bool(solver_),
"No solver initialized!");
65 test_exit_dbg(
bool(matrix_),
"No matrix initialized!");
67 y.checked_change_resource(x);
68 test_exit(size(y) == num_cols(*matrix_),
"incompatible size");
69 solver_->apply(y, x, stat_);
75 error_exit(
"Not Implemented.");
79 mutable Dune::InverseOperatorResult stat_;
81 std::shared_ptr<LinearSolverInterface<M,X,Y>> solver_;
82 M
const* matrix_ =
nullptr;
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 std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
Interface for Preconditioner y = M*x.
Definition: PreconditionerInterface.hpp:10
Use a LinearSolver as Preconditioner.
Definition: SolverPrecon.hpp:23
void finish() override
Implementation of PreconditionerInterface::exit()
Definition: SolverPrecon.hpp:56
void init(M const &matrix) override
Implementation of PreconditionerBase::init()
Definition: SolverPrecon.hpp:48
void adjoint_solve(X const &x, Y &y) const override
Implementation of PreconditionerInterface::adjointSolve()
Definition: SolverPrecon.hpp:73
void solve(X const &x, Y &y) const override
Implementation of PreconditionerInterface::solve()
Definition: SolverPrecon.hpp:62
A creator to be used instead of the constructor.
Definition: SolverPrecon.hpp:30
std::unique_ptr< Super > createWithString(std::string prefix) override
Must be implemented by sub classes of CreatorInterfaceName. Creates a new instance of the sub class o...
Definition: SolverPrecon.hpp:31