LinearSolverInterface.hpp 1.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
#pragma once

/** \file LinearSolverInterface.h */

/**
 * \defgroup Solver Solver module
 * @{ <img src="solver.png"> @}
 *
 * \brief
 * Contains all classes needed for solving linear and non linear equation
 * systems.
 */

14
#include <amdis/common/TypeTraits.hpp>
15

16
17
18
#include <amdis/linearalgebra/PreconditionerInterface.hpp>
#include <amdis/linearalgebra/RunnerInterface.hpp>
#include <amdis/linearalgebra/SolverInfo.hpp>
19

20
namespace AMDiS
21
{
22
  /// Abstract base class for linear solvers
23
  template <class Mat, class Sol, class Rhs = Sol>
24
  class LinearSolverInterface
25
  {
26
  protected:
27
    using RunnerBase = RunnerInterface<Mat, Sol, Rhs>;
28

29
  public:
30
    /// Destructor.
31
    virtual ~LinearSolverInterface() = default;
32

33
34
35
36
    /// Public method to call in order to solve a linear system Ax = b.
    /**
     * The method redirects to the specific linear solver and prints statistics
     * and error estimations at the end.
37
     *
38
     * The parameters correspond to
39
40
41
     *  \p A     A [block-]matrix that represents the system-matrix.
     *  \p x     A [block-]vector for the unknown components.
     *  \p b     A [block-]vector for the right-hand side of the linear system.
42
     **/
43
    void solve(Mat const& A, Sol& x, Rhs const& b, SolverInfo& solverInfo)
44
    {
45
      solveImpl(A, x, b, solverInfo);
46
    }
47

48
    // return the runner/worker corresponding to this solver (optional)
49
    virtual std::shared_ptr<RunnerBase> runner() { return {}; };
50
51
52

  private:
    /// main methods that all solvers must implement
53
    virtual void solveImpl(Mat const& A, Sol& x, Rhs const& b, SolverInfo& solverInfo) = 0;
54
  };
55
56


57
58
  template <class Matrix, class Vector>
  struct SolverCreator;
59
60

} // end namespace AMDiS