Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_PhysicsStateTest_StepperForwardEuler.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_PhysicsStateTest_StepperForwardEuler_hpp
10 #define Tempus_PhysicsStateTest_StepperForwardEuler_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_StepperForwardEuler.hpp"
15 
16 
17 namespace Tempus_Test {
18 
24 template<class Scalar>
26  : virtual public Tempus::StepperExplicit<Scalar>
27 {
28 public:
29 
32  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel)
33  {
34  this->setStepperType( this->description());
35  this->setUseFSAL( false);
36  this->setICConsistency( "None");
37  this->setICConsistencyCheck( false);
38 
39  this->setModel(appModel);
40  }
41 
42  void initialize() {}
44  { return Teuchos::null; }
45  Scalar getOrder() const {return 1.0;}
46  Scalar getOrderMin() const {return 1.0;}
47  Scalar getOrderMax() const {return 1.0;}
49 
51  virtual void takeStep(
52  const Teuchos::RCP<Tempus::SolutionHistory<Scalar> >& solutionHistory)
53 {
54  using Teuchos::RCP;
55 
56  TEMPUS_FUNC_TIME_MONITOR("Tempus::StepperPhysicsStateTest::takeStep()");
57  {
58  RCP<Tempus::SolutionState<Scalar> > currentState =
59  solutionHistory->getCurrentState();
60 
61  typedef Thyra::ModelEvaluatorBase MEB;
62  this->inArgs_.set_x(currentState->getX());
63  if (this->inArgs_.supports(MEB::IN_ARG_t))
64  this->inArgs_.set_t(currentState->getTime());
65 
66  // For model evaluators whose state function f(x, x_dot, t) describes
67  // an implicit ODE, and which accept an optional x_dot input argument,
68  // make sure the latter is set to null in order to request the evaluation
69  // of a state function corresponding to the explicit ODE formulation
70  // x_dot = f(x, t)
71  if (this->inArgs_.supports(MEB::IN_ARG_x_dot))
72  this->inArgs_.set_x_dot(Teuchos::null);
73  this->outArgs_.set_f(currentState->getXDot());
74 
75  this->appModel_->evalModel(this->inArgs_,this->outArgs_);
76 
77  // Forward Euler update, x = x + dt*xdot
78  RCP<Tempus::SolutionState<Scalar> > workingState =
79  solutionHistory->getWorkingState();
80  const Scalar dt = workingState->getTimeStep();
81  Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
82  *(currentState->getX()),dt,*(currentState->getXDot()));
83 
85  Teuchos::rcp_dynamic_cast<PhysicsStateCounter<Scalar> >
86  (workingState->getPhysicsState());
87  int counter = pSC->getCounter();
88  counter++;
89  pSC->setCounter(counter);
90 
91  workingState->setSolutionStatus(Tempus::Status::PASSED);
92  workingState->setOrder(this->getOrder());
93  }
94  return;
95 }
96 
98 {
99  return Teuchos::null;
100 }
101 
102 };
103 
104 } // namespace Tempus_Test
105 
106 #endif // Tempus_PhysicsStateTest_StepperForwardEuler_hpp
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Explicit ODE ModelEvaluator.
This is a Forward Euler time stepper to test the PhysicsState.
virtual void takeStep(const Teuchos::RCP< Tempus::SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
void setICConsistencyCheck(bool c)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
PhysicsStateCounter is a simple PhysicsState that counts steps.
Stepper integrates first-order ODEs.
void initialize()
Initialize after construction and changing input parameters.
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
virtual void setUseFSAL(bool a)
Thyra Base interface for implicit time steppers.
void setStepperType(std::string s)
Set the stepper type.
StepperPhysicsStateTest(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
Constructor.
void setICConsistency(std::string s)