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: 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
17namespace Tempus_Test {
18
24template <class Scalar>
25class 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() {}
40 Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState()
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
83 RCP<PhysicsStateCounter<Scalar> > pSC =
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
96 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const
97 {
98 return Teuchos::null;
99 }
100};
101
102} // namespace Tempus_Test
103
104#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.