Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_StepperForwardEulerModifierXBase.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_StepperForwardEulerModifierXBase_hpp
11 #define Tempus_StepperForwardEulerModifierXBase_hpp
12 
13 #include "Tempus_config.hpp"
14 #include "Tempus_SolutionHistory.hpp"
16 
17 namespace Tempus {
18 
37 template <class Scalar>
39  : virtual public Tempus::StepperForwardEulerAppAction<Scalar> {
40  private:
41  /* \brief Adaptor execute function
42  *
43  * This is an adaptor function to bridge between the AppAction
44  * interface and the ModifierX interface. It is meant to be private
45  * and non-virtual as deriving from this class should only need to
46  * implement the modify function.
47  *
48  * For the ModifierX interface, this adaptor maps the
49  * StepperForwardEulerAppAction::ACTION_LOCATION to the
50  * StepperForwardEulerModifierX::MODIFIERX_TYPE, and only pass the solution
51  * (\f$x\f$ and/or \f$\dot{x}\f$ and other parameters to the modify
52  * function.
53  */
54  void execute(
58  actLoc)
59  {
60  using Teuchos::RCP;
61 
62  MODIFIER_TYPE modType = X_BEGIN_STEP;
63  RCP<SolutionState<Scalar> > workingState = sh->getWorkingState();
64  const Scalar time = workingState->getTime();
65  const Scalar dt = workingState->getTimeStep();
66  RCP<Thyra::VectorBase<Scalar> > x;
67 
68  switch (actLoc) {
70  modType = X_BEGIN_STEP;
71  x = workingState->getX();
72  break;
73  }
75  modType = X_BEFORE_EXPLICIT_EVAL;
76  x = workingState->getX();
77  break;
78  }
80  modType = XDOT_END_STEP;
81  if (workingState->getXDot() != Teuchos::null)
82  x = workingState->getXDot();
83  else
84  x = stepper->getStepperXDot();
85  break;
86  }
87  default:
88  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
89  "Error - unknown action location.\n");
90  }
91 
92  this->modify(x, time, dt, modType);
93  }
94 
95  public:
101  };
102 
104  virtual void modify(Teuchos::RCP<Thyra::VectorBase<Scalar> > /* x */,
105  const Scalar /* time */, const Scalar /* dt */,
106  const MODIFIER_TYPE modType) = 0;
107 };
108 
109 } // namespace Tempus
110 
111 #endif // Tempus_StepperForwardEulerModifierXBase_hpp
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ACTION_LOCATION
Indicates the location of application action (see algorithm).
Application Action for StepperForwardEuler.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
void execute(Teuchos::RCP< SolutionHistory< Scalar > > sh, Teuchos::RCP< StepperForwardEuler< Scalar > > stepper, const typename StepperForwardEulerAppAction< Scalar >::ACTION_LOCATION actLoc)
Execute application action for ForwardEuler Stepper.
virtual void modify(Teuchos::RCP< Thyra::VectorBase< Scalar > >, const Scalar, const Scalar, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.