Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_IntegratorObserverLogging_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_IntegratorObserverLogging_decl_hpp
10 #define Tempus_IntegratorObserverLogging_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::IntegratorObserver<Scalar>
25 {
26 public:
27 
28  /// Constructor
30 
31  /// Destructor
33 
34  /// \name Override IntegratorObserver basic methods
35  //@{
36  /// Observe the beginning of the time integrator.
37  virtual void observeStartIntegrator(const Integrator<Scalar>& integrator) override;
38 
39  /// Observe the beginning of the time step loop.
40  virtual void observeStartTimeStep(const Integrator<Scalar>& integrator) override;
41 
42  /// Observe after the next time step size is selected.
43  virtual void observeNextTimeStep(const Integrator<Scalar>& integrator) override;
44 
45  /// Observe before Stepper takes step.
46  virtual void observeBeforeTakeStep(const Integrator<Scalar>& integrator) override;
47 
48  /// Observe after Stepper takes step.
49  virtual void observeAfterTakeStep(const Integrator<Scalar>& integrator) override;
50 
51  /// Observe after checking time step.
52  virtual void observeAfterCheckTimeStep(const Integrator<Scalar>& integrator) override;
53 
54  /// Observe the end of the time step loop.
55  virtual void observeEndTimeStep(const Integrator<Scalar>& integrator) override;
56 
57  /// Observe the end of the time integrator.
58  virtual void observeEndIntegrator(const Integrator<Scalar>& integrator) override;
59  //@}
60 
61  void resetLogCounters();
62 
63  Teuchos::RCP<const std::map<std::string,int> > getCounters();
64 
65  Teuchos::RCP<const std::list<std::string> > getOrder();
66 
67  /** \name String names logged in map
68  Use these strings to validate a call stack with this observer
69  */
70  //@{
71  const std::string nameObserveStartIntegrator_;
72  const std::string nameObserveStartTimeStep_;
73  const std::string nameObserveNextTimeStep_;
74  const std::string nameObserveBeforeTakeStep_;
75  const std::string nameObserveAfterTakeStep_;
76  const std::string nameObserveAfterCheckTimeStep_;
77  const std::string nameObserveEndTimeStep_;
78  const std::string nameObserveEndIntegrator_;
79  //@}
80 
81 private:
82 
83  /** \brief Asserts next call on the stack is correct and removes from stack
84 
85  This is a const method so that it can be called from the
86  derived IntegratorObserver methods that are const.
87  */
88  void logCall(const std::string call) const;
89 
90  Teuchos::RCP< std::map<std::string,int> > counters_;
91  Teuchos::RCP< std::list<std::string> > order_;
92 
93 };
94 
95 } // namespace Tempus
96 #endif // Tempus_IntegratorObserverLogging_decl_hpp
Teuchos::RCP< const std::list< std::string > > getOrder()
virtual void observeNextTimeStep(const Integrator< Scalar > &integrator) override
Observe after the next time step size is selected.
Teuchos::RCP< std::list< std::string > > order_
Teuchos::RCP< std::map< std::string, int > > counters_
virtual void observeBeforeTakeStep(const Integrator< Scalar > &integrator) override
Observe before Stepper takes step.
void logCall(const std::string call) const
Asserts next call on the stack is correct and removes from stack.
virtual void observeAfterCheckTimeStep(const Integrator< Scalar > &integrator) override
Observe after checking time step.
virtual void observeEndTimeStep(const Integrator< Scalar > &integrator) override
Observe the end of the time step loop.
This observer logs calls to observer functions. This observer simply logs and counts the calls to eac...
IntegratorObserver class for time integrators.
Thyra Base interface for time integrators. Time integrators are designed to advance the solution from...
virtual void observeAfterTakeStep(const Integrator< Scalar > &integrator) override
Observe after Stepper takes step.
virtual void observeEndIntegrator(const Integrator< Scalar > &integrator) override
Observe the end of the time integrator.
Teuchos::RCP< const std::map< std::string, int > > getCounters()
virtual void observeStartIntegrator(const Integrator< Scalar > &integrator) override
Observe the beginning of the time integrator.
virtual void observeStartTimeStep(const Integrator< Scalar > &integrator) override
Observe the beginning of the time step loop.