30 #ifndef RYTHMOS_RAMPING_INTEGRATION_CONTROL_STRATEGY_DEF_HPP 
   31 #define RYTHMOS_RAMPING_INTEGRATION_CONTROL_STRATEGY_DEF_HPP 
   33 #include "Rythmos_RampingIntegrationControlStrategy_decl.hpp" 
   34 #include "Teuchos_VerboseObjectParameterListHelpers.hpp" 
   40 template<
class Scalar>
 
   41 RCP<RampingIntegrationControlStrategy<Scalar> >
 
   42 rampingIntegrationControlStrategy()
 
   44   RCP<RampingIntegrationControlStrategy<Scalar> >
 
   47   return integrationControl;
 
   51 template<
class Scalar>
 
   52 RCP<RampingIntegrationControlStrategy<Scalar> >
 
   53 rampingIntegrationControlStrategy( 
const RCP<ParameterList> ¶mList )
 
   55   RCP<RampingIntegrationControlStrategy<Scalar> >
 
   58   integrationControl->setParameterList(paramList);
 
   59   return integrationControl;
 
   71 template<
class Scalar>
 
   74 = 
"Take Variable Steps";
 
   76 template<
class Scalar>
 
   82 template<
class Scalar>
 
   85 = 
"Number of Initial Constant Steps";
 
   87 template<
class Scalar>
 
   93 template<
class Scalar>
 
   96 = 
"Number of Ramping Steps";
 
   98 template<
class Scalar>
 
  104 template<
class Scalar>
 
  109 template<
class Scalar>
 
  115 template<
class Scalar>
 
  120 template<
class Scalar>
 
  123 = std::numeric_limits<Scalar>::min();
 
  126 template<
class Scalar>
 
  131 template<
class Scalar>
 
  134 = std::numeric_limits<Scalar>::max();
 
  137 template<
class Scalar>
 
  142 template<
class Scalar>
 
  148 template<
class Scalar>
 
  151 = 
"Maximum Number of Step Failures";
 
  153 template<
class Scalar>
 
  163 template<
class Scalar>
 
  165   : take_variable_steps_(take_variable_steps_default_),
 
  166     num_constant_steps_(num_constant_steps_default_),
 
  167     num_ramping_steps_(num_ramping_steps_default_),
 
  168     initial_dt_(initial_dt_default_),
 
  169     min_dt_(min_dt_default_),
 
  170     max_dt_(max_dt_default_),
 
  171     ramping_factor_(ramping_factor_default_),
 
  172     num_step_failures_(0),
 
  173     max_step_failures_(max_step_failures_default_),
 
  181 template<
class Scalar>
 
  183   RCP<ParameterList> 
const& paramList
 
  189   TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
 
  190   paramList->validateParametersAndSetDefaults(*getValidParameters());
 
  191   this->setMyParamList(paramList);
 
  193   take_variable_steps_ = paramList->get<
bool>  (take_variable_steps_name_,
 
  194                                                 take_variable_steps_default_);
 
  195   num_constant_steps_  = paramList->get<
int>   (num_constant_steps_name_,
 
  196                                                 num_constant_steps_default_);
 
  197   num_ramping_steps_   = paramList->get<
int>   (num_ramping_steps_name_,
 
  198                                                 num_ramping_steps_default_);
 
  199   initial_dt_          = paramList->get<
double>(initial_dt_name_,
 
  200                                                 initial_dt_default_);
 
  201   min_dt_              = paramList->get<
double>(min_dt_name_, min_dt_default_);
 
  202   max_dt_              = paramList->get<
double>(max_dt_name_, max_dt_default_);
 
  203   ramping_factor_      = paramList->get<
double>(ramping_factor_name_,
 
  204                                                 ramping_factor_default_);
 
  205   max_step_failures_   = paramList->get<
int>   (max_step_failures_name_,
 
  206                                                 max_step_failures_default_);
 
  208   Teuchos::readVerboseObjectSublist(&*paramList,
this);
 
  212 template<
