|
Rythmos - Transient Integration for Differential Equations
Version of the Day
|
00001 00002 #ifndef RYTHMOS_INTEGRATION_OBSERVER_BASE_HPP 00003 #define RYTHMOS_INTEGRATION_OBSERVER_BASE_HPP 00004 00005 #include "Rythmos_Types.hpp" 00006 #include "Teuchos_Describable.hpp" 00007 #include "Teuchos_VerboseObject.hpp" 00008 00009 namespace Rythmos { 00010 00011 00012 // Forwards 00013 template<class Scalar> class TimeRange; 00014 template<class Scalar> class StepControlInfo; 00015 template<class Scalar> class StepperBase; 00016 00017 00023 template<class Scalar> 00024 class IntegrationObserverBase 00025 : virtual public Teuchos::Describable, 00026 virtual public Teuchos::VerboseObject<IntegrationObserverBase<Scalar> > 00027 { 00028 public: 00029 00035 virtual RCP<IntegrationObserverBase<Scalar> > 00036 cloneIntegrationObserver() const = 0; 00037 00049 virtual void resetIntegrationObserver( 00050 const TimeRange<Scalar> &integrationTimeDomain 00051 // ToDo: Pass in the initial condition to the observer 00052 ) = 0; 00053 00068 virtual void observeStartTimeIntegration( 00069 const StepperBase<Scalar> &stepper); 00070 00085 virtual void observeEndTimeIntegration( 00086 const StepperBase<Scalar> &stepper); 00087 00088 // ToDo: add observeStartTimeStep(stepper, ...) 00113 virtual void observeStartTimeStep( 00114 const StepperBase<Scalar> &stepper, 00115 const StepControlInfo<Scalar> &stepCtrlInfo, 00116 const int timeStepIter 00117 ); 00118 00150 virtual void observeCompletedTimeStep( 00151 const StepperBase<Scalar> &stepper, 00152 const StepControlInfo<Scalar> &stepCtrlInfo, 00153 const int timeStepIter 00154 ) = 0; 00155 00191 virtual void observeFailedTimeStep( 00192 const StepperBase<Scalar> &stepper, 00193 const StepControlInfo<Scalar> &stepCtrlInfo, 00194 const int timeStepIter 00195 ); 00196 00197 }; 00198 00199 00205 template<class Scalar> 00206 bool isInitialTimeStep( 00207 const TimeRange<Scalar> ¤tTimeRange, 00208 const TimeRange<Scalar> &fullTimeRange 00209 ) 00210 { 00211 typedef Teuchos::ScalarTraits<Scalar> ST; 00212 return compareTimeValues(currentTimeRange.lower(), fullTimeRange.lower()) == ST::zero(); 00213 } 00214 00215 00221 template<class Scalar> 00222 bool isFinalTimeStep( 00223 const TimeRange<Scalar> ¤tTimeRange, 00224 const TimeRange<Scalar> &fullTimeRange 00225 ) 00226 { 00227 typedef Teuchos::ScalarTraits<Scalar> ST; 00228 return compareTimeValues(currentTimeRange.upper(), fullTimeRange.upper()) >= ST::zero(); 00229 } 00230 00231 00232 // ///////////////////////////////////////////////////////////// 00233 /* Default implementations for backwards compatibility 00234 00235 Some of the observer methods were added after rythmos was released. 00236 Even though all methods should be pure virtual, we provide a 00237 default implementation here for the recently added methods to 00238 maintain backwards compatibility. These should be removed in the 00239 future. 00240 */ 00241 00242 template<class Scalar> 00243 void IntegrationObserverBase<Scalar>:: 00244 observeStartTimeIntegration(const StepperBase<Scalar> &stepper) 00245 { 00246 00247 } 00248 00249 template<class Scalar> 00250 void IntegrationObserverBase<Scalar>:: 00251 observeEndTimeIntegration(const StepperBase<Scalar> &stepper) 00252 { 00253 00254 } 00255 00256 template<class Scalar> 00257 void IntegrationObserverBase<Scalar>:: 00258 observeStartTimeStep( 00259 const StepperBase<Scalar> &stepper, 00260 const StepControlInfo<Scalar> &stepCtrlInfo, 00261 const int timeStepIter 00262 ) 00263 { 00264 00265 } 00266 00267 template<class Scalar> 00268 void IntegrationObserverBase<Scalar>:: 00269 observeFailedTimeStep( 00270 const StepperBase<Scalar> &stepper, 00271 const StepControlInfo<Scalar> &stepCtrlInfo, 00272 const int timeStepIter 00273 ) 00274 { 00275 00276 } 00277 00278 00279 } // namespace Rythmos 00280 00281 00282 #endif // RYTHMOS_INTEGRATION_OBSERVER_BASE_HPP
1.7.6.1