Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperOperatorSplitModifierXBase.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_StepperOperatorSplitModifierXBase_hpp
10 #define Tempus_StepperOperatorSplitModifierXBase_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_SolutionHistory.hpp"
15 
16 
17 namespace Tempus {
18 
19 /** \brief Base ModifierX for StepperOperatorSplit.
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  */
32 
33 template<class Scalar>
35  : virtual public Tempus::StepperOperatorSplitAppAction<Scalar>
36 {
37 private:
38 
39  /* \brief Adaptor execute function
40  *
41  * This is an adaptor function to bridge between the AppAction
42  * interface and the ModifierX interface. It is meant to be private
43  * and non-virtual as deriving from this class should only need to
44  * implement the modify function.
45  *
46  * For the ModifierX interface, this adaptor maps the
47  * StepperOperatorSplitAppAction::ACTION_LOCATION to the
48  * StepperOperatorSplitModifierX::MODIFIERX_TYPE, and only pass the solution
49  * (\f$x\f$ and/or \f$\dot{x}\f$ and other parameters to the modify
50  * function.
51  */
52  void execute(
53  Teuchos::RCP<SolutionHistory<Scalar> > sh,
54  Teuchos::RCP<StepperOperatorSplit<Scalar> > stepper,
56  {
57  using Teuchos::RCP;
58 
59  MODIFIER_TYPE modType = X_BEGIN_STEP;
60  RCP<SolutionState<Scalar> > workingState = sh->getWorkingState();
61  const Scalar time = workingState->getTime();
62  const Scalar dt = workingState->getTimeStep();
63  RCP<Thyra::VectorBase<Scalar> > x;
64 
65  switch(actLoc) {
67  {
68  modType = X_BEGIN_STEP;
69  x = workingState->getX();
70  break;
71  }
73  {
74  modType = X_BEFORE_STEPPER;
75  x = workingState->getX();
76  break;
77  }
79  {
80  modType = X_AFTER_STEPPER;
81  x = workingState->getX();
82  break;
83  }
85  {
86  modType = XDOT_END_STEP;
87  x = stepper->getStepperXDot(workingState);
88  break;
89  }
90  default:
91  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
92  "Error - unknown action location.\n");
93  }
94 
95  this->modify(x, time, dt, modType);
96  }
97 
98 public:
99 
100  /// Indicates the location of application action (see algorithm).
102  X_BEGIN_STEP, ///< Modify \f$x\f$ at the beginning of the step.
103  X_BEFORE_STEPPER, ///< Modify \f$x\f$ before the implicit solve.
105  XDOT_END_STEP ///< Modify \f$\dot{x}\f$ at the end of the step.
106  };
107 
108  /// Modify solution based on the MODIFIER_TYPE.
109  virtual void modify(
110  Teuchos::RCP<Thyra::VectorBase<Scalar> > /* x */,
111  const Scalar /* time */, const Scalar /* dt */,
112  const MODIFIER_TYPE modType) = 0;
113 
114 };
115 
116 } // namespace Tempus
117 
118 #endif // Tempus_StepperOperatorSplitModifierXBase_hpp
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
OperatorSplit stepper loops through the Stepper list.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void modify(Teuchos::RCP< Thyra::VectorBase< Scalar > >, const Scalar, const Scalar, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
StepperOperatorSplitAppAction class for StepperOperatorSplit.
void execute(Teuchos::RCP< SolutionHistory< Scalar > > sh, Teuchos::RCP< StepperOperatorSplit< Scalar > > stepper, const typename StepperOperatorSplitAppAction< Scalar >::ACTION_LOCATION actLoc)
Execute application action for OperatorSplit Stepper.