Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperSubcyclingModifierXBase.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_StepperSubcyclingModifierXBase_hpp
10 #define Tempus_StepperSubcyclingModifierXBase_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_SolutionHistory.hpp"
15 
16 
17 namespace Tempus {
18 
19 /** \brief Base ModifierX for StepperSubcycling.
20  *
21  * This class provides a means to modify just the solution values
22  * (i.e., \f$x\f$ and \f$dot{x}\f$), and nothing else, but time and
23  * timestep are also provided.
24  *
25  * Users deriving from this class can access and change the solution
26  * during the timestep (e.g., limiting the solution for monoticity).
27  * It is expected that the user knows what changes are allowable without
28  * affecting the Stepper correctness, performance, accuracy and stability
29  * (i.e., USER BEWARE!!).
30  *
31  * Below is the Subcycling algorithm with the locations of the ModifierX calls
32  * italicized.
33  *
34  * \f{algorithm}{
35  * \renewcommand{\thealgorithm}{}
36  * \caption{Subcycling with the locations of the application actions indicated}
37  * \begin{algorithmic}[1]
38  * \State ToDO
39  * \end{algorithmic}
40  * \f}
41  */
42 
43 template<class Scalar>
45  : virtual public Tempus::StepperSubcyclingAppAction<Scalar>
46 {
47 private:
48 
49  /* \brief Adaptor execute function
50  *
51  * This is an adaptor function to bridge between the AppAction
52  * interface and the ModifierX interface. It is meant to be private
53  * and non-virtual as deriving from this class should only need to
54  * implement the modify function.
55  *
56  * For the ModifierX interface, this adaptor maps the
57  * StepperSubcyclingAppAction::ACTION_LOCATION to the
58  * StepperSubcyclingModifierX::MODIFIERX_TYPE, and only pass the solution
59  * (\f$x\f$ and/or \f$\dot{x}\f$ and other parameters to the modify
60  * function.
61  */
62  void execute(
63  Teuchos::RCP<SolutionHistory<Scalar> > sh,
64  Teuchos::RCP<StepperSubcycling<Scalar> > stepper,
66  {
67  using Teuchos::RCP;
68 
69  MODIFIER_TYPE modType = X_BEGIN_STEP;
70  RCP<SolutionState<Scalar> > workingState = sh->getWorkingState();
71  const Scalar time = workingState->getTime();
72  const Scalar dt = workingState->getTimeStep();
73  RCP<Thyra::VectorBase<Scalar> > x;
74 
75  switch(actLoc) {
77  {
78  modType = X_BEGIN_STEP;
79  x = workingState->getX();
80  break;
81  }
83  {
84  modType = XDOT_END_STEP;
85  x = stepper->getStepperXDot(workingState);
86  break;
87  }
88  default:
89  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
90  "Error - unknown action location.\n");
91  }
92 
93  this->modify(x, time, dt, modType);
94  }
95 
96 public:
97 
98  /// Indicates the location of application action (see algorithm).
100  X_BEGIN_STEP, ///< Modify \f$x\f$ at the beginning of the step.
101  XDOT_END_STEP ///< Modify \f$\dot{x}\f$ at the end of the step.
102  };
103 
104  /// Modify solution based on the MODIFIER_TYPE.
105  virtual void modify(
106  Teuchos::RCP<Thyra::VectorBase<Scalar> > /* x */,
107  const Scalar /* time */, const Scalar /* dt */,
108  const MODIFIER_TYPE modType) = 0;
109 
110 };
111 
112 } // namespace Tempus
113 
114 #endif // Tempus_StepperSubcyclingModifierXBase_hpp
Application Action for StepperSubcycling.
virtual void modify(Teuchos::RCP< Thyra::VectorBase< Scalar > >, const Scalar, const Scalar, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
ACTION_LOCATION
Indicates the location of application action (see algorithm).
void execute(Teuchos::RCP< SolutionHistory< Scalar > > sh, Teuchos::RCP< StepperSubcycling< Scalar > > stepper, const typename StepperSubcyclingAppAction< Scalar >::ACTION_LOCATION actLoc)
Execute application action for Subcycling Stepper.
MODIFIER_TYPE
Indicates the location of application action (see algorithm).