Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SteadyQuadraticModel_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_TEST_STEADY_QUADRATIC_MODEL_DECL_HPP
10 #define TEMPUS_TEST_STEADY_QUADRATIC_MODEL_DECL_HPP
11 
12 #include "Thyra_ModelEvaluator.hpp" // Interface
13 #include "Thyra_StateFuncModelEvaluatorBase.hpp" // Implementation
14 
15 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
16 #include "Teuchos_ParameterList.hpp"
17 
18 namespace Tempus_Test {
19 
20 /** \brief Simple quadratic equation with a stable steady-state.
21  * This is a simple differential equation
22  * \f[
23  * \mathbf{\dot{x}}=\mathbf{x}^2 - b^2
24  * \f]
25  * which has steady state solutions \f$\mathbf{x} = \pm b\f$. The solution
26  * \f$\mathbf{x} = b\f$ is stable if \f$b < 0\f$ and the solution
27  * \f$\mathbf{x} = -b\f$ is stable if \f$b > 0\f$. This model is used to
28  * test pseudo-transient sensitivity analysis methods.
29  */
30 template<class Scalar>
32  : public Thyra::StateFuncModelEvaluatorBase<Scalar>,
33  public Teuchos::ParameterListAcceptorDefaultBase
34 {
35  public:
36 
37  // Constructor
38  SteadyQuadraticModel(Teuchos::RCP<Teuchos::ParameterList> pList = Teuchos::null);
39 
40  // Exact solution
41  Scalar getSteadyStateSolution() const;
42 
43  // Exact sensitivity solution
44  Scalar getSteadyStateSolutionSensitivity() const;
45 
46  /** \name Public functions overridden from ModelEvaluator. */
47  //@{
48 
49  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_x_space() const;
50  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_f_space() const;
51  Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
52  Teuchos::RCP<Thyra::LinearOpWithSolveBase<Scalar> > create_W() const;
53  Teuchos::RCP<Thyra::LinearOpBase<Scalar> > create_W_op() const;
54  Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const;
55  Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const;
56 
57  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_p_space(int l) const;
58  Teuchos::RCP<const Teuchos::Array<std::string> > get_p_names(int l) const;
59  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_g_space(int j) const;
60 
61  //@}
62 
63  /** \name Public functions overridden from ParameterListAcceptor. */
64  //@{
65  void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const& paramList);
66  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
67  //@}
68 
69 private:
70 
71  void setupInOutArgs_() const;
72 
73  /** \name Private functions overridden from ModelEvaluatorDefaultBase. */
74  //@{
75  Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const;
76  void evalModelImpl(
77  const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs_bar,
78  const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs_bar
79  ) const;
80  //@}
81 
82 private:
83  int dim_; ///< Number of state unknowns (2)
84  int Np_; ///< Number of parameter vectors (1)
85  int np_; ///< Number of parameters in this vector (2)
86  int Ng_; ///< Number of observation functions (1)
87  int ng_; ///< Number of elements in this observation function (1)
88  bool useDfDpAsTangent_; ///< Treat DfDp OutArg as tangent (df/dx*dx/dp+df/dp)
89  mutable bool isInitialized_;
90  mutable Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs_;
91  mutable Thyra::ModelEvaluatorBase::OutArgs<Scalar> outArgs_;
92  mutable Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_;
93  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > x_space_;
94  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > f_space_;
95  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > p_space_;
96  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > g_space_;
97  Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > DxDp_space_;
98 
99  // Parameters for the model
100  Scalar b_; ///< Model parameter
101 };
102 
103 
104 } // namespace Tempus_Test
105 #endif // TEMPUS_TEST_STEADY_QUADRATIC_MODEL_DECL_HPP
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
int ng_
Number of elements in this observation function (1)
int Ng_
Number of observation functions (1)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > x_space_
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > g_space_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int l) const
int np_
Number of parameters in this vector (2)
Thyra::ModelEvaluatorBase::InArgs< Scalar > nominalValues_
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 > > get_g_space(int j) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > p_space_
int Np_
Number of parameter vectors (1)
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > f_space_
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > create_W() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
Simple quadratic equation with a stable steady-state. This is a simple differential equation which h...
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > DxDp_space_
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
SteadyQuadraticModel(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
int dim_
Number of state unknowns (2)