30 #ifndef RYTHMOS_SIMPLE_INTEGRATION_CONTROL_STRATEGY_DEF_HPP
31 #define RYTHMOS_SIMPLE_INTEGRATION_CONTROL_STRATEGY_DEF_HPP
33 #include "Rythmos_SimpleIntegrationControlStrategy_decl.hpp"
34 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
40 template<
class Scalar>
41 RCP<SimpleIntegrationControlStrategy<Scalar> >
42 simpleIntegrationControlStrategy()
44 RCP<SimpleIntegrationControlStrategy<Scalar> >
46 return integrationControl;
50 template<
class Scalar>
51 RCP<SimpleIntegrationControlStrategy<Scalar> >
52 simpleIntegrationControlStrategy(
const RCP<ParameterList> ¶mList )
54 RCP<SimpleIntegrationControlStrategy<Scalar> >
56 integrationControl->setParameterList(paramList);
57 return integrationControl;
69 template<
class Scalar>
72 =
"Take Variable Steps";
74 template<
class Scalar>
80 template<
class Scalar>
85 template<
class Scalar>
88 = std::numeric_limits<Scalar>::max();
91 template<
class Scalar>
94 =
"Number of Time Steps";
96 template<
class Scalar>
102 template<
class Scalar>
107 template<
class Scalar>
116 template<
class Scalar>
118 :takeVariableSteps_(takeVariableSteps_default_),
119 max_dt_(max_dt_default_),
120 numTimeSteps_(numTimeSteps_default_),
121 fixed_dt_(fixed_dt_default_)
128 template<
class Scalar>
130 RCP<ParameterList>
const& paramList
135 typedef Teuchos::ScalarTraits<Scalar> ST;
136 TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
137 paramList->validateParameters(*getValidParameters());
138 this->setMyParamList(paramList);
139 takeVariableSteps_ = paramList->get(
140 takeVariableSteps_name_, takeVariableSteps_ );
141 if (!takeVariableSteps_) {
142 numTimeSteps_ = paramList->get(numTimeSteps_name_,numTimeSteps_);
143 fixed_dt_ = paramList->get(fixed_dt_name_,fixed_dt_default_);
144 TEUCHOS_TEST_FOR_EXCEPTION(
145 numTimeSteps_ < 0 && fixed_dt_ <= ST::zero(), std::logic_error,
146 "Error, when taking fixed steps, the user must set the parameters "
147 "\""<<numTimeSteps_name_<<
"\" > 0 or \""<<fixed_dt_name_<<
"\" > 0.0!" );
150 max_dt_ = paramList->get(max_dt_name_,max_dt_);
152 Teuchos::readVerboseObjectSublist(&*paramList,
this);
156 template<
class Scalar>
157 RCP<const ParameterList>
160 static RCP<const ParameterList> validPL;
161 if (is_null(validPL) ) {
162 RCP<ParameterList> pl = Teuchos::parameterList();
164 takeVariableSteps_name_, takeVariableSteps_default_,
165 "Take variable time steps or fixed time steps.\n"
166 "If set to false, then the parameter \"" + fixed_dt_name_ +
"\"\n"
167 "or \"" + numTimeSteps_name_ +
"\" must be set!"
170 max_dt_name_, max_dt_default_,
171 "Gives the max size of the variable time steps. This is only read and used if\n"
172 "\"" + takeVariableSteps_name_ +
"\" is set to true."
175 numTimeSteps_name_, numTimeSteps_default_,
176 "Gives the number of fixed time steps. The actual step size gets computed\n"
177 "on the fly given the size of the time domain.\n"
178 "This is only read and used if \"" + takeVariableSteps_name_ +
"\" is set to false\n"
179 "and \"" + fixed_dt_name_ +
"\" is set to < 0.0."
182 fixed_dt_name_, fixed_dt_default_,
183 "Gives the size of the fixed time steps. This is only read and used if\n"
184 "\"" + takeVariableSteps_name_ +
"\" is set to false."
186 Teuchos::setupVerboseObjectSublist(&*pl);
196 template<
class Scalar>
197 RCP<IntegrationControlStrategyBase<Scalar> >
200 RCP<SimpleIntegrationControlStrategy<Scalar> >
201 integrCtrlStry = simpleIntegrationControlStrategy<Scalar>();
202 const RCP<const ParameterList> paramList = this->getParameterList();
203 if (!is_null(paramList))
204 integrCtrlStry->setParameterList(Teuchos::parameterList(*paramList));
205 integrCtrlStry->takeVariableSteps_ = takeVariableSteps_;
206 integrCtrlStry->max_dt_ = max_dt_;
207 integrCtrlStry->numTimeSteps_ = numTimeSteps_;
208 integrCtrlStry->fixed_dt_ = fixed_dt_;
209 return integrCtrlStry;
213 template<
class Scalar>
219 typedef Teuchos::ScalarTraits<Scalar> ST;
220 #ifdef HAVE_RYTHMOS_DEBUG
221 TEUCHOS_ASSERT(integrationTimeDomain.
length() >= ST::zero());
223 integrationTimeDomain_ = integrationTimeDomain;
224 if (takeVariableSteps_) {
225 if (max_dt_ < ST::zero()) {
226 max_dt_ = integrationTimeDomain_.
length();
230 if (fixed_dt_ < ST::zero()) {
231 #ifdef HAVE_RYTHMOS_DEBUG
232 TEUCHOS_ASSERT(numTimeSteps_ > 0);
234 fixed_dt_ = integrationTimeDomain_.length()/numTimeSteps_;
240 template<
class Scalar>
249 #ifdef HAVE_RYTHMOS_DEBUG
250 typedef Teuchos::ScalarTraits<Scalar> ST;
251 TEUCHOS_ASSERT(integrationTimeDomain_.length() >= ST::zero());
256 if (takeVariableSteps_) {
257 trialStepCtrlInfo.
stepType = STEP_TYPE_VARIABLE;
258 trialStepCtrlInfo.stepSize = max_dt_;
261 trialStepCtrlInfo.stepType = STEP_TYPE_FIXED;
262 trialStepCtrlInfo.stepSize = fixed_dt_;
265 return trialStepCtrlInfo;
275 #define RYTHMOS_SIMPLE_INTEGRATION_CONTROL_STRATEGY_INSTANT(SCALAR) \
277 template class SimpleIntegrationControlStrategy< SCALAR >; \
279 template RCP<SimpleIntegrationControlStrategy< SCALAR > > \
280 simpleIntegrationControlStrategy(); \
282 template RCP<SimpleIntegrationControlStrategy< SCALAR > > \
283 simpleIntegrationControlStrategy( const RCP<ParameterList> ¶mList );
289 #endif // RYTHMOS_SIMPLE_INTEGRATION_CONTROL_STRATEGY_DEF_HPP
StepControlInfo< Scalar > getNextStepControlInfo(const StepperBase< Scalar > &stepper, const StepControlInfo< Scalar > &stepCtrlInfoLast, const int timeStepIter)
Base class for defining stepper functionality.
RCP< IntegrationControlStrategyBase< Scalar > > cloneIntegrationControlStrategy() const
Overridden from IntegrationControlStrategyBase.
Simple struct to aggregate integration/stepper control information.
Base class for strategy objects that control integration by selecting step sizes for a stepper...
RCP< const ParameterList > getValidParameters() const
void setParameterList(RCP< ParameterList > const ¶mList)
StepSizeType stepType
The type of time step.
SimpleIntegrationControlStrategy()
Constructors/Initializers.
void resetIntegrationControlStrategy(const TimeRange< Scalar > &integrationTimeDomain)