Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_StepperBackwardEulerModifierXBase.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_StepperBackwardEulerModifierXBase_hpp
10 #define Tempus_StepperBackwardEulerModifierXBase_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_SolutionHistory.hpp"
15 
16 
17 namespace Tempus {
18 
36 template<class Scalar>
38  : virtual public Tempus::StepperBackwardEulerAppAction<Scalar>
39 {
40 private:
41 
42  /* \brief Adaptor execute function
43  *
44  * This is an adaptor function to bridge between the AppAction
45  * interface and the ModifierX interface. It is meant to be private
46  * and non-virtual as deriving from this class should only need to
47  * implement the modify function.
48  *
49  * For the ModifierX interface, this adaptor maps the
50  * StepperBackwardEulerAppAction::ACTION_LOCATION to the
51  * StepperBackwardEulerModifierX::MODIFIERX_TYPE, and only pass the solution
52  * (\f$x\f$ and/or \f$\dot{x}\f$ and other parameters to the modify
53  * function.
54  */
55  void execute(
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  {
71  modType = X_BEGIN_STEP;
72  x = workingState->getX();
73  break;
74  }
76  {
77  modType = X_BEFORE_SOLVE;
78  x = workingState->getX();
79  break;
80  }
82  {
83  modType = X_AFTER_SOLVE;
84  x = workingState->getX();
85  break;
86  }
88  {
89  modType = XDOT_END_STEP;
90  if (workingState->getXDot() != Teuchos::null)
91  x = workingState->getXDot();
92  else
93  x = stepper->getStepperXDot();
94  break;
95  }
96  default:
97  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
98  "Error - unknown action location.\n");
99  }
100 
101  this->modify(x, time, dt, modType);
102  }
103 
104 public:
105 
112  };
113 
115  virtual void modify(
117  const Scalar /* time */, const Scalar /* dt */,
118  const MODIFIER_TYPE modType) = 0;
119 
120 };
121 
122 } // namespace Tempus
123 
124 #endif // Tempus_StepperBackwardEulerModifierXBase_hpp
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
ACTION_LOCATION
Indicates the location of application action (see algorithm).
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void modify(Teuchos::RCP< Thyra::VectorBase< Scalar > >, const Scalar, const Scalar, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
Application Action for StepperBackwardEuler.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
void execute(Teuchos::RCP< SolutionHistory< Scalar > > sh, Teuchos::RCP< StepperBackwardEuler< Scalar > > stepper, const typename StepperBackwardEulerAppAction< Scalar >::ACTION_LOCATION actLoc)
Execute application action for BackwardEuler Stepper.