00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef BELOS_STATUS_TEST_MAXRESTARTS_HPP
00031 #define BELOS_STATUS_TEST_MAXRESTARTS_HPP
00032
00038 #include "BelosStatusTest.hpp"
00039
00048 namespace Belos {
00049
00050 template <class ScalarType, class MV, class OP>
00051 class StatusTestMaxRestarts: public StatusTest<ScalarType,MV,OP> {
00052
00053 public:
00054
00056
00057
00059 StatusTestMaxRestarts(int maxIters);
00060
00062 virtual ~StatusTestMaxRestarts() {};
00064
00066
00067
00069
00072 StatusType CheckStatus(IterativeSolver<ScalarType,MV,OP> *iSolver );
00073
00075 StatusType GetStatus() const {return(status_);};
00076
00078
00080
00081
00083 void Reset();
00084
00086
00088
00089
00091 int GetMaxRestarts() const { return(maxRestarts_); };
00092
00094 int GetNumRestarts() const { return(nRestarts_); };
00095
00097
00099
00100
00102 bool ResidualVectorRequired() const { return(false); } ;
00104
00106
00107
00109 ostream& Print(ostream& os, int indent = 0) const;
00110
00112
00113
00114 private:
00115
00117
00118
00119 int maxRestarts_;
00120
00122 int nRestarts_;
00123
00125 StatusType status_;
00127
00128 };
00129
00130 template <class ScalarType, class MV, class OP>
00131 StatusTestMaxRestarts<ScalarType,MV,OP>::StatusTestMaxRestarts(int maxRestarts)
00132 {
00133 if (maxRestarts < 1)
00134 maxRestarts_ = 1;
00135 else
00136 maxRestarts_ = maxRestarts;
00137
00138 nRestarts_ = 0;
00139 status_ = Unchecked;
00140 }
00141
00142 template <class ScalarType, class MV, class OP>
00143 StatusType StatusTestMaxRestarts<ScalarType,MV,OP>::CheckStatus(IterativeSolver<ScalarType,MV,OP> *iSolver )
00144 {
00145 status_ = Unconverged;
00146 nRestarts_ = iSolver->GetNumRestarts();
00147 if (nRestarts_ >= maxRestarts_)
00148 status_ = Failed;
00149 return status_;
00150 }
00151
00152 template <class ScalarType, class MV, class OP>
00153 void StatusTestMaxRestarts<ScalarType,MV,OP>::Reset()
00154 {
00155 status_ = Unchecked;
00156 nRestarts_ = 0;
00157 }
00158
00159 template <class ScalarType, class MV, class OP>
00160 ostream& StatusTestMaxRestarts<ScalarType,MV,OP>::Print(ostream& os, int indent) const
00161 {
00162 for (int j = 0; j < indent; j ++)
00163 os << ' ';
00164 this->PrintStatus(os, status_);
00165 os << "Number of Restarts = ";
00166 os << nRestarts_;
00167 os << ((nRestarts_ < maxRestarts_) ? " < " : ((nRestarts_ == maxRestarts_) ? " == " : " > "));
00168 os << maxRestarts_;
00169 os << endl;
00170 return os;
00171 }
00172
00173 }
00174
00175 #endif