10 #ifndef DUMMY_TEST_MODEL_EVALUATOR_DEF_HPP
11 #define DUMMY_TEST_MODEL_EVALUATOR_DEF_HPP
14 #include "Thyra_DummyTestModelEvaluator_decl.hpp"
15 #include "Thyra_SimpleDenseLinearOp.hpp"
16 #include "Thyra_DefaultSpmdVectorSpace.hpp"
17 #include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory.hpp"
18 #include "Thyra_DefaultPreconditioner.hpp"
19 #include "Thyra_DetachedMultiVectorView.hpp"
20 #include "Thyra_DetachedVectorView.hpp"
21 #include "Thyra_MultiVectorStdOps.hpp"
22 #include "Thyra_VectorStdOps.hpp"
30 template<
class Scalar>
32 dummyTestModelEvaluator(
36 const bool supports_x_dot,
37 const bool supports_x_dot_dot,
38 const bool supports_extended_inargs,
39 const bool supports_extended_outargs,
40 const bool supports_derivatives
50 template<
class Scalar>
55 const bool supports_x_dot,
56 const bool supports_x_dot_dot,
57 const bool supports_extended_inargs,
58 const bool supports_extended_outargs,
59 const bool supports_derivatives
66 x_space_ = defaultSpmdVectorSpace<Scalar>(x_size);
68 p_space_.resize(p_sizes.
size());
70 p_space_[l] = defaultSpmdVectorSpace<Scalar>(p_sizes[l]);
75 g_space_.resize(g_sizes.
size());
77 g_space_[j] = defaultSpmdVectorSpace<Scalar>(g_sizes[j]);
80 W_factory_ = defaultSerialDenseLinearOpWithSolveFactory<Scalar>();
82 MEB::InArgsSetup<Scalar> inArgs;
83 inArgs.setModelEvalDescription(this->description());
84 inArgs.set_Np_Ng(p_space_.size(),g_sizes.
size());
85 inArgs.setSupports(MEB::IN_ARG_x);
87 inArgs.setSupports(MEB::IN_ARG_x_dot);
88 if (supports_x_dot_dot)
89 inArgs.setSupports(MEB::IN_ARG_x_dot_dot);
90 inArgs.setSupports(MEB::IN_ARG_step_size);
91 inArgs.setSupports(MEB::IN_ARG_stage_number);
92 inArgs.template setSupports<Thyra::MockExtendedInArgs<Scalar> >(
true);
94 if (!supports_extended_inargs)
95 inArgs.template setSupports<Thyra::MockExtendedInArgs<Scalar> >(
false);
96 prototypeInArgs_ = inArgs;
98 MEB::OutArgsSetup<Scalar> outArgs;
99 outArgs.setModelEvalDescription(this->description());
100 outArgs.set_Np_Ng(p_space_.size(), g_space_.size());
101 outArgs.setSupports(MEB::OUT_ARG_f);
102 outArgs.setSupports(MEB::OUT_ARG_W_op);
103 outArgs.setSupports(MEB::OUT_ARG_W_prec);
104 outArgs.template setSupports<Thyra::MockExtendedOutArgs<Scalar> >(
true);
106 if (!supports_extended_outargs)
107 outArgs.template setSupports<Thyra::MockExtendedOutArgs<Scalar> >(
false);
108 if (supports_derivatives)
110 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
111 outArgs.setHessianSupports(
true);
114 MEB::DerivativeSupport derivativeSupport(MEB::DERIV_MV_BY_COL);
116 for (
int j=0; j<g_space_.size(); ++j)
117 outArgs.setSupports(MEB::OUT_ARG_DgDx,j,derivativeSupport);
119 prototypeOutArgs_ = outArgs;
121 nominalValues_ = inArgs;
123 V_S(x0.
ptr(), ST::zero());
124 nominalValues_.set_x(x0);
132 template<
class Scalar>
140 template<
class Scalar>
148 template<
class Scalar>
152 return Teuchos::null;
156 template<
class Scalar>
164 template<
class Scalar>
172 template<
class Scalar>
180 template<
class Scalar>
184 return nominalValues_;
188 template<
class Scalar>
196 template<
class Scalar>
204 template<
class Scalar>
208 return createNonconstSimpleDenseLinearOp<Scalar>(
209 createMembers<Scalar>(f_space_, x_space_->dim())
214 template<
class Scalar>
218 return nonconstUnspecifiedPrec<Scalar>(
219 createNonconstSimpleDenseLinearOp<Scalar>(
220 createMembers<Scalar>(f_space_, x_space_->dim())
226 template<
class Scalar>
234 template<
class Scalar>
238 return prototypeInArgs_;
242 template<
class Scalar>
251 template<
class Scalar>
258 MEB::InArgsSetup<Scalar> inArgs(prototypeInArgs_);
259 inArgs.set_Np(new_size);
260 prototypeInArgs_ = inArgs;
263 MEB::OutArgsSetup<Scalar> outArgs(prototypeOutArgs_);
264 outArgs.set_Np_Ng(new_size,g_space_.size());
265 prototypeOutArgs_ = outArgs;
270 template<
class Scalar>
272 DummyTestModelEvaluator<Scalar>::
273 change_p_size_correctly(
const Ordinal new_size)
275 this->change_p_size_incorrectly(new_size);
276 this->resetDefaultBase();
282 template<
class Scalar>
283 ModelEvaluatorBase::OutArgs<Scalar>
284 DummyTestModelEvaluator<Scalar>::createOutArgsImpl()
const
286 return prototypeOutArgs_;
290 template<
class Scalar>
291 void DummyTestModelEvaluator<Scalar>::evalModelImpl(
292 const ModelEvaluatorBase::InArgs<Scalar> &,
293 const ModelEvaluatorBase::OutArgs<Scalar> &
309 #define DUMMY_TEST_MODEL_EVALUATOR_INSTANT(SCALAR) \
311 template class DummyTestModelEvaluator<SCALAR >; \
313 template Teuchos::RCP<DummyTestModelEvaluator<SCALAR > > \
314 dummyTestModelEvaluator( \
315 const Ordinal x_size, \
316 const ArrayView<const Ordinal> &p_sizes, \
317 const ArrayView<const Ordinal> &g_sizes, \
318 const bool supports_x_dot, \
319 const bool supports_x_dot_dot, \
320 const bool supports_extended_inargs, \
321 const bool supports_extended_outargs, \
322 const bool supports_derivatives \
326 #endif // DUMMY_TEST_MODEL_EVALUATOR_DEF_HPP
ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
void reportFinalPoint(const ModelEvaluatorBase::InArgs< Scalar > &finalPoint, const bool wasSolved)
RCP< const VectorSpaceBase< Scalar > > get_p_space(int l) const
RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Test helper ModelEvaluator.
RCP< LinearOpBase< Scalar > > create_W_op() const
ModelEvaluatorBase::InArgs< Scalar > getUpperBounds() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
RCP< const VectorSpaceBase< Scalar > > get_x_space() const
Base subclass for ModelEvaluator that defines some basic types.
Teuchos::ArrayView< const std::string > get_g_names(int j) const
RCP< const VectorSpaceBase< Scalar > > get_f_space() const
ModelEvaluatorBase::InArgs< Scalar > getLowerBounds() const
RCP< const VectorSpaceBase< Scalar > > get_g_space(int j) const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
DummyTestModelEvaluator(const Ordinal x_size, const ArrayView< const Ordinal > &p_sizes, const ArrayView< const Ordinal > &g_sizes, const bool supports_x_dot=false, const bool supports_x_dot_dot=false, const bool supports_extended_inargs=true, const bool supports_extended_outargs=true, const bool supports_derivatives=false)
RCP< const LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
RCP< PreconditionerBase< Scalar > > create_W_prec() const
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...