Stratimikos Version of the Day
Thyra_GeneralSolveCriteriaBelosStatusTest_decl.hpp
00001 
00002 #ifndef THYRA_GENERAL_SOLVE_CRITERIA_BELOS_STATUS_TEST_DECL_HPP
00003 #define THYRA_GENERAL_SOLVE_CRITERIA_BELOS_STATUS_TEST_DECL_HPP
00004 
00005 #include "Thyra_SolveSupportTypes.hpp"
00006 #include "BelosStatusTest.hpp"
00007 #include "BelosLinearProblem.hpp"
00008 #include "BelosMultiVecTraits.hpp"
00009 #include "Teuchos_VerboseObject.hpp"
00010 
00011 
00012 namespace Thyra {
00013 
00014 
00019 template<class Scalar>
00020 class GeneralSolveCriteriaBelosStatusTest
00021   : public Belos::StatusTest<Scalar, MultiVectorBase<Scalar>, LinearOpBase<Scalar> >,
00022     public Teuchos::VerboseObject<GeneralSolveCriteriaBelosStatusTest<Scalar> >
00023 {
00024 public:
00025 
00029   typedef MultiVectorBase<Scalar> MV;
00031   typedef LinearOpBase<Scalar> OP;
00033   typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
00035 
00038 
00040   GeneralSolveCriteriaBelosStatusTest();
00041 
00043   void setSolveCriteria(const SolveCriteria<Scalar> &solveCriteria,
00044     const int convergenceTestFrequency);
00045 
00047   ArrayView<const ScalarMag> achievedTol() const;
00048 
00050   
00054   virtual Belos::StatusType checkStatus(Belos::Iteration<Scalar,MV,OP> *iSolver);
00056   virtual Belos::StatusType getStatus() const;
00058   virtual void reset();
00060   virtual void print(std::ostream& os, int indent) const;
00062 
00063 private:
00064 
00065   SolveCriteria<Scalar> solveCriteria_;
00066   int convergenceTestFrequency_;
00067 
00068   bool compute_x_;
00069   bool compute_r_;
00070 
00071   Array<ScalarMag> r0_nrm_;
00072   Array<ScalarMag> b_nrm_;
00073   Array<ScalarMag> lastNumerator_;
00074   Array<ScalarMag> lastDenominator_;
00075   Array<ScalarMag> lastAchievedTol_;
00076   int lastCurrIter_;
00077   Belos::StatusType lastRtnStatus_;
00078 
00079   // Private member functions
00080 
00081   ScalarMag computeReductionFunctional(ESolveMeasureNormType measureType,
00082     const Ptr<const ReductionFunctional<Scalar> > &reductFunc,
00083     const Ptr<const VectorBase<Scalar> > &x,
00084     const Ptr<const VectorBase<Scalar> > &r
00085     ) const;
00086 
00087   void printRhsStatus(const int currIter, const int j, std::ostream &out,
00088     int indent = 0) const;
00089 
00090 };
00091 
00092 
00097 template<class Scalar>
00098 RCP<GeneralSolveCriteriaBelosStatusTest<Scalar> >
00099 createGeneralSolveCriteriaBelosStatusTest(
00100   const SolveCriteria<Scalar> &solveCriteria,
00101   const int convergenceTestFrequency
00102   )
00103 {
00104   RCP<GeneralSolveCriteriaBelosStatusTest<Scalar> >
00105     gscbst = Teuchos::rcp(new GeneralSolveCriteriaBelosStatusTest<Scalar>);
00106   gscbst->setSolveCriteria(solveCriteria, convergenceTestFrequency);
00107   return gscbst;
00108 }
00109 
00110 
00111 } // namespace Thyra
00112 
00113 
00114 #endif  // THYRA_GENERAL_SOLVE_CRITERIA_BELOS_STATUS_TEST_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends