Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperSubcycling_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_StepperSubcycling_decl_hpp
10 #define Tempus_StepperSubcycling_decl_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_StepperExplicit.hpp"
15 #include "Tempus_IntegratorBasic.hpp"
16 
17 
18 namespace Tempus {
19 
20 /** \brief Subcycling time stepper.
21  *
22  * This stepper wraps an IntegratorBasic object to perform the
23  * subcycling, thus it has all the capbilities of an IntegratorBasic
24  * with the following specializations and defaults:
25  * - Main Integrator operates independently from subcycling Stepper,
26  * and can be driven by another physics.
27  * - Need separate TimeStepControl for the subcycling so it can be
28  * driven by the physics (e.g., variable time stepping).
29  * - Finish the subcycling exactly on the full timestep.
30  * - No solution I/O within the subcycling.
31  * - No restart capability within subcycling, but still have restart
32  * capability from the full timestep.
33  * - Do not need to keep a solution history of the subcycling.
34  */
35 template<class Scalar>
36 class StepperSubcycling : virtual public Tempus::Stepper<Scalar>
37 {
38 public:
39 
40  /** \brief Default constructor.
41  *
42  * - Requires subsequent setModel() and initialize() call before
43  * calling takeStep().
44  */
46 
47  /// Constructor
49  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
50  const Teuchos::RCP<StepperSubcyclingObserver<Scalar> >& obs,
51  const Teuchos::RCP<IntegratorBasic<Scalar> >& integrator,
52  bool useFSAL,
53  std::string ICConsistency,
54  bool ICConsistencyCheck);
55 
56  /// \name Basic stepper methods
57  //@{
58  virtual void setModel(
59  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel);
60 
61  virtual void setNonConstModel(
62  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel);
63 
64  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
65  getModel(){return scIntegrator_->getStepper()->getModel();}
66 
67  virtual void setObserver(
68  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null);
69 
70  virtual Teuchos::RCP<StepperObserver<Scalar> > getObserver() const;
71 
72  /// Initialize during construction and after changing input parameters.
73  virtual void initialize();
74 
75  virtual Scalar getInitTimeStep(
76  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) const;
77 
78  /// Set the initial conditions, make them consistent, and set needed memory.
79  virtual void setInitialConditions (
80  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
81 
82  /// Pass initial guess to Newton solver (only relevant for implicit solvers)
83  // thus a no-op for explicit steppers.
84  virtual void setInitialGuess(
85  Teuchos::RCP<const Thyra::VectorBase<Scalar> > initial_guess);
86 
87  virtual void setSolver(
88  Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver = Teuchos::null);
89 
90  virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > getSolver() const;
91 
92  /// Take the specified timestep, dt, and return true if successful.
93  virtual void takeStep(
94  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
95 
96  /// Get a default (initial) StepperState
97  virtual Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState();
98 
99  virtual bool isExplicit() const;
100  virtual bool isImplicit() const;
101  virtual bool isExplicitImplicit() const;
102  virtual bool isOneStepMethod() const;
103  virtual bool isMultiStepMethod() const;
104 
105  virtual Scalar getOrder() const;
106  virtual Scalar getOrderMin() const;
107  virtual Scalar getOrderMax() const;
108 
109  virtual OrderODE getOrderODE() const;
110  //@}
111 
112  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
113 
114  /// \name Overridden from Teuchos::Describable
115  //@{
116  virtual void describe(Teuchos::FancyOStream & out,
117  const Teuchos::EVerbosityLevel verbLevel) const;
118  //@}
119 
120  /// \name Functions to set the subcycling stepper.
121  //@{
122  virtual void setSubcyclingStepper(Teuchos::RCP<Stepper<Scalar> > stepper);
123  virtual void setSubcyclingMinTimeStep(Scalar MinTimeStep);
124  virtual void setSubcyclingInitTimeStep(Scalar InitTimeStep);
125  virtual void setSubcyclingMaxTimeStep(Scalar MaxTimeStep);
126  virtual void setSubcyclingStepType(std::string StepType);
127  virtual void setSubcyclingMaxFailures(int MaxFailures);
128  virtual void setSubcyclingMaxConsecFailures(int MaxConsecFailures);
129  virtual void setSubcyclingScreenOutputIndexInterval(int i);
131  Teuchos::RCP<TimeStepControlStrategy<Scalar> > tscs);
132  //@}
133 
134  // Temporary until 5908 branch is committed.
135  bool isInitialized_ = false;
136 
137 protected:
138 
139  Teuchos::RCP<StepperSubcyclingObserver<Scalar> > stepperSCObserver_;
140  Teuchos::RCP<IntegratorBasic<Scalar> > scIntegrator_;
141 
142 };
143 
144 } // namespace Tempus
145 
146 #endif // Tempus_StepperSubcycling_decl_hpp
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual void setSubcyclingStepper(Teuchos::RCP< Stepper< Scalar > > stepper)
virtual void initialize()
Initialize during construction and after changing input parameters.
virtual void setSubcyclingMinTimeStep(Scalar MinTimeStep)
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setSubcyclingScreenOutputIndexInterval(int i)
virtual void setSubcyclingMaxTimeStep(Scalar MaxTimeStep)
Teuchos::RCP< IntegratorBasic< Scalar > > scIntegrator_
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
virtual void setSolver(Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > solver=Teuchos::null)
Set solver.
virtual void setSubcyclingMaxConsecFailures(int MaxConsecFailures)
virtual void setSubcyclingTimeStepControlStrategy(Teuchos::RCP< TimeStepControlStrategy< Scalar > > tscs)
Thyra Base interface for time steppers.
Teuchos::RCP< StepperSubcyclingObserver< Scalar > > stepperSCObserver_
virtual void setObserver(Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)
Set Observer.
virtual Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > getSolver() const
Get solver.
virtual void setSubcyclingStepType(std::string StepType)
StepperObserver class for Stepper class.
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual Scalar getInitTimeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory) const
virtual void setSubcyclingInitTimeStep(Scalar InitTimeStep)
virtual void setInitialGuess(Teuchos::RCP< const Thyra::VectorBase< Scalar > > initial_guess)
Pass initial guess to Newton solver (only relevant for implicit solvers)
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel()
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
StepperSubcyclingObserver class for StepperSubcycling.
StepControlStrategy class for TimeStepControl.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions, make them consistent, and set needed memory.
virtual void setNonConstModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > &appModel)
virtual Teuchos::RCP< StepperObserver< Scalar > > getObserver() const
Get Observer.
virtual void setSubcyclingMaxFailures(int MaxFailures)