LinearSolverInterface.hpp 1.89 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 <dune/amdis/common/Utility.hpp>
15
16
17
18
19
#include <dune/amdis/linear_algebra/LinearAlgebraBase.hpp>

#include <dune/amdis/linear_algebra/PreconditionerInterface.hpp>
#include <dune/amdis/linear_algebra/RunnerInterface.hpp>
#include <dune/amdis/linear_algebra/SolverInfo.hpp>
20

21
namespace AMDiS
22
{
23
  /// Abstract base class for linear solvers
24
25
  template <class Matrix, class VectorX, class VectorB = VectorX>
  class LinearSolverInterface
26
  {
27
  protected:
28
    using RunnerBase = RunnerInterface<Matrix, BaseVector_t<VectorX>,
29
                                               BaseVector_t<VectorB>>;
30

31
  public:
32
33
    /// Destructor.
    virtual ~LinearSolverInterface() {}
34

35
36
37
38
    /// 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.
39
     *
40
     * The parameters correspond to
41
42
43
     *  \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.
44
45
     **/
    void solve(Matrix const& A, VectorX& x, VectorB const& b,
46
               SolverInfo& solverInfo)
47
    {
48
      solveImpl(A, x, b, solverInfo);
49
    }
50

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

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


61
62
  template <class Matrix, class Vector>
  struct SolverCreator;
63
64

} // end namespace AMDiS