Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SinCosModel_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_TEST_SINCOS_MODEL_DECL_HPP
11 #define TEMPUS_TEST_SINCOS_MODEL_DECL_HPP
12 
13 #include "Thyra_ModelEvaluator.hpp" // Interface
14 #include "Thyra_StateFuncModelEvaluatorBase.hpp" // Implementation
15 
16 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
18 
19 namespace Tempus_Test {
20 
108 template <class Scalar>
111  public:
112  // Constructor
113  SinCosModel(Teuchos::RCP<Teuchos::ParameterList> pList = Teuchos::null);
114 
115  // Exact solution
117 
118  // Exact sensitivity solution
120  int j, double t) const;
121 
124 
131  get_W_factory() const;
133 
137 
139 
145 
146  private:
147  void setupInOutArgs_() const;
148 
152  void evalModelImpl(
154  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs_bar) const;
156 
157  void calculateCoeffFromIC_();
158 
159  protected:
160  int dim_;
161  int Np_;
162  int np_;
163  int Ng_;
164  int ng_;
165  bool haveIC_;
168  mutable bool isInitialized_;
177 
178  // Parameters for the model: x_0(t) = a + b*sin(f*t+phi)
179  // x_1(t) = b*f*cos(f*t+phi)
180  Scalar a_;
181  Scalar f_;
182  Scalar L_;
183  Scalar phi_;
184  Scalar b_;
185  Scalar t0_ic_;
186  Scalar x0_ic_;
187  Scalar x1_ic_;
188 };
189 
191 // Teuchos::RCP<SinCosModel> sineCosineModel(
192 // Teuchos::RCP<Teuchos::ParameterList> pList_)
193 //{
194 // Teuchos::RCP<SinCosModel> model = rcp(new SinCosModel(pList_));
195 // return(model);
196 // }
197 
199 
203 template <class Scalar>
204 class SinCosModelAdjoint : public SinCosModel<Scalar> {
205  public:
206  // Constructor
208  : SinCosModel<Scalar>(pList)
209  {
210  }
211 
214 
218 
220 
221  private:
225  void evalModelImpl(
227  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs_bar) const;
229 };
230 
231 } // namespace Tempus_Test
232 #endif // TEMPUS_TEST_SINCOS_MODEL_DECL_HPP
Scalar b_
Parameter determined from the IC.
Scalar L_
Model parameter.
int Ng_
Number of observation functions (1)
int ng_
Number of elements in this observation function (1)
Thyra::ModelEvaluatorBase::InArgs< Scalar > nominalValues_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > DxDp_space_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > p_space_
Scalar f_
Model parameter.
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
bool useDfDpAsTangent_
Treat DfDp OutArg as tangent (df/dx*dx/dp+df/dp)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > f_space_
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
int dim_
Number of state unknowns (2)
int Np_
Number of parameter vectors (1)
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > create_W() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
bool haveIC_
false =&gt; no nominal values are provided (default=true)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs_
bool acceptModelParams_
Changes inArgs to require parameters.
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs_bar, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs_bar) const
Scalar t0_ic_
Time value where the initial condition is specified.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getExactSolution(double t) const
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
SinCosModel(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
int np_
Number of parameters in this vector (2)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int l) const
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > g_space_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs_bar, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs_bar) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > x_space_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int j) const
Scalar x1_ic_
Initial condition for x1.
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Scalar phi_
Parameter determined from the IC.
Thyra::ModelEvaluatorBase::InArgs< Scalar > getExactSensSolution(int j, double t) const
Scalar x0_ic_
Initial condition for x0.
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
Scalar a_
Model parameter.
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > create_W() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
SinCosModelAdjoint(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)