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> >
46 return integrationControl;
50 template<
class Scalar>
51 RCP<RampingIntegrationControlStrategy<Scalar> >
52 rampingIntegrationControlStrategy(
const RCP<ParameterList> ¶mList )
54 RCP<RampingIntegrationControlStrategy<Scalar> >
56 integrationControl->setParameterList(paramList);
57 return integrationControl;
69 template<
class Scalar>
72 =
"Number of Ramping Steps";
74 template<
class Scalar>
80 template<
class Scalar>
85 template<
class Scalar>
91 template<
class Scalar>
96 template<
class Scalar>
99 = std::numeric_limits<Scalar>::max();
102 template<
class Scalar>
107 template<
class Scalar>
117 template<
class Scalar>
119 num_ramping_steps_(num_ramping_steps_default_),
120 initial_dt_(initial_dt_default_),
121 max_dt_(max_dt_default_),
122 ramping_factor_(ramping_factor_default_),
130 template<
class Scalar>
132 RCP<ParameterList>
const& paramList
137 typedef Teuchos::ScalarTraits<Scalar> ST;
138 TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
139 paramList->validateParametersAndSetDefaults(*getValidParameters());
140 this->setMyParamList(paramList);
142 num_ramping_steps_ = paramList->get<
int>(num_ramping_steps_name_);
143 initial_dt_ = paramList->get<
double>(initial_dt_name_);
144 max_dt_ = paramList->get<
double>(max_dt_name_);
145 ramping_factor_ = paramList->get<
double>(ramping_factor_name_);
147 Teuchos::readVerboseObjectSublist(&*paramList,
this);
151 template<
class Scalar>
152 RCP<const ParameterList>
155 static RCP<const ParameterList> validPL;
156 if (is_null(validPL) ) {
157 RCP<ParameterList> pl = Teuchos::parameterList();
158 pl->set(num_ramping_steps_name_, num_ramping_steps_default_,
159 "Number of ramping steps to take before handing control to variable stepper.");
160 pl->set(initial_dt_name_, initial_dt_default_,
161 "Initial teim step.");
162 pl->set(max_dt_name_, max_dt_default_,
163 "Maximum time step.");
164 pl->set(ramping_factor_name_, ramping_factor_default_,
165 "Time step growth factor used during ramping phase.dt_{n+1} = (ramping factor) * dt_n");
166 Teuchos::setupVerboseObjectSublist(&*pl);
176 template<
class Scalar>
183 template<
class Scalar>
184 RCP<IntegrationControlStrategyBase<Scalar> >
187 RCP<RampingIntegrationControlStrategy<Scalar> >
188 integrCtrlStry = rampingIntegrationControlStrategy<Scalar>();
189 const RCP<const ParameterList> paramList = this->getParameterList();
190 if (!is_null(paramList))
191 integrCtrlStry->setParameterList(Teuchos::parameterList(*paramList));
192 integrCtrlStry->num_ramping_steps_ = this->num_ramping_steps_;
193 integrCtrlStry->initial_dt_ = this->initial_dt_;
194 integrCtrlStry->max_dt_ = this->max_dt_;
195 integrCtrlStry->ramping_factor_ = this->ramping_factor_;
196 integrCtrlStry->current_dt_ = this->current_dt_;
197 return integrCtrlStry;
201 template<
class Scalar>
207 typedef Teuchos::ScalarTraits<Scalar> ST;
208 #ifdef HAVE_RYTHMOS_DEBUG
209 TEUCHOS_ASSERT(integrationTimeDomain.
length() > ST::zero());
211 integrationTimeDomain_ = integrationTimeDomain;
212 if (max_dt_ < ST::zero()) {
213 max_dt_ = integrationTimeDomain_.
length();
216 current_dt_ = initial_dt_;
220 template<
class Scalar>
225 const int timeStepIter
229 typedef Teuchos::ScalarTraits<Scalar> ST;
231 #ifdef HAVE_RYTHMOS_DEBUG
232 TEUCHOS_ASSERT(integrationTimeDomain_.length() > ST::zero());
237 if (timeStepIter == 0)
238 current_dt_ = initial_dt_;
240 current_dt_ *= ramping_factor_;
242 if (timeStepIter < num_ramping_steps_) {
243 trialStepCtrlInfo.
stepType = STEP_TYPE_FIXED;
244 trialStepCtrlInfo.stepSize = current_dt_;
247 trialStepCtrlInfo.stepType = STEP_TYPE_VARIABLE;
248 trialStepCtrlInfo.stepSize = max_dt_;
251 return trialStepCtrlInfo;
256 template<
class Scalar>
260 const int timeStepIter,
265 current_dt_ /= ramping_factor_;
278 #define RYTHMOS_RAMPING_INTEGRATION_CONTROL_STRATEGY_INSTANT(SCALAR) \
280 template class RampingIntegrationControlStrategy< SCALAR >; \
282 template RCP<RampingIntegrationControlStrategy< SCALAR > > \
283 rampingIntegrationControlStrategy(); \
285 template RCP<RampingIntegrationControlStrategy< SCALAR > > \
286 rampingIntegrationControlStrategy( const RCP<ParameterList> ¶mList );
292 #endif // RYTHMOS_RAMPING_INTEGRATION_CONTROL_STRATEGY_DEF_HPP
void resetIntegrationControlStrategy(const TimeRange< Scalar > &integrationTimeDomain)
RampingIntegrationControlStrategy()
Constructors/Initializers.
Base class for defining stepper functionality.
Simple strict 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)
StepSizeType stepType
The type of time step.