AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
LinearSolver.hpp
1#pragma once
2
3#include <memory>
4#include <string>
5
6#include <amdis/CreatorMap.hpp>
7#include <amdis/CreatorInterface.hpp>
8#include <amdis/linearalgebra/LinearSolverInterface.hpp>
9
10namespace AMDiS
11{
13 template <class Mat, class VecX, class VecY = VecX>
14 class LinearSolver
15 : public LinearSolverInterface<Mat,VecX,VecY>
16 {
17 using M = typename Mat::BaseMatrix;
18 using X = typename VecX::BaseVector;
19 using Y = typename VecX::BaseVector;
20
21 using Map = CreatorMap<LinearSolverInterface<M,X,Y>>;
22
23 public:
24 LinearSolver(std::string const& name, std::string const& prefix)
25 : solver_(named(Map::get(name, prefix))->createWithString(prefix))
26 {}
27
29 void init(Mat const& A) override
30 {
31 solver_->init(A.matrix());
32 }
33
35 void finish() override
36 {
37 solver_->finish();
38 }
39
41 void apply(VecX& x, VecY const& b, Dune::InverseOperatorResult& stat) override
42 {
43 solver_->apply(x.vector(), b.vector(), stat);
44 }
45
46 private:
47 std::shared_ptr<LinearSolverInterface<M,X,Y>> solver_;
48 };
49
50} // end namespace AMDiS
void apply(VecX &x, VecY const &b, Dune::InverseOperatorResult &stat) override
Implements LinearSolverInterface::apply()
Definition: LinearSolver.hpp:41
void init(Mat const &A) override
Implements LinearSolverInterface::init()
Definition: LinearSolver.hpp:29
void finish() override
Implements LinearSolverInterface::finish()
Definition: LinearSolver.hpp:35