~gabriel1984sibiu/agros2d/agros2d

« back to all changes in this revision

Viewing changes to 3rdparty/paralution/src/solvers/krylov/gmres.hpp

  • Committer: Grevutiu Gabriel
  • Date: 2014-11-15 19:05:36 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20141115190536-1d4q8ez0f8b89ktj
originalĀ upstreamĀ code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// *************************************************************************
 
2
//
 
3
//    PARALUTION   www.paralution.com
 
4
//
 
5
//    Copyright (C) 2012-2013 Dimitar Lukarski
 
6
//
 
7
//    This program is free software: you can redistribute it and/or modify
 
8
//    it under the terms of the GNU General Public License as published by
 
9
//    the Free Software Foundation, either version 3 of the License, or
 
10
//    (at your option) any later version.
 
11
//
 
12
//    This program is distributed in the hope that it will be useful,
 
13
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//    GNU General Public License for more details.
 
16
//
 
17
//    You should have received a copy of the GNU General Public License
 
18
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
//
 
20
// *************************************************************************
 
21
 
 
22
#ifndef PARALUTION_GMRES_GMRES_HPP_
 
23
#define PARALUTION_GMRES_GMRES_HPP_
 
24
 
 
25
#include "../solver.hpp"
 
26
 
 
27
#include <vector>
 
28
 
 
29
namespace paralution {
 
30
 
 
31
 
 
32
template <class OperatorType, class VectorType, typename ValueType>
 
33
class GMRES : public IterativeLinearSolver<OperatorType, VectorType, ValueType> {
 
34
  
 
35
public:
 
36
 
 
37
  GMRES();
 
38
  virtual ~GMRES();
 
39
 
 
40
  virtual void Print(void) const;
 
41
 
 
42
  virtual void Build(void);
 
43
  virtual void Clear(void);
 
44
 
 
45
  /// Set the size of the Krylov-space basis
 
46
  virtual void SetBasisSize(const int size_basis);
 
47
 
 
48
protected:
 
49
 
 
50
  virtual void SolveNonPrecond_(const VectorType &rhs,
 
51
                                VectorType *x);
 
52
  virtual void SolvePrecond_(const VectorType &rhs,
 
53
                             VectorType *x);
 
54
 
 
55
  virtual void PrintStart_(void) const;
 
56
  virtual void PrintEnd_(void) const;
 
57
 
 
58
  virtual void MoveToHostLocalData_(void);
 
59
  virtual void MoveToAcceleratorLocalData_(void);
 
60
 
 
61
  void ApplyGivensRotation_(const ValueType &c, const ValueType &s,
 
62
                                  ValueType &x,       ValueType &y) const;
 
63
 
 
64
  void BackSubstitute_(std::vector<ValueType> &g,
 
65
                       const std::vector<ValueType> &H,
 
66
                       int k) const;
 
67
 
 
68
private:
 
69
 
 
70
  VectorType z_, w_;
 
71
  VectorType **v_;
 
72
 
 
73
  int size_basis_;
 
74
 
 
75
};
 
76
 
 
77
 
 
78
}
 
79
 
 
80
#endif // PARALUTION_GMRES_GMRES_HPP_
 
81