LinearSolverInterface.hpp 1.75 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/Utility.hpp>
15

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

20
namespace AMDiS
21
{
22
  /// Abstract base class for linear solvers
23
24
  template <class Matrix, class VectorX, class VectorB = VectorX>
  class LinearSolverInterface
25
  {
26
  protected:
27
    using RunnerBase = RunnerInterface<Matrix, VectorX, VectorB>;
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(Matrix const& A, VectorX& x, VectorB const& b,
44
               SolverInfo& solverInfo)
45
    {
46
      solveImpl(A, x, b, solverInfo);
47
    }
48

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

  private:
    /// main methods that all solvers must implement
    virtual void solveImpl(Matrix const& A, VectorX& x, VectorB const& b,
55
                           SolverInfo& solverInfo) = 0;
56
  };
57
58


59
60
  template <class Matrix, class Vector>
  struct SolverCreator;
61
62

} // end namespace AMDiS