class Scalar>
 
  213 RCP<const ParameterList>
 
  216   static RCP<const ParameterList> validPL;
 
  217   if (is_null(validPL) ) {
 
  218     RCP<ParameterList> pl = Teuchos::parameterList();
 
  220     pl->set( take_variable_steps_name_, take_variable_steps_default_,
 
  221       "Take variable time steps after '" + num_constant_steps_name_ +
 
  222       "' plus '" + num_ramping_steps_name_ + 
"' steps.  Variable time " 
  223       "stepping allows the Stepper to adjust the time step through a " 
  224       "StepControlStrategy after fixed time steps during initial constant " 
  225       "steps and ramping steps.  If false, fixed-time steps are taken " 
  226       "after ramping.  Fixed time stepping requires the Stepper " 
  227       "to take the time step set by this IntegrationControlStrategy.");
 
  228     pl->set(num_constant_steps_name_, num_constant_steps_default_,
 
  229       "Number of initial constant steps to take before starting the ramping.");
 
  230     pl->set(num_ramping_steps_name_, num_ramping_steps_default_,
 
  231       "Number of ramping steps to take before handing control to " 
  232       "variable stepper if '" + take_variable_steps_name_ +
 
  233       "' is set to true.  Otherwise take fixed-time steps.");
 
  234     pl->set(initial_dt_name_, initial_dt_default_,
 
  235             "Initial time step.");
 
  236     pl->set(min_dt_name_, min_dt_default_,
 
  237             "Minimum time step.");
 
  238     pl->set(max_dt_name_, max_dt_default_,
 
  239             "Maximum time step.");
 
  240     pl->set(ramping_factor_name_, ramping_factor_default_,
 
  241             "Time step growth factor used during ramping phase. dt_{n+1} = " 
  242       "(ramping factor) * dt_n");
 
  243     pl->set(max_step_failures_name_, max_step_failures_default_,
 
  244             "The maximum number of step failures before exiting with error.");
 
  245     Teuchos::setupVerboseObjectSublist(&*pl);
 
  255 template<
class Scalar>
 
  262 template<
class Scalar>
 
  263 RCP<IntegrationControlStrategyBase<Scalar> >
 
  266   RCP<RampingIntegrationControlStrategy<Scalar> >
 
  267     integrCtrlStry = rampingIntegrationControlStrategy<Scalar>();
 
  268   const RCP<const ParameterList> paramList = this->getParameterList();
 
  269   if (!is_null(paramList))
 
  270     integrCtrlStry->setParameterList(Teuchos::parameterList(*paramList));
 
  272   integrCtrlStry->take_variable_steps_ = this->take_variable_steps_;
 
  273   integrCtrlStry->num_constant_steps_  = this->num_constant_steps_;
 
  274   integrCtrlStry->num_ramping_steps_   = this->num_ramping_steps_;
 
  275   integrCtrlStry->initial_dt_          = this->initial_dt_;
 
  276   integrCtrlStry->min_dt_              = this->min_dt_;
 
  277   integrCtrlStry->max_dt_              = this->max_dt_;
 
  278   integrCtrlStry->ramping_factor_      = this->ramping_factor_;
 
  279   integrCtrlStry->current_dt_          = this->current_dt_;
 
  281   return integrCtrlStry;
 
  285 template<
class Scalar>
 
  291   typedef Teuchos::ScalarTraits<Scalar> ST;
 
  292 #ifdef HAVE_RYTHMOS_DEBUG 
  293   TEUCHOS_ASSERT(integrationTimeDomain.
length() > ST::zero());
 
  295   integrationTimeDomain_ = integrationTimeDomain;
 
  296   if (max_dt_ < ST::zero()) {
 
  297     max_dt_ = integrationTimeDomain_.
length();
 
  300   current_dt_ = initial_dt_;
 
  304 template<
class Scalar>
 
  309   const int timeStepIter
 
  313 #ifdef HAVE_RYTHMOS_DEBUG 
  314   typedef Teuchos::ScalarTraits<Scalar> ST;
 
  315   TEUCHOS_ASSERT(integrationTimeDomain_.length() > ST::zero());
 
  320   if (timeStepIter < num_constant_steps_)
 
  321     current_dt_ = initial_dt_;
 
  322   else if (timeStepIter < num_constant_steps_ + num_ramping_steps_)
 
  323     current_dt_ *= ramping_factor_;
 
  325   current_dt_ = std::min(max_dt_, current_dt_);
 
  326   current_dt_ = std::max(min_dt_, current_dt_);
 
  328   num_step_failures_ = std::min(num_step_failures_-1,0);
 
  330   trialStepCtrlInfo.stepSize = current_dt_;
 
  331   if (take_variable_steps_) {
 
  332     if (timeStepIter < num_constant_steps_ + num_ramping_steps_)
 
  333       trialStepCtrlInfo.stepType = STEP_TYPE_FIXED;
 
  335       trialStepCtrlInfo.stepType = STEP_TYPE_VARIABLE;
 
  337     trialStepCtrlInfo.stepType = STEP_TYPE_FIXED;
 
  340   return trialStepCtrlInfo;
 
  344 template<
class Scalar>
 
  352   if (current_dt_ == min_dt_) 
return false;
 
  353   num_step_failures_++;
 
  354   if (num_step_failures_ > max_step_failures_) 
return false;
 
  355   current_dt_ = std::max(min_dt_, current_dt_/ramping_factor_);
 
  366 #define RYTHMOS_RAMPING_INTEGRATION_CONTROL_STRATEGY_INSTANT(SCALAR) \ 
  368   template class RampingIntegrationControlStrategy< SCALAR >; \ 
  370   template RCP<RampingIntegrationControlStrategy< SCALAR > > \ 
  371   rampingIntegrationControlStrategy(); \ 
  373   template RCP<RampingIntegrationControlStrategy< SCALAR > > \ 
  374   rampingIntegrationControlStrategy( const RCP<ParameterList> ¶mList ); 
  380 #endif // RYTHMOS_RAMPING_INTEGRATION_CONTROL_STRATEGY_DEF_HPP 
void resetIntegrationControlStrategy(const TimeRange< Scalar > &integrationTimeDomain)
 
RampingIntegrationControlStrategy()
Constructors/Initializers. 
 
Base class for defining stepper functionality. 
 
Simple struct to aggregate integration/stepper control information. 
 
bool handlesFailedTimeSteps() const 
Overridden from IntegrationControlStrategyBase. 
 
bool resetForFailedTimeStep(const StepperBase< Scalar > &stepper, const StepControlInfo< Scalar > &stepCtrlInfoLast, const int timeStepIter, const StepControlInfo< Scalar > &stepCtrlInfo)
 
Controls inital ramping at a fixed or incrementing time step size. 
 
void setParameterList(RCP< ParameterList > const ¶mList)
 
RCP< const ParameterList > getValidParameters() const 
 
RCP< IntegrationControlStrategyBase< Scalar > > cloneIntegrationControlStrategy() const 
 
StepControlInfo< Scalar > getNextStepControlInfo(const StepperBase< Scalar > &stepper, const StepControlInfo< Scalar > &stepCtrlInfoLast, const int timeStepIter)