Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_IntegratorObserverLogging_impl.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_impl_hpp
10 #define Tempus_IntegratorObserverLogging_impl_hpp
11 
13 #include "Tempus_TimeStepControl.hpp"
14 
15 namespace Tempus {
16 
17 template <class Scalar>
19  : nameObserveStartIntegrator_("observeStartIntegrator"),
20  nameObserveStartTimeStep_("observeStartTimeStep"),
21  nameObserveNextTimeStep_("observeNextTimeStep"),
22  nameObserveBeforeTakeStep_("observeBeforeTakeStep"),
23  nameObserveAfterTakeStep_("observeAfterTakeStep"),
24  nameObserveAfterCheckTimeStep_("observeAfterCheckTimeStep"),
25  nameObserveEndTimeStep_("observeEndTimeStep"),
26  nameObserveEndIntegrator_("observeEndIntegrator")
27 {
28  counters_ = Teuchos::rcp(new std::map<std::string, int>);
29  order_ = Teuchos::rcp(new std::list<std::string>);
30  this->resetLogCounters();
31 }
32 
33 template <class Scalar>
35 {
36 }
37 
38 template <class Scalar>
40  const Integrator<Scalar>&)
41 {
42  logCall(nameObserveStartIntegrator_);
43 }
44 
45 template <class Scalar>
47  const Integrator<Scalar>&)
48 {
49  logCall(nameObserveStartTimeStep_);
50 }
51 
52 template <class Scalar>
54  const Integrator<Scalar>&)
55 {
56  logCall(nameObserveNextTimeStep_);
57 }
58 
59 template <class Scalar>
61  const Integrator<Scalar>&)
62 {
63  logCall(nameObserveBeforeTakeStep_);
64 }
65 
66 template <class Scalar>
68  const Integrator<Scalar>&)
69 {
70  logCall(nameObserveAfterTakeStep_);
71 }
72 
73 template <class Scalar>
75  const Integrator<Scalar>&)
76 {
77  logCall(nameObserveAfterCheckTimeStep_);
78 }
79 
80 template <class Scalar>
82  const Integrator<Scalar>&)
83 {
84  logCall(nameObserveEndTimeStep_);
85 }
86 
87 template <class Scalar>
89  const Integrator<Scalar>&)
90 {
91  logCall(nameObserveEndIntegrator_);
92 }
93 
94 template <class Scalar>
96 {
97  (*counters_)[nameObserveStartIntegrator_] = 0;
98  (*counters_)[nameObserveStartTimeStep_] = 0;
99  (*counters_)[nameObserveNextTimeStep_] = 0;
100  (*counters_)[nameObserveBeforeTakeStep_] = 0;
101  (*counters_)[nameObserveAfterTakeStep_] = 0;
102  (*counters_)[nameObserveAfterCheckTimeStep_] = 0;
103  (*counters_)[nameObserveEndTimeStep_] = 0;
104  (*counters_)[nameObserveEndIntegrator_] = 0;
105  order_->clear();
106 }
107 
108 template <class Scalar>
111 {
112  return counters_;
113 }
114 
115 template <class Scalar>
118 {
119  return order_;
120 }
121 
122 template <class Scalar>
123 void IntegratorObserverLogging<Scalar>::logCall(const std::string call) const
124 {
125  (*counters_)[call] += 1;
126  order_->push_back(call);
127 }
128 
129 } // namespace Tempus
130 #endif // Tempus_IntegratorObserverLogging_impl_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_
virtual void observeBeforeTakeStep(const Integrator< Scalar > &integrator) override
Observe before Stepper takes step.
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 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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.