12#ifndef BELOS_STATUS_TEST_COMBO_H
13#define BELOS_STATUS_TEST_COMBO_H
58template <
class ScalarType,
class MV,
class OP,
class DM = DefaultDenseMatrix<
int,ScalarType>>
63#ifndef DOXYGEN_SHOULD_SKIP_THIS
65 typedef std::vector< Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > > st_vector;
66 typedef typename st_vector::iterator iterator;
67 typedef typename st_vector::const_iterator const_iterator;
150 void print(std::ostream& os,
int indent = 0)
const;
188template <
class ScalarType,
class MV,
class OP,
class DM>
195template <
class ScalarType,
class MV,
class OP,
class DM>
200 tests_.push_back(test1);
204template <
class ScalarType,
class MV,
class OP,
class DM>
210 tests_.push_back(test1);
215template <
class ScalarType,
class MV,
class OP,
class DM>
219 tests_.push_back(add_test);
222 const int indent = 2;
223 std::cout <<
"\n*** WARNING! ***\n";
224 std::cout <<
"This combo test currently consists of the following:\n";
225 this->
print(std::cout, indent);
226 std::cout <<
"Unable to add the following test:\n";
227 add_test->print(std::cout, indent);
233template <
class ScalarType,
class MV,
class OP,
class DM>
237 if (test1.get() ==
this)
242 for (iterator i = tests_.begin(); i != tests_.end(); ++i) {
252template <
class ScalarType,
class MV,
class OP,
class DM>
259 else if (type_ ==
AND)
267template <
class ScalarType,
class MV,
class OP,
class DM>
271 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i)
281template <
class ScalarType,
class MV,
class OP,
class DM>
288 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i)
297template <
class ScalarType,
class MV,
class OP,
class DM>
300 bool isFailed =
false;
302 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i) {
307 if (s==
Failed) isFailed =
true;
316 if ((!isFailed) && (status_ ==
Failed)) {
322 if (isFailed) status_ =
Failed;
327template <
class ScalarType,
class MV,
class OP,
class DM>
330 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i) {
350template <
class ScalarType,
class MV,
class OP,
class DM>
352 for (
int j = 0; j < indent; j ++)
355 os << ((type_ ==
OR) ?
"OR" : (type_ ==
AND) ?
"AND" :
"SEQ");
356 os <<
" Combination";
357 os <<
" -> " << std::endl;
359 for (const_iterator i = tests_.begin(); i != tests_.end(); ++i)
360 (*i)->print(os, indent+2);
Pure virtual base class for defining the status testing capabilities of Belos.
StatusType checkStatus(Iteration< ScalarType, MV, OP, DM > *iSolver)
Check convergence status of the iterative solver.
StatusType getStatus() const
Return the result of the most recent checkStatus call.
bool isSafe(const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &test1)
StatusTestCombo(ComboType t, const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &test1)
Single test constructor.
void seqOp(Iteration< ScalarType, MV, OP, DM > *iSolver)
Use this for checkStatus when this is a sequential AND type combo. Updates status.
StatusTestCombo(ComboType t, const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &test1, const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &test2)
Dual test constructor.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
StatusTestCombo(ComboType t)
Constructor.
void andOp(Iteration< ScalarType, MV, OP, DM > *iSolver)
Use this for checkStatus when this is an AND type combo. Updates status.
void reset()
Resets all the status tests in this combination to their initial internal state.
StatusTestCombo< ScalarType, MV, OP, DM > & addStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &add_test)
Add another test to this combination.
st_vector getStatusTests()
Return the vector of status tests.
virtual ~StatusTestCombo()
Destructor.
void orOp(Iteration< ScalarType, MV, OP, DM > *iSolver)
Use this for checkStatus when this is an OR type combo. Updates status.
ComboType getComboType() const
Return the type of combination (OR, AND, or SEQ).
virtual void printStatus(std::ostream &os, StatusType type) const
Output the result of the most recent CheckStatus call.
StatusType
Whether the StatusTest wants iteration to stop.