Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus_StepperRKModifierXBase.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_StepperRKModifierXBase_hpp
10#define Tempus_StepperRKModifierXBase_hpp
11
12#include "Tempus_config.hpp"
13#include "Tempus_SolutionHistory.hpp"
15
16#include "Teuchos_SerialDenseVector.hpp"
17
18namespace Tempus {
19
38template<class Scalar>
40 : virtual public Tempus::StepperRKAppAction<Scalar>
41{
42private:
43
44 /* \brief Adaptor execute function
45 *
46 * This is an adaptor function to bridge between the AppAction
47 * interface and the ModifierX interface. It is meant to be private
48 * and non-virtual as deriving from this class should only need to
49 * implement the modify function.
50 *
51 * For the ModifierX interface, this adaptor maps the
52 * StepperRKAppAction::ACTION_LOCATION to the
53 * StepperRKModifierX::MODIFIERX_TYPE, and only pass the solution
54 * (\f$x\f$ and/or \f$\dot{x}\f$ and other parameters to the modify
55 * function.
56 */
57 void execute(
58 Teuchos::RCP<SolutionHistory<Scalar> > sh,
59 Teuchos::RCP<StepperRKBase<Scalar> > stepper,
61 {
62 using Teuchos::RCP;
63
65 const int stageNumber = stepper->getStageNumber();
66 Teuchos::SerialDenseVector<int,Scalar> c = stepper->getTableau()->c();
67 RCP<SolutionState<Scalar> > workingState = sh->getWorkingState();
68 const Scalar dt = workingState->getTimeStep();
69 Scalar time = sh->getCurrentState()->getTime();
70 if (stageNumber >= 0) time += c(stageNumber)*dt;
71 RCP<Thyra::VectorBase<Scalar> > x = workingState->getX();
72
73 switch(actLoc) {
75 {
76 modType = X_BEGIN_STEP;
77 break;
78 }
80 {
81 modType = X_BEGIN_STAGE;
82 break;
83 }
85 {
86 modType = X_BEFORE_SOLVE;
87 break;
88 }
90 {
91 modType = X_AFTER_SOLVE;
92 break;
93 }
95 {
96 modType = X_BEFORE_EXPLICIT_EVAL;
97 break;
98 }
100 {
101 modType = X_END_STAGE;
102 break;
103 }
105 {
106 modType = X_END_STEP;
107 time = workingState->getTime();
108 break;
109 }
110 default:
111 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
112 "Error - unknown action location.\n");
113 }
114
115 this->modify(x, time, dt, stageNumber, modType);
116 }
117
118public:
119
130
132 virtual void modify(
133 Teuchos::RCP<Thyra::VectorBase<Scalar> > /* x */,
134 const Scalar /* time */, const Scalar /* dt */,
135 const int /* stageNumber */,
136 const MODIFIER_TYPE modType) = 0;
137
138};
139
140} // namespace Tempus
141
142#endif // Tempus_StepperRKModifierXBase_hpp
Application Action for StepperRKBase.
ACTION_LOCATION
Indicates the location of application action (see algorithm).
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
@ X_END_STEP
Modify at the end of the step.
@ X_BEGIN_STEP
Modify at the beginning of the step.
@ X_AFTER_SOLVE
Modify after the implicit solve.
@ X_END_STAGE
Modify at the end of the stage.
@ X_BEFORE_SOLVE
Modify before the implicit solve.
@ X_BEFORE_EXPLICIT_EVAL
Modify before the explicit evaluation.
@ X_BEGIN_STAGE
Modify at the beginning of the stage.
virtual void modify(Teuchos::RCP< Thyra::VectorBase< Scalar > >, const Scalar, const Scalar, const int, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
void execute(Teuchos::RCP< SolutionHistory< Scalar > > sh, Teuchos::RCP< StepperRKBase< Scalar > > stepper, const typename StepperRKAppAction< Scalar >::ACTION_LOCATION actLoc)
Execute application action for RK Stepper.