Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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>
14 
15 namespace Tempus {
16 
17 
18 /** \brief A ModelEvaluator for residual evaluations given a state.
19  * This ModelEvaluator takes a state, x, and determines its residual,
20  * \f$ g(x) \f$, which is suitable for a nonlinear solve. This is
21  * accomplished by computing the time derivative of the state, x_dot,
22  * (through Lambda functions), supplying the current time, and calling
23  * the application application ModelEvaluator, \f$ f(x,\dot{x},t) \f$.
24  */
25 template <typename Scalar>
27  : public Tempus::WrapperModelEvaluator<Scalar>
28 {
29 public:
30 
31  /// Constructor
33  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel)
34  : appModel_(appModel), timeDer_(Teuchos::null), evaluationType_(SOLVE_FOR_X)
35  {
36  wrapperInArgs_ = this->createInArgs();
37  wrapperOutArgs_ = this->createOutArgs();
38  }
39 
40  /// Set the underlying application ModelEvaluator
41  virtual void setAppModel(
42  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > & me)
43  { appModel_ = me; }
44 
45  /// Get the underlying application model 'f'
46  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
47  getAppModel() const { return appModel_; }
48 
49  /// Set InArgs the wrapper ModelEvalutor.
50  virtual void setInArgs(Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs)
51  { wrapperInArgs_.setArgs(inArgs); }
52 
53  /// Get InArgs the wrapper ModelEvalutor.
54  virtual Thyra::ModelEvaluatorBase::InArgs<Scalar> getInArgs()
55  { return wrapperInArgs_; }
56 
57  /// Set OutArgs the wrapper ModelEvalutor.
58  virtual void setOutArgs(Thyra::ModelEvaluatorBase::OutArgs<Scalar> outArgs)
59  { wrapperOutArgs_.setArgs(outArgs); }
60 
61  /// Get OutArgs the wrapper ModelEvalutor.
62  virtual Thyra::ModelEvaluatorBase::OutArgs<Scalar> getOutArgs()
63  { return wrapperOutArgs_; }
64 
65  /// Set parameters for application implicit ModelEvaluator solve.
66  virtual void setForSolve(Teuchos::RCP<TimeDerivative<Scalar> > timeDer,
67  Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs,
68  Thyra::ModelEvaluatorBase::OutArgs<Scalar> outArgs,
69  EVALUATION_TYPE evaluationType = SOLVE_FOR_X)
70  {
71  timeDer_ = timeDer;
72  wrapperInArgs_.setArgs(inArgs);
73  wrapperOutArgs_.setArgs(outArgs);
74  evaluationType_ = evaluationType;
75  }
76 
77  /// \name Overridden from Thyra::StateFuncModelEvaluatorBase
78  //@{
79  Teuchos::RCP<Thyra::LinearOpBase<Scalar> > create_W_op() const
80  { return appModel_->create_W_op(); }
81 
82  Teuchos::RCP<Thyra::PreconditionerBase<Scalar> > create_W_prec() const
83  { return appModel_->create_W_prec(); }
84 
85  Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> >
86  get_W_factory() const { return appModel_->get_W_factory(); }
87 
88  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_f_space() const
89  { return appModel_->get_f_space(); }
90 
91  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_p_space(int p) const
92  { return appModel_->get_p_space(p); };
93 
94  Teuchos::RCP<const Teuchos::Array<std::string> > get_p_names(int p) const
95  { return appModel_->get_p_names(p); }
96 
97  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_x_space() const
98  { return appModel_->get_x_space(); }
99 
100  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_g_space(int i) const
101  { return appModel_->get_g_space(i); }
102 
103  Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const
104  { return appModel_->getNominalValues(); }
105 
106  Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const;
107  Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const;
108 
109  void evalModelImpl(
110  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
111  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs) const;
112  //@}
113 
114 private:
115  /// Default constructor - not allowed
117 
118 private:
119  Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > appModel_;
120  Teuchos::RCP<TimeDerivative<Scalar> > timeDer_;
121  Thyra::ModelEvaluatorBase::InArgs<Scalar> wrapperInArgs_;
122  Thyra::ModelEvaluatorBase::OutArgs<Scalar> wrapperOutArgs_;
124 };
125 
126 } // namespace Tempus
127 
128 #endif // Tempus_WrapperModelEvaluatorBasic_decl_hpp
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int p) const
virtual void setInArgs(Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs)
Set InArgs the wrapper ModelEvalutor.
EVALUATION_TYPE
EVALUATION_TYPE indicates the evaluation to apply to the implicit ODE.
Thyra::ModelEvaluatorBase::InArgs< Scalar > wrapperInArgs_
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getAppModel() const
Get the underlying application model &#39;f&#39;.
virtual void setOutArgs(Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs)
Set OutArgs the wrapper ModelEvalutor.
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Teuchos::RCP< TimeDerivative< Scalar > > timeDer_
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
virtual Thyra::ModelEvaluatorBase::InArgs< Scalar > getInArgs()
Get InArgs the wrapper ModelEvalutor.
virtual void setForSolve(Teuchos::RCP< TimeDerivative< Scalar > > timeDer, Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs, Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs, EVALUATION_TYPE evaluationType=SOLVE_FOR_X)
Set parameters for application implicit ModelEvaluator solve.
A ModelEvaluator which wraps the application ModelEvaluator.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int i) const
Get the g space.
virtual void setAppModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &me)
Set the underlying application ModelEvaluator.
WrapperModelEvaluatorBasic(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
Constructor.
virtual Thyra::ModelEvaluatorBase::OutArgs< Scalar > getOutArgs()
Get OutArgs the wrapper ModelEvalutor.
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
Teuchos::RCP< Thyra::PreconditionerBase< Scalar > > create_W_prec() const
This interface defines the time derivative connection between an implicit Stepper and WrapperModelEva...
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
Thyra::ModelEvaluatorBase::OutArgs< Scalar > wrapperOutArgs_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Get the x-solution space.
A ModelEvaluator for residual evaluations given a state. This ModelEvaluator takes a state...
Solve for x and determine xDot from x.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int p) const
Get the p space.
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const