11#ifndef BELOS_STATUS_TEST_RESNORM_OUTPUT_HPP
12#define BELOS_STATUS_TEST_RESNORM_OUTPUT_HPP
41template <
class ScalarType,
class MV,
class OP>
74 headerPrinted_(
false),
117 state_ = test_->checkStatus(
solver);
122 if (currLSNum_ !=
currProb.getLSNumber()) {
123 currLSNum_ =
currProb.getLSNumber();
124 blockSize_ =
solver->getBlockSize();
126 currNumRHS_ = currIdx_.size();
127 numLSDgts_ = (
int)std::floor((
double)MVT::GetNumberVecs(*(
currProb.getRHS())))+1;
128 numIterDgts_ = (
int)std::floor(std::log10((
double)iterTest_->getMaxIters()))+1;
131 if (((iterTest_->getNumIters() % modTest_ == 0) && (iterTest_->getNumIters()!=lastNumIters_)) || (state_ ==
Passed)) {
132 lastNumIters_ = iterTest_->getNumIters();
133 if ( (state_ & stateTest_) == state_) {
137 else if ( printer_->isVerbosity(
Debug) ) {
171 Teuchos::RCP<StatusTestCombo_t>
comboTest = Teuchos::rcp_dynamic_cast<StatusTestCombo_t>(
test);
173 std::vector<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > >
tmpVec =
comboTest->getStatusTests();
182 Teuchos::RCP<StatusTestMaxIters_t>
tmpItrTest = Teuchos::rcp_dynamic_cast<StatusTestMaxIters_t>(
tmpVec[
i]);
189 Teuchos::RCP<StatusTestResNorm_t>
tmpResTest = Teuchos::rcp_dynamic_cast<StatusTestResNorm_t>(
tmpVec[
i]);
193 resTestVec_.resize( numResTests_ );
199 Teuchos::RCP<StatusTestCombo_t>
tmpComboTest = Teuchos::rcp_dynamic_cast<StatusTestCombo_t>(
tmpVec[
i]);
203 numResTests_ =
tmpVec.size();
204 resTestVec_.resize( numResTests_ );
205 for (
int j=0;
j<numResTests_; ++
j) {
219 Teuchos::RCP<StatusTest<ScalarType,MV,OP> >
getChild()
const {
244 headerPrinted_ =
false;
264 std::ios_base::fmtflags
osFlags(
os.flags());
266 os.setf(std::ios::scientific, std::ios::floatfield);
270 if (!headerPrinted_) {
272 os <<
ind <<
starFront <<
" Belos Iterative Solver: " << solverDesc_ << std::endl;
273 if (precondDesc_ !=
"")
274 os <<
ind <<
starFront <<
" Preconditioner: " << precondDesc_ << std::endl;
275 os <<
ind <<
starFront <<
" Maximum Iterations: " << iterTest_->getMaxIters() << std::endl;
276 os <<
ind <<
starFront <<
" Block Size: " << blockSize_ << std::endl;
277 if (numResTests_ > 1) {
279 << ((comboType_ == StatusTestCombo_t::OR) ?
"OR" : (comboType_ == StatusTestCombo_t::AND) ?
"AND" :
"SEQ")
280 <<
"): " << std::endl;
284 for (
int i=0;
i<numResTests_; ++
i) {
285 os <<
ind <<
starFront <<
" Test " <<
i+1 <<
" : " << resTestVec_[
i]->description() << std::endl;
288 headerPrinted_ =
true;
292 os.setf(std::ios_base::right, std::ios_base::adjustfield);
293 std::string
ind2( 7 + numIterDgts_,
' ' );
294 os <<
ind <<
"Iter " << std::setw(numIterDgts_) << iterTest_->getNumIters() <<
", ";
295 for (
int i=0;
i<currNumRHS_; ++
i) {
296 if (
i > 0 && currIdx_[
i]!=-1 ) {
300 os <<
"[" << std::setw(numLSDgts_) << currIdx_[
i]+1 <<
"] : ";
301 for (
int j=0;
j<numResTests_; ++
j) {
303 os << std::setw(15) << (*resTestVec_[
j]->getTestValue())[currIdx_[
i]];
305 os << std::setw(15) <<
"---";
318 Teuchos::RCP<OutputManager<ScalarType> > printer_;
321 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test_;
324 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> > iterTest_;
327 std::vector<Teuchos::RCP<StatusTestResNorm<ScalarType,MV,OP> > > resTestVec_;
329 std::string solverDesc_;
330 std::string precondDesc_;
331 std::vector<int> currIdx_;
333 mutable bool headerPrinted_;
334 int stateTest_, modTest_;
335 int lastNumIters_, comboType_;
336 int numResTests_, blockSize_;
337 int currNumRHS_, currLSNum_;
338 int numLSDgts_, numIterDgts_;
Belos header file which uses auto-configuration information to include necessary C++ headers.
Pure virtual base class which describes the basic interface to the linear solver iteration.
Belos::StatusTest for logically combining several status tests.
Belos::StatusTest class for specifying a maximum number of iterations.
Virtual base class for StatusTest that printing status tests.
Belos::StatusTest abstract class for specifying a residual norm stopping criteria.
Pure virtual base class for defining the status testing capabilities of Belos.
Collection of types and exceptions used within the Belos solvers.
Alternative run-time polymorphic interface for operators.
Exception thrown to signal error in a status test during Belos::StatusTest::checkStatus().
A virtual base class for StatusTest that print other status tests.
A special StatusTest for printing other status tests in a simple format.
void setOutputManager(const Teuchos::RCP< OutputManager< ScalarType > > &printer)
Set the output manager.
StatusTestResNormOutput(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod=1, int printStates=Passed)
Constructor.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
StatusType checkStatus(Iteration< ScalarType, MV, OP > *solver)
void setSolverDesc(const std::string &solverDesc)
Set a short solver description for output clarity.
void setChild(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Set child test, which must be a combination of a Belos::StatusTestMaxIters AND a single or combinatio...
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > getChild() const
Get child test.
void resetNumCalls()
Informs the outputting status test that it should reset the number of calls to zero.
StatusType getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run.
void setOutputFrequency(int mod)
Set how often the child test is printed.
void setPrecondDesc(const std::string &precondDesc)
Set a short preconditioner description for output clarity.
virtual ~StatusTestResNormOutput()
Destructor.
StatusType
Whether the StatusTest wants iteration to stop.