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"
14 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
16 #endif
18 #include "Tempus_IntegratorBasic.hpp"
19 
20 
21 namespace Tempus {
22 
23 /** \brief Subcycling time stepper.
24  *
25  * This stepper wraps an IntegratorBasic object to perform the
26  * subcycling, thus it has all the capbilities of an IntegratorBasic
27  * with the following specializations and defaults:
28  * - Main Integrator operates independently from subcycling Stepper,
29  * and can be driven by another physics.
30  * - Need separate TimeStepControl for the subcycling so it can be
31  * driven by the physics (e.g., variable time stepping).
32  * - Finish the subcycling exactly on the full timestep.
33  * - No solution I/O within the subcycling.
34  * - No restart capability within subcycling, but still have restart
35  * capability from the full timestep.
36  * - Do not need to keep a solution history of the subcycling.
37  */
38 template<class Scalar>
39 class StepperSubcycling : virtual public Tempus::Stepper<Scalar>
40 {
41 public:
42 
43  /** \brief Default constructor.
44  *
45  * - Requires subsequent setModel() and initialize() call before
46  * calling takeStep().
47  */
49 
50 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
51  /// Constructor
53  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
54  const Teuchos::RCP<StepperSubcyclingObserver<Scalar> >& obs,
55  const Teuchos::RCP<IntegratorBasic<Scalar> >& integrator,
56  bool useFSAL,
57  std::string ICConsistency,
58  bool ICConsistencyCheck);
59 #endif
60 
61  /// Constructor
63  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
64  const Teuchos::RCP<IntegratorBasic<Scalar> >& integrator,
65  bool useFSAL,
66  std::string ICConsistency,
67  bool ICConsistencyCheck,
68  const Teuchos::RCP<StepperSubcyclingAppAction<Scalar> >& stepperSCAppAction);
69 
70  /// \name Basic stepper methods
71  //@{
72  virtual void setModel(
73  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel);
74 
75  virtual void setNonConstModel(
76  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel);
77 
78  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
79  getModel(){return scIntegrator_->getStepper()->getModel();}
80 
81 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
82  virtual void setObserver(
83  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null);
84 
85  virtual Teuchos::RCP<StepperObserver<Scalar> > getObserver() const;
86 #endif
87 
88  virtual void setAppAction(
89  Teuchos::RCP<StepperSubcyclingAppAction<Scalar> > appAction = Teuchos::null);
90 
91  virtual Teuchos::RCP<StepperSubcyclingAppAction<Scalar> > getAppAction() const
92  { return stepperSCAppAction_; }
93 
94  /// Initialize during construction and after changing input parameters.
95  virtual void initialize();
96 
97  virtual Scalar getInitTimeStep(
98  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory) const;
99 
100  /// Set the initial conditions, make them consistent, and set needed memory.
101  virtual void setInitialConditions (
102  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
103 
104  /// Pass initial guess to Newton solver (only relevant for implicit solvers)
105  // thus a no-op for explicit steppers.
106  virtual void setInitialGuess(
107  Teuchos::RCP<const Thyra::VectorBase<Scalar> > initial_guess);
108 
109  virtual void setSolver(
110  Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver = Teuchos::null);
111 
112  virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > getSolver() const;
113 
114  /// Take the specified timestep, dt, and return true if successful.
115  virtual void takeStep(
116  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
117 
118  /// Get a default (initial) StepperState
119  virtual Teuchos::RCP<Tempus::StepperState<Scalar> > getDefaultStepperState();
120 
121  virtual bool isExplicit() const;
122  virtual bool isImplicit() const;
123  virtual bool isExplicitImplicit() const;
124  virtual bool isOneStepMethod() const;
125  virtual bool isMultiStepMethod() const;
126 
127  virtual Scalar getOrder() const;
128  virtual Scalar getOrderMin() const;
129  virtual Scalar getOrderMax() const;
130 
131  virtual OrderODE getOrderODE() const;
132  //@}
133 
134  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
135 
136  /// \name Overridden from Teuchos::Describable
137  //@{
138  virtual void describe(Teuchos::FancyOStream & out,
139  const Teuchos::EVerbosityLevel verbLevel) const;
140  //@}
141 
142  /// \name Functions to set the subcycling stepper values.
143  //@{
144  virtual void setSubcyclingStepper(Teuchos::RCP<Stepper<Scalar> > stepper);
145  virtual void setSubcyclingMinTimeStep(Scalar MinTimeStep);
146  virtual void setSubcyclingInitTimeStep(Scalar InitTimeStep);
147  virtual void setSubcyclingMaxTimeStep(Scalar MaxTimeStep);
148  virtual void setSubcyclingStepType(std::string StepType);
149  virtual void setSubcyclingMaxFailures(int MaxFailures);
150  virtual void setSubcyclingMaxConsecFailures(int MaxConsecFailures);
151  virtual void setSubcyclingScreenOutputIndexInterval(int i);
152  virtual void setSubcyclingScreenOutputIndexList(std::string s);
154  Teuchos::RCP<TimeStepControlStrategy<Scalar> > tscs);
155  virtual void setSubcyclingIntegratorObserver(
156  Teuchos::RCP<IntegratorObserver<Scalar> > obs);
157  virtual void setSubcyclingPrintDtChanges(bool printDtChanges);
158  //@}
159 
160  /// \name Functions to get the subcycling stepper values.
161  //@{
162  virtual Teuchos::RCP<const Stepper<Scalar> > getSubcyclingStepper() const;
163  virtual Scalar getSubcyclingMinTimeStep() const;
164  virtual Scalar getSubcyclingInitTimeStep() const;
165  virtual Scalar getSubcyclingMaxTimeStep() const;
166  virtual std::string getSubcyclingStepType() const;
167  virtual int getSubcyclingMaxFailures() const;
168  virtual int getSubcyclingMaxConsecFailures() const;
169  virtual int getSubcyclingScreenOutputIndexInterval() const;
170  virtual std::string getSubcyclingScreenOutputIndexList() const;
171  virtual Teuchos::RCP<TimeStepControlStrategy<Scalar> >
173  virtual Teuchos::RCP<IntegratorObserver<Scalar> >
175  virtual bool getSubcyclingPrintDtChanges() const;
176  //@}
177 
178 protected:
179 
180 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
181  Teuchos::RCP<StepperSubcyclingObserver<Scalar> > stepperSCObserver_;
182 #endif
183  Teuchos::RCP<StepperSubcyclingAppAction<Scalar> > stepperSCAppAction_;
184  Teuchos::RCP<IntegratorBasic<Scalar> > scIntegrator_;
185 
186 };
187 
188 } // namespace Tempus
189 
190 #endif // Tempus_StepperSubcycling_decl_hpp
virtual int getSubcyclingMaxConsecFailures() const
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 Scalar getSubcyclingMaxTimeStep() const
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)
Application Action for StepperSubcycling.
Thyra Base interface for time steppers.
virtual Teuchos::RCP< IntegratorObserver< Scalar > > getSubcyclingIntegratorObserver() const
Teuchos::RCP< StepperSubcyclingObserver< Scalar > > stepperSCObserver_
virtual int getSubcyclingScreenOutputIndexInterval() const
virtual void setSubcyclingIntegratorObserver(Teuchos::RCP< IntegratorObserver< Scalar > > obs)
IntegratorObserver class for time integrators.
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)
virtual void setSubcyclingScreenOutputIndexList(std::string s)
virtual std::string getSubcyclingStepType() const
StepperObserver class for Stepper class.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Teuchos::RCP< StepperSubcyclingAppAction< Scalar > > stepperSCAppAction_
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 Teuchos::RCP< const Stepper< Scalar > > getSubcyclingStepper() const
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
virtual void setSubcyclingPrintDtChanges(bool printDtChanges)
virtual Teuchos::RCP< StepperSubcyclingAppAction< Scalar > > getAppAction() const
virtual std::string getSubcyclingScreenOutputIndexList() const
virtual Scalar getSubcyclingMinTimeStep() const
virtual bool getSubcyclingPrintDtChanges() const
StepperSubcyclingObserver class for StepperSubcycling.
StepControlStrategy class for TimeStepControl.
virtual Teuchos::RCP< TimeStepControlStrategy< Scalar > > getSubcyclingTimeStepControlStrategy() const
virtual Scalar getSubcyclingInitTimeStep() const
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 void setAppAction(Teuchos::RCP< StepperSubcyclingAppAction< Scalar > > appAction=Teuchos::null)
virtual Teuchos::RCP< StepperObserver< Scalar > > getObserver() const
Get Observer.
virtual void setSubcyclingMaxFailures(int MaxFailures)