Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
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
16namespace Tempus {
17
18template <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
34template <class Scalar>
38
39template <class Scalar>
41 const Integrator<Scalar>&)
42{
43 logCall(nameObserveStartIntegrator_);
44}
45
46template <class Scalar>
48 const Integrator<Scalar>&)
49{
50 logCall(nameObserveStartTimeStep_);
51}
52
53template <class Scalar>
55 const Integrator<Scalar>&)
56{
57 logCall(nameObserveNextTimeStep_);
58}
59
60template <class Scalar>
62 const Integrator<Scalar>&)
63{
64 logCall(nameObserveBeforeTakeStep_);
65}
66
67template <class Scalar>
69 const Integrator<Scalar>&)
70{
71 logCall(nameObserveAfterTakeStep_);
72}
73
74template <class Scalar>
76 const Integrator<Scalar>&)
77{
78 logCall(nameObserveAfterCheckTimeStep_);
79}
80
81template <class Scalar>
83 const Integrator<Scalar>&)
84{
85 logCall(nameObserveEndTimeStep_);
86}
87
88template <class Scalar>
90 const Integrator<Scalar>&)
91{
92 logCall(nameObserveEndIntegrator_);
93}
94
95template <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
109template <class Scalar>
110Teuchos::RCP<const std::map<std::string, int> >
112{
113 return counters_;
114}
115
116template <class Scalar>
117Teuchos::RCP<const std::list<std::string> >
119{
120 return order_;
121}
122
123template <class Scalar>
124void 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 observeAfterTakeStep(const Integrator< Scalar > &integrator) override
Observe after Stepper takes step.
virtual void observeNextTimeStep(const Integrator< Scalar > &integrator) override
Observe after the next time step size is selected.
virtual void observeBeforeTakeStep(const Integrator< Scalar > &integrator) override
Observe before Stepper takes step.
virtual void observeStartTimeStep(const Integrator< Scalar > &integrator) override
Observe the beginning of the time step loop.
virtual void observeStartIntegrator(const Integrator< Scalar > &integrator) override
Observe the beginning of the time integrator.
Teuchos::RCP< const std::map< std::string, int > > getCounters()
void logCall(const std::string call) const
Asserts next call on the stack is correct and removes from stack.
Teuchos::RCP< std::map< std::string, int > > counters_
Teuchos::RCP< std::list< std::string > > order_
virtual void observeEndIntegrator(const Integrator< Scalar > &integrator) override
Observe the end of the time integrator.
virtual void observeEndTimeStep(const Integrator< Scalar > &integrator) override
Observe the end of the time step loop.
virtual void observeAfterCheckTimeStep(const Integrator< Scalar > &integrator) override
Observe after checking time step.
Thyra Base interface for time integrators. Time integrators are designed to advance the solution from...