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 namespace Tempus_Test {
17 
23 template <class Scalar>
24 class StepperPhysicsStateTest : virtual public Tempus::StepperExplicit<Scalar> {
25  public:
28  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel)
29  {
30  this->setStepperType(this->description());
31  this->setUseFSAL(false);
32  this->setICConsistency("None");
33  this->setICConsistencyCheck(false);
34 
35  this->setModel(appModel);
36  }
37 
38  void initialize() {}
40  {
41  return Teuchos::null;
42  }
43  Scalar getOrder() const { return 1.0; }
44  Scalar getOrderMin() const { return 1.0; }
45  Scalar getOrderMax() const { return 1.0; }
47 
49  virtual void takeStep(
50  const Teuchos::RCP<Tempus::SolutionHistory<Scalar> >& solutionHistory)
51  {
52  using Teuchos::RCP;
53 
54  TEMPUS_FUNC_TIME_MONITOR("Tempus::StepperPhysicsStateTest::takeStep()");
55  {
56  RCP<Tempus::SolutionState<Scalar> > currentState =
57  solutionHistory->getCurrentState();
58 
59  typedef Thyra::ModelEvaluatorBase MEB;
60  this->inArgs_.set_x(currentState->getX());
61  if (this->inArgs_.supports(MEB::IN_ARG_t))
62  this->inArgs_.set_t(currentState->getTime());
63 
64  // For model evaluators whose state function f(x, x_dot, t) describes
65  // an implicit ODE, and which accept an optional x_dot input argument,
66  // make sure the latter is set to null in order to request the evaluation
67  // of a state function corresponding to the explicit ODE formulation
68  // x_dot = f(x, t)
69  if (this->inArgs_.supports(MEB::IN_ARG_x_dot))
70  this->inArgs_.set_x_dot(Teuchos::null);
71  this->outArgs_.set_f(currentState->getXDot());
72 
73  this->appModel_->evalModel(this->inArgs_, this->outArgs_);
74 
75  // Forward Euler update, x = x + dt*xdot
76  RCP<Tempus::SolutionState<Scalar> > workingState =
77  solutionHistory->getWorkingState();
78  const Scalar dt = workingState->getTimeStep();
79  Thyra::V_VpStV(Teuchos::outArg(*(workingState->getX())),
80  *(currentState->getX()), dt, *(currentState->getXDot()));
81 
83  Teuchos::rcp_dynamic_cast<PhysicsStateCounter<Scalar> >(
84  workingState->getPhysicsState());
85  int counter = pSC->getCounter();
86  counter++;
87  pSC->setCounter(counter);
88 
89  workingState->setSolutionStatus(Tempus::Status::PASSED);
90  workingState->setOrder(this->getOrder());
91  }
92  return;
93  }
94 
96  {
97  return Teuchos::null;
98  }
99 };
100 
101 } // namespace Tempus_Test
102 
103 #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)
Set model.
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)