Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
HarmonicOscillatorModel_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_HARMONIC_OSCILLATOR_MODEL_DECL_HPP
11#define TEMPUS_TEST_HARMONIC_OSCILLATOR_MODEL_DECL_HPP
12
13#include "Thyra_ModelEvaluator.hpp" // Interface
14#include "Thyra_StateFuncModelEvaluatorBase.hpp" // Implementation
15
16#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
17#include "Teuchos_ParameterList.hpp"
18
19namespace Tempus_Test {
20
54template <class Scalar>
56 : public Thyra::StateFuncModelEvaluatorBase<Scalar>,
57 public Teuchos::ParameterListAcceptorDefaultBase {
58 public:
59 // Constructor
61 Teuchos::RCP<Teuchos::ParameterList> pList = Teuchos::null,
62 const bool use_accel_IC = false);
63
64 // Exact solution
65 Thyra::ModelEvaluatorBase::InArgs<Scalar> getExactSolution(double t) const;
66
69
70 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_x_space() const;
71 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_f_space() const;
72 Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
73 Teuchos::RCP<Thyra::LinearOpWithSolveBase<Scalar> > create_W() const;
74 Teuchos::RCP<Thyra::LinearOpBase<Scalar> > create_W_op() const;
75 Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> >
76 get_W_factory() const;
77 Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const;
78
79 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_p_space(int l) const;
80 Teuchos::RCP<const Teuchos::Array<std::string> > get_p_names(int l) const;
81 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > get_g_space(int j) const;
82
84
87 void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const &paramList);
88 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
90
91 private:
92 void setupInOutArgs_() const;
93
96 Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const;
97 void evalModelImpl(
98 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs_bar,
99 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs_bar) const;
101
102 private:
103 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > x_space_;
104 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > p_space_;
105 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > g_space_;
106 Teuchos::RCP<Thyra::VectorBase<Scalar> > x_vec_;
107 Teuchos::RCP<Thyra::VectorBase<Scalar> > x_dot_vec_;
108 Teuchos::RCP<Thyra::VectorBase<Scalar> > x_dot_dot_vec_;
109 Teuchos::RCP<Thyra::VectorBase<Scalar> > p_init_;
110 int vecLength_; // Number of state unknowns (1)
111 int numResponses_; // Number of responses (1)
112 mutable Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs_;
113 mutable Thyra::ModelEvaluatorBase::OutArgs<Scalar> outArgs_;
114 mutable Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_;
115 mutable bool isInitialized_;
116 double c_; // damping coefficient
117 double f_; // forcing coefficient
118 double k_; // coefficient multiplying x in ODE
119 double m_; // mass coefficient
120 Teuchos::RCP<Teuchos::FancyOStream> out_;
121};
122
123} // namespace Tempus_Test
124#endif // TEMPUS_TEST_HARMONIC_OSCILLATOR_MODEL_DECL_HPP
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > inArgs_
Teuchos::RCP< Thyra::VectorBase< Scalar > > p_init_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int l) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > g_space_
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Teuchos::RCP< Thyra::VectorBase< Scalar > > x_dot_vec_
Teuchos::RCP< Thyra::VectorBase< Scalar > > x_vec_
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getExactSolution(double t) const
Thyra::ModelEvaluatorBase::OutArgs< Scalar > outArgs_
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &paramList)
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > create_W() const
Teuchos::RCP< Teuchos::FancyOStream > out_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int j) const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs_bar, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs_bar) const
Teuchos::RCP< Thyra::VectorBase< Scalar > > x_dot_dot_vec_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > x_space_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > p_space_
Thyra::ModelEvaluatorBase::InArgs< Scalar > nominalValues_