45 #ifndef DUMMY_TEST_MODEL_EVALUATOR_DEF_HPP
46 #define DUMMY_TEST_MODEL_EVALUATOR_DEF_HPP
49 #include "Thyra_DummyTestModelEvaluator_decl.hpp"
50 #include "Thyra_SimpleDenseLinearOp.hpp"
51 #include "Thyra_DefaultSpmdVectorSpace.hpp"
52 #include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory.hpp"
53 #include "Thyra_DefaultPreconditioner.hpp"
54 #include "Thyra_DetachedMultiVectorView.hpp"
55 #include "Thyra_DetachedVectorView.hpp"
56 #include "Thyra_MultiVectorStdOps.hpp"
57 #include "Thyra_VectorStdOps.hpp"
65 template<
class Scalar>
67 dummyTestModelEvaluator(
71 const bool supports_x_dot,
72 const bool supports_x_dot_dot,
73 const bool supports_extended_inargs,
74 const bool supports_extended_outargs
84 template<
class Scalar>
89 const bool supports_x_dot,
90 const bool supports_x_dot_dot,
91 const bool supports_extended_inargs,
92 const bool supports_extended_outargs
99 x_space_ = defaultSpmdVectorSpace<Scalar>(x_size);
101 p_space_.resize(p_sizes.
size());
103 p_space_[l] = defaultSpmdVectorSpace<Scalar>(p_sizes[l]);
108 g_space_.resize(g_sizes.
size());
110 g_space_[j] = defaultSpmdVectorSpace<Scalar>(g_sizes[j]);
113 W_factory_ = defaultSerialDenseLinearOpWithSolveFactory<Scalar>();
115 MEB::InArgsSetup<Scalar> inArgs;
116 inArgs.setModelEvalDescription(this->description());
117 inArgs.set_Np(p_space_.size());
118 inArgs.setSupports(MEB::IN_ARG_x);
120 inArgs.setSupports(MEB::IN_ARG_x_dot);
121 if (supports_x_dot_dot)
122 inArgs.setSupports(MEB::IN_ARG_x_dot_dot);
123 inArgs.setSupports(MEB::IN_ARG_step_size);
124 inArgs.setSupports(MEB::IN_ARG_stage_number);
125 inArgs.template setSupports<Thyra::MockExtendedInArgs<Scalar> >(
true);
127 if (!supports_extended_inargs)
128 inArgs.template setSupports<Thyra::MockExtendedInArgs<Scalar> >(
false);
129 prototypeInArgs_ = inArgs;
131 MEB::OutArgsSetup<Scalar> outArgs;
132 outArgs.setModelEvalDescription(this->description());
133 outArgs.set_Np_Ng(p_space_.size(), g_space_.size());
134 outArgs.setSupports(MEB::OUT_ARG_f);
135 outArgs.setSupports(MEB::OUT_ARG_W_op);
136 outArgs.setSupports(MEB::OUT_ARG_W_prec);
137 outArgs.template setSupports<Thyra::MockExtendedOutArgs<Scalar> >(
true);
139 if (!supports_extended_outargs)
140 outArgs.template setSupports<Thyra::MockExtendedOutArgs<Scalar> >(
false);
141 prototypeOutArgs_ = outArgs;
143 nominalValues_ = inArgs;
145 V_S(x0.
ptr(), ST::zero());
146 nominalValues_.set_x(x0);
154 template<
class Scalar>
162 template<
class Scalar>
170 template<
class Scalar>
174 return Teuchos::null;
178 template<
class Scalar>
186 template<
class Scalar>
194 template<
class Scalar>
202 template<
class Scalar>
206 return nominalValues_;
210 template<
class Scalar>
218 template<
class Scalar>
226 template<
class Scalar>
230 return createNonconstSimpleDenseLinearOp<Scalar>(
231 createMembers<Scalar>(f_space_, x_space_->dim())
236 template<
class Scalar>
240 return nonconstUnspecifiedPrec<Scalar>(
241 createNonconstSimpleDenseLinearOp<Scalar>(
242 createMembers<Scalar>(f_space_, x_space_->dim())
248 template<
class Scalar>
256 template<
class Scalar>
260 return prototypeInArgs_;
264 template<
class Scalar>
273 template<
class Scalar>
280 MEB::InArgsSetup<Scalar> inArgs(prototypeInArgs_);
281 inArgs.set_Np(new_size);
282 prototypeInArgs_ = inArgs;
285 MEB::OutArgsSetup<Scalar> outArgs(prototypeOutArgs_);
286 outArgs.set_Np_Ng(new_size,g_space_.size());
287 prototypeOutArgs_ = outArgs;
292 template<
class Scalar>
294 DummyTestModelEvaluator<Scalar>::
295 change_p_size_correctly(
const Ordinal new_size)
297 this->change_p_size_incorrectly(new_size);
298 this->resetDefaultBase();
304 template<
class Scalar>
305 ModelEvaluatorBase::OutArgs<Scalar>
306 DummyTestModelEvaluator<Scalar>::createOutArgsImpl()
const
308 return prototypeOutArgs_;
312 template<
class Scalar>
313 void DummyTestModelEvaluator<Scalar>::evalModelImpl(
314 const ModelEvaluatorBase::InArgs<Scalar> &,
315 const ModelEvaluatorBase::OutArgs<Scalar> &
331 #define DUMMY_TEST_MODEL_EVALUATOR_INSTANT(SCALAR) \
333 template class DummyTestModelEvaluator<SCALAR >; \
335 template Teuchos::RCP<DummyTestModelEvaluator<SCALAR > > \
336 dummyTestModelEvaluator( \
337 const Ordinal x_size, \
338 const ArrayView<const Ordinal> &p_sizes, \
339 const ArrayView<const Ordinal> &g_sizes, \
340 const bool supports_x_dot, \
341 const bool supports_x_dot_dot, \
342 const bool supports_extended_inargs, \
343 const bool supports_extended_outargs \
347 #endif // DUMMY_TEST_MODEL_EVALUATOR_DEF_HPP
ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
void reportFinalPoint(const ModelEvaluatorBase::InArgs< Scalar > &finalPoint, const bool wasSolved)
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)
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)
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...