Rythmos_StepperHelpers.hpp

00001 
00002 #ifndef RYTHMOS_STEPPER_HELPERS_HPP
00003 #define RYTHMOS_STEPPER_HELPERS_HPP
00004 
00005 
00006 #include "Rythmos_StepperBase.hpp"
00007 
00008 
00009 namespace Rythmos {
00010 
00011 
00019 template<class Scalar>
00020 void restart( StepperBase<Scalar> *stepper )
00021 {
00022 #ifdef TEUCHOS_DEBUG
00023   TEST_FOR_EXCEPT(0==stepper);
00024 #endif // TEUCHOS_DEBUG
00025   typedef Thyra::ModelEvaluatorBase MEB;
00026   const Rythmos::StepStatus<double>
00027     stepStatus = stepper->getStepStatus();
00028   const RCP<const Thyra::ModelEvaluator<Scalar> >
00029     model = stepper->getModel();
00030   // First, copy all of the model's state, including parameter values etc.
00031   MEB::InArgs<double> initialCondition = model->createInArgs();
00032   initialCondition.setArgs(model->getNominalValues());
00033   // Set the current values of the state and time
00034   RCP<const Thyra::VectorBase<double> > x, x_dot;
00035   Rythmos::get_x_and_x_dot(*stepper,stepStatus.time,&x,&x_dot);
00036   initialCondition.set_x(x);
00037   initialCondition.set_x_dot(x_dot);
00038   initialCondition.set_t(stepStatus.time);
00039   // Set the new initial condition back on the stepper.  This will effectively
00040   // reset the stepper to think that it is starting over again (which it is).
00041   stepper->setInitialCondition(initialCondition);
00042 }
00043 
00044 
00045 
00046 } // namespace Rythmos
00047 
00048 
00049 #endif // RYTHMOS_STEPPER_HELPERS_HPP

Generated on Tue Oct 20 12:46:08 2009 for Rythmos - Transient Integration for Differential Equations by doxygen 1.4.7