Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperRKObserverLogging_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_StepperRKObserverLogging_impl_hpp
10 #define Tempus_StepperRKObserverLogging_impl_hpp
11 
13 #include "Tempus_TimeStepControl.hpp"
14 
15 namespace Tempus {
16 
17 template<class Scalar>
19  : nameObserveBeginTakeStep_ ( "observeBeginTakeStep"),
20  nameObserveBeginStage_ ( "observeBeginStage"),
21  nameObserveBeforeImplicitExplicitly_ ( "observeBeforeImplicitExplicitly"),
22  nameObserveBeforeSolve_ ( "observeBeforeSolve"),
23  nameObserveAfterSolve_ ( "observeAfterSolve"),
24  nameObserveBeforeExplicit_ ( "observeBeforeExplicit"),
25  nameObserveEndStage_ ( "observeEndStage"),
26  nameObserveEndTakeStep_ ( "observeEndTakeStep")
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 template<class Scalar>
39  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
40  Stepper<Scalar> & /* stepper */)
41 { logCall(nameObserveBeginTakeStep_); }
42 
43 template<class Scalar>
46  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
47  Stepper<Scalar> & /* stepper */)
48 { logCall(nameObserveBeginStage_); }
49 
50 template<class Scalar>
53  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
54  Stepper<Scalar> & /* stepper */)
55 { logCall(nameObserveBeforeImplicitExplicitly_); }
56 
57 template<class Scalar>
60  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
61  Stepper<Scalar> & /* stepper */)
62 { logCall(nameObserveBeforeSolve_); }
63 
64 template<class Scalar>
67  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
68  Stepper<Scalar> & /* stepper */)
69 { logCall(nameObserveAfterSolve_); }
70 
71 template<class Scalar>
74  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
75  Stepper<Scalar> & /* stepper */)
76 { logCall(nameObserveBeforeExplicit_); }
77 
78 template<class Scalar>
81  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
82  Stepper<Scalar> & /* stepper */)
83 { logCall(nameObserveEndStage_); }
84 
85 template<class Scalar>
88  Teuchos::RCP<SolutionHistory<Scalar> > /* sh */,
89  Stepper<Scalar> & /* stepper */)
90 { logCall(nameObserveEndTakeStep_); }
91 
92 template<class Scalar>
94 {
95  (*counters_)[nameObserveBeginTakeStep_ ] = 0;
96  (*counters_)[nameObserveBeginStage_ ] = 0;
97  (*counters_)[nameObserveBeforeImplicitExplicitly_ ] = 0;
98  (*counters_)[nameObserveBeforeSolve_ ] = 0;
99  (*counters_)[nameObserveAfterSolve_ ] = 0;
100  (*counters_)[nameObserveBeforeExplicit_ ] = 0;
101  (*counters_)[nameObserveEndStage_ ] = 0;
102  (*counters_)[nameObserveEndTakeStep_ ] = 0;
103  order_->clear();
104 }
105 
106 template<class Scalar>
107 Teuchos::RCP<const std::map<std::string,int> >
109 { return counters_; }
110 
111 template<class Scalar>
112 Teuchos::RCP<const std::list<std::string> >
114 { return order_; }
115 
116 template<class Scalar>
117 void StepperRKObserverLogging<Scalar>::logCall(const std::string call) const
118 {
119  (*counters_)[call] += 1;
120  order_->push_back(call);
121 }
122 
123 } // namespace Tempus
124 #endif // Tempus_StepperRKObserverLogging_impl_hpp
void logCall(const std::string call) const
Asserts next call on the stack is correct and removes from stack.
Teuchos::RCP< std::list< std::string > > order_
Teuchos::RCP< std::map< std::string, int > > counters_
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).
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).