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,
75 const bool supports_derivatives
85 template<
class Scalar>
90 const bool supports_x_dot,
91 const bool supports_x_dot_dot,
92 const bool supports_extended_inargs,
93 const bool supports_extended_outargs,
94 const bool supports_derivatives
101 x_space_ = defaultSpmdVectorSpace<Scalar>(x_size);
103 p_space_.resize(p_sizes.
size());
105 p_space_[l] = defaultSpmdVectorSpace<Scalar>(p_sizes[l]);
110 g_space_.resize(g_sizes.
size());
112 g_space_[j] = defaultSpmdVectorSpace<Scalar>(g_sizes[j]);
115 W_factory_ = defaultSerialDenseLinearOpWithSolveFactory<Scalar>();
117 MEB::InArgsSetup<Scalar> inArgs;
118 inArgs.setModelEvalDescription(this->description());
119 inArgs.set_Np_Ng(p_space_.size(),g_sizes.
size());
120 inArgs.setSupports(MEB::IN_ARG_x);
122 inArgs.setSupports(MEB::IN_ARG_x_dot);
123 if (supports_x_dot_dot)
124 inArgs.setSupports(MEB::IN_ARG_x_dot_dot);
125 inArgs.setSupports(MEB::IN_ARG_step_size);
126 inArgs.setSupports(MEB::IN_ARG_stage_number);
127 inArgs.template setSupports<Thyra::MockExtendedInArgs<Scalar> >(
true);
129 if (!supports_extended_inargs)
130 inArgs.template setSupports<Thyra::MockExtendedInArgs<Scalar> >(
false);
131 prototypeInArgs_ = inArgs;
133 MEB::OutArgsSetup<Scalar> outArgs;
134 outArgs.setModelEvalDescription(this->description());
135 outArgs.set_Np_Ng(p_space_.size(), g_space_.size());
136 outArgs.setSupports(MEB::OUT_ARG_f);
137 outArgs.setSupports(MEB::OUT_ARG_W_op);
138 outArgs.setSupports(MEB::OUT_ARG_W_prec);
139 outArgs.template setSupports<Thyra::MockExtendedOutArgs<Scalar> >(
true);
141 if (!supports_extended_outargs)
142 outArgs.template setSupports<Thyra::MockExtendedOutArgs<Scalar> >(
false);
143 if (supports_derivatives)
145 outArgs.setHessianSupports(
true);
147 MEB::DerivativeSupport derivativeSupport(MEB::DERIV_MV_BY_COL);
149 for (
int j=0; j<g_space_.size(); ++j)
150 outArgs.setSupports(MEB::OUT_ARG_DgDx,j,derivativeSupport);
152 prototypeOutArgs_ = outArgs;
154 nominalValues_ = inArgs;
156 V_S(x0.
ptr(), ST::zero());
157 nominalValues_.set_x(x0);
165 template<
class Scalar>
173 template<
class Scalar>
181 template<
class Scalar>
185 return Teuchos::null;
189 template<
class Scalar>
197 template<
class Scalar>
205 template<
class Scalar>
213 template<
class Scalar>
217 return nominalValues_;
221 template<
class Scalar>
229 template<
class Scalar>
237 template<
class Scalar>
241 return createNonconstSimpleDenseLinearOp<Scalar>(
242 createMembers<Scalar>(f_space_, x_space_->dim())
247 template<
class Scalar>
251 return nonconstUnspecifiedPrec<Scalar>(
252 createNonconstSimpleDenseLinearOp<Scalar>(
253 createMembers<Scalar>(f_space_, x_space_->dim())
259 template<
class Scalar>
267 template<
class Scalar>
271 return prototypeInArgs_;
275 template<
class Scalar>
284 template<
class Scalar>
291 MEB::InArgsSetup<Scalar> inArgs(prototypeInArgs_);
292 inArgs.set_Np(new_size);
293 prototypeInArgs_ = inArgs;
296 MEB::OutArgsSetup<Scalar> outArgs(prototypeOutArgs_);
297 outArgs.set_Np_Ng(new_size,g_space_.size());
298 prototypeOutArgs_ = outArgs;
303 template<
class Scalar>
305 DummyTestModelEvaluator<Scalar>::
306 change_p_size_correctly(
const Ordinal new_size)
308 this->change_p_size_incorrectly(new_size);
309 this->resetDefaultBase();
315 template<
class Scalar>
316 ModelEvaluatorBase::OutArgs<Scalar>
317 DummyTestModelEvaluator<Scalar>::createOutArgsImpl()
const
319 return prototypeOutArgs_;
323 template<
class Scalar>
324 void DummyTestModelEvaluator<Scalar>::evalModelImpl(
325 const ModelEvaluatorBase::InArgs<Scalar> &,
326 const ModelEvaluatorBase::OutArgs<Scalar> &
342 #define DUMMY_TEST_MODEL_EVALUATOR_INSTANT(SCALAR) \
344 template class DummyTestModelEvaluator<SCALAR >; \
346 template Teuchos::RCP<DummyTestModelEvaluator<SCALAR > > \
347 dummyTestModelEvaluator( \
348 const Ordinal x_size, \
349 const ArrayView<const Ordinal> &p_sizes, \
350 const ArrayView<const Ordinal> &g_sizes, \
351 const bool supports_x_dot, \
352 const bool supports_x_dot_dot, \
353 const bool supports_extended_inargs, \
354 const bool supports_extended_outargs, \
355 const bool supports_derivatives \
359 #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...