9 #ifndef Tempus_Stepper_decl_hpp
10 #define Tempus_Stepper_decl_hpp
13 #include "Teuchos_TimeMonitor.hpp"
16 #include "Thyra_ModelEvaluator.hpp"
17 #include "Thyra_NonlinearSolverBase.hpp"
20 #include "Tempus_config.hpp"
21 #include "Tempus_SolutionHistory.hpp"
60 template<
class Scalar>
62 :
virtual public Teuchos::Describable,
63 virtual public Teuchos::VerboseObject<Stepper<Scalar> >
70 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel) {}
72 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
74 const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& ){}
76 #endif // TEMPUS_HIDE_DEPRECATED_CODE
77 virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
getModel()
78 {
return Teuchos::null; }
82 Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver) {}
85 virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> >
getSolver()
const
86 {
return Teuchos::null; }
93 virtual Teuchos::RCP<StepperObserver<Scalar> >
getObserver()
const
94 {
return Teuchos::null; }
114 virtual void setInitialGuess(Teuchos::RCP<
const Thyra::VectorBase<Scalar> >
115 initialGuess = Teuchos::null) = 0;
117 virtual Teuchos::RCP<Tempus::StepperState<Scalar> >
119 virtual Scalar
getOrder()
const = 0;
153 virtual Teuchos::RCP<Thyra::VectorBase<Scalar> >
getStepperX(
172 virtual void describe(Teuchos::FancyOStream & out,
173 const Teuchos::EVerbosityLevel verbLevel)
const;
176 virtual bool isValidSetup(Teuchos::FancyOStream & out)
const;
181 std::vector<Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> > > ){}
201 virtual void setStepperX(Teuchos::RCP<Thyra::VectorBase<Scalar> > x)
220 Teuchos::RCP<Teuchos::ParameterList> pl, std::string stepperType);
227 template<
class Scalar>
229 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
231 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
232 typedef Thyra::ModelEvaluatorBase MEB;
233 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
234 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
235 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
236 outArgs.supports(MEB::OUT_ARG_f);
238 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
239 model->description() <<
"can not support an explicit ODE with\n"
240 <<
" IN_ARG_x = " << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
241 <<
" OUT_ARG_f = " << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
242 <<
"Explicit ODE requires:\n"
243 <<
" IN_ARG_x = true\n"
244 <<
" OUT_ARG_f = true\n"
246 <<
"NOTE: Currently the convention to evaluate f(x,t) is to set\n"
247 <<
"xdot=null! There is no InArgs support to test if xdot is null,\n"
248 <<
"so we set xdot=null and hope the ModelEvaluator can handle it.\n");
259 template<
class Scalar>
261 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
263 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
264 typedef Thyra::ModelEvaluatorBase MEB;
265 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
266 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
267 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
268 inArgs.supports(MEB::IN_ARG_x_dot) and
269 outArgs.supports(MEB::OUT_ARG_f);
271 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
272 model->description() <<
"can not support an explicit ODE with\n"
273 <<
" IN_ARG_x = " << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
274 <<
" IN_ARG_x_dot = " << inArgs.supports(MEB::IN_ARG_x_dot) <<
"\n"
275 <<
" OUT_ARG_f = " << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
276 <<
"Explicit ODE requires:\n"
277 <<
" IN_ARG_x = true\n"
278 <<
" IN_ARG_x_dot = true\n"
279 <<
" OUT_ARG_f = true\n"
281 <<
"NOTE: Currently the convention to evaluate f(x, xdot, t) is to\n"
282 <<
"set xdotdot=null! There is no InArgs support to test if xdotdot\n"
283 <<
"is null, so we set xdotdot=null and hope the ModelEvaluator can\n"
291 template<
class Scalar>
293 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
295 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
296 typedef Thyra::ModelEvaluatorBase MEB;
297 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
298 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
299 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
300 inArgs.supports(MEB::IN_ARG_x_dot) and
301 inArgs.supports(MEB::IN_ARG_alpha) and
302 inArgs.supports(MEB::IN_ARG_beta) and
303 !inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) and
304 outArgs.supports(MEB::OUT_ARG_f) and
305 outArgs.supports(MEB::OUT_ARG_W);
307 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
308 model->description() <<
" can not support an implicit ODE with\n"
310 << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
311 <<
" IN_ARG_x_dot = "
312 << inArgs.supports(MEB::IN_ARG_x_dot) <<
"\n"
313 <<
" IN_ARG_alpha = "
314 << inArgs.supports(MEB::IN_ARG_alpha) <<
"\n"
316 << inArgs.supports(MEB::IN_ARG_beta) <<
"\n"
317 <<
" IN_ARG_W_x_dot_dot_coeff = "
318 << inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) <<
"\n"
320 << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
322 << outArgs.supports(MEB::OUT_ARG_W) <<
"\n"
323 <<
"Implicit ODE requires:\n"
324 <<
" IN_ARG_x = true\n"
325 <<
" IN_ARG_x_dot = true\n"
326 <<
" IN_ARG_alpha = true\n"
327 <<
" IN_ARG_beta = true\n"
328 <<
" IN_ARG_W_x_dot_dot_coeff = false\n"
329 <<
" OUT_ARG_f = true\n"
330 <<
" OUT_ARG_W = true\n");
337 template<
class Scalar>
339 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
341 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
342 typedef Thyra::ModelEvaluatorBase MEB;
343 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
344 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
345 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
346 inArgs.supports(MEB::IN_ARG_x_dot) and
347 inArgs.supports(MEB::IN_ARG_x_dot_dot) and
348 inArgs.supports(MEB::IN_ARG_alpha) and
349 inArgs.supports(MEB::IN_ARG_beta) and
350 inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) and
351 outArgs.supports(MEB::OUT_ARG_f) and
352 outArgs.supports(MEB::OUT_ARG_W);
354 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
355 model->description() <<
" can not support an implicit ODE with\n"
357 << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
358 <<
" IN_ARG_x_dot = "
359 << inArgs.supports(MEB::IN_ARG_x_dot) <<
"\n"
360 <<
" IN_ARG_x_dot_dot = "
361 << inArgs.supports(MEB::IN_ARG_x_dot_dot) <<
"\n"
362 <<
" IN_ARG_alpha = "
363 << inArgs.supports(MEB::IN_ARG_alpha) <<
"\n"
365 << inArgs.supports(MEB::IN_ARG_beta) <<
"\n"
366 <<
" IN_ARG_W_x_dot_dot_coeff = "
367 << inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) <<
"\n"
369 << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
371 << outArgs.supports(MEB::OUT_ARG_W) <<
"\n"
372 <<
"Implicit Second Order ODE requires:\n"
373 <<
" IN_ARG_x = true\n"
374 <<
" IN_ARG_x_dot = true\n"
375 <<
" IN_ARG_x_dot_dot = true\n"
376 <<
" IN_ARG_alpha = true\n"
377 <<
" IN_ARG_beta = true\n"
378 <<
" IN_ARG_W_x_dot_dot_coeff = true\n"
379 <<
" OUT_ARG_f = true\n"
380 <<
" OUT_ARG_W = true\n");
392 #endif // Tempus_Stepper_decl_hpp
virtual bool isInitialized()
True if stepper's member data is initialized.
virtual Scalar getOrderMax() const =0
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)=0
Take the specified timestep, dt, and return true if successful.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
virtual OrderODE getOrderODE() const =0
std::string getStepperType() const
virtual void setNonConstModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &)
virtual Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > getSolver() const
Get solver.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel()
virtual void setSolver(Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > solver)
Set solver.
bool getICConsistencyCheck() const
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperX(Teuchos::RCP< SolutionState< Scalar > > state)
Get x from SolutionState or Stepper storage.
virtual bool isExplicit() const =0
virtual bool getICConsistencyCheckDefault() const
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers.
virtual void setStepperXDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot)
Set xDot for Stepper storage.
void validExplicitODE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Validate that the model supports explicit ODE evaluation, f(x,t) [=xdot].
virtual std::string getICConsistencyDefault() const
virtual void initialize()
Initialize after construction and changing input parameters.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDotDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDotDot from SolutionState or Stepper storage.
bool isInitialized_
True if stepper's member data is initialized.
virtual bool isOneStepMethod() const =0
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
virtual Scalar getOrderMin() const =0
std::string getICConsistency() const
virtual bool isMultiStepMethod() const =0
Stepper integrates second-order ODEs.
virtual void checkInitialized()
Check initialization, and error out on failure.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDot_
bool useFSAL_
Use First-Step-As-Last (FSAL) principle.
virtual void setStepperX(Teuchos::RCP< Thyra::VectorBase< Scalar > > x)
Set x for Stepper storage.
virtual std::string description() const
virtual Scalar getInitTimeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory) const =0
virtual void setInitialGuess(Teuchos::RCP< const Thyra::VectorBase< Scalar > > initialGuess=Teuchos::null)=0
Pass initial guess to Newton solver (for implicit schemes)
virtual Teuchos::RCP< StepperObserver< Scalar > > getObserver() const
Get Observer.
void setICConsistencyCheck(bool c)
StepperObserver class for Stepper class.
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperXDotDot_
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setStepperXDotDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot)
Set x for Stepper storage.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()=0
std::string ICConsistency_
Type of consistency to apply to ICs.
Stepper integrates first-order ODEs.
void validSecondOrderExplicitODE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Validate that the model supports explicit second order ODE evaluation, f(x,xdot,t) [=xdotdot]...
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)=0
Set initial conditions, make them consistent, and set stepper memory.
void validSecondOrderODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Validate ME supports 2nd order implicit ODE/DAE evaluation, f(xdotdot,xdot,x,t) [= 0]...
bool ICConsistencyCheck_
Check if the initial condition is consistent.
Teuchos::RCP< Thyra::VectorBase< Scalar > > stepperX_
virtual bool getUseFSALDefault() const
virtual void setObserver(Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)
Set Observer.
std::string stepperType_
Name of stepper type.
void validImplicitODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Validate ME supports implicit ODE/DAE evaluation, f(xdot,x,t) [= 0].
virtual bool isImplicit() const =0
virtual void createSubSteppers(std::vector< Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > >)
void getValidParametersBasic(Teuchos::RCP< Teuchos::ParameterList > pl, std::string stepperType)
Provide basic parameters to Steppers.
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const =0
void setStepperType(std::string s)
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDot from SolutionState or Stepper storage.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
virtual bool isExplicitImplicit() const =0
virtual Scalar getOrder() const =0
void setICConsistency(std::string s)