Tempus  Version of the Day
Time Integration
Tempus_StepperRKObserverLogging_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_StepperRKObserverLogging_decl_hpp
10 #define Tempus_StepperRKObserverLogging_decl_hpp
11 
13 #include <list>
14 
15 namespace Tempus {
16 
17 /** \brief This observer logs calls to observer functions.
18  * This observer simply logs and counts the calls to each of the
19  * observer functions. This is useful in monirtoring and debugging
20  * the time integration.
21  */
22 template<class Scalar>
24  : virtual public Tempus::StepperRKObserver<Scalar>
25 {
26 public:
27 
28  /// Constructor
30 
31  /// Destructor
32  virtual ~StepperRKObserverLogging();
33 
34  /// \name Override StepperRKObserver basic methods
35  //@{
36  /// 1.) Observe Stepper at beginning of takeStep.
37  virtual void observeBeginTakeStep(
38  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
39  Stepper<Scalar> & /* stepper */) override;
40 
41  /// 2.) Observe Stepper at beginning of each stage.
42  virtual void observeBeginStage(
43  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
44  Stepper<Scalar> & /* stepper */) override;
45 
46  /// 3.) Observe Stepper before Explicit evaluation of Implicit ODE ME (IMEX).
48  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
49  Stepper<Scalar> & /* stepper */) override;
50 
51  /// 4.) Observe Stepper before nonlinear solve (DIRK/IMEX).
52  virtual void observeBeforeSolve(
53  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
54  Stepper<Scalar> & /* stepper */) override;
55 
56  /// 5.) Observe Stepper after nonlinear solve (DIRK/IMEX).
57  virtual void observeAfterSolve(
58  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
59  Stepper<Scalar> & /* stepper */) override;
60 
61  /// 6.) Observe Stepper before Explicit evaluation of Implicit ODE ME (IMEX).
62  virtual void observeBeforeExplicit(
63  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
64  Stepper<Scalar> & /* stepper */) override;
65 
66  /// 7.) Observe Stepper at end of each stage.
67  virtual void observeEndStage(
68  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
69  Stepper<Scalar> & /* stepper */) override;
70 
71  /// 8.) Observe Stepper at end of takeStep.
72  virtual void observeEndTakeStep(
73  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
74  Stepper<Scalar> & /* stepper */) override;
75  //@}
76 
77  void resetLogCounters();
78 
79  Teuchos::RCP<const std::map<std::string,int> > getCounters();
80 
81  Teuchos::RCP<const std::list<std::string> > getOrder();
82 
83  /** \name String names logged in map
84  Use these strings to validate a call stack with this observer
85  */
86  //@{
87  const std::string nameObserveBeginTakeStep_;
88  const std::string nameObserveBeginStage_;
90  const std::string nameObserveBeforeSolve_;
91  const std::string nameObserveAfterSolve_;
92  const std::string nameObserveBeforeExplicit_;
93  const std::string nameObserveEndStage_;
94  const std::string nameObserveEndTakeStep_;
95  //@}
96 
97 private:
98 
99  /** \brief Asserts next call on the stack is correct and removes from stack
100 
101  This is a const method so that it can be called from the
102  derived StepperRKObserver methods that are const.
103  */
104  void logCall(const std::string call) const;
105 
106  Teuchos::RCP< std::map<std::string,int> > counters_;
107  Teuchos::RCP< std::list<std::string> > order_;
108 
109 };
110 
111 } // namespace Tempus
112 #endif // Tempus_StepperRKObserverLogging_decl_hpp
This observer logs calls to observer functions. This observer simply logs and counts the calls to eac...
Teuchos::RCP< std::list< std::string > > order_
Teuchos::RCP< std::map< std::string, int > > counters_
void logCall(const std::string call) const
Asserts next call on the stack is correct and removes from stack.
virtual void observeBeginStage(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
2.) Observe Stepper at beginning of each stage.
Teuchos::RCP< const std::map< std::string, int > > getCounters()
Thyra Base interface for time steppers.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void observeBeforeExplicit(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
6.) Observe Stepper before Explicit evaluation of Implicit ODE ME (IMEX).
Teuchos::RCP< const std::list< std::string > > getOrder()
virtual void observeBeforeImplicitExplicitly(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
3.) Observe Stepper before Explicit evaluation of Implicit ODE ME (IMEX).
StepperRKObserver class for StepperRK.
virtual void observeBeginTakeStep(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
1.) Observe Stepper at beginning of takeStep.
virtual void observeAfterSolve(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
5.) Observe Stepper after nonlinear solve (DIRK/IMEX).
virtual void observeEndStage(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
7.) Observe Stepper at end of each stage.
virtual void observeEndTakeStep(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
8.) Observe Stepper at end of takeStep.
virtual void observeBeforeSolve(Teuchos::RCP< SolutionHistory< Scalar > >, Stepper< Scalar > &) override
4.) Observe Stepper before nonlinear solve (DIRK/IMEX).