10 #ifndef TEMPUS_TEST_DAHLQUIST_TEST_MODEL_IMPL_HPP
11 #define TEMPUS_TEST_DAHLQUIST_TEST_MODEL_IMPL_HPP
13 #include "Thyra_DefaultSpmdVectorSpace.hpp"
14 #include "Thyra_DetachedVectorView.hpp"
15 #include "Thyra_DetachedMultiVectorView.hpp"
16 #include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory.hpp"
17 #include "Thyra_DefaultMultiVectorLinearOpWithSolve.hpp"
18 #include "Thyra_DefaultLinearOpSource.hpp"
19 #include "Thyra_VectorStdOps.hpp"
20 #include "Thyra_MultiVectorStdOps.hpp"
21 #include "Thyra_DefaultMultiVectorProductVector.hpp"
25 namespace Tempus_Test {
27 template <
class Scalar>
30 constructDahlquistTestModel(-1.0,
false);
33 template <
class Scalar>
36 constructDahlquistTestModel(lambda, includeXDot);
39 template <
class Scalar>
44 includeXDot_ = includeXDot;
45 isInitialized_ =
false;
47 xDotIC_ = Scalar(lambda);
54 acceptModelParams_ =
false;
57 x_space_ = Thyra::defaultSpmdVectorSpace<Scalar>(dim_);
58 f_space_ = Thyra::defaultSpmdVectorSpace<Scalar>(dim_);
64 MEB::InArgsSetup<Scalar> inArgs;
65 inArgs.setModelEvalDescription(this->description());
66 inArgs.setSupports(MEB::IN_ARG_t);
67 inArgs.setSupports(MEB::IN_ARG_x);
68 inArgs.setSupports(MEB::IN_ARG_x_dot);
70 inArgs.setSupports(MEB::IN_ARG_beta);
71 inArgs.setSupports(MEB::IN_ARG_alpha);
72 if (acceptModelParams_) inArgs.set_Np(Np_);
79 MEB::OutArgsSetup<Scalar> outArgs;
80 outArgs.setModelEvalDescription(this->description());
81 outArgs.setSupports(MEB::OUT_ARG_f);
83 outArgs.setSupports(MEB::OUT_ARG_W_op);
84 if (acceptModelParams_) {
85 outArgs.set_Np_Ng(Np_, Ng_);
86 outArgs.setSupports(MEB::OUT_ARG_DfDp, 0, MEB::DERIV_MV_JACOBIAN_FORM);
87 outArgs.setSupports(MEB::OUT_ARG_DgDp, 0, 0, MEB::DERIV_MV_JACOBIAN_FORM);
88 outArgs.setSupports(MEB::OUT_ARG_DgDx, 0, MEB::DERIV_MV_GRADIENT_FORM);
94 nominalValues_ = inArgs_;
96 nominalValues_.set_t(Scalar(0.0));
102 nominalValues_.set_x(x_ic);
109 x_dot_ic_view[0] = xDotIC_;
111 nominalValues_.set_x_dot(x_dot_ic);
114 isInitialized_ =
true;
117 template <
class Scalar>
123 inArgs.
set_t(exact_t);
129 exact_x_view[0] = exp(lambda_ * exact_t);
131 inArgs.
set_x(exact_x);
136 createMember(x_space_);
139 exact_x_dot_view[0] = lambda_ * exp(lambda_ * exact_t);
147 template <
class Scalar>
154 template <
class Scalar>
161 template <
class Scalar>
165 return nominalValues_;
168 template <
class Scalar>
175 template <
class Scalar>
182 template <
class Scalar>
188 using Teuchos::rcp_dynamic_cast;
192 "Error, setupInOutArgs_ must be called first!\n");
203 f_out_view[0] = lambda_ * x_in_view[0];
207 true, std::logic_error,
208 "Error -- Dahlquist Test Model requires f_out!\n");
216 matrix_view(0, 0) = lambda_;
222 x_dot_in = inArgs.
get_x_dot().assert_not_null();
229 f_out_view[0] = x_dot_in_view[0] - lambda_ * x_in_view[0];
237 matrix_view(0, 0) = alpha - beta * lambda_;
243 template <
class Scalar>
249 this->get_W_factory();
259 vec_view[0] = lambda_;
261 V_V(multivec->col(0).
ptr(), *vec);
265 Thyra::linearOpWithSolve<Scalar>(*W_factory, matrix);
269 template <
class Scalar>
275 Thyra::createMembers(x_space_, dim_);
279 template <
class Scalar>
284 Thyra::defaultSerialDenseLinearOpWithSolveFactory<Scalar>();
288 template <
class Scalar>
292 if (!acceptModelParams_) {
293 return Teuchos::null;
298 else if (l == 1 || l == 2)
300 return Teuchos::null;
303 template <
class Scalar>
307 if (!acceptModelParams_) {
308 return Teuchos::null;
314 p_strings->push_back(
"Model Coefficient: a");
319 p_strings->push_back(
"DxDp");
321 p_strings->push_back(
"Dx_dotDp");
325 template <
class Scalar>
334 #endif // TEMPUS_TEST_DAHLQUIST_TEST_MODEL_IMPL_HPP
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs_bar, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs_bar) const
bool is_null(const boost::shared_ptr< T > &p)
RCP< const VectorBase< Scalar > > get_x_dot() const
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Evaluation< VectorBase< Scalar > > get_f() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
#define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(index, lower_inclusive, upper_exclusive)
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
void set_x(const RCP< const VectorBase< Scalar > > &x)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Thyra::ModelEvaluatorBase::InArgs< Scalar > getExactSolution(double t) const
Exact solution.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
void set_x_dot(const RCP< const VectorBase< Scalar > > &x_dot)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int j) const
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int l) const
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > create_W() const
void constructDahlquistTestModel(Scalar lambda, bool includeXDot)
RCP< LinearOpBase< Scalar > > get_W_op() const
RCP< const VectorBase< Scalar > > get_x() const