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: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_WrapperModelEvaluatorBasic_decl_hpp
10 #define Tempus_WrapperModelEvaluatorBasic_decl_hpp
11 
12 #include <functional>
13 #include "Tempus_config.hpp"
15 
16 namespace Tempus {
17 
25 template <typename Scalar>
27  : public Tempus::WrapperModelEvaluator<Scalar> {
28  public:
31  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar>> &appModel)
32  : appModel_(appModel), timeDer_(Teuchos::null), evaluationType_(SOLVE_FOR_X)
33  {
34  using Teuchos::rcp_const_cast;
35 
37  index_ = -1;
38 
39  typedef Thyra::ModelEvaluatorBase MEB;
40  MEB::InArgs<Scalar> inArgs = appModel_->getNominalValues();
41  x_ = rcp_const_cast<Thyra::VectorBase<Scalar>>(inArgs.get_x());
42 
43  if (inArgs.supports(MEB::IN_ARG_x_dot)) {
44  xDot_ = rcp_const_cast<Thyra::VectorBase<Scalar>>(inArgs.get_x_dot());
45  }
46  else {
47  xDot_ = Teuchos::null;
48  }
49  }
50 
52  virtual void setAppModel(
54  {
55  appModel_ = me;
56  }
57 
60  {
61  return appModel_;
62  }
63 
67  const Teuchos::RCP<Thyra::VectorBase<Scalar>> &xDot, const Scalar time,
69  const Teuchos::RCP<Thyra::VectorBase<Scalar>> &y = Teuchos::null,
70  const int index = -1 /* index and y are for IMEX_RK_Partition */)
71  {
72  x_ = x;
73  xDot_ = xDot;
74  time_ = time;
75  p_ = p;
76  y_ = y;
77  index_ = index;
78 
79  timeDer_ = p->timeDer_;
80  evaluationType_ = p->evaluationType_;
81  }
82 
84 
86  {
87  return appModel_->create_W_op();
88  }
89 
91  {
92  return appModel_->create_W_prec();
93  }
94 
96  get_W_factory() const
97  {
98  return appModel_->get_W_factory();
99  }
100 
102  {
103  return appModel_->get_f_space();
104  }
105 
107  {
108  return appModel_->get_p_space(p);
109  }
110 
112  {
113  return appModel_->get_p_names(p);
114  }
115 
117  {
118  return appModel_->get_g_names(g);
119  }
120 
122  {
123  return appModel_->get_x_space();
124  }
125 
127  {
128  return appModel_->get_g_space(i);
129  }
130 
132  {
133  return appModel_->getNominalValues();
134  }
135 
137  {
138  return appModel_->create_DfDp_op(l);
139  }
140 
142  {
143  return appModel_->create_DgDx_op(j);
144  }
145 
147  {
148  return appModel_->create_DgDp_op(j, l);
149  }
150 
153 
154  void evalModelImpl(
156  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs) const;
158 
159  private:
162 
163  private:
165 
168  Scalar time_;
171  int index_;
172 
175 };
176 
177 } // namespace Tempus
178 
179 #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