6 #include <boost/numeric/itl/itl.hpp> 7 #include <boost/numeric/mtl/mtl.hpp> 10 #include <amdis/linearalgebra/RunnerInterface.hpp> 11 #include <amdis/linearalgebra/SolverInfo.hpp> 13 #include <amdis/linearalgebra/mtl/ITL_Preconditioner.hpp> 23 template <
class Mat,
class Vec,
class ITLSolver>
27 using M =
typename Mat::BaseMatrix;
28 using X =
typename Vec::BaseVector;
29 using Y =
typename Vec::BaseVector;
32 using FloatType =
typename Mat::value_type;
47 void init(M
const& A)
override 62 test_exit(
bool(P_),
"There is no preconditioner. Call init() before solve().");
65 itl::cyclic_iteration<FloatType> iter(two_norm(b - A*x), maxIter_, rTol_, aTol_, printCycle_);
66 iter.set_quite(solverInfo.
info() == 0);
67 iter.suppress_resume(solverInfo.
info() == 0);
69 int error = itlSolver_(A, x, b, *P_, iter);
79 test_exit(
bool(P_),
"There is no preconditioner. Call init() before adjointSolve().");
84 itl::cyclic_iteration<FloatType> iter(two_norm(b - At*x), maxIter_, rTol_, aTol_, printCycle_);
85 iter.set_quite(solverInfo.
info() == 0);
86 iter.suppress_resume(solverInfo.
info() == 0);
88 int error = itlSolver_(At, x, b, *P_, iter);
101 std::string preconName =
"default";
106 P_ = creator->createWithString(prefix +
"->precon");
111 ITLSolver itlSolver_;
117 std::shared_ptr<PreconBase> P_;
123 FloatType rTol_ = 1.e-6;
126 std::size_t maxIter_ = 1000;
129 std::size_t printCycle_ = 100;
int solve(M const &A, X &x, Y const &b, SolverInfo &solverInfo) override
Implementation of RunnerInterface::solve()
Definition: KrylovRunner.hpp:60
void setAbsResidual(double r)
Sets absResidual_.
Definition: SolverInfo.hpp:80
A CreatorMap is used to construct objects, which types depends on key words determined at run time...
Definition: CreatorMap.hpp:29
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
KrylovRunner(std::string const &prefix)
Constructor.
Definition: KrylovRunner.hpp:36
void exit() override
Implementation of RunnerInterface::exit()
Definition: KrylovRunner.hpp:54
void setRelResidual(double r)
Sets relResidual_.
Definition: SolverInfo.hpp:86
int info() const
Returns info.
Definition: SolverInfo.hpp:38
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
CreatorInterfaceName< BaseClass > * named(CreatorInterface< BaseClass > *ptr)
cast a ptr of CreatorInterface to CreatorInterfaceName
Definition: CreatorInterface.hpp:64
Wrapper class for different MTL4 itl-solvers. These solvers are parametrized by Matrix and Vector...
Definition: KrylovRunner.hpp:24
int adjointSolve(M const &A, X &x, Y const &b, SolverInfo &solverInfo) override
Implementation of RunnerInterface::solve()
Definition: KrylovRunner.hpp:77
void createPrecon(std::string const &prefix)
Create left/right preconditioners from parameters given in the init-file.
Definition: KrylovRunner.hpp:98
Definition: SolverInfo.hpp:11
Interface for Preconditioner y = M*x.
Definition: PreconditionerInterface.hpp:9
void test_exit(bool condition, std::string const &str, Args &&... args)
test for condition and in case of failure print message and exit
Definition: Output.hpp:163
void init(M const &A) override
Implementation of RunnerInterface::initImpl()
Definition: KrylovRunner.hpp:47
Interface for Runner / Worker types used in solver classes.
Definition: RunnerInterface.hpp:11