LinearSolverInterface.hpp 1.37 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
namespace AMDiS
15
{
16
17
  class SolverInfo;

18
  /// Abstract base class for linear solvers
19
  template <class Traits>
20
  class LinearSolverInterface
21
  {
22
  protected:
23
    using Mat = typename Traits::Mat;
24
    using Vec = typename Traits::Vec;
25
    using Comm = typename Traits::Comm;
26

27
  public:
28
    /// Destructor.
29
    virtual ~LinearSolverInterface() = default;
30

31
32
33
34
    /// 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.
35
     *
36
     * The parameters correspond to
37
38
39
     *  \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.
40
     **/
41
    void solve(Mat const& A, Vec& x, Vec const& b, Comm const& comm, SolverInfo& solverInfo)
42
    {
43
      solveImpl(A, x, b, comm, solverInfo);
44
    }
45

46
47
  private:
    /// main methods that all solvers must implement
48
    virtual void solveImpl(Mat const& A, Vec& x, Vec const& b, Comm const& comm, SolverInfo& solverInfo) = 0;
49
  };
50

51
} // end namespace AMDiS