Rythmos - Transient Integration for Differential Equations  Version of the Day
 All Classes Functions Variables Typedefs Pages
Rythmos_StepControlInfo.hpp
1 
2 #ifndef RYTHMOS_STEP_CONTROL_INFO_HPP
3 #define RYTHMOS_STEP_CONTROL_INFO_HPP
4 
5 // disable clang warnings
6 #ifdef __clang__
7 #pragma clang system_header
8 #endif
9 
10 #include "Rythmos_StepperSupportTypes.hpp"
11 
12 namespace Rythmos {
13 
14 
17 template<class Scalar>
18 struct StepControlInfo {
20  Scalar stepSize;
22  StepSizeType stepType;
27  EBreakPointType breakPointType;
30  :stepSize(-1.0), stepType(STEP_TYPE_FIXED),
31  limitedByBreakPoint(false),
32  breakPointType(BREAK_POINT_TYPE_SOFT)
33  {}
34 };
35 
36 
38 template<class Scalar>
39 std::ostream& operator<<(
40  std::ostream &out, const StepControlInfo<Scalar> &stepCtrlInfo
41  )
42 {
43  using std::endl;
44  out
45  << "stepType = " << toString(stepCtrlInfo.stepType) << endl
46  << "stepSize = " << stepCtrlInfo.stepSize << endl
47  << "limitedByBreakPoint = " << stepCtrlInfo.limitedByBreakPoint << endl
48  << "breakPointType = " << toString(stepCtrlInfo.breakPointType) << endl;
49  return out;
50 }
51 
52 
60 template<class Scalar>
61 StepControlInfo<Scalar>
63  const StepControlInfo<Scalar> &trialStepCtrlInfo,
64  const Scalar &stepSizeTaken
65  )
66 {
67  typedef Teuchos::ScalarTraits<Scalar> ST;
68  const Scalar zero = ST::zero();
69  StepControlInfo<Scalar> stepCtrlInfo = trialStepCtrlInfo;
70  stepCtrlInfo.stepSize = stepSizeTaken;
71  if ( trialStepCtrlInfo.stepSize > zero && stepSizeTaken > zero ) {
72  if (stepSizeTaken < trialStepCtrlInfo.stepSize) {
73  stepCtrlInfo.limitedByBreakPoint = false;
74  }
75  }
76  else {
77  stepCtrlInfo.limitedByBreakPoint = false;
78  }
79  return stepCtrlInfo;
80 }
81 
82 
83 // 2007/09/14: rabartl: ToDo: Above: Move this function into
84 // Rythmos_IntegratorBaseHelpers.hpp once created!
85 
86 
87 } // namespace Rythmos
88 
89 
90 #endif // RYTHMOS_STEP_CONTROL_INFO_HPP
StepControlInfo()
Initialize to invalid state.
StepControlInfo< Scalar > stepCtrlInfoTaken(const StepControlInfo< Scalar > &trialStepCtrlInfo, const Scalar &stepSizeTaken)
Return a step control info object for a step actually taken.
Simple struct to aggregate integration/stepper control information.
Scalar stepSize
The size of the time step.
EBreakPointType breakPointType
True if the time integrator should restart when passing over the breakpoint.
bool limitedByBreakPoint
True if step size is limited by a breakpoint.
StepSizeType stepType
The type of time step.