ITL_Solver.h 6.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file ITL_Preconditioner.h */

#ifndef AMDIS_ITL_SOLVER_H
#define AMDIS_ITL_SOLVER_H

#include "ITL_OEMSolver.h"
#include <boost/numeric/itl/krylov/cg.hpp>
#include <boost/numeric/itl/krylov/bicg.hpp>
#include <boost/numeric/itl/krylov/bicgstab.hpp>
#include <boost/numeric/itl/krylov/bicgstab_2.hpp>
#include <boost/numeric/itl/krylov/bicgstab_ell.hpp>

namespace AMDiS {

  // ============================================================================
  // ===== class CGSolver =======================================================
  // ============================================================================
  
  /// Helper class to establish a type from a function
  class cg_solver_type
  {
  public:
    template < class LO, class X, class B, class L, class R, class I >
    int operator()(const LO& A, X& x, const B& b, const L& l, const R& r, I& iter)
    { return itl::cg(A, x, b, l, r, iter); }
  };


  /**
   * \ingroup Solver
   * 
   * \brief
   * Solves a linear system by the conjugate gradient method and can be used for
   * symmetric positive definite system matrices.
   */
  class CGSolver : public ITL_OEMSolver<cg_solver_type>
  {
  public:
    /// The constructor reads required parameters and sets solvers \ref name.
    CGSolver(std::string name) : ITL_OEMSolver<cg_solver_type>(name) {}
  };


  // ============================================================================
  // ===== class BiCGSolver =====================================================
  // ============================================================================

  /// Helper class to establish a type from a function
  class bicg_solver_type
  {
  public:
    template < class LO, class X, class B, class L, class R, class I >
    int operator()(const LO& A, X& x, const B& b, const L& l, const R&, I& iter)
    { return itl::bicg(A, x, b, l, iter); }
  };

  /**  
   * \ingroup Solver
   *
   * \brief
   * Solves a linear system by a stabilized BiCG method and can be used for 
   * system matrices.
   */
  class BiCGSolver : public ITL_OEMSolver<bicg_solver_type>
  {
  public:
    /// The constructor reads required parameters and sets solvers \ref name.
87
    BiCGSolver(std::string name) : ITL_OEMSolver<bicg_solver_type>(name) {}
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  };


  // ============================================================================
  // ===== class BiCGStab =======================================================
  // ============================================================================

  /// Helper class to establish a type from a function
  class bicgstab_type
  {
  public:
    template < class LinOp, class X, class B, class L, class R, class I >
    int operator()(const LinOp& A, X& x, const B& b, const L& l, const R&, I& iter)
    { return itl::bicgstab(A, x, b, l, iter); }
  };


  /**  
   * \ingroup Solver
   *
   * \brief
   * Solves a linear system by a stabilized BiCG method and can be used for 
   * system matrices.
   */
  class BiCGStab : public ITL_OEMSolver<bicgstab_type>
  {
  public:
    /// The constructor reads required parameters and sets solvers \ref name.
116
    BiCGStab(std::string name) : ITL_OEMSolver<bicgstab_type>(name) {}
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  };


  // ============================================================================
  // ===== class BiCGStab2 ======================================================
  // ============================================================================

  /// Helper class to establish a type from a function
  class bicgstab2_type
  {
  public:
    template < class LinOp, class X, class B, class L, class R, class I >
    int operator()(const LinOp& A, X& x, const B& b, const L& l, const R&, I& iter)
    { return itl::bicgstab_2(A, x, b, l, iter); }
  };


  /**  
   * \ingroup Solver
   *
   * \brief
   * Solves a linear system by a stabilized BiCG method and can be used for 
   * system matrices.
   */
  class BiCGStab2 : public ITL_OEMSolver<bicgstab2_type>
  {
  public:
    /// The constructor reads required parameters and sets solvers \ref name.
145
    BiCGStab2(std::string name) : ITL_OEMSolver<bicgstab2_type>(name) {}
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  };


  // ============================================================================
  // ===== class BiCGStabEll ======================================================
  // ============================================================================

  /// Helper class to establish a type from a function
  class bicgstab_ell_type
  {
  public:
    template < class LinOp, class X, class B, class L, class R, class I >
    int operator()(const LinOp& A, X& x, const B& b, const L& l, const R& r, I& iter, int ell)
    { return itl::bicgstab_ell(A, x, b, l, r, iter, ell); }
  };

  /**  
   * \ingroup Solver
   *
   * \brief
   * Solves a linear system by a stabilized BiCG method and can be used for 
   * system matrices.
   */
  class BiCGStabEll : public ITL_OEMSolver_para<bicgstab_ell_type>
  {
  public:
    /// The constructor reads required parameters and sets solvers \ref name.
173
    BiCGStabEll(std::string name) : ITL_OEMSolver_para<bicgstab_ell_type>(name) {}
174
175
176
177
178
179
180
  };


} // namespace AMDiS

#endif // AMDIS_ITL_SOLVER