Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_WrapperModelEvaluatorBasic_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_WrapperModelEvaluatorBasic_decl_hpp
11 #define Tempus_WrapperModelEvaluatorBasic_decl_hpp
12 
13 #include <functional>
14 #include "Tempus_config.hpp"
16 
17 namespace Tempus {
18 
26 template <typename Scalar>
28  : public Tempus::WrapperModelEvaluator<Scalar> {
29  public:
32  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar>> &appModel)
33  : appModel_(appModel), timeDer_(Teuchos::null), evaluationType_(SOLVE_FOR_X)
34  {
35  using Teuchos::rcp_const_cast;
36 
38  index_ = -1;
39 
40  typedef Thyra::ModelEvaluatorBase MEB;
41  MEB::InArgs<Scalar> inArgs = appModel_->getNominalValues();
42  x_ = rcp_const_cast<Thyra::VectorBase<Scalar>>(inArgs.get_x());
43 
44  if (inArgs.supports(MEB::IN_ARG_x_dot)) {
45  xDot_ = rcp_const_cast<Thyra::VectorBase<Scalar>>(inArgs.get_x_dot());
46  }
47  else {
48  xDot_ = Teuchos::null;
49  }
50  }
51 
53  virtual void setAppModel(
55  {
56  appModel_ = me;
57  }
58 
61  {
62  return appModel_;
63  }
64 
68  const Teuchos::RCP<Thyra::VectorBase<Scalar>> &xDot, const Scalar time,
70  const Teuchos::RCP<Thyra::VectorBase<Scalar>> &y = Teuchos::null,
71  const int index = -1 /* index and y are for IMEX_RK_Partition */)
72  {
73  x_ = x;
74  xDot_ = xDot;
75  time_ = time;
76  p_ = p;
77  y_ = y;
78  index_ = index;
79 
80  timeDer_ = p->timeDer_;
81  evaluationType_ = p->evaluationType_;
82  }
83 
85 
87  {
88  return appModel_->create_W_op();
89  }
90 
92  {
93  return appModel_->create_W_prec();
94  }
95 
97  get_W_factory() const
98  {
99  return appModel_->get_W_factory();
100  }
101 
103  {
104  return appModel_->get_f_space();
105  }
106 
108  {
109  return appModel_->get_p_space(p);
110  }
111 
113  {
114  return appModel_->get_p_names(p);
115  }
116 
118  {
119  return appModel_->get_g_names(g);
120  }
121 
123  {
124  return appModel_->get_x_space();
125  }
126 
128  {
129  return appModel_->get_g_space(i);
130  }
131 
133  {
134  return appModel_->getNominalValues();
135  }
136 
138  {
139  return appModel_->create_DfDp_op(l);
140  }
141 
143  {
144  return appModel_->create_DgDx_op(j);
145  }
146 
148  {
149  return appModel_->create_DgDp_op(j, l);
150  }
151 
154 
155  void evalModelImpl(
157  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs) const;
159 
160  private:
163 
164  private:
166 
169  Scalar time_;
172  int index_;
173 
176 };
177 
178 } // namespace Tempus
179 
180 #endif // Tempus_WrapperModelEvaluatorBasic_decl_hpp
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int p) const
Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot_
EVALUATION_TYPE
EVALUATION_TYPE indicates the evaluation to apply to the implicit ODE.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getAppModel() const
Get the underlying application model &#39;f&#39;.
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Teuchos::RCP< ImplicitODEParameters< Scalar > > p_
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_DfDp_op(int l) const
Teuchos::RCP< TimeDerivative< Scalar > > timeDer_
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
A ModelEvaluator which wraps the application ModelEvaluator.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int i) const
Get the g space.
Teuchos::RCP< Thyra::VectorBase< Scalar > > y_
void setForSolve(const Teuchos::RCP< Thyra::VectorBase< Scalar >> &x, const Teuchos::RCP< Thyra::VectorBase< Scalar >> &xDot, const Scalar time, const Teuchos::RCP< ImplicitODEParameters< Scalar >> &p, const Teuchos::RCP< Thyra::VectorBase< Scalar >> &y=Teuchos::null, const int index=-1)
Set parameters for application implicit ModelEvaluator solve.
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_DgDp_op(int j, int l) const
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
Teuchos::RCP< Thyra::PreconditionerBase< Scalar > > create_W_prec() const
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_DgDx_op(int j) const
Teuchos::ArrayView< const std::string > get_g_names(int g) const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
WrapperModelEvaluatorBasic()
Default constructor - not allowed.
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Get the x-solution space.
Teuchos::RCP< Thyra::VectorBase< Scalar > > x_
virtual void setAppModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar >> &me)
Set the underlying application ModelEvaluator.
A ModelEvaluator for residual evaluations given a state. This ModelEvaluator takes a state...
Solve for x and determine xDot from x.
WrapperModelEvaluatorBasic(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar >> &appModel)
Constructor.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int p) const
Get the p space.
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const