5 #include <amdis/CreatorMap.hpp> 6 #include <amdis/Initfile.hpp> 7 #include <amdis/Output.hpp> 8 #include <amdis/linearalgebra/LinearSolverInterface.hpp> 9 #include <amdis/linearalgebra/mtl/PreconditionerInterface.hpp> 18 template <
class Mat,
class Vec>
22 using M =
typename Mat::BaseMatrix;
23 using X =
typename Vec::BaseVector;
24 using Y =
typename Vec::BaseVector;
35 return std::make_unique<Self>(std::move(prefix));
41 : solverInfo_(prefix +
"->solver")
43 std::string solverName =
"default";
47 solver_ = solverCreator->createWithString(prefix +
"->solver");
51 void init(M
const& matrix)
override 54 solver_->runner()->init(matrix);
64 void solve(X
const& x, Y& y)
const override 69 y.checked_change_resource(x);
70 test_exit(size(y) == num_cols(*matrix_),
"incompatible size");
71 solver_->runner()->solve(*matrix_, y, x, solverInfo_);
81 y.checked_change_resource(x);
82 test_exit(size(y) == num_rows(*matrix_),
"incompatible size");
83 solver_->runner()->adjointSolve(*matrix_, y, x, solverInfo_);
89 std::shared_ptr<LinearSolverInterface<Mat,Vec>> solver_;
90 M
const* matrix_ =
nullptr;
A creator to be used instead of the constructor.
Definition: SolverPrecon.hpp:31
void solve(X const &x, Y &y) const override
Implementation of PreconditionerInterface::solve()
Definition: SolverPrecon.hpp:64
void error_exit(std::string const &str, Args &&... args)
print a message and exit
Definition: Output.hpp:142
void adjoint_solve(X const &x, Y &y) const override
Implementation of PreconditionerInterface::adjointSolve()
Definition: SolverPrecon.hpp:75
void test_exit_dbg(bool condition, Args &&... args)
call assert_msg, in debug mode only
Definition: Output.hpp:205
Use a LinearSolver as Preconditioner.
Definition: SolverPrecon.hpp:19
Interface for creators with name.
Definition: CreatorInterface.hpp:42
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
void init(M const &matrix) override
Implementation of PreconditionerBase::init()
Definition: SolverPrecon.hpp:51
void exit() override
Implementation of PreconditionerInterface::exit()
Definition: SolverPrecon.hpp:58
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
Abstract base class for linear solvers.
Definition: LinearSolverInterface.hpp:27
Definition: SolverInfo.hpp:11
Interface for Preconditioner y = M*x.
Definition: PreconditionerInterface.hpp:9
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:33
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