42 #ifndef THYRA_MODEL_EVALUATOR_BASE_DEF_HPP 43 #define THYRA_MODEL_EVALUATOR_BASE_DEF_HPP 46 #include "Thyra_ModelEvaluatorBase_decl.hpp" 47 #include "Thyra_MultiVectorBase.hpp" 48 #include "Thyra_VectorBase.hpp" 49 #include "Thyra_MultiVectorStdOps.hpp" 50 #include "Thyra_VectorStdOps.hpp" 56 namespace ModelEvaluatorHelperPack {
59 template<
class Scalar>
61 RCP<const Thyra::VectorBase<Scalar> >
68 return vec->clone_v();
73 RCP<const Stokhos::ProductEpetraVector >
75 const RCP<const Stokhos::ProductEpetraVector > &vec,
81 printf(
"Warning: clone_v not implemented for ProductEpetraVector: %s %d\n",__FILE__,__LINE__);
95 template<
class Scalar>
97 :modelEvalDescription_(
"WARNING! THIS INARGS OBJECT IS UNINITALIZED!")
99 typedef Teuchos::ScalarTraits<Scalar> ST;
100 typedef Teuchos::ScalarTraits<typename ST::magnitudeType> SMT;
101 std::fill_n(&supports_[0],NUM_E_IN_ARGS_MEMBERS,
false);
105 step_size_ = ST::zero();
106 stage_number_ = ST::one();
110 template<
class Scalar>
112 {
return p_.size(); }
114 template<
class Scalar>
117 TEUCHOS_TEST_FOR_EXCEPTION(
118 int(arg)>=NUM_E_IN_ARGS_MEMBERS ||
int(arg) < 0,std::logic_error
119 ,
"model = \'"<<modelEvalDescription_
120 <<
"\': Error, arg="<<
toString(arg)<<
" is invalid!" 122 return supports_[arg];
125 template<
class Scalar>
129 return supports_p_mp_[l];
132 template<
class Scalar>
136 { assert_supports(IN_ARG_x_dot); x_dot_ = x_dot; }
139 template<
class Scalar>
140 RCP<const VectorBase<Scalar> >
142 { assert_supports(IN_ARG_x_dot);
return x_dot_; }
145 template<
class Scalar>
149 { assert_supports(IN_ARG_x); x_ = x; }
152 template<
class Scalar>
153 RCP<const VectorBase<Scalar> >
155 { assert_supports(IN_ARG_x);
return x_; }
158 template<
class Scalar>
160 const RCP<const Stokhos::ProductEpetraVector > &x_dot_mp
162 { assert_supports(IN_ARG_x_dot_mp); x_dot_mp_ = x_dot_mp; }
165 template<
class Scalar>
166 RCP<const Stokhos::ProductEpetraVector >
168 { assert_supports(IN_ARG_x_dot_mp);
return x_dot_mp_; }
171 template<
class Scalar>
173 const RCP<const Stokhos::ProductEpetraVector > &x_mp
175 { assert_supports(IN_ARG_x_mp); x_mp_ = x_mp; }
178 template<
class Scalar>
179 RCP<const Stokhos::ProductEpetraVector >
181 { assert_supports(IN_ARG_x_mp);
return x_mp_; }
184 #ifdef HAVE_THYRA_ME_POLYNOMIAL 186 template<
class Scalar>
190 { assert_supports(IN_ARG_x_dot_poly); x_dot_poly_ = x_dot_poly; }
193 template<
class Scalar>
194 RCP<const Teuchos::Polynomial< VectorBase<Scalar> > >
196 { assert_supports(IN_ARG_x_dot_poly);
return x_dot_poly_; }
199 template<
class Scalar>
200 void ModelEvaluatorBase::InArgs<Scalar>::set_x_poly(
201 const RCP<
const Teuchos::Polynomial< VectorBase<Scalar> > > &x_poly
203 { assert_supports(IN_ARG_x_poly); x_poly_ = x_poly; }
206 template<
class Scalar>
207 RCP<const Teuchos::Polynomial< VectorBase<Scalar> > >
208 ModelEvaluatorBase::InArgs<Scalar>::get_x_poly()
const 209 { assert_supports(IN_ARG_x_poly);
return x_poly_; }
212 #endif // HAVE_THYRA_ME_POLYNOMIAL 214 template<
class Scalar>
218 { assert_l(l); p_[l] = p_l; }
221 template<
class Scalar>
222 RCP<const VectorBase<Scalar> >
224 { assert_l(l);
return p_[l]; }
227 template<
class Scalar>
229 int l,
const RCP<const Stokhos::ProductEpetraVector > &p_mp_l
231 { assert_supports(IN_ARG_p_mp, l); p_mp_[l] = p_mp_l; }
233 template<
class Scalar>
234 RCP<const Stokhos::ProductEpetraVector >
236 { assert_supports(IN_ARG_p_mp, l);
return p_mp_[l]; }
239 template<
class Scalar>
241 { assert_supports(IN_ARG_t); t_ = t; }
244 template<
class Scalar>
247 { assert_supports(IN_ARG_t);
return t_; }
250 template<
class Scalar>
252 { assert_supports(IN_ARG_alpha); alpha_ = alpha; }
255 template<
class Scalar>
257 { assert_supports(IN_ARG_alpha);
return alpha_; }
260 template<
class Scalar>
262 { assert_supports(IN_ARG_beta); beta_ = beta; }
265 template<
class Scalar>
267 { assert_supports(IN_ARG_beta);
return beta_; }
269 template<
class Scalar>
271 { assert_supports(IN_ARG_step_size); step_size_ = step_size; }
273 template<
class Scalar>
275 { assert_supports(IN_ARG_step_size);
return step_size_; }
277 template<
class Scalar>
279 { assert_supports(IN_ARG_stage_number);
return stage_number_; }
282 template<
class Scalar>
284 { assert_supports(IN_ARG_stage_number); stage_number_ = stage_number; }
287 template<
class Scalar>
289 const InArgs<Scalar>& inArgs,
bool ignoreUnsupported,
bool cloneObjects
292 using ModelEvaluatorHelperPack::condCloneVec;
293 using ModelEvaluatorHelperPack::condCloneVec_mp;
295 if(supports(IN_ARG_x_dot) || !ignoreUnsupported)
296 set_x_dot(condCloneVec(inArgs.
get_x_dot(),cloneObjects));
299 if(supports(IN_ARG_x_dot_mp) || !ignoreUnsupported)
300 set_x_dot_mp(condCloneVec_mp(inArgs.
get_x_dot_mp(),cloneObjects));
303 if(supports(IN_ARG_x) || !ignoreUnsupported)
304 set_x(condCloneVec(inArgs.
get_x(),cloneObjects));
307 if(supports(IN_ARG_x_mp) || !ignoreUnsupported)
308 set_x_mp(condCloneVec_mp(inArgs.
get_x_mp(),cloneObjects));
310 #ifdef HAVE_THYRA_ME_POLYNOMIAL 311 if( inArgs.
supports(IN_ARG_x_dot_poly) && nonnull(inArgs.get_x_dot_poly()) ) {
312 if(supports(IN_ARG_x_dot_poly) || !ignoreUnsupported) {
313 TEUCHOS_TEST_FOR_EXCEPT(
314 cloneObjects &&
"Have not implemented cloning for x_dot_poly yet!" );
315 set_x_dot_poly(inArgs.get_x_dot_poly());
318 if( inArgs.
supports(IN_ARG_x_poly) && nonnull(inArgs.get_x_poly()) ) {
319 if(supports(IN_ARG_x_poly) || !ignoreUnsupported) {
320 TEUCHOS_TEST_FOR_EXCEPT(
321 cloneObjects &&
"Have not implemented cloning for x_poly yet!" );
322 set_x_poly(inArgs.get_x_poly());
325 #endif // HAVE_THYRA_ME_POLYNOMIAL 326 const int min_Np = TEUCHOS_MIN(this->Np(),inArgs.
Np());
327 for (
int l = 0; l < min_Np; ++l) {
328 if (nonnull(inArgs.
get_p(l)))
329 set_p(l,condCloneVec(inArgs.
get_p(l),cloneObjects));
331 for (
int l = 0; l < min_Np; ++l) {
332 if (inArgs.
supports(IN_ARG_p_mp,l)) {
333 if (nonnull(inArgs.get_p_mp(l)))
334 set_p_mp(l,condCloneVec_mp(inArgs.get_p_mp(l),cloneObjects));
338 if(supports(IN_ARG_t) || !ignoreUnsupported)
339 set_t(inArgs.
get_t());
341 if (inArgs.
supports(IN_ARG_alpha)) {
342 if(supports(IN_ARG_alpha) || !ignoreUnsupported)
346 if(supports(IN_ARG_beta) || !ignoreUnsupported)
349 if (inArgs.
supports(IN_ARG_step_size)) {
350 if(supports(IN_ARG_step_size) || !ignoreUnsupported)
353 if (inArgs.
supports(IN_ARG_stage_number)) {
354 if(supports(IN_ARG_stage_number) || !ignoreUnsupported)
360 template<
class Scalar>
365 for (
int inArg_i = 0; inArg_i < NUM_E_IN_ARGS_MEMBERS; ++inArg_i ) {
367 const std::string inArg_name =
toString(inArg_arg);
368 TEUCHOS_TEST_FOR_EXCEPTION(
369 supports(inArg_arg) != inArgs.
supports(inArg_arg), std::logic_error,
370 "Error, the input argument "<<inArg_name<<
" with support "<<inArgs.
supports(inArg_arg)<<
"\n" 371 "in the InArgs object for the model:\n\n" 373 "is not the same the argument "<<inArg_name<<
" with support "<<supports(inArg_arg)<<
"\n" 374 "in the InArgs object for the model:\n\n" 375 " "<<modelEvalDescription()<<
"\n\n" 376 "and these two InArgs objects are not compatible!" 379 TEUCHOS_ASSERT_EQUALITY( this->Np(), inArgs.
Np() );
383 template<
class Scalar>
386 return modelEvalDescription_;
390 template<
class Scalar>
393 typedef Teuchos::ScalarTraits<Scalar> ST;
394 std::ostringstream oss;
396 <<
"Thyra::ModelEvaluatorBase::InArgs<"<<ST::name()<<
">" 398 <<
"model="<<modelEvalDescription_
405 template<
class Scalar>
407 Teuchos::FancyOStream &out_arg,
const Teuchos::EVerbosityLevel verbLevel
411 typedef Teuchos::ScalarTraits<Scalar> ST;
412 using Teuchos::OSTab;
413 using Teuchos::describe;
414 using Teuchos::includesVerbLevel;
415 typedef RCP<const VectorBase<Scalar> > CV_ptr;
417 if(verbLevel == Teuchos::VERB_NONE)
420 RCP<Teuchos::FancyOStream>
421 out = Teuchos::rcp(&out_arg,
false);
422 const bool dump_x = includesVerbLevel(verbLevel,Teuchos::VERB_HIGH);
423 const Teuchos::EVerbosityLevel x_verbLevel =
424 dump_x?Teuchos::VERB_EXTREME:verbLevel;
425 const bool print_x_nrm = includesVerbLevel(verbLevel,Teuchos::VERB_LOW);
426 const bool dump_p = includesVerbLevel(verbLevel,Teuchos::VERB_MEDIUM);
427 const Teuchos::EVerbosityLevel p_verbLevel =
428 dump_p?Teuchos::VERB_EXTREME:verbLevel;
429 const bool print_p_nrm = includesVerbLevel(verbLevel,Teuchos::VERB_LOW);
432 *out <<
"Thyra::ModelEvaluatorBase::InArgs<"<<ST::name()<<
">:\n";
435 *out <<
"model = " << modelEvalDescription_ <<
"\n";
436 *out <<
"Np = " << Np() <<
"\n";
439 if ( this->supports(IN_ARG_x_dot) && !is_null(x_dot=get_x_dot()) ) {
440 *out <<
"x_dot = " << Teuchos::describe(*x_dot,x_verbLevel);
442 *out <<
"||x_dot|| = " <<
norm(*x_dot) << endl;
446 if ( this->supports(IN_ARG_x) && !is_null(x=get_x()) ) {
447 *out <<
"x = " << Teuchos::describe(*x,x_verbLevel);
449 *out <<
"||x|| = " <<
norm(*x) << endl;
453 for(
int l = 0; l < Np(); ++l ) {
455 if ( !is_null(p_l = this->get_p(l)) ) {
456 *out <<
"p("<<l<<
") = " << Teuchos::describe(*p_l,p_verbLevel);
458 *out <<
"||p("<<l<<
")|| = " <<
norm(*p_l) << endl;
463 if (includesVerbLevel(verbLevel,Teuchos::VERB_MEDIUM)) {
464 if (this->supports(IN_ARG_t)) {
465 *out <<
"t = " << t_ << endl;
467 if (this->supports(IN_ARG_alpha)) {
468 *out <<
"alpha = " << alpha_ << endl;
470 if (this->supports(IN_ARG_beta)) {
471 *out <<
"beta = " << beta_ << endl;
473 if (this->supports(IN_ARG_step_size)) {
474 *out <<
"step_size = " << step_size_ << endl;
476 if (this->supports(IN_ARG_stage_number)) {
477 *out <<
"stage_number = " << stage_number_ << endl;
484 template<
class Scalar>
486 const std::string &modelEvalDescription_in
489 modelEvalDescription_ = modelEvalDescription_in;
493 template<
class Scalar>
498 supports_p_mp_.resize(Np_in);
502 template<
class Scalar>
507 TEUCHOS_TEST_FOR_EXCEPTION(
508 int(arg)>=NUM_E_IN_ARGS_MEMBERS ||
int(arg) < 0,std::logic_error
509 ,
"model = \'"<<modelEvalDescription_
510 <<
"\': Error, arg="<<
toString(arg)<<
" is invalid!");
511 supports_[arg] = supports_in;
514 template<
class Scalar>
520 supports_p_mp_[l] = supports_in;
524 template<
class Scalar>
530 &inArgs.supports_[0],
531 &inArgs.supports_[0] + NUM_E_IN_ARGS_MEMBERS, &supports_[0] );
532 this->_set_Np( Np_in >= 0 ? Np_in : inArgs.
Np() );
536 template<
class Scalar>
543 this->_setSupports(IN_ARG_x_dot,
false);
544 this->_setSupports(IN_ARG_x_dot_poly,
false);
545 this->_setSupports(IN_ARG_alpha,
false);
546 this->_setSupports(IN_ARG_beta,
false);
547 this->_setSupports(IN_ARG_step_size,
false);
548 this->_setSupports(IN_ARG_stage_number,
false);
552 TEUCHOS_TEST_FOR_EXCEPTION(
553 true ,std::logic_error,
554 "Error, can not handle args other than IN_ARG_x yet!" 558 this->_setSupports(arg,
false);
562 template<
class Scalar>
567 TEUCHOS_TEST_FOR_EXCEPTION(
568 !supports_[arg], std::logic_error
569 ,
"Thyra::ModelEvaluatorBase::InArgs<" 570 << Teuchos::ScalarTraits<Scalar>::name() <<
">::assert_supports(arg): " 571 "model = \'"<<modelEvalDescription_<<
"\': Error, " 572 "The argument arg = " <<
toString(arg) <<
" is not supported!" 576 template<
class Scalar>
578 EInArgs_p_mp arg,
int l
582 TEUCHOS_TEST_FOR_EXCEPTION(
583 !supports_p_mp_[l], std::logic_error
584 ,
"Thyra::ModelEvaluatorBase::InArgs<" 585 << Teuchos::ScalarTraits<Scalar>::name() <<
">::assert_supports(IN_ARG_p_mp,1): " 586 "model = \'"<<modelEvalDescription_<<
"\': Error, " 587 "The argument p_mp(l) with index l = " << l <<
" is not supported!" 592 template<
class Scalar>
593 void ModelEvaluatorBase::InArgs<Scalar>::assert_l(
int l)
const 595 TEUCHOS_TEST_FOR_EXCEPTION(
596 !( 0 <= l && l < Np() ), std::logic_error
597 ,
"Thyra::ModelEvaluatorBase::InArgs<Scalar>::assert_l(l):\n\n" 598 " model = \'"<<modelEvalDescription_<<
"\':\n\n" 599 "Error, The parameter l = " << l <<
" is not in the range [0,"<<Np()<<
")!" 609 template<
class Scalar>
613 std::ostringstream oss;
614 oss <<
"DerivativeMultiVector{";
615 if (is_null(getMultiVector())) {
621 <<
",orientation=" <<
toString(getOrientation());
628 template<
class Scalar>
630 Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel
634 using Teuchos::describe;
635 Teuchos::OSTab tab1(out);
636 out <<
"DerivativeMultiVector\n";
637 Teuchos::OSTab tab2(out);
640 << describe(*getMultiVector(),verbLevel)
642 <<
toString(getOrientation()) << endl;
659 template<
class Scalar>
664 std::ostringstream oss;
665 oss <<
"Derivative{";
669 else if (!is_null(getLinearOp())) {
670 oss <<
"linearOp=" << getLinearOp()->
description();
673 oss <<
"derivMultiVec=" << getDerivativeMultiVector().description();
680 template<
class Scalar>
682 Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel
686 using Teuchos::describe;
687 Teuchos::OSTab tab1(out);
688 out <<
"Derivative:";
692 else if (!is_null(getLinearOp())) {
695 <<
"linearOp = " << describe(*getLinearOp(),verbLevel);
700 <<
"derivMultiVec = ";
701 getDerivativeMultiVector().describe(out,verbLevel);
711 template<
class Scalar>
713 :modelEvalDescription_(
"WARNING! THIS OUTARGS OBJECT IS UNINITALIZED!"),
715 { std::fill_n(&supports_[0],NUM_E_OUT_ARGS_MEMBERS,
false); }
718 template<
class Scalar>
720 {
return DfDp_.size(); }
723 template<
class Scalar>
725 {
return g_.size(); }
728 template<
class Scalar>
733 TEUCHOS_TEST_FOR_EXCEPTION(
734 int(arg)>=NUM_E_OUT_ARGS_MEMBERS ||
int(arg) < 0,std::logic_error
735 ,
"model = \'"<<modelEvalDescription_
736 <<
"\': Error, arg="<<
toString(arg)<<
" is invalid!" 738 return supports_[arg];
742 template<
class Scalar>
749 return supports_DfDp_[l];
753 template<
class Scalar>
760 return supports_DgDx_dot_[j];
764 template<
class Scalar>
771 return supports_DgDx_[j];
775 template<
class Scalar>
783 return supports_DgDp_[ j*Np() + l ];
787 template<
class Scalar>
794 return supports_g_mp_[j];
797 template<
class Scalar>
800 EOutArgsDfDp_mp arg,
int l
804 return supports_DfDp_mp_[l];
808 template<
class Scalar>
809 const ModelEvaluatorBase::DerivativeSupport&
810 ModelEvaluatorBase::OutArgs<Scalar>::supports(
811 EOutArgsDgDx_dot_mp arg,
int j
815 return supports_DgDx_dot_mp_[j];
819 template<
class Scalar>
820 const ModelEvaluatorBase::DerivativeSupport&
821 ModelEvaluatorBase::OutArgs<Scalar>::supports(
822 EOutArgsDgDx_mp arg,
int j
826 return supports_DgDx_mp_[j];
830 template<
class Scalar>
831 const ModelEvaluatorBase::DerivativeSupport&
832 ModelEvaluatorBase::OutArgs<Scalar>::supports(
833 EOutArgsDgDp_mp arg,
int j,
int l
838 return supports_DgDp_mp_[ j*Np() + l ];
843 template<
class Scalar>
848 assert_supports(OUT_ARG_f);
853 template<
class Scalar>
857 assert_supports(OUT_ARG_f);
862 template<
class Scalar>
872 template<
class Scalar>
881 template<
class Scalar>
883 const RCP<Stokhos::ProductEpetraVector > &f_mp
886 assert_supports(OUT_ARG_f_mp);
891 template<
class Scalar>
892 RCP<Stokhos::ProductEpetraVector >
895 assert_supports(OUT_ARG_f_mp);
900 template<
class Scalar>
902 int j,
const RCP<Stokhos::ProductEpetraVector> &g_mp_j
905 assert_supports(OUT_ARG_g_mp,j);
910 template<
class Scalar>
911 RCP<Stokhos::ProductEpetraVector>
914 assert_supports(OUT_ARG_g_mp,j);
919 template<
class Scalar>
924 assert_supports(OUT_ARG_W);
929 template<
class Scalar>
930 RCP<LinearOpWithSolveBase<Scalar> >
933 assert_supports(OUT_ARG_W);
938 template<
class Scalar>
940 const RCP<Stokhos::ProductEpetraOperator> &W_mp
943 assert_supports(OUT_ARG_W_mp);
948 template<
class Scalar>
949 RCP<Stokhos::ProductEpetraOperator>
952 assert_supports(OUT_ARG_W_mp);
957 template<
class Scalar>
962 assert_supports(OUT_ARG_W_op);
967 template<
class Scalar>
968 RCP<LinearOpBase<Scalar> >
971 assert_supports(OUT_ARG_W_op);
976 template<
class Scalar>
981 assert_supports(OUT_ARG_W_prec);
986 template<
class Scalar>
987 RCP<PreconditionerBase<Scalar> >
990 assert_supports(OUT_ARG_W_prec);
995 template<
class Scalar>
999 assert_supports(OUT_ARG_f);
1000 return W_properties_;
1004 template<
class Scalar>
1009 assert_supports(OUT_ARG_DfDp,l,DfDp_l);
1014 template<
class Scalar>
1018 assert_supports(OUT_ARG_DfDp,l);
1023 template<
class Scalar>
1027 assert_supports(OUT_ARG_DfDp,l);
1028 return DfDp_properties_[l];
1032 template<
class Scalar>
1037 assert_supports(OUT_ARG_DfDp_mp,l,DfDp_mp_l);
1038 DfDp_mp_[l] = DfDp_mp_l;
1042 template<
class Scalar>
1046 assert_supports(OUT_ARG_DfDp_mp,l);
1051 template<
class Scalar>
1052 ModelEvaluatorBase::DerivativeProperties
1053 ModelEvaluatorBase::OutArgs<Scalar>::get_DfDp_mp_properties(
int l)
const 1055 assert_supports(OUT_ARG_DfDp_mp,l);
1056 return DfDp_mp_properties_[l];
1060 template<
class Scalar>
1065 assert_supports(OUT_ARG_DgDx_dot,j,DgDx_dot_j);
1066 DgDx_dot_[j] = DgDx_dot_j;
1070 template<
class Scalar>
1074 assert_supports(OUT_ARG_DgDx_dot,j);
1075 return DgDx_dot_[j];
1079 template<
class Scalar>
1083 assert_supports(OUT_ARG_DgDx_dot,j);
1084 return DgDx_dot_properties_[j];
1088 template<
class Scalar>
1093 assert_supports(OUT_ARG_DgDx_dot_mp,j,DgDx_dot_mp_j);
1094 DgDx_dot_mp_[j] = DgDx_dot_mp_j;
1098 template<
class Scalar>
1102 assert_supports(OUT_ARG_DgDx_dot_mp,j);
1103 return DgDx_dot_mp_[j];
1107 template<
class Scalar>
1108 ModelEvaluatorBase::DerivativeProperties
1109 ModelEvaluatorBase::OutArgs<Scalar>::get_DgDx_dot_mp_properties(
int j)
const 1111 assert_supports(OUT_ARG_DgDx_dot_mp,j);
1112 return DgDx_dot_mp_properties_[j];
1116 template<
class Scalar>
1121 assert_supports(OUT_ARG_DgDx,j,DgDx_j);
1126 template<
class Scalar>
1130 assert_supports(OUT_ARG_DgDx,j);
1135 template<
class Scalar>
1139 assert_supports(OUT_ARG_DgDx,j);
1140 return DgDx_properties_[j];
1144 template<
class Scalar>
1149 assert_supports(OUT_ARG_DgDx_mp,j,DgDx_mp_j);
1150 DgDx_mp_[j] = DgDx_mp_j;
1154 template<
class Scalar>
1158 assert_supports(OUT_ARG_DgDx_mp,j);
1163 template<
class Scalar>
1164 ModelEvaluatorBase::DerivativeProperties
1165 ModelEvaluatorBase::OutArgs<Scalar>::get_DgDx_mp_properties(
int j)
const 1167 assert_supports(OUT_ARG_DgDx_mp,j);
1168 return DgDx_mp_properties_[j];
1172 template<
class Scalar>
1177 assert_supports(OUT_ARG_DgDp,j,l,DgDp_j_l);
1178 DgDp_[ j*Np() + l ] = DgDp_j_l;
1182 template<
class Scalar>
1186 assert_supports(OUT_ARG_DgDp,j,l);
1187 return DgDp_[ j*Np() + l ];
1191 template<
class Scalar>
1195 assert_supports(OUT_ARG_DgDp,j,l);
1196 return DgDp_properties_[ j*Np() + l ];
1200 template<
class Scalar>
1205 assert_supports(OUT_ARG_DgDp_mp,j,l,DgDp_mp_j_l);
1206 DgDp_mp_[ j*Np() + l ] = DgDp_mp_j_l;
1210 template<
class Scalar>
1214 assert_supports(OUT_ARG_DgDp_mp,j,l);
1215 return DgDp_mp_[ j*Np() + l ];
1219 template<
class Scalar>
1220 ModelEvaluatorBase::DerivativeProperties
1221 ModelEvaluatorBase::OutArgs<Scalar>::get_DgDp_mp_properties(
int j,
int l)
const 1223 assert_supports(OUT_ARG_DgDp_mp,j,l);
1224 return DgDp_mp_properties_[ j*Np() + l ];
1228 #ifdef HAVE_THYRA_ME_POLYNOMIAL 1231 template<
class Scalar>
1232 void ModelEvaluatorBase::OutArgs<Scalar>::set_f_poly(
1233 const RCP<Teuchos::Polynomial< VectorBase<Scalar> > > &f_poly
1240 template<
class Scalar>
1241 RCP<Teuchos::Polynomial< VectorBase<Scalar> > >
1242 ModelEvaluatorBase::OutArgs<Scalar>::get_f_poly()
const 1248 #endif // HAVE_THYRA_ME_POLYNOMIAL 1251 template<
class Scalar>
1257 const int min_Np = TEUCHOS_MIN(this->Np(),inputOutArgs.
Np());
1258 const int min_Ng = TEUCHOS_MIN(this->Ng(),inputOutArgs.
Ng());
1260 if ( inputOutArgs.
supports(OUT_ARG_f) && nonnull(inputOutArgs.
get_f()) ) {
1261 if ( supports(OUT_ARG_f) || !ignoreUnsupported )
1262 set_f(inputOutArgs.
get_f());
1264 if ( inputOutArgs.
supports(OUT_ARG_f_mp) && nonnull(inputOutArgs.
get_f_mp()) ) {
1265 if ( supports(OUT_ARG_f_mp) || !ignoreUnsupported )
1268 #ifdef HAVE_THYRA_ME_POLYNOMIAL 1270 if ( inputOutArgs.
supports(OUT_ARG_f_poly) && nonnull(inputOutArgs.get_f_poly()) ) {
1271 if ( supports(OUT_ARG_f_poly) || !ignoreUnsupported )
1272 set_f_poly(inputOutArgs.get_f_poly());
1274 #endif // HAVE_THYRA_ME_POLYNOMIAL 1276 for (
int j = 0; j < min_Ng; ++j ) {
1277 if ( nonnull(inputOutArgs.
get_g(j)) )
1278 set_g(j,inputOutArgs.
get_g(j));
1280 for (
int j = 0; j < min_Ng; ++j ) {
1281 if ( inputOutArgs.
supports(OUT_ARG_g_mp,j) && nonnull(inputOutArgs.
get_g_mp(j)) ) {
1282 if ( supports(OUT_ARG_g_mp,j) || !ignoreUnsupported )
1283 set_g_mp(j,inputOutArgs.
get_g_mp(j));
1287 if( inputOutArgs.
supports(OUT_ARG_W) && nonnull(inputOutArgs.
get_W()) ) {
1288 if ( supports(OUT_ARG_W) || !ignoreUnsupported )
1289 set_W(inputOutArgs.
get_W());
1291 if( inputOutArgs.
supports(OUT_ARG_W_mp) && nonnull(inputOutArgs.
get_W_mp()) ) {
1292 if ( supports(OUT_ARG_W_mp) || !ignoreUnsupported )
1296 if( inputOutArgs.
supports(OUT_ARG_W_op) && nonnull(inputOutArgs.
get_W_op()) ) {
1297 if ( supports(OUT_ARG_W_op) || !ignoreUnsupported )
1302 if ( supports(OUT_ARG_W_prec) || !ignoreUnsupported )
1306 for (
int l = 0; l < min_Np; ++l ) {
1307 MEB::Derivative<Scalar> DfDp_l;
1308 if ( !inputOutArgs.
supports(OUT_ARG_DfDp,l).none()
1309 && !(DfDp_l=inputOutArgs.
get_DfDp(l)).isEmpty() )
1311 if ( DfDp_l.isSupportedBy(supports(OUT_ARG_DfDp,l)) || !ignoreUnsupported )
1315 for (
int l = 0; l < min_Np; ++l ) {
1316 MEB::MPDerivative DfDp_mp_l;
1317 if ( !inputOutArgs.
supports(OUT_ARG_DfDp_mp,l).none()
1318 && !(DfDp_mp_l=inputOutArgs.get_DfDp_mp(l)).isEmpty() )
1320 if ( DfDp_mp_l.isSupportedBy(supports(OUT_ARG_DfDp_mp,l)) || !ignoreUnsupported )
1321 set_DfDp_mp(l,DfDp_mp_l);
1325 for (
int j = 0; j < min_Ng; ++j ) {
1327 MEB::Derivative<Scalar> DgDx_dot_j;
1328 if ( !inputOutArgs.
supports(OUT_ARG_DgDx_dot,j).none()
1329 && !(DgDx_dot_j=inputOutArgs.
get_DgDx_dot(j)).isEmpty() )
1331 if( DgDx_dot_j.isSupportedBy(supports(OUT_ARG_DgDx_dot,j)) || !ignoreUnsupported )
1332 set_DgDx_dot(j,DgDx_dot_j);
1335 MEB::Derivative<Scalar> DgDx_j;
1336 if ( !inputOutArgs.
supports(OUT_ARG_DgDx,j).none()
1337 && !(DgDx_j=inputOutArgs.
get_DgDx(j)).isEmpty() ) {
1338 if ( DgDx_j.isSupportedBy(supports(OUT_ARG_DgDx,j)) || !ignoreUnsupported )
1342 for (
int j = 0; j < min_Ng; ++j ) {
1344 MEB::MPDerivative DgDx_dot_mp_j;
1345 if ( !inputOutArgs.
supports(OUT_ARG_DgDx_dot_mp,j).none()
1346 && !(DgDx_dot_mp_j=inputOutArgs.get_DgDx_dot_mp(j)).isEmpty() )
1348 if( DgDx_dot_mp_j.isSupportedBy(supports(OUT_ARG_DgDx_dot_mp,j)) || !ignoreUnsupported )
1349 set_DgDx_dot_mp(j,DgDx_dot_mp_j);
1352 MEB::MPDerivative DgDx_mp_j;
1353 if ( !inputOutArgs.
supports(OUT_ARG_DgDx_mp,j).none()
1354 && !(DgDx_mp_j=inputOutArgs.get_DgDx_mp(j)).isEmpty() ) {
1355 if ( DgDx_mp_j.isSupportedBy(supports(OUT_ARG_DgDx_mp,j)) || !ignoreUnsupported )
1356 set_DgDx_mp(j,DgDx_mp_j);
1360 for (
int l = 0; l < min_Np; ++l ) {
1361 for (
int j = 0; j < min_Ng; ++j ) {
1362 MEB::Derivative<Scalar> DgDp_j_l;
1363 if ( !inputOutArgs.
supports(OUT_ARG_DgDp,j,l).none()
1364 && !(DgDp_j_l=inputOutArgs.
get_DgDp(j,l)).isEmpty() )
1366 if ( DgDp_j_l.isSupportedBy(supports(OUT_ARG_DgDp,j,l)) || !ignoreUnsupported )
1367 set_DgDp(j,l,DgDp_j_l);
1371 for (
int l = 0; l < min_Np; ++l ) {
1372 for (
int j = 0; j < min_Ng; ++j ) {
1373 MEB::MPDerivative DgDp_mp_j_l;
1374 if ( !inputOutArgs.
supports(OUT_ARG_DgDp_mp,j,l).none()
1375 && !(DgDp_mp_j_l=inputOutArgs.get_DgDp_mp(j,l)).isEmpty() )
1377 if ( DgDp_mp_j_l.isSupportedBy(supports(OUT_ARG_DgDp_mp,j,l)) || !ignoreUnsupported )
1378 set_DgDp_mp(j,l,DgDp_mp_j_l);
1386 template<
class Scalar>
1389 typedef Teuchos::ScalarTraits<Scalar> ST;
1391 if( this->supports(OUT_ARG_f) && nonnull(this->get_f()) ) {
1392 assign(this->get_f().ptr(),ST::nan());
1394 for(
int j = 0; j < this->Ng(); ++j ) {
1395 if (nonnull(this->get_g(j)))
1396 assign(this->get_g(j).ptr(),ST::nan());
1402 template<
class Scalar>
1409 template<
class Scalar>
1416 if (!is_null(W_op_))
1418 for (
int l = 0; l < Np(); ++l ) {
1419 if (!DfDp_[l].isEmpty())
1422 #ifdef HAVE_THYRA_ME_POLYNOMIAL 1423 if (!is_null(f_poly_))
1425 #endif // HAVE_THYRA_ME_POLYNOMIAL 1426 for (
int j = 0; j < Ng(); ++j ) {
1427 if (!is_null(g_[j]))
1429 if (!DgDx_dot_[j].isEmpty())
1431 if (!DgDx_[j].isEmpty())
1433 for (
int l = 0; l < Np(); ++l ) {
1434 if (!DgDp_[j*Np()+l].isEmpty())
1442 template<
class Scalar>
1448 for (
int outArg_i = 0; outArg_i < NUM_E_OUT_ARGS_MEMBERS; ++outArg_i ) {
1450 const std::string outArg_name =
toString(outArg_arg);
1451 TEUCHOS_TEST_FOR_EXCEPTION(
1452 supports(outArg_arg) != outArgs.
supports(outArg_arg), std::logic_error,
1453 "Error, the output argument "<<outArg_name<<
" with support "<<outArgs.
supports(outArg_arg)<<
"\n" 1454 "in the OutArgs object for the model:\n\n" 1456 "is not the same the argument "<<outArg_name<<
" with support "<<supports(outArg_arg)<<
"\n" 1457 "in the OutArgs object for the model:\n\n" 1458 " "<<modelEvalDescription()<<
"\n\n" 1459 "and these two OutArgs objects are not compatible!" 1463 const int l_Np = this->Np();
1464 const int l_Ng = this->Ng();
1465 TEUCHOS_ASSERT_EQUALITY( l_Np, outArgs.
Np() );
1466 TEUCHOS_ASSERT_EQUALITY( l_Ng, outArgs.
Ng() );
1468 if (supports(OUT_ARG_f)) {
1469 for (
int l = 0; l < l_Np; ++l ) {
1470 TEUCHOS_TEST_FOR_EXCEPTION(
1471 !supports(OUT_ARG_DfDp,l).isSameSupport(outArgs.
supports(OUT_ARG_DfDp,l)),
1473 "Error, the support for DfDp("<<l<<
") is not the same for the models\n\n" 1476 " "<<modelEvalDescription()<<
"\n\n" 1477 "and these two OutArgs objects are not compatible!" 1482 for (
int j = 0; j < l_Ng; ++j ) {
1483 TEUCHOS_TEST_FOR_EXCEPTION(
1484 !supports(OUT_ARG_DgDx_dot,j).isSameSupport(outArgs.
supports(OUT_ARG_DgDx_dot,j)),
1486 "Error, the support for DgDx_dot("<<j<<
") is not the same for the models\n\n" 1489 " "<<modelEvalDescription()<<
"\n\n" 1490 "and these two OutArgs objects are not compatible!" 1492 TEUCHOS_TEST_FOR_EXCEPTION(
1493 !supports(OUT_ARG_DgDx,j).isSameSupport(outArgs.
supports(OUT_ARG_DgDx,j)),
1495 "Error, the support for DgDx("<<j<<
") is not the same for the models\n\n" 1498 " "<<modelEvalDescription()<<
"\n\n" 1499 "and these two OutArgs objects are not compatible!" 1501 for (
int l = 0; l < l_Np; ++l ) {
1502 TEUCHOS_TEST_FOR_EXCEPTION(
1503 !supports(OUT_ARG_DgDp,j,l).isSameSupport(outArgs.
supports(OUT_ARG_DgDp,j,l)),
1505 "Error, the support for DgDp("<<j<<
","<<l<<
") is not the same for the models\n\n" 1508 " "<<modelEvalDescription()<<
"\n\n" 1509 "and these two OutArgs objects are not compatible!" 1516 template<
class Scalar>
1519 return modelEvalDescription_;
1523 template<
class Scalar>
1526 typedef Teuchos::ScalarTraits<Scalar> ST;
1527 std::ostringstream oss;
1529 <<
"Thyra::ModelEvaluatorBase::OutArgs<"<<ST::name()<<
">" 1531 <<
"model="<<modelEvalDescription_
1539 template<
class Scalar>
1541 Teuchos::FancyOStream &out_arg,
const Teuchos::EVerbosityLevel verbLevel
1545 using Teuchos::OSTab;
1546 using Teuchos::describe;
1547 typedef Teuchos::ScalarTraits<Scalar> ST;
1548 typedef RCP<const VectorBase<Scalar> > CV_ptr;
1549 typedef RCP<const LinearOpBase<Scalar> > CLO_ptr;
1550 typedef RCP<const LinearOpWithSolveBase<Scalar> > CLOWS_ptr;
1552 typedef MEB::Derivative<Scalar> Deriv;
1554 if( verbLevel == Teuchos::VERB_NONE && verbLevel == Teuchos::VERB_DEFAULT )
1557 RCP<Teuchos::FancyOStream>
1558 out = Teuchos::rcp(&out_arg,
false);
1561 *out <<
"Thyra::ModelEvaluatorBase::OutArgs<"<<ST::name()<<
">:\n";
1564 *out <<
"model = " << modelEvalDescription_ <<
"\n";
1565 *out <<
"Np = " << Np() <<
"\n";
1566 *out <<
"Ng = " << Ng() <<
"\n";
1569 if (this->supports(OUT_ARG_f) && !is_null(f=get_f()) ) {
1570 *out <<
"f = " << Teuchos::describe(*f,verbLevel);
1573 for(
int j = 0; j < Ng(); ++j ) {
1575 if (!is_null(g_j=this->get_g(j)))
1576 *out <<
"g("<<j<<
") = " << Teuchos::describe(*g_j,verbLevel);
1580 if ( this->supports(OUT_ARG_W) && !is_null(W=get_W()) ) {
1581 *out <<
"W = " << Teuchos::describe(*W,verbLevel);
1585 if ( this->supports(OUT_ARG_W_op) && !is_null(W_op=get_W_op()) ) {
1586 *out <<
"W_op = " << Teuchos::describe(*W_op,verbLevel);
1589 for(
int l = 0; l < Np(); ++l ) {
1592 !this->supports(OUT_ARG_DfDp,l).none()
1593 && !(DfDp_l=get_DfDp(l)).isEmpty()
1596 *out <<
"DfDp("<<l<<
") = ";
1597 DfDp_l.describe(*out,verbLevel);
1601 for(
int j = 0; j < Ng(); ++j ) {
1605 !this->supports(OUT_ARG_DgDx_dot,j).none()
1606 && !(DgDx_dot_j=get_DgDx_dot(j)).isEmpty()
1609 *out <<
"DgDx_dot("<<j<<
") = ";
1610 DgDx_dot_j.describe(*out,verbLevel);
1615 !this->supports(OUT_ARG_DgDx,j).none()
1616 && !(DgDx_j=get_DgDx(j)).isEmpty()
1619 *out <<
"DgDx("<<j<<
") = ";
1620 DgDx_j.describe(*out,verbLevel);
1623 for(
int l = 0; l < Np(); ++l ) {
1627 !this->supports(OUT_ARG_DgDp,j,l).none()
1628 && !(DgDp_j_l=get_DgDp(j,l)).isEmpty()
1631 *out <<
"DgDp("<<j<<
","<<l<<
") = ";
1632 DgDp_j_l.describe(*out,verbLevel);
1646 template<
class Scalar>
1648 const std::string &modelEvalDescription_in
1651 modelEvalDescription_ = modelEvalDescription_in;
1654 template<
class Scalar>
1658 supports_DfDp_.resize(Np_in);
1660 DfDp_properties_.resize(Np_in); std::fill_n(DfDp_properties_.begin(),Np_in,
DerivativeProperties());
1662 supports_DfDp_mp_.resize(Np_in);
1663 DfDp_mp_.resize(Np_in); std::fill_n(DfDp_mp_.begin(),Np_in,
MPDerivative());
1664 DfDp_mp_properties_.resize(Np_in); std::fill_n(DfDp_mp_properties_.begin(),Np_in,
DerivativeProperties());
1667 g_.resize(Ng_in); std::fill_n(g_.begin(),Ng_in,Teuchos::null);
1668 supports_DgDx_dot_.resize(Ng_in);
1670 DgDx_dot_properties_.resize(Ng_in); std::fill_n(DgDx_dot_properties_.begin(),Ng_in,
DerivativeProperties());
1671 supports_DgDx_.resize(Ng_in);
1673 DgDx_properties_.resize(Ng_in); std::fill_n(DgDx_properties_.begin(),Ng_in,
DerivativeProperties());
1675 g_mp_.resize(Ng_in); std::fill_n(g_mp_.begin(),Ng_in,Teuchos::null);
1676 supports_g_mp_.resize(Ng_in);
1677 supports_DgDx_dot_mp_.resize(Ng_in);
1678 DgDx_dot_mp_.resize(Ng_in); std::fill_n(DgDx_dot_mp_.begin(),Ng_in,
MPDerivative());
1679 DgDx_dot_mp_properties_.resize(Ng_in); std::fill_n(DgDx_dot_mp_properties_.begin(),Ng_in,
DerivativeProperties());
1680 supports_DgDx_mp_.resize(Ng_in);
1681 DgDx_mp_.resize(Ng_in); std::fill_n(DgDx_mp_.begin(),Ng_in,
MPDerivative());
1682 DgDx_mp_properties_.resize(Ng_in); std::fill_n(DgDx_mp_properties_.begin(),Ng_in,
DerivativeProperties());
1684 if(Np_in && Ng_in) {
1685 const int NpNg = Np_in*Ng_in;
1686 supports_DgDp_.resize(NpNg);
1688 DgDp_properties_.resize(NpNg); std::fill_n(DgDp_properties_.begin(),NpNg,
DerivativeProperties());
1690 supports_DgDp_mp_.resize(NpNg);
1691 DgDp_mp_.resize(NpNg); std::fill_n(DgDp_mp_.begin(),NpNg,
MPDerivative());
1692 DgDp_mp_properties_.resize(NpNg); std::fill_n(DgDp_mp_properties_.begin(),NpNg,
DerivativeProperties());
1697 template<
class Scalar>
1701 TEUCHOS_TEST_FOR_EXCEPTION(
1702 int(arg)>=NUM_E_OUT_ARGS_MEMBERS ||
int(arg) < 0,std::logic_error
1703 ,
"model = \'"<<modelEvalDescription_
1704 <<
"\': Error, arg="<<
toString(arg)<<
" is invalid!" 1706 supports_[arg] = supports_in;
1710 template<
class Scalar>
1715 assert_supports(OUT_ARG_f);
1717 supports_DfDp_[l] = supports_in;
1721 template<
class Scalar>
1727 supports_DgDx_dot_[j] = supports_in;
1731 template<
class Scalar>
1737 supports_DgDx_[j] = supports_in;
1741 template<
class Scalar>
1748 supports_DgDp_[ j*Np()+ l ] = supports_in;
1752 template<
class Scalar>
1759 supports_g_mp_[j] = supports_in;
1763 template<
class Scalar>
1765 EOutArgsDfDp_mp arg,
int l,
const DerivativeSupport& supports_in
1768 assert_supports(OUT_ARG_f_mp);
1770 supports_DfDp_mp_[l] = supports_in;
1774 template<
class Scalar>
1775 void ModelEvaluatorBase::OutArgs<Scalar>::_setSupports(
1776 EOutArgsDgDx_dot_mp arg,
int j,
const DerivativeSupport& supports_in
1780 supports_DgDx_dot_mp_[j] = supports_in;
1784 template<
class Scalar>
1785 void ModelEvaluatorBase::OutArgs<Scalar>::_setSupports(
1786 EOutArgsDgDx_mp arg,
int j,
const DerivativeSupport& supports_in
1790 supports_DgDx_mp_[j] = supports_in;
1794 template<
class Scalar>
1795 void ModelEvaluatorBase::OutArgs<Scalar>::_setSupports(
1796 EOutArgsDgDp_mp arg,
int j,
int l,
const DerivativeSupport& supports_in
1801 supports_DgDp_mp_[ j*Np()+ l ] = supports_in;
1805 template<
class Scalar>
1810 W_properties_ = properties;
1814 template<
class Scalar>
1819 assert_supports(OUT_ARG_DfDp,l);
1820 DfDp_properties_[l] = properties;
1824 template<
class Scalar>
1829 assert_supports(OUT_ARG_DgDx_dot,j);
1830 DgDx_dot_properties_[j] = properties;
1834 template<
class Scalar>
1839 assert_supports(OUT_ARG_DgDx,j);
1840 DgDx_properties_[j] = properties;
1844 template<
class Scalar>
1849 assert_supports(OUT_ARG_DgDp,j,l);
1850 DgDp_properties_[ j*Np()+ l ] = properties;
1854 template<
class Scalar>
1859 assert_supports(OUT_ARG_DfDp_mp,l);
1860 DfDp_mp_properties_[l] = properties;
1864 template<
class Scalar>
1866 int j,
const DerivativeProperties &properties
1869 assert_supports(OUT_ARG_DgDx_dot_mp,j);
1870 DgDx_dot_mp_properties_[j] = properties;
1874 template<
class Scalar>
1875 void ModelEvaluatorBase::OutArgs<Scalar>::_set_DgDx_mp_properties(
1876 int j,
const DerivativeProperties &properties
1879 assert_supports(OUT_ARG_DgDx_mp,j);
1880 DgDx_mp_properties_[j] = properties;
1884 template<
class Scalar>
1885 void ModelEvaluatorBase::OutArgs<Scalar>::_set_DgDp_mp_properties(
1886 int j,
int l,
const DerivativeProperties &properties
1889 assert_supports(OUT_ARG_DgDp_mp,j,l);
1890 DgDp_mp_properties_[ j*Np()+ l ] = properties;
1894 template<
class Scalar>
1900 const int l_Np = TEUCHOS_MIN(this->Np(),inputOutArgs.
Np());
1901 const int l_Ng = TEUCHOS_MIN(this->Ng(),inputOutArgs.
Ng());
1903 &inputOutArgs.supports_[0],
1904 &inputOutArgs.supports_[0] + NUM_E_OUT_ARGS_MEMBERS, &supports_[0] );
1905 for(
int l = 0; l < l_Np; ++l ) {
1908 this->_setSupports(MEB::OUT_ARG_DfDp,l,ds);
1912 for(
int l = 0; l < l_Np; ++l ) {
1915 this->_setSupports(MEB::OUT_ARG_DfDp_mp,l,ds);
1916 this->_set_DfDp_mp_properties(l,inputOutArgs.get_DfDp_mp_properties(l));
1919 for(
int j = 0; j < l_Ng; ++j ) {
1921 this->_setSupports(MEB::OUT_ARG_DgDx_dot,j,ds);
1924 for(
int j = 0; j < l_Ng; ++j ) {
1926 this->_setSupports(MEB::OUT_ARG_DgDx_dot_mp,j,ds);
1927 if(!ds.
none()) this->_set_DgDx_dot_mp_properties(j,inputOutArgs.get_DgDx_dot_mp_properties(j));
1929 for(
int j = 0; j < l_Ng; ++j ) {
1931 this->_setSupports(MEB::OUT_ARG_DgDx,j,ds);
1934 for(
int j = 0; j < l_Ng; ++j ) {
1936 this->_setSupports(MEB::OUT_ARG_DgDx_mp,j,ds);
1937 if(!ds.
none()) this->_set_DgDx_mp_properties(j,inputOutArgs.get_DgDx_mp_properties(j));
1939 for(
int j = 0; j < l_Ng; ++j )
for(
int l = 0; l < l_Np; ++l ) {
1941 this->_setSupports(MEB::OUT_ARG_DgDp,j,l,ds);
1944 for(
int j = 0; j < l_Ng; ++j )
for(
int l = 0; l < l_Np; ++l ) {
1946 this->_setSupports(MEB::OUT_ARG_DgDp_mp,j,l,ds);
1947 if(!ds.
none()) this->_set_DgDp_mp_properties(j,l,inputOutArgs.get_DgDp_mp_properties(j,l));
1949 if(this->supports(OUT_ARG_W) || this->supports(OUT_ARG_W_op))
1951 if(this->supports(OUT_ARG_W_mp))
1956 template<
class Scalar>
1963 const int l_Ng = this->Ng();
1964 for(
int j = 0; j < l_Ng; ++j ) {
1971 const int l_Ng = this->Ng();
1972 for(
int j = 0; j < l_Ng; ++j ) {
1979 TEUCHOS_TEST_FOR_EXCEPTION(
1980 true ,std::logic_error,
1981 "Error, can not handle args other than IN_ARG_x yet!" 1988 template<
class Scalar>
1995 this->_setSupports(OUT_ARG_W,
false);
1996 this->_setSupports(OUT_ARG_W_op,
false);
1997 this->_setSupports(OUT_ARG_f_poly,
false);
1998 const int l_Np = this->Np();
1999 for(
int l = 0; l < l_Np; ++l )
2003 case OUT_ARG_f_mp: {
2004 this->_setSupports(OUT_ARG_W_mp,
false);
2005 this->_setSupports(OUT_ARG_W_op,
false);
2006 this->_setSupports(OUT_ARG_f_poly,
false);
2007 const int l_Np = this->Np();
2008 for(
int l = 0; l < l_Np; ++l )
2013 TEUCHOS_TEST_FOR_EXCEPTION(
2014 true ,std::logic_error,
2015 "Error, can not handle args other than OUT_ARG_f yet!" 2019 this->_setSupports(arg,
false);
2026 template<
class Scalar>
2029 TEUCHOS_TEST_FOR_EXCEPTION(
2030 !this->supports(arg), std::logic_error
2031 ,
"Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(arg):\n\n" 2032 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2033 "Error, The argument arg = " <<
toString(arg) <<
" is not supported!" 2038 template<
class Scalar>
2040 EOutArgsDfDp arg,
int l,
const Derivative<Scalar> &deriv
2043 const DerivativeSupport derivSupport = this->supports(arg,l);
2044 TEUCHOS_TEST_FOR_EXCEPTION(
2045 !deriv.isSupportedBy(derivSupport), std::logic_error,
2046 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DfDp,l):\n\n" 2047 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2048 "Error, The argument DfDp("<<l<<
") = " << deriv.description() <<
"\n" 2049 "is not supported!\n\n" 2050 "The supported types include " << derivSupport.description() <<
"!" 2055 template<
class Scalar>
2056 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2057 EOutArgsDgDx_dot arg,
int j,
const Derivative<Scalar> &deriv
2060 const DerivativeSupport derivSupport = this->supports(arg,j);
2061 TEUCHOS_TEST_FOR_EXCEPTION(
2062 !deriv.isSupportedBy(derivSupport), std::logic_error,
2063 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx_dot,j):\n\n" 2064 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2065 "Error, The argument DgDx_dot("<<j<<
") = " << deriv.description() <<
"\n" 2066 "is not supported!\n\n" 2067 "The supported types include " << derivSupport.description() <<
"!" 2072 template<
class Scalar>
2073 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2074 EOutArgsDgDx arg,
int j,
const Derivative<Scalar> &deriv
2077 const DerivativeSupport derivSupport = this->supports(arg,j);
2078 TEUCHOS_TEST_FOR_EXCEPTION(
2079 !deriv.isSupportedBy(derivSupport), std::logic_error,
2080 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx,j):\n\n" 2081 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2082 "Error, The argument DgDx("<<j<<
") = " << deriv.description() <<
"\n" 2083 "is not supported!\n\n" 2084 "The supported types include " << derivSupport.description() <<
"!" 2089 template<
class Scalar>
2090 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2091 EOutArgsDgDp arg,
int j,
int l,
const Derivative<Scalar> &deriv
2094 const DerivativeSupport derivSupport = this->supports(arg,j,l);
2095 TEUCHOS_TEST_FOR_EXCEPTION(
2096 !deriv.isSupportedBy(derivSupport), std::logic_error,
2097 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDp,j,l):\n\n" 2098 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2099 "Error, The argument DgDp("<<j<<
","<<l<<
") = " << deriv.description() <<
"\n" 2100 "is not supported!\n\n" 2101 "The supported types include " << derivSupport.description() <<
"!" 2106 template<
class Scalar>
2107 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2108 EOutArgs_g_mp arg,
int j
2112 TEUCHOS_TEST_FOR_EXCEPTION(
2113 !supports_g_mp_[j], std::logic_error,
2114 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_g_mp,j):\n\n" 2115 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2116 "Error, The argument g_mp("<<j<<
") \n" 2117 "is not supported!\n\n" 2122 template<
class Scalar>
2123 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2124 EOutArgsDfDp_mp arg,
int l,
const MPDerivative &deriv
2127 const DerivativeSupport derivSupport = this->supports(arg,l);
2128 TEUCHOS_TEST_FOR_EXCEPTION(
2129 !deriv.isSupportedBy(derivSupport), std::logic_error,
2130 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DfDp_mp,l):\n\n" 2131 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2132 "Error, The argument DfDp_mp("<<l<<
") = " << deriv.description() <<
"\n" 2133 "is not supported!\n\n" 2134 "The supported types include " << derivSupport.description() <<
"!" 2139 template<
class Scalar>
2140 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2141 EOutArgsDgDx_dot_mp arg,
int j,
const MPDerivative &deriv
2144 const DerivativeSupport derivSupport = this->supports(arg,j);
2145 TEUCHOS_TEST_FOR_EXCEPTION(
2146 !deriv.isSupportedBy(derivSupport), std::logic_error,
2147 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx_dot_mp,j):\n\n" 2148 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2149 "Error, The argument DgDx_dot_mp("<<j<<
") = " << deriv.description() <<
"\n" 2150 "is not supported!\n\n" 2151 "The supported types include " << derivSupport.description() <<
"!" 2156 template<
class Scalar>
2157 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2158 EOutArgsDgDx_mp arg,
int j,
const MPDerivative &deriv
2161 const DerivativeSupport derivSupport = this->supports(arg,j);
2162 TEUCHOS_TEST_FOR_EXCEPTION(
2163 !deriv.isSupportedBy(derivSupport), std::logic_error,
2164 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx_mp,j):\n\n" 2165 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2166 "Error, The argument DgDx_mp("<<j<<
") = " << deriv.description() <<
"\n" 2167 "is not supported!\n\n" 2168 "The supported types include " << derivSupport.description() <<
"!" 2173 template<
class Scalar>
2174 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
2175 EOutArgsDgDp_mp arg,
int j,
int l,
const MPDerivative &deriv
2178 const DerivativeSupport derivSupport = this->supports(arg,j,l);
2179 TEUCHOS_TEST_FOR_EXCEPTION(
2180 !deriv.isSupportedBy(derivSupport), std::logic_error,
2181 "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDp_mp,j,l):\n\n" 2182 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2183 "Error, The argument DgDp_mp("<<j<<
","<<l<<
") = " << deriv.description() <<
"\n" 2184 "is not supported!\n\n" 2185 "The supported types include " << derivSupport.description() <<
"!" 2190 template<
class Scalar>
2191 void ModelEvaluatorBase::OutArgs<Scalar>::assert_l(
int l)
const 2193 TEUCHOS_TEST_FOR_EXCEPTION(
2194 !( 0 <= l && l < Np() ), std::logic_error
2195 ,
"Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_l(l):\n\n" 2196 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2197 "Error, The parameter subvector p("<<l<<
")" 2198 " is not in the range [0,"<<Np()<<
")!" 2203 template<
class Scalar>
2204 void ModelEvaluatorBase::OutArgs<Scalar>::assert_j(
int j)
const 2206 TEUCHOS_TEST_FOR_EXCEPTION(
2207 !( 0 <= j && j < Ng() ), std::logic_error
2208 ,
"Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_j(j):\n\n" 2209 "model = \'"<<modelEvalDescription_<<
"\':\n\n" 2210 "Error, The auxiliary function g("<<j<<
")" 2211 " is not in the range [0,"<<Ng()<<
")!" 2221 template<
class Scalar>
2226 template<
class Scalar>
2232 template<
class Scalar>
2234 const std::string &modelEvalDescription_in )
2236 this->_setModelEvalDescription(modelEvalDescription_in);
2240 template<
class Scalar>
2242 { this->_set_Np(Np_in); }
2245 template<
class Scalar>
2247 { this->_setSupports(arg,supports_in); }
2250 template<
class Scalar>
2252 { this->_setSupports(arg,l,supports_in); }
2255 template<
class Scalar>
2260 this->_setSupports(inArgs, Np_in);
2264 template<
class Scalar>
2269 this->_setUnsupportsAndRelated(arg);
2278 template<
class Scalar>
2283 template<
class Scalar>
2287 :
OutArgs<Scalar>(inputOutArgs)
2291 template<
class Scalar>
2293 const std::string &modelEvalDescription_in
2295 { this->_setModelEvalDescription(modelEvalDescription_in); }
2298 template<
class Scalar>
2300 { this->_set_Np_Ng(Np_in, Ng_in); }
2303 template<
class Scalar>
2307 { this->_setSupports(arg,supports_in); }
2310 template<
class Scalar>
2314 { this->_setSupports(arg,l,supports_in); }
2317 template<
class Scalar>
2321 { this->_setSupports(arg,j,supports_in); }
2324 template<
class Scalar>
2328 { this->_setSupports(arg,j,supports_in); }
2331 template<
class Scalar>
2335 { this->_setSupports(arg,j,l,supports_in); }
2338 template<
class Scalar>
2342 { this->_setSupports(arg,j,supports_in); }
2345 template<
class Scalar>
2349 { this->_setSupports(arg,l,supports_in); }
2352 template<
class Scalar>
2356 { this->_setSupports(arg,j,supports_in); }
2359 template<
class Scalar>
2363 { this->_setSupports(arg,j,supports_in); }
2366 template<
class Scalar>
2368 EOutArgsDgDp_mp arg,
int j,
int l,
const DerivativeSupport& supports_in
2370 { this->_setSupports(arg,j,l,supports_in); }
2373 template<
class Scalar>
2377 { this->_set_W_properties(properties); }
2380 template<
class Scalar>
2384 { this->_set_DfDp_properties(l,properties); }
2387 template<
class Scalar>
2391 { this->_set_DgDx_dot_properties(j,properties); }
2394 template<
class Scalar>
2398 { this->_set_DgDx_properties(j,properties); }
2401 template<
class Scalar>
2405 { this->_set_DgDp_properties(j,l,properties); }
2408 template<
class Scalar>
2412 { this->_set_DfDp_mp_properties(l,properties); }
2415 template<
class Scalar>
2417 int j,
const DerivativeProperties &properties
2419 { this->_set_DgDx_dot_mp_properties(j,properties); }
2422 template<
class Scalar>
2423 void ModelEvaluatorBase::OutArgsSetup<Scalar>::set_DgDx_mp_properties(
2424 int j,
const DerivativeProperties &properties
2426 { this->_set_DgDx_mp_properties(j,properties); }
2429 template<
class Scalar>
2430 void ModelEvaluatorBase::OutArgsSetup<Scalar>::set_DgDp_mp_properties(
2431 int j,
int l,
const DerivativeProperties &properties
2433 { this->_set_DgDp_mp_properties(j,l,properties); }
2436 template<
class Scalar>
2440 { this->_setSupports(inputOutArgs); }
2443 template<
class Scalar>
2447 { this->_setUnsupportsAndRelated(arg); }
2450 template<
class Scalar>
2454 { this->_setUnsupportsAndRelated(arg); }
2468 #define THYRA_MODEL_EVALUATOR_BASE_INSTANT(SCALAR) \ 2470 template class ModelEvaluatorBase::InArgs<SCALAR >; \ 2472 template std::string \ 2473 ModelEvaluatorBase::Derivative<SCALAR >::description() const; \ 2476 void ModelEvaluatorBase::Derivative<SCALAR >::describe( \ 2477 Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel \ 2480 template class ModelEvaluatorBase::OutArgs<SCALAR >; \ 2482 template class ModelEvaluatorBase::InArgsSetup<SCALAR >; \ 2484 template class ModelEvaluatorBase::OutArgsSetup<SCALAR >; 2487 #endif // THYRA_MODEL_EVALUATOR_BASE_DEF_HPP Protected subclass of InArgs that only ModelEvaluator subclasses can access to set up the selection o...
RCP< const Stokhos::ProductEpetraVector > get_x_dot_mp() const
Precondition: supports(IN_ARG_x_dotmp)==true.
Scalar get_step_size() const
Precondition: supports(IN_ARG_step_size)==true.
void set_DgDx_properties(int j, const DerivativeProperties &properties)
std::string modelEvalDescription() const
RCP< LinearOpWithSolveBase< Scalar > > get_W() const
Precondition: supports(OUT_ARG_W)==true.
void set_DfDp_properties(int l, const DerivativeProperties &properties)
Base class for all linear operators that can support a high-level solve operation.
std::string toString(ModelEvaluatorBase::EInArgsMembers)
std::string description() const
bool supports(EInArgsMembers arg) const
Determines if an input argument is supported or not.
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...
DerivativeProperties get_DgDp_properties(int j, int l) const
Return the know properties of DgDp(j,l) (precondition: supports(OUT_ARG_DgDp,j,l)==true).
void setModelEvalDescription(const std::string &modelEvalDescription)
void assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
Derivative< Scalar > get_DfDp(int l) const
Precondition: supports(OUT_ARG_DfDp,l)==true.
Scalar get_beta() const
Precondition: supports(IN_ARG_beta)==true.
void set_Np_Ng(int Np, int Ng)
Derivative< Scalar > get_DgDp(int j, int l) const
Precondition: supports(OUT_ARG_DgDp,j,l)==true.
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
Scalar get_stage_number() const
Precondition: supports(IN_ARG_stage_number)==true.
RCP< const VectorBase< Scalar > > get_x() const
Precondition: supports(IN_ARG_x)==true.
DerivativeProperties get_DfDp_properties(int l) const
Return the know properties of DfDp(l) (precondition: supports(OUT_ARG_DfDp,l)==true).
RCP< const Stokhos::ProductEpetraVector > get_x_mp() const
Precondition: supports(IN_ARG_x_mp)==true.
Derivative< Scalar > get_DgDx(int j) const
Precondition: supports(OUT_ARG_DgDx,j)==true.
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
Scalar get_alpha() const
Precondition: supports(IN_ARG_alph)==true.
RCP< Stokhos::ProductEpetraVector > get_f_mp() const
Precondition: supports(OUT_ARG_f_mp)==true.
ScalarMag get_t() const
.Precondition: supports(IN_ARG_t)==true
Simple aggregate class for a derivative object represented as a column-wise multi-vector or its trans...
RCP< const VectorBase< Scalar > > get_p(int l) const
Get p(l) where 0 <= l && l < this->Np().
void set_W_properties(const DerivativeProperties &properties)
Derivative< Scalar > get_DgDx_dot(int j) const
Precondition: supports(OUT_ARG_DgDx_dot,j)==true.
void setSupports(EInArgsMembers arg, bool supports=true)
void setUnsupportsAndRelated(EInArgsMembers arg)
void setUnsupportsAndRelated(EInArgsMembers arg)
RCP< const VectorBase< Scalar > > get_x_dot() const
Precondition: supports(IN_ARG_x_dot)==true.
void set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
Teuchos::ScalarTraits< double >::magnitudeType ScalarMag
RCP< PreconditionerBase< Scalar > > get_W_prec() const
Precondition: supports(OUT_ARG_W_op)==true.
std::string modelEvalDescription() const
bool supports(EOutArgsMembers arg) const
Determine if an input argument is supported or not.
Abstract interface for finite-dimensional dense vectors.
Simple public strict containing properties of a derivative object.
RCP< Stokhos::ProductEpetraOperator > get_W_mp() const
Precondition: supports(OUT_ARG_W_mp)==true.
Evaluation< VectorBase< Scalar > > get_g(int j) const
Precondition: supports(OUT_ARG_g)==true..
Base class for all linear operators.
void set_DgDx_dot_properties(int j, const DerivativeProperties &properties)
int Ng() const
Return the number of axillary response functions g(j)(...) supported (Ng >= 0).
Base subclass for ModelEvaluator that defines some basic types.
int Np() const
Return the number of parameter subvectors p(l) supported (Np >= 0).
void setSupports(EOutArgsMembers arg, bool supports=true)
DerivativeProperties get_DgDx_properties(int j) const
Return the know properties of DgDx(j) (precondition: supports(OUT_ARG_DgDx,j)==true).
DerivativeProperties get_DgDx_dot_properties(int j) const
Return the know properties of DgDx_dot(j) (precondition: supports(OUT_ARG_DgDx_dot,j)==true).
RCP< LinearOpBase< Scalar > > get_W_op() const
Precondition: supports(OUT_ARG_W_op)==true.
Evaluation< VectorBase< Scalar > > get_f() const
Precondition: supports(OUT_ARG_f)==true.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm(const VectorBase< Scalar > &v)
Natural norm: result = sqrt(<v,v>).
Determines the forms of a general derivative that are supported.
std::string description() const
void setModelEvalDescription(const std::string &modelEvalDescription)
Type to embed evaluation accuracy with an RCP-managed object.
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
RCP< Stokhos::ProductEpetraVector > get_g_mp(int j) const
Precondition: supports(OUT_ARG_g_mp)==true..
Protected subclass of OutArgs that only ModelEvaluator subclasses can access to set up the selection ...
DerivativeProperties get_W_properties() const
Return the known properties of W (precondition: supports(OUT_ARG_f)==true).
int Np() const
Return the number of parameter subvectors p(l) supported (Np >= 0).
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...