11#ifndef BELOS_STATUS_TEST_USER_OUTPUT_HPP
12#define BELOS_STATUS_TEST_USER_OUTPUT_HPP
37template <
class ScalarType,
class MV,
class OP>
72 headerPrinted_(
false),
114 state_ = test_->checkStatus(
solver);
119 if (currLSNum_ !=
currProb.getLSNumber()) {
120 currLSNum_ =
currProb.getLSNumber();
121 blockSize_ =
solver->getBlockSize();
123 currNumRHS_ = currIdx_.size();
124 numLSDgts_ = (
int)std::floor((
double)MVT::GetNumberVecs(*(
currProb.getRHS())))+1;
125 numIterDgts_ = (
int)std::floor(std::log10((
double)iterTest_->getMaxIters()))+1;
128 if (((iterTest_->getNumIters() % modTest_ == 0) && (iterTest_->getNumIters()!=lastNumIters_)) || (state_ ==
Passed)) {
129 lastNumIters_ = iterTest_->getNumIters();
130 if ( (state_ & stateTest_) == state_) {
134 else if ( printer_->isVerbosity(
Debug) ) {
168 Teuchos::RCP<StatusTestCombo_t>
comboTest = Teuchos::rcp_dynamic_cast<StatusTestCombo_t>(
test);
170 std::vector<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > >
tmpVec =
comboTest->getStatusTests();
179 Teuchos::RCP<StatusTestMaxIters_t>
tmpItrTest = Teuchos::rcp_dynamic_cast<StatusTestMaxIters_t>(
tmpVec[
i]);
188 Teuchos::RCP<StatusTestResNorm_t>
tmpResTest = Teuchos::rcp_dynamic_cast<StatusTestResNorm_t>(
tmpVec[
i]);
191 resTestVec_.resize( 1 );
193 resTestNamesVec_.resize( 1 );
194 resTestNamesVec_[0] =
"IMPLICIT RES";
201 Teuchos::RCP<StatusTestCombo_t>
tmpComboTest = Teuchos::rcp_dynamic_cast<StatusTestCombo_t>(
tmpVec[
i]);
208 typename std::map<std::string,Teuchos::RCP<StatusTest<ScalarType,MV,OP> > >::iterator
it;
215 for(
it = taggedTests_->begin();
it != taggedTests_->end(); ++
it) {
220 resTestNamesVec_.push_back(
"IMPLICIT RES");
225 for(
it = taggedTests_->begin();
it != taggedTests_->end(); ++
it) {
226 resTestVec_.push_back(
it->second);
227 resTestNamesVec_.push_back(
it->first);
238 Teuchos::RCP<StatusTest<ScalarType,MV,OP> >
getChild()
const {
263 headerPrinted_ =
false;
283 std::ios_base::fmtflags
osFlags(
os.flags());
285 os.setf(std::ios::scientific, std::ios::floatfield);
289 if (!headerPrinted_) {
291 os <<
ind <<
starFront <<
" Belos Iterative Solver: " << solverDesc_ << std::endl;
292 if (precondDesc_ !=
"")
293 os <<
ind <<
starFront <<
" Preconditioner: " << precondDesc_ << std::endl;
294 os <<
ind <<
starFront <<
" Maximum Iterations: " << iterTest_->getMaxIters() << std::endl;
295 os <<
ind <<
starFront <<
" Block Size: " << blockSize_ << std::endl;
299 os.setf(std::ios_base::right, std::ios_base::adjustfield);
300 std::string
indheader( 7 + numIterDgts_,
' ' );
302 for (
int i=0;
i<currNumRHS_; ++
i) {
303 if (
i > 0 && currIdx_[
i]!=-1 ) {
307 os <<
"[" << std::setw(numLSDgts_) << currIdx_[
i]+1 <<
"] : ";
308 for (
size_t j=0;
j<resTestVec_.size(); ++
j) {
309 os << std::setw(15) << resTestNamesVec_[
j];
313 headerPrinted_ =
true;
317 os.setf(std::ios_base::right, std::ios_base::adjustfield);
318 std::string
ind2( 7 + numIterDgts_,
' ' );
319 os <<
ind <<
"Iter " << std::setw(numIterDgts_) << iterTest_->getNumIters() <<
", ";
320 for (
int i=0;
i<currNumRHS_; ++
i) {
321 if (
i > 0 && currIdx_[
i]!=-1 ) {
325 os <<
"[" << std::setw(numLSDgts_) << currIdx_[
i]+1 <<
"] : ";
326 for (
size_t j=0;
j<resTestVec_.size(); ++
j) {
329 Teuchos::RCP<StatusTestResNorm_t>
tempResTest = Teuchos::rcp_dynamic_cast<StatusTestResNorm_t>(resTestVec_[
j]);
331 os << std::setw(15) << (*
tempResTest->getTestValue())[currIdx_[
i]];
334 os << std::setw(15) <<
"Passed";
336 os << std::setw(15) <<
"Failed";
337 else os << std::setw(15) <<
"Undefined";
340 os << std::setw(15) <<
"---";
353 Teuchos::RCP<OutputManager<ScalarType> > printer_;
356 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > test_;
359 Teuchos::RCP<std::map<std::string,Teuchos::RCP<StatusTest<ScalarType,MV,OP> > > > taggedTests_;
362 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> > iterTest_;
365 std::vector<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > > resTestVec_;
368 std::vector<std::string> resTestNamesVec_;
370 std::string solverDesc_;
371 std::string precondDesc_;
372 std::vector<int> currIdx_;
374 mutable bool headerPrinted_;
375 int stateTest_, modTest_;
376 int lastNumIters_, comboType_;
378 int currNumRHS_, currLSNum_;
379 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 setSolverDesc(const std::string &solverDesc)
Set a short solver description for output clarity.
void setOutputFrequency(int mod)
Set how often the child test is printed.
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > getChild() const
Get child test.
StatusType checkStatus(Iteration< ScalarType, MV, OP > *solver)
StatusTestUserOutput(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, Teuchos::RCP< std::map< std::string, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > > > taggedTests, int mod=1, int printStates=Passed)
Constructor.
void setPrecondDesc(const std::string &precondDesc)
Set a short preconditioner description for output clarity.
void resetNumCalls()
Informs the outputting status test that it should reset the number of calls to zero.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
StatusType getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run.
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state.
void setChild(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Set child test, which must be a combination of a Belos::StatusTestMaxIters AND a combination of Belos...
void setOutputManager(const Teuchos::RCP< OutputManager< ScalarType > > &printer)
Set the output manager.
virtual ~StatusTestUserOutput()
Destructor.
StatusType
Whether the StatusTest wants iteration to stop.