Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_IntegratorForwardSensitivity_decl.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_IntegratorForwardSensitivity_decl_hpp
11 #define Tempus_IntegratorForwardSensitivity_decl_hpp
12 
13 // Tempus
14 #include "Tempus_config.hpp"
15 #include "Tempus_IntegratorBasic.hpp"
17 #include "Tempus_StepperStaggeredForwardSensitivity.hpp"
18 
19 namespace Tempus {
20 
48 template <class Scalar>
49 class IntegratorForwardSensitivity : virtual public Tempus::Integrator<Scalar> {
50  public:
91  const Teuchos::RCP<IntegratorBasic<Scalar>> &integrator,
94  &sens_stepper,
95  const bool use_combined_method);
96 
98 
101 
104 
106 
107  virtual bool advanceTime() { return integrator_->advanceTime(); }
110  virtual bool advanceTime(const Scalar timeFinal) override
111  {
112  return integrator_->advanceTime(timeFinal);
113  }
115  virtual void startIntegrator() { integrator_->startIntegrator(); }
117  virtual void startTimeStep() { integrator_->startTimeStep(); }
119  virtual void checkTimeStep() { integrator_->checkTimeStep(); }
121  virtual void endIntegrator() { integrator_->endIntegrator(); }
123 
125 
126  virtual Scalar getTime() const override { return integrator_->getTime(); }
129  virtual int getIndex() const override { return integrator_->getIndex(); }
131  virtual Status getStatus() const override { return integrator_->getStatus(); }
132  // Set Status
133  virtual void setStatus(const Status st) override
134  {
135  integrator_->setStatus(st);
136  }
138  virtual Teuchos::RCP<Stepper<Scalar>> getStepper() const override
139  {
140  return integrator_->getStepper();
141  }
142 
145 
147  virtual void setStepper(Teuchos::RCP<Stepper<Scalar>> stepper)
148  {
149  integrator_->setStepper(stepper);
150  }
153  Teuchos::RCP<SolutionState<Scalar>> state = Teuchos::null)
154  {
155  integrator_->initializeSolutionHistory(state);
156  }
157 
159  virtual void initializeSolutionHistory(
160  Scalar t0, Teuchos::RCP<const Thyra::VectorBase<Scalar>> x0,
161  Teuchos::RCP<const Thyra::VectorBase<Scalar>> xdot0 = Teuchos::null,
162  Teuchos::RCP<const Thyra::VectorBase<Scalar>> xdotdot0 = Teuchos::null,
163  Teuchos::RCP<const Thyra::MultiVectorBase<Scalar>> DxDp0 = Teuchos::null,
165  Teuchos::null,
166  Teuchos::RCP<const Thyra::MultiVectorBase<Scalar>> DxdotdotDp0 =
167  Teuchos::null);
168 
171  const override
172  {
173  return integrator_->getSolutionHistory();
174  }
177  override
178  {
179  return integrator_->getNonConstSolutionHistory();
180  }
182  virtual void setSolutionHistory(
183  Teuchos::RCP<SolutionHistory<Scalar>> sh = Teuchos::null)
184  {
185  integrator_->setSolutionHistory(sh);
186  }
189  const override
190  {
191  return integrator_->getTimeStepControl();
192  }
194  override
195  {
196  return integrator_->getNonConstTimeStepControl();
197  }
199  virtual void setTimeStepControl(
200  Teuchos::RCP<TimeStepControl<Scalar>> tsc = Teuchos::null)
201  {
202  integrator_->setTimeStepControl(tsc);
203  }
206  {
207  return integrator_->getObserver();
208  }
210  virtual void setObserver(
211  Teuchos::RCP<IntegratorObserver<Scalar>> obs = Teuchos::null)
212  {
213  integrator_->setObserver(obs);
214  }
216  virtual void initialize() { integrator_->initialize(); }
218  {
219  return integrator_->getIntegratorTimer();
220  }
222  {
223  return integrator_->getStepperTimer();
224  }
225 
237 
258  const;
259 
264 
267  {
268  return integrator_->getCurrentState();
269  }
271 
273  void parseScreenOutput() { integrator_->parseScreenOutput(); }
274 
276 
277  std::string description() const override;
279  const Teuchos::EVerbosityLevel verbLevel) const override;
281 
284 
285  protected:
291 };
292 
294 
309 template <class Scalar>
314  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar>> &sens_residual_model,
315  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar>> &sens_solve_model);
316 
318 
332 template <class Scalar>
337  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar>> &sens_residual_model)
338 {
339  return createIntegratorForwardSensitivity(pList, model, sens_residual_model,
340  sens_residual_model);
341 }
342 
344 
357 template <class Scalar>
362 {
363  return createIntegratorForwardSensitivity(pList, model, model, model);
364 }
365 
367 
375 template <class Scalar>
378 
379 } // namespace Tempus
380 
381 #endif // Tempus_IntegratorForwardSensitivity_decl_hpp
virtual Teuchos::RCP< const SolutionHistory< Scalar > > getSolutionHistory() const override
Get the SolutionHistory.
Teuchos::RCP< IntegratorBasic< Scalar > > integrator_
virtual Teuchos::RCP< Teuchos::Time > getIntegratorTimer() const override
Returns the IntegratorTimer_ for this Integrator.
virtual int getIndex() const override
Get current index.
Teuchos::RCP< IntegratorForwardSensitivity< Scalar > > createIntegratorForwardSensitivity(Teuchos::RCP< Teuchos::ParameterList > pList, const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &model, const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &sens_residual_model, const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &sens_solve_model)
Nonmember constructor.
virtual Teuchos::RCP< SolutionHistory< Scalar > > getNonConstSolutionHistory() override
Get the SolutionHistory.
virtual bool advanceTime()
Advance the solution to timeMax, and return true if successful.
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getXDotDot() const
Get current the second time derivative of the solution, xdotdot, only. This is the first block only a...
virtual void setStepper(Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> model)
Set the Stepper.
SensitivityStepMode getStepMode() const
What mode the current time integration step is in.
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getDXDotDp() const
virtual Teuchos::RCP< IntegratorObserver< Scalar > > getObserver()
Get the Observer.
virtual Teuchos::RCP< const TimeStepControl< Scalar > > getTimeStepControl() const override
Get the TimeStepControl.
virtual void endIntegrator()
Perform tasks after end of integrator.
virtual void setStatus(const Status st) override
Set the Status.
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getDXDotDotDp() const
A stepper implementing staggered forward sensitivity analysis.
Teuchos::RCP< StepperStaggeredForwardSensitivity< Scalar > > sens_stepper_
virtual void setSolutionHistory(Teuchos::RCP< SolutionHistory< Scalar >> sh=Teuchos::null)
Set the SolutionHistory.
virtual void setObserver(Teuchos::RCP< IntegratorObserver< Scalar >> obs=Teuchos::null)
Set the Observer.
virtual Teuchos::RCP< SolutionState< Scalar > > getCurrentState()
Get current state.
virtual Status getStatus() const override
Get Status.
virtual void setStepper(Teuchos::RCP< Stepper< Scalar >> stepper)
Set the Stepper.
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getDgDp() const
Return forward sensitivity stored in Jacobian format.
Thyra Base interface for time steppers.
virtual void startIntegrator()
Perform tasks before start of integrator.
virtual void checkTimeStep()
Check if time step has passed or failed.
virtual Teuchos::RCP< Teuchos::Time > getStepperTimer() const override
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getDxDp() const
Get the forward sensitivities .
virtual void initialize()
Initializes the Integrator after set* function calls.
virtual Teuchos::RCP< Stepper< Scalar > > getStepper() const override
Get the Stepper.
Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > model_
Status
Status for the Integrator, the Stepper and the SolutionState.
IntegratorObserver class for time integrators.
TimeStepControl manages the time step size. There several mechanisms that effect the time step size a...
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
void parseScreenOutput()
Parse when screen output should be executed.
virtual Scalar getTime() const override
Get current time.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getG() const
Return response function g.
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getX() const
Get the current solution, x, only. If looking for the solution vector and the sensitivities, use SolutionState-&gt;getX() which will return a Block MultiVector with the first block containing the current solution, x, and the remaining blocks are the forward sensitivities .
Thyra Base interface for time integrators. Time integrators are designed to advance the solution from...
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getXDot() const
Get current the time derivative of the solution, xdot, only. This is the first block only and not the...
virtual Teuchos::RCP< TimeStepControl< Scalar > > getNonConstTimeStepControl() override
A ModelEvaluator decorator for sensitivity analysis.
Teuchos::RCP< SensitivityModelEvaluatorBase< Scalar > > sens_model_
Time integrator implementing forward sensitivity analysis.
virtual void initializeSolutionHistory(Teuchos::RCP< SolutionState< Scalar >> state=Teuchos::null)
Set the initial state which has the initial conditions.
virtual bool advanceTime(const Scalar timeFinal) override
Advance the solution to timeFinal, and return true if successful.
Solution state for integrators and steppers.
virtual void setTimeStepControl(Teuchos::RCP< TimeStepControl< Scalar >> tsc=Teuchos::null)
Set the TimeStepControl.