44 #ifndef BELOS_STATUS_TEST_COMBO_H
45 #define BELOS_STATUS_TEST_COMBO_H
90 template <
class ScalarType,
class MV,
class OP>
95 #ifndef DOXYGEN_SHOULD_SKIP_THIS
97 typedef std::vector< Teuchos::RCP<StatusTest<ScalarType,MV,OP> > > st_vector;
98 typedef typename st_vector::iterator iterator;
99 typedef typename st_vector::const_iterator const_iterator;
101 #endif // DOXYGEN_SHOULD_SKIP_THIS
182 void print(std::ostream& os,
int indent = 0)
const;
220 template <
class ScalarType,
class MV,
class OP>
227 template <
class ScalarType,
class MV,
class OP>
232 tests_.push_back(test1);
236 template <
class ScalarType,
class MV,
class OP>
242 tests_.push_back(test1);
243 addStatusTest(test2);
247 template <
class ScalarType,
class MV,
class OP>
250 if (isSafe(add_test))
251 tests_.push_back(add_test);
254 const int indent = 2;
255 std::cout <<
"\n*** WARNING! ***\n";
256 std::cout <<
"This combo test currently consists of the following:\n";
257 this->print(std::cout, indent);
258 std::cout <<
"Unable to add the following test:\n";
259 add_test->print(std::cout, indent);
265 template <
class ScalarType,
class MV,
class OP>
269 if (test1.get() ==
this)
274 for (iterator i = tests_.begin(); i != tests_.end(); ++i) {
284 template <
class ScalarType,
class MV,
class OP>
291 else if (type_ == AND)
299 template <
class ScalarType,
class MV,
class OP>
303 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i)
313 template <
class ScalarType,
class MV,
class OP>
320 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i)
329 template <
class ScalarType,
class MV,
class OP>
332 bool isFailed =
false;
334 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i) {
339 if (s==
Failed) isFailed =
true;
348 if ((!isFailed) && (status_ ==
Failed)) {
354 if (isFailed) status_ =
Failed;
359 template <
class ScalarType,
class MV,
class OP>
362 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i) {
382 template <
class ScalarType,
class MV,
class OP>
384 for (
int j = 0; j < indent; j ++)
386 this->printStatus(os, status_);
387 os << ((type_ == OR) ?
"OR" : (type_ == AND) ?
"AND" :
"SEQ");
388 os <<
" Combination";
389 os <<
" -> " << std::endl;
391 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i)
392 (*i)->print(os, indent+2);
ComboType
The test can be either the AND of all the component tests, or the OR of all the component tests...
StatusType checkStatus(Iteration< ScalarType, MV, OP > *iSolver)
Check convergence status of the iterative solver.
Pure virtual base class for defining the status testing capabilities of Belos.
ComboType getComboType() const
Return the type of combination (OR, AND, or SEQ).
void seqOp(Iteration< ScalarType, MV, OP > *iSolver)
Use this for checkStatus when this is a sequential AND type combo. Updates status.
StatusTestCombo< ScalarType, MV, OP > & addStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &add_test)
Add another test to this combination.
A pure virtual class for defining the status tests for the Belos iterative solvers.
virtual ~StatusTestCombo()
Destructor.
StatusType
Whether the StatusTest wants iteration to stop.
void andOp(Iteration< ScalarType, MV, OP > *iSolver)
Use this for checkStatus when this is an AND type combo. Updates status.
void orOp(Iteration< ScalarType, MV, OP > *iSolver)
Use this for checkStatus when this is an OR type combo. Updates status.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
StatusTestCombo(ComboType t)
Constructor.
StatusType getStatus() const
Return the result of the most recent checkStatus call.
bool isSafe(const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &test1)
Check whether or not it is safe to add a to the list of tests.
A class for extending the status testing capabilities of Belos via logical combinations.
st_vector getStatusTests()
Return the vector of status tests.
void reset()
Resets all the status tests in this combination to their initial internal state.