Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_IntegratorAdjointSensitivity_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_IntegratorAdjointSensitivity_decl_hpp
11 #define Tempus_IntegratorAdjointSensitivity_decl_hpp
12 
13 // Tempus
14 #include "Tempus_config.hpp"
15 #include "Tempus_IntegratorBasic.hpp"
16 #include "Tempus_AdjointAuxSensitivityModelEvaluator.hpp"
17 
18 #include "Tempus_StepperStaggeredForwardSensitivity.hpp" // For SensitivityStepMode
19 
20 namespace Tempus {
21 
51 template <class Scalar>
52 class IntegratorAdjointSensitivity : virtual public Tempus::Integrator<Scalar> {
53  public:
115  const Teuchos::RCP<IntegratorBasic<Scalar>> &state_integrator,
116  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar>> &adjoint_model,
118  &adjoint_aux_model,
119  const Teuchos::RCP<IntegratorBasic<Scalar>> &adjoint_integrator,
120  const Teuchos::RCP<SolutionHistory<Scalar>> &solution_history,
121  const int p_index, const int g_index, const bool g_depends_on_p,
122  const bool f_depends_on_p, const bool ic_depends_on_p,
123  const bool mass_matrix_is_identity);
124 
128 
131 
133 
134 
136  virtual bool advanceTime();
138  virtual bool advanceTime(const Scalar timeFinal) override;
140  virtual Scalar getTime() const override;
142  virtual int getIndex() const override;
144  virtual Status getStatus() const override;
146  virtual void setStatus(const Status st) override;
148  virtual Teuchos::RCP<Stepper<Scalar>> getStepper() const override;
151  const override;
156  override;
159  const override;
161  override;
166  {
167  return state_integrator_->getIntegratorTimer();
168  }
170  {
171  return state_integrator_->getStepperTimer();
172  }
173 
175 
177  virtual void initializeSolutionHistory(
178  Scalar t0, Teuchos::RCP<const Thyra::VectorBase<Scalar>> x0,
179  Teuchos::RCP<const Thyra::VectorBase<Scalar>> xdot0 = Teuchos::null,
180  Teuchos::RCP<const Thyra::VectorBase<Scalar>> xdotdot0 = Teuchos::null,
181  Teuchos::RCP<const Thyra::MultiVectorBase<Scalar>> DxDp0 = Teuchos::null,
183  Teuchos::null,
184  Teuchos::RCP<const Thyra::MultiVectorBase<Scalar>> DxdotdotDp0 =
185  Teuchos::null);
186 
190  virtual void setObserver(
191  Teuchos::RCP<IntegratorObserver<Scalar>> obs = Teuchos::null);
193  virtual void initialize();
194 
201 
208 
211 
213  {
214  return adjoint_model_;
215  };
216 
218 
219  std::string description() const override;
221  const Teuchos::EVerbosityLevel verbLevel) const override;
223 
226 
227  protected:
228  // Create sensitivity model evaluator from application model
231  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar>> &adjoint_model,
232  const Teuchos::RCP<Teuchos::ParameterList> &inputPL);
233 
235  const Teuchos::RCP<const SolutionHistory<Scalar>> &state_solution_history,
237  &adjoint_solution_history);
238 
245  int p_index_;
246  int g_index_;
254 };
255 
257 
273 template <class Scalar>
278  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar>> &adjoint_model =
279  Teuchos::null);
280 
282 template <class Scalar>
285 
286 } // namespace Tempus
287 
288 #endif // Tempus_IntegratorAdjointSensitivity_decl_hpp
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getYDot() const
Get the current time derivative of the adjoint solution, ydot.
SensitivityStepMode getStepMode() const
What mode the current time integration step is in.
Teuchos::RCP< Thyra::MultiVectorBase< Scalar > > dgdp_
virtual Teuchos::RCP< TimeStepControl< Scalar > > getNonConstTimeStepControl() override
virtual void setObserver(Teuchos::RCP< IntegratorObserver< Scalar >> obs=Teuchos::null)
Set the Observer.
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getXDotDot() const
Get the current second time derivative of the solution, xdotdot.
virtual void setStatus(const Status st) override
Set Status.
void buildSolutionHistory(const Teuchos::RCP< const SolutionHistory< Scalar >> &state_solution_history, const Teuchos::RCP< const SolutionHistory< Scalar >> &adjoint_solution_history)
Teuchos::RCP< AdjointAuxSensitivityModelEvaluator< Scalar > > adjoint_aux_model_
virtual Teuchos::RCP< SolutionHistory< Scalar > > getNonConstSolutionHistory() override
Get the SolutionHistory.
ModelEvaluator for forming adjoint sensitivity equations.
virtual Teuchos::RCP< Teuchos::Time > getStepperTimer() const override
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getXDot() const
Get the current time derivative of the solution, xdot.
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory_
virtual Teuchos::RCP< IntegratorObserver< Scalar > > getObserver()
Get the Observer.
Teuchos::RCP< IntegratorBasic< Scalar > > adjoint_integrator_
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getX() const
Get the current solution, x.
virtual Teuchos::RCP< Teuchos::Time > getIntegratorTimer() const override
Returns the IntegratorTimer_ for this Integrator.
Teuchos::RCP< IntegratorAdjointSensitivity< Scalar > > createIntegratorAdjointSensitivity(Teuchos::RCP< Teuchos::ParameterList > pList, const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &model, const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &adjoint_model=Teuchos::null)
Nonmember constructor.
virtual Teuchos::RCP< const SolutionHistory< Scalar > > getSolutionHistory() const override
Get the SolutionHistory.
Status
Status for the Integrator, the Stepper and the SolutionState.
Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > dxdp_init_
IntegratorObserver class for time integrators.
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getYDotDot() const
Get the current second time derivative of the adjoint solution, ydotdot.
Teuchos::RCP< AdjointAuxSensitivityModelEvaluator< Scalar > > createAdjointModel(const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &model, const Teuchos::RCP< Thyra::ModelEvaluator< Scalar >> &adjoint_model, const Teuchos::RCP< Teuchos::ParameterList > &inputPL)
virtual Teuchos::RCP< const TimeStepControl< Scalar > > getTimeStepControl() const override
Get the TimeStepControl.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual bool advanceTime()
Advance the solution to timeMax, and return true if successful.
Teuchos::RCP< TimeStepControl< Scalar > > getSensNonConstTimeStepControl()
Teuchos::RCP< const SolutionHistory< Scalar > > getSensSolutionHistory() const
Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > getAdjointModel() const
Teuchos::RCP< IntegratorBasic< Scalar > > state_integrator_
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getY() const
Get the current adjoint solution, y.
virtual void initializeSolutionHistory(Scalar t0, Teuchos::RCP< const Thyra::VectorBase< Scalar >> x0, Teuchos::RCP< const Thyra::VectorBase< Scalar >> xdot0=Teuchos::null, Teuchos::RCP< const Thyra::VectorBase< Scalar >> xdotdot0=Teuchos::null, Teuchos::RCP< const Thyra::MultiVectorBase< Scalar >> DxDp0=Teuchos::null, Teuchos::RCP< const Thyra::MultiVectorBase< Scalar >> DxdotDp0=Teuchos::null, Teuchos::RCP< const Thyra::MultiVectorBase< Scalar >> DxdotdotDp0=Teuchos::null)
Set the initial state from Thyra::VectorBase(s)
Teuchos::RCP< const SolutionHistory< Scalar > > getStateSolutionHistory() const
Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > model_
Teuchos::RCP< Thyra::ModelEvaluator< Scalar > > adjoint_model_
Thyra Base interface for time integrators. Time integrators are designed to advance the solution from...
Time integrator suitable for adjoint sensitivity analysis.
virtual int getIndex() const override
Get current index.
Teuchos::RCP< TimeStepControl< Scalar > > getStateNonConstTimeStepControl()
virtual Scalar getTime() const override
Get current time.
virtual Status getStatus() const override
Get Status.
virtual void initialize()
Initializes the Integrator after set* function calls.
virtual Teuchos::RCP< Stepper< Scalar > > getStepper() const override
Get the Stepper.
virtual Teuchos::RCP< const Thyra::MultiVectorBase< Scalar > > getDgDp() const
Return adjoint sensitivity stored in gradient format.
IntegratorAdjointSensitivity()
Constructor that requires a subsequent setParameterList, setStepper, and initialize calls...