Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
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
17namespace Tempus_Test {
18
24template<class Scalar>
26 : virtual public Tempus::StepperExplicit<Scalar>
27{
28public:
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() {}
43 Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState()
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
84 RCP<PhysicsStateCounter<Scalar> > pSC =
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
97Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const
98{
99 return Teuchos::null;
100}
101
102};
103
104} // namespace Tempus_Test
105
106#endif // Tempus_PhysicsStateTest_StepperForwardEuler_hpp
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Thyra Base interface for implicit time steppers.
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs_
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Explicit ODE ModelEvaluator.
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
Set model.
void setICConsistencyCheck(bool c)
virtual std::string description() const
virtual void setUseFSAL(bool a)
void setStepperType(std::string s)
Set the stepper type.
void setICConsistency(std::string s)
This is a Forward Euler time stepper to test the PhysicsState.
StepperPhysicsStateTest(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
Constructor.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
virtual void takeStep(const Teuchos::RCP< Tempus::SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
void initialize()
Initialize after construction and changing input parameters.
@ FIRST_ORDER_ODE
Stepper integrates first-order ODEs.