10 #ifndef THYRA_MODEL_EVALUATOR_DEFAULT_BASE_HPP
11 #define THYRA_MODEL_EVALUATOR_DEFAULT_BASE_HPP
13 #include "Thyra_VectorBase.hpp"
15 #include "Thyra_ModelEvaluator.hpp"
16 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
19 #ifdef HAVE_THYRA_ME_POLYNOMIAL
35 #include "Thyra_PolynomialVectorTraits.hpp"
38 #endif // HAVE_THYRA_ME_POLYNOMIAL
51 namespace ModelEvaluatorDefaultBaseTypes {
57 class DefaultDerivLinearOpSupport {
59 DefaultDerivLinearOpSupport()
60 :provideDefaultLinearOp_(false),
61 mvImplOrientation_(ModelEvaluatorBase::DERIV_MV_BY_COL)
63 DefaultDerivLinearOpSupport(
66 :provideDefaultLinearOp_(true),
67 mvImplOrientation_(mvImplOrientation_in)
69 bool provideDefaultLinearOp()
const
70 {
return provideDefaultLinearOp_; }
72 {
return mvImplOrientation_; }
74 bool provideDefaultLinearOp_;
82 class DefaultDerivMvAdjointSupport {
84 DefaultDerivMvAdjointSupport()
85 :provideDefaultAdjoint_(false),
86 mvAdjointCopyOrientation_(ModelEvaluatorBase::DERIV_MV_BY_COL)
88 DefaultDerivMvAdjointSupport(
91 :provideDefaultAdjoint_(true),
92 mvAdjointCopyOrientation_(mvAdjointCopyOrientation_in)
94 bool provideDefaultAdjoint()
const
95 {
return provideDefaultAdjoint_; }
97 {
return mvAdjointCopyOrientation_; }
99 bool provideDefaultAdjoint_;
106 template<
class Scalar>
107 struct MultiVectorAdjointPair {
108 MultiVectorAdjointPair()
110 MultiVectorAdjointPair(
111 const RCP<MultiVectorBase<Scalar> > &in_mvOuter,
112 const RCP<
const MultiVectorBase<Scalar> > &in_mvImplAdjoint
114 : mvOuter(in_mvOuter),
115 mvImplAdjoint(in_mvImplAdjoint)
117 RCP<MultiVectorBase<Scalar> > mvOuter;
118 RCP<const MultiVectorBase<Scalar> > mvImplAdjoint;
155 template<
class Scalar>
189 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
202 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
255 virtual void evalModelImpl(
272 typedef ModelEvaluatorDefaultBaseTypes::DefaultDerivLinearOpSupport
273 DefaultDerivLinearOpSupport;
275 typedef ModelEvaluatorDefaultBaseTypes::DefaultDerivMvAdjointSupport
276 DefaultDerivMvAdjointSupport;
278 typedef ModelEvaluatorDefaultBaseTypes::MultiVectorAdjointPair<Scalar>
279 MultiVectorAdjointPair;
295 bool default_W_support_;
302 void lazyInitializeDefaultBase()
const;
304 void assert_l(
const int l)
const;
306 void assert_j(
const int j)
const;
311 static DefaultDerivLinearOpSupport
312 determineDefaultDerivLinearOpSupport(
317 createDefaultLinearOp(
318 const DefaultDerivLinearOpSupport &defaultLinearOpSupport,
324 updateDefaultLinearOpSupport(
326 const DefaultDerivLinearOpSupport &defaultLinearOpSupport
330 getOutArgImplForDefaultLinearOpSupport(
332 const DefaultDerivLinearOpSupport &defaultLinearOpSupport
335 static DefaultDerivMvAdjointSupport
336 determineDefaultDerivMvAdjointSupport(
343 updateDefaultDerivMvAdjointSupport(
345 const DefaultDerivMvAdjointSupport &defaultMvAdjointSupport
359 #include "Thyra_ModelEvaluatorHelpers.hpp"
360 #include "Thyra_DefaultScaledAdjointLinearOp.hpp"
361 #include "Thyra_DetachedMultiVectorView.hpp"
362 #include "Teuchos_Assert.hpp"
371 template<
class Scalar>
374 lazyInitializeDefaultBase();
375 return prototypeOutArgs_.Np();
379 template<
class Scalar>
382 lazyInitializeDefaultBase();
383 return prototypeOutArgs_.Ng();
387 template<
class Scalar>
391 lazyInitializeDefaultBase();
392 if (default_W_support_)
393 return this->get_W_factory()->createOp();
394 return Teuchos::null;
398 template<
class Scalar>
402 lazyInitializeDefaultBase();
406 const DefaultDerivLinearOpSupport
407 defaultLinearOpSupport = DfDp_default_op_support_[l];
408 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
409 return createDefaultLinearOp(
410 defaultLinearOpSupport,
415 return this->create_DfDp_op_impl(l);
419 template<
class Scalar>
423 lazyInitializeDefaultBase();
427 const DefaultDerivLinearOpSupport
428 defaultLinearOpSupport = DgDx_dot_default_op_support_[j];
429 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
430 return createDefaultLinearOp(
431 defaultLinearOpSupport,
432 this->get_g_space(j),
436 return this->create_DgDx_dot_op_impl(j);
440 template<
class Scalar>
444 lazyInitializeDefaultBase();
448 const DefaultDerivLinearOpSupport
449 defaultLinearOpSupport = DgDx_default_op_support_[j];
450 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
451 return createDefaultLinearOp(
452 defaultLinearOpSupport,
453 this->get_g_space(j),
457 return this->create_DgDx_op_impl(j);
461 template<
class Scalar>
465 lazyInitializeDefaultBase();
470 const DefaultDerivLinearOpSupport
471 defaultLinearOpSupport = DgDp_default_op_support_[j][l];
472 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
473 return createDefaultLinearOp(
474 defaultLinearOpSupport,
475 this->get_g_space(j),
479 return this->create_DgDp_op_impl(j,l);
483 template<
class Scalar>
487 lazyInitializeDefaultBase();
488 return prototypeOutArgs_;
492 template<
class Scalar>
499 using Teuchos::outArg;
502 lazyInitializeDefaultBase();
504 const int l_Np = outArgs.
Np();
505 const int l_Ng = outArgs.
Ng();
512 assertInArgsEvalObjects(*
this,inArgs);
513 assertOutArgsEvalObjects(*
this,outArgs,&inArgs);
521 MEB::OutArgs<Scalar> outArgsImpl = this->createOutArgsImpl();
526 outArgsImpl.setArgs(outArgs,
true);
529 if (outArgsImpl.supports(MEB::OUT_ARG_f)) {
530 for (
int l = 0; l < l_Np; ++l ) {
531 const DefaultDerivLinearOpSupport defaultLinearOpSupport =
532 DfDp_default_op_support_[l];
533 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
534 outArgsImpl.set_DfDp( l,
535 getOutArgImplForDefaultLinearOpSupport(
536 outArgs.
get_DfDp(l), defaultLinearOpSupport
547 for (
int j = 0; j < l_Ng; ++j ) {
548 const DefaultDerivLinearOpSupport defaultLinearOpSupport =
549 DgDx_dot_default_op_support_[j];
550 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
551 outArgsImpl.set_DgDx_dot( j,
552 getOutArgImplForDefaultLinearOpSupport(
563 for (
int j = 0; j < l_Ng; ++j ) {
564 const DefaultDerivLinearOpSupport defaultLinearOpSupport =
565 DgDx_default_op_support_[j];
566 if (defaultLinearOpSupport.provideDefaultLinearOp()) {
567 outArgsImpl.set_DgDx( j,
568 getOutArgImplForDefaultLinearOpSupport(
569 outArgs.
get_DgDx(j), defaultLinearOpSupport
579 for (
int j = 0; j < l_Ng; ++j ) {
581 DgDp_default_op_support_[j];
583 DgDp_default_mv_support_[j];
584 for (
int l = 0; l < l_Np; ++l ) {
585 const DefaultDerivLinearOpSupport defaultLinearOpSupport =
586 DgDp_default_op_support_j[l];
587 const DefaultDerivMvAdjointSupport defaultMvAdjointSupport =
588 DgDp_default_mv_support_j[l];
589 MEB::Derivative<Scalar> DgDp_j_l;
590 if (!outArgs.
supports(MEB::OUT_ARG_DgDp,j,l).none())
593 defaultLinearOpSupport.provideDefaultLinearOp()
594 && !
is_null(DgDp_j_l.getLinearOp())
597 outArgsImpl.set_DgDp( j, l,
598 getOutArgImplForDefaultLinearOpSupport(
599 DgDp_j_l, defaultLinearOpSupport
604 defaultMvAdjointSupport.provideDefaultAdjoint()
605 && !
is_null(DgDp_j_l.getMultiVector())
609 DgDp_j_l.getMultiVector();
611 defaultMvAdjointSupport.mvAdjointCopyOrientation()
613 DgDp_j_l.getMultiVectorOrientation()
620 createMembers(DgDp_j_l_mv->domain(), DgDp_j_l_mv->range()->dim());
621 outArgsImpl.set_DgDp( j, l,
622 MEB::Derivative<Scalar>(
624 getOtherDerivativeMultiVectorOrientation(
625 defaultMvAdjointSupport.mvAdjointCopyOrientation()
632 MultiVectorAdjointPair(DgDp_j_l_mv, DgDp_j_l_mv_adj)
649 if ( default_W_support_ && !
is_null(W=outArgs.
get_W()) ) {
651 W_factory = this->get_W_factory();
654 uninitializeOp<Scalar>(*W_factory, W.
ptr(), outArg(W_op_const));
666 W_op = this->create_W_op();
668 outArgsImpl.set_W_op(W_op);
677 this->evalModelImpl( inArgs, outArgsImpl );
684 const int numMvAdjointCopies = DgDp_temp_adjoint_copies.
size();
685 for (
int adj_copy_i = 0; adj_copy_i < numMvAdjointCopies; ++adj_copy_i ) {
686 const MultiVectorAdjointPair adjPair =
687 DgDp_temp_adjoint_copies[adj_copy_i];
688 doExplicitMultiVectorAdjoint( *adjPair.mvImplAdjoint, &*adjPair.mvOuter );
694 if ( default_W_support_ && !
is_null(W=outArgs.
get_W()) ) {
696 W_factory = this->get_W_factory();
697 W_factory->setOStream(this->getOStream());
698 W_factory->setVerbLevel(this->getVerbLevel());
699 initializeOp<Scalar>(*W_factory, outArgsImpl.get_W_op().
getConst(), W.
ptr());
711 template<
class Scalar>
718 isInitialized_ =
false;
719 default_W_support_ =
false;
725 const MEB::InArgs<Scalar> inArgs = this->createInArgs();
726 const MEB::OutArgs<Scalar> outArgsImpl = this->createOutArgsImpl();
733 assertInArgsOutArgsSetup( this->description(), inArgs, outArgsImpl );
734 #endif // TEUCHOS_DEBUG
740 const int l_Ng = outArgsImpl.Ng();
741 const int l_Np = outArgsImpl.Np();
744 MEB::OutArgsSetup<Scalar> outArgs;
745 outArgs.setModelEvalDescription(this->description());
746 outArgs.set_Np_Ng(l_Np,l_Ng);
747 outArgs.setSupports(outArgsImpl);
750 DfDp_default_op_support_.clear();
751 if (outArgs.supports(MEB::OUT_ARG_f)) {
752 for (
int l = 0; l < l_Np; ++l ) {
753 const MEB::DerivativeSupport DfDp_l_impl_support =
754 outArgsImpl.supports(MEB::OUT_ARG_DfDp,l);
755 const DefaultDerivLinearOpSupport DfDp_l_op_support =
756 determineDefaultDerivLinearOpSupport(DfDp_l_impl_support);
757 DfDp_default_op_support_.push_back(DfDp_l_op_support);
759 MEB::OUT_ARG_DfDp, l,
760 updateDefaultLinearOpSupport(
761 DfDp_l_impl_support, DfDp_l_op_support
768 DgDx_dot_default_op_support_.clear();
769 for (
int j = 0; j < l_Ng; ++j ) {
770 const MEB::DerivativeSupport DgDx_dot_j_impl_support =
771 outArgsImpl.supports(MEB::OUT_ARG_DgDx_dot,j);
772 const DefaultDerivLinearOpSupport DgDx_dot_j_op_support =
773 determineDefaultDerivLinearOpSupport(DgDx_dot_j_impl_support);
774 DgDx_dot_default_op_support_.push_back(DgDx_dot_j_op_support);
776 MEB::OUT_ARG_DgDx_dot, j,
777 updateDefaultLinearOpSupport(
778 DgDx_dot_j_impl_support, DgDx_dot_j_op_support
784 DgDx_default_op_support_.clear();
785 for (
int j = 0; j < l_Ng; ++j ) {
786 const MEB::DerivativeSupport DgDx_j_impl_support =
787 outArgsImpl.supports(MEB::OUT_ARG_DgDx,j);
788 const DefaultDerivLinearOpSupport DgDx_j_op_support =
789 determineDefaultDerivLinearOpSupport(DgDx_j_impl_support);
790 DgDx_default_op_support_.push_back(DgDx_j_op_support);
792 MEB::OUT_ARG_DgDx, j,
793 updateDefaultLinearOpSupport(
794 DgDx_j_impl_support, DgDx_j_op_support
800 DgDp_default_op_support_.clear();
801 DgDp_default_mv_support_.clear();
802 for (
int j = 0; j < l_Ng; ++j ) {
805 for (
int l = 0; l < l_Np; ++l ) {
806 const MEB::DerivativeSupport DgDp_j_l_impl_support =
807 outArgsImpl.supports(MEB::OUT_ARG_DgDp,j,l);
809 const DefaultDerivLinearOpSupport DgDp_j_l_op_support =
810 determineDefaultDerivLinearOpSupport(DgDp_j_l_impl_support);
811 DgDp_default_op_support_[j].push_back(DgDp_j_l_op_support);
813 MEB::OUT_ARG_DgDp, j, l,
814 updateDefaultLinearOpSupport(
815 DgDp_j_l_impl_support, DgDp_j_l_op_support
819 const DefaultDerivMvAdjointSupport DgDp_j_l_mv_support =
820 determineDefaultDerivMvAdjointSupport(
821 DgDp_j_l_impl_support, *this->get_g_space(j), *this->get_p_space(l)
823 DgDp_default_mv_support_[j].push_back(DgDp_j_l_mv_support);
825 MEB::OUT_ARG_DgDp, j, l,
826 updateDefaultDerivMvAdjointSupport(
827 outArgs.supports(MEB::OUT_ARG_DgDp, j, l),
837 default_W_support_ =
false;
838 if ( outArgsImpl.supports(MEB::OUT_ARG_W_op) && !
is_null(this->get_W_factory())
839 && !outArgsImpl.supports(MEB::OUT_ARG_W) )
841 default_W_support_ =
true;
842 outArgs.setSupports(MEB::OUT_ARG_W);
843 outArgs.set_W_properties(outArgsImpl.get_W_properties());
850 prototypeOutArgs_ = outArgs;
851 isInitialized_ =
true;
855 template<
class Scalar>
858 isInitialized_ =
false;
864 template<
class Scalar>
869 MEB::OutArgs<Scalar> outArgs = this->createOutArgsImpl();
871 outArgs.supports(MEB::OUT_ARG_DfDp,l).supports(MEB::DERIV_LINEAR_OP),
873 "Error, The ModelEvaluator subclass "<<this->description()<<
" says that it"
874 " supports the LinearOpBase form of DfDp("<<l<<
") (as determined from its"
875 " OutArgs object created by createOutArgsImpl())"
876 " but this function create_DfDp_op_impl(...) has not been overridden"
877 " to create such an object!"
879 return Teuchos::null;
883 template<
class Scalar>
884 RCP<LinearOpBase<Scalar> >
885 ModelEvaluatorDefaultBase<Scalar>::create_DgDx_dot_op_impl(
int j)
const
887 typedef ModelEvaluatorBase MEB;
888 MEB::OutArgs<Scalar> outArgs = this->createOutArgsImpl();
890 outArgs.supports(MEB::OUT_ARG_DgDx_dot,j).supports(MEB::DERIV_LINEAR_OP),
892 "Error, The ModelEvaluator subclass "<<this->description()<<
" says that it"
893 " supports the LinearOpBase form of DgDx_dot("<<j<<
") (as determined from"
894 " its OutArgs object created by createOutArgsImpl())"
895 " but this function create_DgDx_dot_op_impl(...) has not been overridden"
896 " to create such an object!"
898 return Teuchos::null;
902 template<
class Scalar>
903 RCP<LinearOpBase<Scalar> >
904 ModelEvaluatorDefaultBase<Scalar>::create_DgDx_op_impl(
int j)
const
906 typedef ModelEvaluatorBase MEB;
907 MEB::OutArgs<Scalar> outArgs = this->createOutArgsImpl();
909 outArgs.supports(MEB::OUT_ARG_DgDx,j).supports(MEB::DERIV_LINEAR_OP),
911 "Error, The ModelEvaluator subclass "<<this->description()<<
" says that it"
912 " supports the LinearOpBase form of DgDx("<<j<<
") (as determined from"
913 " its OutArgs object created by createOutArgsImpl())"
914 " but this function create_DgDx_op_impl(...) has not been overridden"
915 " to create such an object!"
917 return Teuchos::null;
921 template<
class Scalar>
922 RCP<LinearOpBase<Scalar> >
923 ModelEvaluatorDefaultBase<Scalar>::create_DgDp_op_impl(
int j,
int l)
const
925 typedef ModelEvaluatorBase MEB;
926 MEB::OutArgs<Scalar> outArgs = this->createOutArgsImpl();
928 outArgs.supports(MEB::OUT_ARG_DgDp,j,l).supports(MEB::DERIV_LINEAR_OP),
930 "Error, The ModelEvaluator subclass "<<this->description()<<
" says that it"
931 " supports the LinearOpBase form of DgDp("<<j<<
","<<l<<
")"
932 " (as determined from its OutArgs object created by createOutArgsImpl())"
933 " but this function create_DgDp_op_impl(...) has not been overridden"
934 " to create such an object!"
936 return Teuchos::null;
940 template<
class Scalar>
941 RCP<const VectorSpaceBase<Scalar> >
944 return this->get_f_space();
947 template<
class Scalar>
951 return this->get_g_space(j);
954 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
956 template<
class Scalar>
960 return Teuchos::null;
963 template<
class Scalar>
964 RCP<LinearOpBase<Scalar> >
965 ModelEvaluatorDefaultBase<Scalar>::create_hess_f_xp(
int l)
const
967 return Teuchos::null;
970 template<
class Scalar>
971 RCP<LinearOpBase<Scalar> >
972 ModelEvaluatorDefaultBase<Scalar>::create_hess_f_pp(
int l1,
int l2 )
const
974 return Teuchos::null;
977 template<
class Scalar>
978 RCP<LinearOpBase<Scalar> >
979 ModelEvaluatorDefaultBase<Scalar>::create_hess_g_xx(
int j)
const
981 return Teuchos::null;
984 template<
class Scalar>
985 RCP<LinearOpBase<Scalar> >
986 ModelEvaluatorDefaultBase<Scalar>::create_hess_g_xp(
int j,
int l )
const
988 return Teuchos::null;
991 template<
class Scalar>
992 RCP<LinearOpBase<Scalar> >
993 ModelEvaluatorDefaultBase<Scalar>::create_hess_g_pp(
int j,
int l1,
int l2 )
const
995 return Teuchos::null;
998 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1003 template<
class Scalar>
1005 :isInitialized_(false), default_W_support_(false)
1012 template<
class Scalar>
1015 if (!isInitialized_)
1020 template<
class Scalar>
1021 void ModelEvaluatorDefaultBase<Scalar>::assert_l(
const int l)
const
1027 template<
class Scalar>
1028 void ModelEvaluatorDefaultBase<Scalar>::assert_j(
const int j)
const
1037 template<
class Scalar>
1038 ModelEvaluatorDefaultBaseTypes::DefaultDerivLinearOpSupport
1039 ModelEvaluatorDefaultBase<Scalar>::determineDefaultDerivLinearOpSupport(
1040 const ModelEvaluatorBase::DerivativeSupport &derivSupportImpl
1043 typedef ModelEvaluatorBase MEB;
1046 derivSupportImpl.supports(MEB::DERIV_MV_BY_COL)
1048 derivSupportImpl.supports(MEB::DERIV_TRANS_MV_BY_ROW)
1051 !derivSupportImpl.supports(MEB::DERIV_LINEAR_OP)
1054 return DefaultDerivLinearOpSupport(
1055 derivSupportImpl.supports(MEB::DERIV_MV_BY_COL)
1056 ? MEB::DERIV_MV_BY_COL
1057 : MEB::DERIV_TRANS_MV_BY_ROW
1060 return DefaultDerivLinearOpSupport();
1064 template<
class Scalar>
1065 RCP<LinearOpBase<Scalar> >
1066 ModelEvaluatorDefaultBase<Scalar>::createDefaultLinearOp(
1067 const DefaultDerivLinearOpSupport &defaultLinearOpSupport,
1068 const RCP<
const VectorSpaceBase<Scalar> > &fnc_space,
1069 const RCP<
const VectorSpaceBase<Scalar> > &var_space
1072 using Teuchos::rcp_implicit_cast;
1073 typedef LinearOpBase<Scalar> LOB;
1074 typedef ModelEvaluatorBase MEB;
1075 switch(defaultLinearOpSupport.mvImplOrientation()) {
1076 case MEB::DERIV_MV_BY_COL:
1078 return createMembers(fnc_space, var_space->dim());
1079 case MEB::DERIV_TRANS_MV_BY_ROW:
1081 return nonconstAdjoint<Scalar>(
1082 rcp_implicit_cast<LOB>(createMembers(var_space, fnc_space->dim()))
1084 #ifdef TEUCHOS_DEBUG
1089 return Teuchos::null;
1093 template<
class Scalar>
1094 ModelEvaluatorBase::DerivativeSupport
1095 ModelEvaluatorDefaultBase<Scalar>::updateDefaultLinearOpSupport(
1096 const ModelEvaluatorBase::DerivativeSupport &derivSupportImpl,
1097 const DefaultDerivLinearOpSupport &defaultLinearOpSupport
1100 typedef ModelEvaluatorBase MEB;
1101 MEB::DerivativeSupport derivSupport = derivSupportImpl;
1102 if (defaultLinearOpSupport.provideDefaultLinearOp())
1103 derivSupport.plus(MEB::DERIV_LINEAR_OP);
1104 return derivSupport;
1108 template<
class Scalar>
1109 ModelEvaluatorBase::Derivative<Scalar>
1110 ModelEvaluatorDefaultBase<Scalar>::getOutArgImplForDefaultLinearOpSupport(
1111 const ModelEvaluatorBase::Derivative<Scalar> &deriv,
1112 const DefaultDerivLinearOpSupport &defaultLinearOpSupport
1116 using Teuchos::rcp_dynamic_cast;
1117 typedef ModelEvaluatorBase MEB;
1118 typedef MultiVectorBase<Scalar> MVB;
1119 typedef ScaledAdjointLinearOpBase<Scalar> SALOB;
1124 if (
is_null(deriv.getLinearOp()))
1129 switch(defaultLinearOpSupport.mvImplOrientation()) {
1130 case MEB::DERIV_MV_BY_COL: {
1131 return MEB::Derivative<Scalar>(
1132 rcp_dynamic_cast<MVB>(deriv.getLinearOp(),
true),
1133 MEB::DERIV_MV_BY_COL
1136 case MEB::DERIV_TRANS_MV_BY_ROW: {
1137 return MEB::Derivative<Scalar>(
1138 rcp_dynamic_cast<MVB>(
1139 rcp_dynamic_cast<SALOB>(deriv.getLinearOp(),
true)->getNonconstOrigOp()
1141 MEB::DERIV_TRANS_MV_BY_ROW
1144 #ifdef TEUCHOS_DEBUG
1150 return ModelEvaluatorBase::Derivative<Scalar>();
1155 template<
class Scalar>
1156 ModelEvaluatorDefaultBaseTypes::DefaultDerivMvAdjointSupport
1157 ModelEvaluatorDefaultBase<Scalar>::determineDefaultDerivMvAdjointSupport(
1158 const ModelEvaluatorBase::DerivativeSupport &derivSupportImpl,
1159 const VectorSpaceBase<Scalar> &fnc_space,
1160 const VectorSpaceBase<Scalar> &var_space
1163 typedef ModelEvaluatorBase MEB;
1166 const bool implSupportsMv =
1167 ( derivSupportImpl.supports(MEB::DERIV_MV_BY_COL)
1168 || derivSupportImpl.supports(MEB::DERIV_TRANS_MV_BY_ROW) );
1169 const bool implLacksMvOrientSupport =
1170 ( !derivSupportImpl.supports(MEB::DERIV_MV_BY_COL)
1171 || !derivSupportImpl.supports(MEB::DERIV_TRANS_MV_BY_ROW) );
1172 const bool bothSpacesHaveInCoreViews =
1173 ( fnc_space.hasInCoreView() && var_space.hasInCoreView() );
1174 if ( implSupportsMv && implLacksMvOrientSupport && bothSpacesHaveInCoreViews ) {
1175 return DefaultDerivMvAdjointSupport(
1176 derivSupportImpl.supports(MEB::DERIV_MV_BY_COL)
1177 ? MEB::DERIV_TRANS_MV_BY_ROW
1178 : MEB::DERIV_MV_BY_COL
1182 return DefaultDerivMvAdjointSupport();
1186 template<
class Scalar>
1187 ModelEvaluatorBase::DerivativeSupport
1188 ModelEvaluatorDefaultBase<Scalar>::updateDefaultDerivMvAdjointSupport(
1189 const ModelEvaluatorBase::DerivativeSupport &derivSupportImpl,
1190 const DefaultDerivMvAdjointSupport &defaultMvAdjointSupport
1193 typedef ModelEvaluatorBase MEB;
1194 MEB::DerivativeSupport derivSupport = derivSupportImpl;
1195 if (defaultMvAdjointSupport.provideDefaultAdjoint())
1196 derivSupport.plus(defaultMvAdjointSupport.mvAdjointCopyOrientation());
1197 return derivSupport;
1204 #endif // THYRA_MODEL_EVALUATOR_DEFAULT_BASE_HPP
RCP< const T > getConst() const
int Ng() const
Return the number of axillary response functions g(j)(...) supported (Ng >= 0).
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
RCP< LinearOpWithSolveBase< Scalar > > create_W() const
Default base class for concrete model evaluators.
bool is_null(const boost::shared_ptr< T > &p)
RCP< LinearOpBase< Scalar > > create_DfDp_op(int l) const
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...
Derivative< Scalar > get_DfDp(int l) const
Precondition: supports(OUT_ARG_DfDp,l)==true.
EDerivativeMultiVectorOrientation
void evalModel(const ModelEvaluatorBase::InArgs< Scalar > &inArgs, const ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual RCP< const VectorSpaceBase< Scalar > > get_g_multiplier_space(int j) const
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
ModelEvaluatorDefaultBase()
Abstract interface for objects that represent a space for vectors.
bool supports(EOutArgsMembers arg) const
Determine if an input argument is supported or not.
Derivative< Scalar > get_DgDp(int j, int l) const
Precondition: supports(OUT_ARG_DgDp,j,l)==true.
void initializeDefaultBase()
Function called by subclasses to fully initialize this object on any important change.
#define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(index, lower_inclusive, upper_exclusive)
int Np() const
Return the number of parameter subvectors p(l) supported (Np >= 0).
RCP< LinearOpBase< Scalar > > create_DgDx_op(int j) const
virtual RCP< const VectorSpaceBase< Scalar > > get_f_multiplier_space() const
Base class for all linear operators.
RCP< LinearOpBase< Scalar > > create_DgDx_dot_op(int j) const
Base subclass for ModelEvaluator that defines some basic types.
void push_back(const value_type &x)
RCP< LinearOpWithSolveBase< Scalar > > get_W() const
Precondition: supports(OUT_ARG_W)==true.
void resetDefaultBase()
Sets the the DefaultBase to an uninitialized state, forcing lazy initialization when needed...
Derivative< Scalar > get_DgDx_dot(int j) const
Precondition: supports(OUT_ARG_DgDx_dot,j)==true.
Determines the forms of a general derivative that are supported.
ModelEvaluatorBase::OutArgs< Scalar > createOutArgs() const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Derivative< Scalar > get_DgDx(int j) const
Precondition: supports(OUT_ARG_DgDx,j)==true.
RCP< LinearOpBase< Scalar > > create_DgDp_op(int j, int l) const
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...