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