SolverStatistics.hpp 2.04 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
87
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
116
117
118
#pragma once

#include <string>

namespace AMDiS
{

  class SolverStatistics
  {
  public:
    /// The constructor reads needed parameters and sets solvers \p prefix.
    /**
     * Reads parameters for a solver with name 'NAME':
     *   NAME->absolute tolerance   \ref aTol
     *   NAME->relative tolerance   \ref rTol
     *   NAME->info                 \ref info
     *   NAME->break if tolerance not reached \ref breakTolNotReached
    **/
    explicit SolverStatistics(std::string prefix);


    /** \name getting methods
     * \{
     */

    /// Returns \ref aTol
    double getAbsTolerance() const
    {
      return aTol;
    }

    /// Returns \ref rTol
    double getRelTolerance() const
    {
      return rTol;
    }

    /// Returns error code in last run of an iterative solver
    int getErrorCode() const
    {
      return error;
    }

    /// Returns info
    int getInfo() const
    {
      return info;
    }

    /// Returns \ref residual
    double getResidual() const
    {
      return residual;
    }
    
    /// Returns the initfile \ref prefix
    std::string getPrefix() const
    {
      return prefix;
    }

    /** \} */


    /** \name setting methods
     * \{
     */

    /// Sets \ref aTol
    void setAbsTolerance(double tol)
    {
      aTol = tol;
    }

    /// Sets \ref rTol
    void setAbsTolerance(double tol)
    {
      rTol = tol;
    }

    /// Sets \ref info
    void setInfo(int i)
    {
      info = i;
    }

    /// Sets \ref info
    void setError(int e)
    {
      error = e;
    }

    /** \} */
    
  private:
    /// The initfile prefix to read parameters
    std::string prefix;
    
  private:
    /// The abolute tolerance
    double aTol = 1.e-6;
    
    /// The relative tolerance
    double rTol = 0.0;
    
    /// Throw an error if tolerance could not be reached
    bool breakTolNotReached = true;
    
    /// The solver verbosity level
    int info = 0;
    
    // some parameters used internally  
    double absRresidual = -1.0;
    double relResidual = -1.0;
    int error = -1;
  };

} // end namespace AMDiS