AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Preconditioner.hpp
1#pragma once
2
3#include <amdis/linearalgebra/mtl/PreconditionerInterface.hpp>
4
5namespace AMDiS
6{
12 template <class M, class X, class Y, template <class> class PreconImpl>
14 : public PreconditionerInterface<M,X,Y>
15 {
16 using Self = Preconditioner;
18 using Precon = PreconImpl<M>;
19
20 public:
23 {
24 std::unique_ptr<Super> createWithString(std::string) override
25 {
26 return std::make_unique<Self>();
27 }
28 };
29
30 public:
32 void init(M const& A) override
33 {
34 precon_ = std::make_shared<Precon>(A);
35 }
36
38 void finish() override
39 {
40 precon_.reset();
41 }
42
44 void solve(X const& x, Y& y) const override
45 {
46 test_exit_dbg(bool(precon_), "No preconditioner initialized!");
47 precon_->solve(x, y);
48 }
49
51 void adjoint_solve(X const& x, Y& y) const override
52 {
53 test_exit_dbg(bool(precon_), "No preconditioner initialized!");
54 precon_->adjoint_solve(x, y);
55 }
56
57 private:
58 std::shared_ptr<Precon> precon_;
59 };
60
61} // namespace AMDiS
Interface for creators with name.
Definition: CreatorInterface.hpp:44
Interface for Preconditioner y = M*x.
Definition: PreconditionerInterface.hpp:10
Wrapper for using ITL preconditioners in AMDiS.
Definition: Preconditioner.hpp:15
void init(M const &A) override
Implementation of PreconditionerInterface::init()
Definition: Preconditioner.hpp:32
void finish() override
Implementation of PreconditionerInterface::finish()
Definition: Preconditioner.hpp:38
void adjoint_solve(X const &x, Y &y) const override
Implementation of PreconditionerInterface::adjointSolve()
Definition: Preconditioner.hpp:51
void solve(X const &x, Y &y) const override
Implementation of PreconditionerInterface::solve()
Definition: Preconditioner.hpp:44
A creator to be used instead of the constructor.
Definition: Preconditioner.hpp:23
std::unique_ptr< Super > createWithString(std::string) override
Must be implemented by sub classes of CreatorInterfaceName. Creates a new instance of the sub class o...
Definition: Preconditioner.hpp:24