Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_WrapperModelEvaluatorSecondOrder_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_WrapperModelEvaluatorSecondOrder_decl_hpp
11 #define Tempus_WrapperModelEvaluatorSecondOrder_decl_hpp
12 
13 #include <functional>
14 #include "Tempus_config.hpp"
16 #include "Thyra_VectorBase.hpp"
17 
18 //#define VERBOSE_DEBUG_OUTPUT
19 
20 namespace Tempus {
21 
32 template <typename Scalar>
34  : public Tempus::WrapperModelEvaluator<Scalar> {
35  public:
37 
40  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > &appModel,
41  const std::string schemeName)
42  : appModel_(appModel), out_(Teuchos::VerboseObjectBase::getDefaultOStream())
43  {
44 #ifdef VERBOSE_DEBUG_OUTPUT
45  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
46  *out_ << " schemeName = " << schemeName << "\n";
47 #endif
48  if (schemeName == "Newmark Implicit a-Form" || schemeName == "HHT-Alpha") {
50  }
51  else if (schemeName == "Newmark Implicit d-Form") {
53  }
54  else {
56  true, std::logic_error,
57  "Error: WrapperModelEvaluatorSecondOrder called with unsopported "
58  << "schemeName = " << schemeName
59  << "! Supported schemeNames are: 'Newmark Implicit a-Form' and "
60  << "'HHT-Alpha'.\n");
61  }
62  }
63 
66  {
67 #ifdef VERBOSE_DEBUG_OUTPUT
68  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
69 #endif
70  appModel_ = me;
71  }
72 
75  {
76 #ifdef VERBOSE_DEBUG_OUTPUT
77  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
78 #endif
79  return appModel_;
80  }
81 
84  Teuchos::RCP<const Vector> d_pred, Scalar delta_t,
85  Scalar t, Scalar beta, Scalar gamma)
86  {
87 #ifdef VERBOSE_DEBUG_OUTPUT
88  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
89 #endif
90  v_pred_ = v_pred;
91  d_pred_ = d_pred;
92  delta_t_ = delta_t;
93  t_ = t;
94  beta_ = beta;
95  gamma_ = gamma;
96  }
97 
99 
101  {
102 #ifdef VERBOSE_DEBUG_OUTPUT
103  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
104 #endif
105  return appModel_->create_W_op();
106  }
107 
110  {
111 #ifdef VERBOSE_DEBUG_OUTPUT
112  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
113 #endif
114  return appModel_->get_W_factory();
115  }
116 
118  {
119 #ifdef VERBOSE_DEBUG_OUTPUT
120  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
121 #endif
122  return appModel_->get_f_space();
123  }
124 
126  {
127 #ifdef VERBOSE_DEBUG_OUTPUT
128  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
129 #endif
130  return appModel_->get_p_space(p);
131  }
132 
134  {
135 #ifdef VERBOSE_DEBUG_OUTPUT
136  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
137 #endif
138  return appModel_->get_p_names(p);
139  }
140 
142  {
143 #ifdef VERBOSE_DEBUG_OUTPUT
144  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
145 #endif
146  return appModel_->get_x_space();
147  }
148 
150  {
151  return appModel_->get_g_space(i);
152  }
153 
155  {
156 #ifdef VERBOSE_DEBUG_OUTPUT
157  *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
158 #endif
159  return appModel_->getNominalValues();
160  }
161 
164  {
165  return wrapperInArgs_;
166  }
167 
170  {
171  return wrapperOutArgs_;
172  }
173 
175  virtual void setForSolve(
177  const Teuchos::RCP<Thyra::VectorBase<Scalar> > &xDot, const Scalar time,
179  const Teuchos::RCP<Thyra::VectorBase<Scalar> > &y = Teuchos::null,
180  const int index = -1 /* index and y are for IMEX_RK_Partition */)
181  {
182  }
183 
186 
187  void evalModelImpl(
189  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs) const;
191 
194 
195  private:
198 
199  private:
201  Scalar t_;
202  Scalar gamma_;
203  Scalar beta_;
204  Scalar delta_t_;
209 
213 };
214 
215 } // namespace Tempus
216 
217 #endif // Tempus_WrapperModelEvaluatorSecondOrder_hpp
virtual Thyra::ModelEvaluatorBase::OutArgs< Scalar > getOutArgs()
Get OutArgs the wrapper ModelEvalutor.
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
void initializeNewmark(Teuchos::RCP< const Vector > v_pred, Teuchos::RCP< const Vector > d_pred, Scalar delta_t, Scalar t, Scalar beta, Scalar gamma)
Set values needed in evalModelImpl.
void setAppModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &me)
Set the underlying application ModelEvaluator.
virtual 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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getAppModel() const
Get the underlying application model &#39;f&#39;.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int p) const
Get the p space.
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...
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > appModel_
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
WrapperModelEvaluatorSecondOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const std::string schemeName)
Constructor.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
A ModelEvaluator which wraps the application ModelEvaluator.
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int p) const
virtual Thyra::ModelEvaluatorBase::InArgs< Scalar > getInArgs()
Get InArgs the wrapper ModelEvalutor.
WrapperModelEvaluatorSecondOrder()
Default constructor - not allowed.
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int i) const
Get the g space.