Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_WrapperModelEvaluatorPairPartIMEX_Basic_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_ModelEvaluatorPairPartIMEX_Basic_decl_hpp
11 #define Tempus_ModelEvaluatorPairPartIMEX_Basic_decl_hpp
12 
13 #include "Tempus_config.hpp"
15 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
16 
17 namespace Tempus {
18 
37 template <typename Scalar>
39  : public Tempus::WrapperModelEvaluatorPairIMEX<Scalar> {
40  public:
44 
47  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& explicitModel,
48  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& implicitModel,
49  int numExplicitOnlyBlocks = 0, int parameterIndex = -1);
50 
53 
55  virtual void initialize();
56 
58 
59  virtual void setAppModel(
62  const;
63 
66  {
68  }
69 
72  {
74  }
75 
79  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xDot, const Scalar time,
81  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& y = Teuchos::null,
82  const int index = -1 /* index and y are for IMEX_RK_Partition */)
83  {
84  timeDer_ = p->timeDer_;
85 
86  typedef Thyra::ModelEvaluatorBase MEB;
87  MEB::InArgs<Scalar> inArgs = this->createInArgs();
88  MEB::OutArgs<Scalar> outArgs = this->createOutArgs();
89  inArgs.set_x(x);
90  if (y != Teuchos::null) inArgs.set_p(index, y);
91  if (inArgs.supports(MEB::IN_ARG_x_dot)) inArgs.set_x_dot(xDot);
92  if (inArgs.supports(MEB::IN_ARG_t)) inArgs.set_t(time);
93  if (inArgs.supports(MEB::IN_ARG_step_size))
94  inArgs.set_step_size(p->timeStepSize_);
95  if (inArgs.supports(MEB::IN_ARG_alpha)) inArgs.set_alpha(p->alpha_);
96  if (inArgs.supports(MEB::IN_ARG_beta)) inArgs.set_beta(p->beta_);
97  if (inArgs.supports(MEB::IN_ARG_stage_number))
98  inArgs.set_stage_number(p->stageNumber_);
99 
100  wrapperImplicitInArgs_.setArgs(inArgs);
101  wrapperImplicitOutArgs_.setArgs(outArgs);
102 
103  useImplicitModel_ = true;
104  }
105 
107 
109 
112  const;
113 
116  int i) const;
117 
120  int i) const;
122 
124  virtual void setNumExplicitOnlyBlocks(int numExp)
125  {
126  numExplicitOnlyBlocks_ = numExp;
127  }
128  virtual void setExplicitModel(
129  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model)
130  {
131  explicitModel_ = model;
132  }
133  virtual void setImplicitModel(
134  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model);
136  const
137  {
138  return explicitModel_;
139  }
141  const
142  {
143  return implicitModel_;
144  }
145  virtual int getNumExplicitOnlyBlocks() const
146  {
147  return numExplicitOnlyBlocks_;
148  }
149 
152  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& full) const;
153 
156  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& full) const;
157 
160  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& full) const;
161 
164  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& full) const;
165 
167  virtual void setParameterIndex(int parameterIndex = -1);
169  virtual int getParameterIndex() const { return parameterIndex_; }
170 
173  virtual void setUseImplicitModel(bool tf) { useImplicitModel_ = tf; }
176  virtual bool getUseImplicitModel() const { return useImplicitModel_; }
178 
180 
182  {
183  return implicitModel_->create_W_op();
184  }
185 
188  {
189  return implicitModel_->get_W_factory();
190  }
191 
193  const;
194 
198 
199  virtual void evalModelImpl(
203 
204  protected:
206  void setup(
207  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& explicitModel,
208  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& implicitModel,
209  int numExplicitOnlyBlocks = 0, int parameterIndex = -1);
210 
213 
217 
221 };
222 
223 } // namespace Tempus
224 
225 #endif // Tempus_ModelEvaluatorPairPartIMEX_Basic_decl_hpp
virtual ModelEvaluatorBase::OutArgs< Scalar > createOutArgs() const =0
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getAppModel() const
Get the underlying application ModelEvaluator.
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int i) const
Get the g space.
virtual void setExplicitModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
virtual int getParameterIndex() const
Get the parameter index for explicit-only vector.
ModelEvaluator pair for implicit and explicit (IMEX) evaluations.
virtual Thyra::ModelEvaluatorBase::InArgs< Scalar > getInArgs()
Get InArgs the wrapper ModelEvalutor.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getExplicitOnlyVector(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &full) const
Extract explicit-only vector from a full solution vector.
virtual Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
virtual void setParameterIndex(int parameterIndex=-1)
Set the parameter index for explicit-only vector.
virtual Thyra::ModelEvaluatorBase::OutArgs< Scalar > getOutArgs()
Get OutArgs the wrapper ModelEvalutor.
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Get the x-solution space.
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getImplicitModel() const
virtual Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
void setup(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &explicitModel, const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &implicitModel, int numExplicitOnlyBlocks=0, int parameterIndex=-1)
Setup ME when using default constructor – for derived classes.
virtual Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
virtual void setImplicitModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
virtual void setAppModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &me)
Set the underlying application ModelEvaluator.
virtual Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getIMEXVector(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &full) const
Extract IMEX vector from a full solution vector.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getExplicitModel() const
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
virtual Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int i) const
Get the p space.
virtual void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &in, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &out) const
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.