Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_StepControlInfo.hpp
00001 
00002 #ifndef RYTHMOS_STEP_CONTROL_INFO_HPP
00003 #define RYTHMOS_STEP_CONTROL_INFO_HPP
00004 
00005 // disable clang warnings
00006 #ifdef __clang__
00007 #pragma clang system_header
00008 #endif
00009 
00010 #include "Rythmos_StepperSupportTypes.hpp"
00011 
00012 namespace Rythmos {
00013 
00014 
00017 template<class Scalar>
00018 struct StepControlInfo {
00020   Scalar stepSize;
00022   StepSizeType stepType;
00024   bool limitedByBreakPoint;
00027   EBreakPointType breakPointType;
00029   StepControlInfo()
00030     :stepSize(-1.0), stepType(STEP_TYPE_FIXED),
00031      limitedByBreakPoint(false),
00032      breakPointType(BREAK_POINT_TYPE_SOFT)
00033     {}
00034 };
00035 
00036 
00038 template<class Scalar>
00039 std::ostream& operator<<(
00040   std::ostream &out, const StepControlInfo<Scalar> &stepCtrlInfo
00041   )
00042 {
00043   using std::endl;
00044   out
00045     << "stepType = " << toString(stepCtrlInfo.stepType) << endl
00046     << "stepSize = " << stepCtrlInfo.stepSize << endl
00047     << "limitedByBreakPoint = " << stepCtrlInfo.limitedByBreakPoint << endl
00048     << "breakPointType = " << toString(stepCtrlInfo.breakPointType) << endl;
00049   return out;
00050 }
00051 
00052 
00060 template<class Scalar>
00061 StepControlInfo<Scalar>
00062 stepCtrlInfoTaken(
00063   const StepControlInfo<Scalar> &trialStepCtrlInfo,
00064   const Scalar &stepSizeTaken
00065   )
00066 {
00067   typedef Teuchos::ScalarTraits<Scalar> ST;
00068   const Scalar zero = ST::zero();
00069   StepControlInfo<Scalar> stepCtrlInfo = trialStepCtrlInfo;
00070   stepCtrlInfo.stepSize = stepSizeTaken;
00071   if ( trialStepCtrlInfo.stepSize > zero && stepSizeTaken > zero ) {
00072     if (stepSizeTaken < trialStepCtrlInfo.stepSize) {
00073       stepCtrlInfo.limitedByBreakPoint = false;
00074     }
00075   }
00076   else {
00077     stepCtrlInfo.limitedByBreakPoint = false;
00078   }
00079   return stepCtrlInfo;
00080 }
00081 
00082 
00083 // 2007/09/14: rabartl: ToDo: Above: Move this function into
00084 // Rythmos_IntegratorBaseHelpers.hpp once created!
00085 
00086 
00087 } // namespace Rythmos
00088 
00089 
00090 #endif // RYTHMOS_STEP_CONTROL_INFO_HPP
 All Classes Functions Variables Typedefs Friends