LinearSolverInterface.hpp 1.88 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
15
16
17
18
#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>
19

20
21
22
namespace AMDiS
{  
  /// Abstract base class for linear solvers
23
24
  template <class Matrix, class VectorX, class VectorB = VectorX>
  class LinearSolverInterface
25
  {
26
  protected:
27
28
    using RunnerBase = RunnerInterface<Matrix, BaseVector_t<VectorX>, 
                                               BaseVector_t<VectorB>>;
29
30
    
  public:
31
32
33
34
35
36
37
38
39
    /// Destructor.
    virtual ~LinearSolverInterface() {}
    
    /// 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.
     * 
     * The parameters correspond to
40
41
42
     *  \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.
43
44
     **/
    void solve(Matrix const& A, VectorX& x, VectorB const& b,
45
               SolverInfo& solverInfo)
46
    {      
47
      solveImpl(A, x, b, solverInfo);
48
49
    }
    
50
    // return the runner/worker corresponding to this solver (optional)
51
    virtual std::shared_ptr<RunnerBase> getRunner() { return {}; };
52
53
54
55

  private:
    /// main methods that all solvers must implement
    virtual void solveImpl(Matrix const& A, VectorX& x, VectorB const& b,
56
                           SolverInfo& solverInfo) = 0;
57
  };
58
59
60
61
  
  
  template <class Matrix, class Vector>
  struct SolverCreator;
62
63

} // end namespace AMDiS