PARALUTION  1.0.0
PARALUTION
iter_ctrl.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_ITER_CTRL_HPP_
2 #define PARALUTION_ITER_CTRL_HPP_
3 
4 #include <vector>
5 #include <string>
6 
7 namespace paralution {
8 
12 
13 public:
14 
17 
20  void Init(const double abs,
21  const double rel,
22  const double div,
23  const int max);
24 
27  void Init(const double abs,
28  const double rel,
29  const double div,
30  const int min,
31  const int max);
32 
34  void InitTolerance(const double abs,
35  const double rel,
36  const double div);
37 
39  void InitMinimumIterations(const int min);
40 
42  void InitMaximumIterations(const int max);
43 
45  int GetMinimumIterations(void) const;
46 
48  int GetMaximumIterations(void) const;
49 
51  bool InitResidual(const double res);
52 
54  void Clear(void);
55 
57  bool CheckResidual(const double res);
58 
61  bool CheckResidual(const double res, const int index);
62 
64  bool CheckResidualNoCount(const double res) const;
65 
67  void RecordHistory(void);
68 
70  void WriteHistoryToFile(const std::string filename) const;
71 
73  void Verbose(const int verb=1);
74 
76  void PrintInit(void);
77 
79  void PrintStatus(void);
80 
81  // Return the iteration count
82  int GetIterationCount(void);
83 
84  // Return the current residual
85  double GetCurrentResidual(void);
86 
87  // Return the current status
88  int GetSolverStatus(void);
89 
91  int GetAmaxResidualIndex(void);
92 
93 private:
94 
99  int verb_;
100 
103 
105  bool init_res_;
106 
109 
120 
127  int reached_;
128 
130  std::vector<double> residual_history_;
131 
133  double current_res_;
134 
137 
139  bool rec_;
140 
141 };
142 
143 
144 }
145 
146 #endif // PARALUTION_ITER_CTRL_HPP_
int verb_
Verbose flag verb == 0 no output verb == 1 print info about the solver (start,end); verb == 2 print (...
Definition: iter_ctrl.hpp:99
int maximum_iter_
Maximum number of iteration.
Definition: iter_ctrl.hpp:119
int GetIterationCount(void)
Definition: iter_ctrl.cpp:150
Iteration control for iterative solvers, monitor the residual (L2 norm) behavior. ...
Definition: iter_ctrl.hpp:11
double current_res_
Current residual (obtained via CheckResidual())
Definition: iter_ctrl.hpp:133
void PrintStatus(void)
Print the current status (is the any criteria reached or not)
Definition: iter_ctrl.cpp:325
int current_index_
Current residual, index for the inf norm (obtained via CheckResidual())
Definition: iter_ctrl.hpp:136
int GetMaximumIterations(void) const
Get the maximal number of iterations.
Definition: iter_ctrl.cpp:144
bool CheckResidualNoCount(const double res) const
Check the residual (without counting the number of iterations)
Definition: iter_ctrl.cpp:238
double divergence_tol_
Divergence tolerance.
Definition: iter_ctrl.hpp:115
bool rec_
Flag == true then the residual is recorded in the residual_history_ vector.
Definition: iter_ctrl.hpp:139
void InitTolerance(const double abs, const double rel, const double div)
Initialize with absolute/relative/divergence tolerance.
Definition: iter_ctrl.cpp:94
void Verbose(const int verb=1)
Provide verbose output of the solver (iter, residual)
Definition: iter_ctrl.cpp:272
void Clear(void)
Clear (reset)
Definition: iter_ctrl.cpp:26
bool CheckResidual(const double res)
Check the residual (this count also the number of iterations)
Definition: iter_ctrl.cpp:174
int minimum_iter_
Minimum number of iteration.
Definition: iter_ctrl.hpp:117
double GetCurrentResidual(void)
Definition: iter_ctrl.cpp:156
void RecordHistory(void)
Record the history of the residual.
Definition: iter_ctrl.cpp:266
void WriteHistoryToFile(const std::string filename) const
Write the history of the residual to an ASCII file.
Definition: iter_ctrl.cpp:278
void Init(const double abs, const double rel, const double div, const int max)
Initialize with absolute/relative/divergence tolerance and maximum number of iterations.
Definition: iter_ctrl.cpp:47
int GetMinimumIterations(void) const
Get the minimum number of iterations.
Definition: iter_ctrl.cpp:138
int GetAmaxResidualIndex(void)
Return absolute maximum index of residual vector when using Linf norm.
Definition: iter_ctrl.cpp:162
Definition: backend_manager.cpp:43
void InitMaximumIterations(const int max)
Set the maximal number of iterations.
Definition: iter_ctrl.cpp:126
double initial_residual_
Initial residual.
Definition: iter_ctrl.hpp:108
~IterationControl()
Definition: iter_ctrl.cpp:20
double absolute_tol_
Absolute tolerance.
Definition: iter_ctrl.hpp:111
int reached_
Indicator for the reached criteria: 0 - not yet; 1 - abs tol is reached; 2 - rel tol is reached; 3 - ...
Definition: iter_ctrl.hpp:127
int GetSolverStatus(void)
Definition: iter_ctrl.cpp:168
IterationControl()
Definition: iter_ctrl.cpp:14
void InitMinimumIterations(const int min)
Set the minimum number of iterations.
Definition: iter_ctrl.cpp:114
void PrintInit(void)
Print the initialized information of the iteration control.
Definition: iter_ctrl.cpp:306
std::vector< double > residual_history_
STL vector keeping the residual history.
Definition: iter_ctrl.hpp:130
int iteration_
Iteration count.
Definition: iter_ctrl.hpp:102
bool init_res_
Flag == true after calling InitResidual()
Definition: iter_ctrl.hpp:105
double relative_tol_
Relative tolerance.
Definition: iter_ctrl.hpp:113
bool InitResidual(const double res)
Initialize the initial residual.
Definition: iter_ctrl.cpp:62