Belos  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BelosStatusTestGeneralOutput.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Belos: Block Linear Solvers Package
4 //
5 // Copyright 2004-2016 NTESS and the Belos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 //
10 
11 #ifndef BELOS_STATUS_TEST_GENERAL_OUTPUT_HPP
12 #define BELOS_STATUS_TEST_GENERAL_OUTPUT_HPP
13 
20 #include "BelosConfigDefs.hpp"
21 #include "BelosTypes.hpp"
22 #include "BelosIteration.hpp"
23 
24 #include "BelosStatusTest.hpp"
26 #include "BelosOutputManager.hpp"
27 
28 namespace Belos {
29 
39 template <class ScalarType, class MV, class OP>
40 class StatusTestGeneralOutput : public StatusTestOutput<ScalarType,MV,OP> {
41 
42  public:
44 
45 
62  int mod = 1,
63  int printStates = Passed)
64  : printer_(printer),
65  test_(test),
66  state_(Undefined),
67  stateTest_(printStates),
68  modTest_(mod),
69  numCalls_(0)
70  {}
71 
75 
77 
78 
96  TEUCHOS_TEST_FOR_EXCEPTION(test_ == Teuchos::null,StatusTestError,"StatusTestGeneralOutput::checkStatus(): child pointer is null.");
97  state_ = test_->checkStatus(solver);
98 
99  if (numCalls_++ % modTest_ == 0) {
100  if ( (state_ & stateTest_) == state_) {
101  if ( printer_->isVerbosity(StatusTestDetails) ) {
102  print( printer_->stream(StatusTestDetails) );
103  }
104  else if ( printer_->isVerbosity(Debug) ) {
105  print( printer_->stream(Debug) );
106  }
107  }
108  }
109 
110  return state_;
111  }
112 
115  return state_;
116  }
118 
119 
121 
122 
125  void setOutputManager(const Teuchos::RCP<OutputManager<ScalarType> > &printer) { printer_ = printer; }
126 
129  void setOutputFrequency(int mod) { modTest_ = mod; }
130 
136  test_ = test;
137  state_ = Undefined;
138  }
139 
142  return test_;
143  }
144 
147  void setSolverDesc(const std::string& solverDesc) { solverDesc_ = solverDesc; }
148 
151  void setPrecondDesc(const std::string& precondDesc) { precondDesc_ = precondDesc; }
152 
154 
155 
157 
158 
163  void reset() {
164  state_ = Undefined;
165  test_->reset();
166  numCalls_ = 0;
167  }
168 
170  void resetNumCalls() { numCalls_ = 0; }
171 
173 
175 
176 
178  void print(std::ostream& os, int indent = 0) const {
179  std::string ind(indent,' ');
180  os << std::endl << ind << "Belos::StatusTestGeneralOutput: ";
181  switch (state_) {
182  case Passed:
183  os << "Passed" << std::endl;
184  break;
185  case Failed:
186  os << "Failed" << std::endl;
187  break;
188  case Undefined:
189  os << "Undefined" << std::endl;
190  break;
191  }
192  os << ind << " (Num calls,Mod test,State test): " << "(" << numCalls_ << ", " << modTest_ << ",";
193  if (stateTest_ == 0) {
194  os << " none)" << std::endl;
195  }
196  else {
197  if ( stateTest_ & Passed ) os << " Passed";
198  if ( stateTest_ & Failed ) os << " Failed";
199  if ( stateTest_ & Undefined ) os << " Undefined";
200  os << ")" << std::endl;
201  }
202  // print child, with extra indention
203  test_->print(os,indent+3);
204  }
205 
207 
208  private:
211  std::string solverDesc_;
212  std::string precondDesc_;
213  StatusType state_;
214  int stateTest_;
215  int modTest_;
216  int numCalls_;
217 };
218 
219 } // end of Belos namespace
220 
221 #endif /* BELOS_STATUS_TEST_OUTPUT_HPP */
StatusTestGeneralOutput(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod=1, int printStates=Passed)
Constructor.
Collection of types and exceptions used within the Belos solvers.
Belos&#39;s basic output manager for sending information of select verbosity levels to the appropriate ou...
Class which manages the output and verbosity of the Belos solvers.
void setChild(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Set child test.
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > getChild() const
Get child test.
Exception thrown to signal error in a status test during Belos::StatusTest::checkStatus().
Virtual base class for StatusTest that printing status tests.
Pure virtual base class for defining the status testing capabilities of Belos.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
Pure virtual base class which describes the basic interface to the linear solver iteration.
A pure virtual class for defining the status tests for the Belos iterative solvers.
StatusType
Whether the StatusTest wants iteration to stop.
Definition: BelosTypes.hpp:157
void setSolverDesc(const std::string &solverDesc)
Set a short solver description for output clarity.
StatusType checkStatus(Iteration< ScalarType, MV, OP > *solver)
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state...
void setOutputManager(const Teuchos::RCP< OutputManager< ScalarType > > &printer)
Set the output manager.
A special StatusTest for printing other status tests.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Belos header file which uses auto-configuration information to include necessary C++ headers...
void resetNumCalls()
Informs the outputting status test that it should reset the number of calls to zero.
A virtual base class for StatusTest that print other status tests.
StatusType getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run...

Generated on Fri Dec 20 2024 09:24:49 for Belos by doxygen 1.8.5