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: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_IntegratorObserverLogging_impl_hpp
11 #define Tempus_IntegratorObserverLogging_impl_hpp
12 
14 #include "Tempus_TimeStepControl.hpp"
15 
16 namespace Tempus {
17 
18 template <class Scalar>
20  : nameObserveStartIntegrator_("observeStartIntegrator"),
21  nameObserveStartTimeStep_("observeStartTimeStep"),
22  nameObserveNextTimeStep_("observeNextTimeStep"),
23  nameObserveBeforeTakeStep_("observeBeforeTakeStep"),
24  nameObserveAfterTakeStep_("observeAfterTakeStep"),
25  nameObserveAfterCheckTimeStep_("observeAfterCheckTimeStep"),
26  nameObserveEndTimeStep_("observeEndTimeStep"),
27  nameObserveEndIntegrator_("observeEndIntegrator")
28 {
29  counters_ = Teuchos::rcp(new std::map<std::string, int>);
30  order_ = Teuchos::rcp(new std::list<std::string>);
31  this->resetLogCounters();
32 }
33 
34 template <class Scalar>
36 {
37 }
38 
39 template <class Scalar>
41  const Integrator<Scalar>&)
42 {
43  logCall(nameObserveStartIntegrator_);
44 }
45 
46 template <class Scalar>
48  const Integrator<Scalar>&)
49 {
50  logCall(nameObserveStartTimeStep_);
51 }
52 
53 template <class Scalar>
55  const Integrator<Scalar>&)
56 {
57  logCall(nameObserveNextTimeStep_);
58 }
59 
60 template <class Scalar>
62  const Integrator<Scalar>&)
63 {
64  logCall(nameObserveBeforeTakeStep_);
65 }
66 
67 template <class Scalar>
69  const Integrator<Scalar>&)
70 {
71  logCall(nameObserveAfterTakeStep_);
72 }
73 
74 template <class Scalar>
76  const Integrator<Scalar>&)
77 {
78  logCall(nameObserveAfterCheckTimeStep_);
79 }
80 
81 template <class Scalar>
83  const Integrator<Scalar>&)
84 {
85  logCall(nameObserveEndTimeStep_);
86 }
87 
88 template <class Scalar>
90  const Integrator<Scalar>&)
91 {
92  logCall(nameObserveEndIntegrator_);
93 }
94 
95 template <class Scalar>
97 {
98  (*counters_)[nameObserveStartIntegrator_] = 0;
99  (*counters_)[nameObserveStartTimeStep_] = 0;
100  (*counters_)[nameObserveNextTimeStep_] = 0;
101  (*counters_)[nameObserveBeforeTakeStep_] = 0;
102  (*counters_)[nameObserveAfterTakeStep_] = 0;
103  (*counters_)[nameObserveAfterCheckTimeStep_] = 0;
104  (*counters_)[nameObserveEndTimeStep_] = 0;
105  (*counters_)[nameObserveEndIntegrator_] = 0;
106  order_->clear();
107 }
108 
109 template <class Scalar>
112 {
113  return counters_;
114 }
115 
116 template <class Scalar>
119 {
120  return order_;
121 }
122 
123 template <class Scalar>
124 void IntegratorObserverLogging<Scalar>::logCall(const std::string call) const
125 {
126  (*counters_)[call] += 1;
127  order_->push_back(call);
128 }
129 
130 } // namespace Tempus
131 #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.