Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_ModelEvaluatorBase_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_MODEL_EVALUATOR_BASE_DECL_HPP
11 #define THYRA_MODEL_EVALUATOR_BASE_DECL_HPP
12 
13 
14 #include "Thyra_LinearOpWithSolveBase.hpp"
15 #include "Teuchos_Describable.hpp"
16 #include "Teuchos_any.hpp"
17 #include "Teuchos_Assert.hpp"
18 
19 #ifdef HAVE_THYRA_ME_POLYNOMIAL
20 # include "Teuchos_Polynomial.hpp"
21 #endif
22 
23 namespace Stokhos {
24  class ProductEpetraVector;
25  class ProductEpetraMultiVector;
26  class ProductEpetraOperator;
27 }
28 
29 namespace Thyra {
30 
31 
52  : virtual public Teuchos::Describable,
53  virtual public Teuchos::VerboseObject<ModelEvaluatorBase>
54 {
55 public:
56 
59 
75  };
77  static const int NUM_E_IN_ARGS_MEMBERS=13;
78 
80  enum EInArgs_p_mp {
82  };
83 
126  template<class Scalar>
127  class InArgs : public Teuchos::Describable {
128  public:
132  InArgs();
135  int Np() const;
138  int Ng() const;
140  bool supports(EInArgsMembers arg) const;
142  void set_x_dot_dot( const RCP<const VectorBase<Scalar> > &x_dot_dot );
146  void set_x_dot( const RCP<const VectorBase<Scalar> > &x_dot );
150  void set_x( const RCP<const VectorBase<Scalar> > &x );
153 
155  void set_x_direction( const RCP<const MultiVectorBase<Scalar> > &x_direction );
157  void set_p_direction( int l, const RCP<const MultiVectorBase<Scalar> > &p_direction_l );
162 
164  void set_f_multiplier( const RCP<const VectorBase<Scalar> > &f_multiplier );
168  void set_g_multiplier( int j, const RCP<const VectorBase<Scalar> > &g_multiplier );
171 
173  template<typename ObjectType>
174  bool supports() const;
176  template<typename ObjectType>
177  void set(const RCP<const ObjectType>& uo);
179  template<typename ObjectType>
180  RCP<const ObjectType> get() const;
181 
182 #ifdef HAVE_THYRA_ME_POLYNOMIAL
183 
184  void set_x_poly(
185  const RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > &x_poly );
189  void set_x_dot_poly(
190  const RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > &x_dot_poly );
192  RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > get_x_dot_poly() const;
193 #endif // HAVE_THYRA_ME_POLYNOMIAL
194 
195  void set_p( int l, const RCP<const VectorBase<Scalar> > &p_l );
197  RCP<const VectorBase<Scalar> > get_p(int l) const;
198 
199 
204 
209 
210  void set_p_mp( int l, const RCP<const Stokhos::ProductEpetraVector > &p_mp_l );
211  RCP<const Stokhos::ProductEpetraVector > get_p_mp(int l) const;
213  bool supports(EInArgs_p_mp arg, int l) const;
214 
215 
217  void set_t( ScalarMag t );
219  ScalarMag get_t() const;
221  void set_alpha( Scalar alpha );
223  Scalar get_alpha() const;
225  void set_beta( Scalar beta );
227  Scalar get_beta() const;
229  void set_W_x_dot_dot_coeff( Scalar W_x_dot_dot_coeff );
231  Scalar get_W_x_dot_dot_coeff() const;
233  void set_step_size( Scalar step_size);
235  Scalar get_step_size() const;
237  void set_stage_number( Scalar stage_number);
239  Scalar get_stage_number() const;
242  void setArgs(
243  const InArgs<Scalar>& inArgs, bool ignoreUnsupported = false,
244  bool cloneObjects = false
245  );
247  void assertSameSupport( const InArgs<Scalar> &inArgs ) const;
249  std::string modelEvalDescription() const;
251  std::string description() const;
254  void describe(
255  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
256  ) const;
257  protected:
259  void _setModelEvalDescription( const std::string &modelEvalDescription );
261  void _set_Np_Ng(int Np, int Ng);
263  void _setSupports( EInArgsMembers arg, bool supports );
265  void _setSupports( EInArgs_p_mp arg, int l, bool supports );
267  void _setSupports( const InArgs<Scalar>& inputInArgs, const int Np );
269  template<typename ObjectType>
270  void _setSupports( const bool supports );
273  private:
274  // types
277  // data
278  std::string modelEvalDescription_;
279  RCP<const VectorBase<Scalar> > x_dot_dot_;
282  RCP<const MultiVectorBase<Scalar> > x_direction_;
285 
286  RCP<const VectorBase<Scalar> > f_multiplier_;
287  p_t g_multiplier_;
289 #ifdef HAVE_THYRA_ME_POLYNOMIAL
292 #endif // HAVE_THYRA_ME_POLYNOMIAL
293  p_t p_;
294  p_direction_t p_direction_;
295  ScalarMag t_;
296  Scalar alpha_;
297  Scalar beta_;
298  Scalar W_x_dot_dot_coeff_;
299  Scalar step_size_;
300  Scalar stage_number_;
301  bool supports_[NUM_E_IN_ARGS_MEMBERS];
302  Teuchos::Array<bool> supports_p_mp_; //Np
303  // functions
304  void assert_supports(EInArgsMembers arg) const;
305  void assert_supports(EInArgs_p_mp arg, int l) const;
306  void assert_l(int l) const;
307  void assert_j(int j) const;
308 
309  std::map<std::string,Teuchos::any> extended_inargs_;
310  };
311 
313  enum EEvalType {
314  EVAL_TYPE_EXACT = 0,
317  };
318 
325  template<class ObjType>
326  class Evaluation : public RCP<ObjType> {
327  public:
330  : evalType_(EVAL_TYPE_EXACT) {}
332  Evaluation() : evalType_(EVAL_TYPE_EXACT) {}
334  Evaluation( const RCP<ObjType> &obj )
335  : RCP<ObjType>(obj), evalType_(EVAL_TYPE_EXACT) {}
337  Evaluation( const RCP<ObjType> &obj, EEvalType evalType )
338  : RCP<ObjType>(obj), evalType_(evalType) {}
340  EEvalType getType() const { return evalType_; }
342  void reset( const RCP<ObjType> &obj, EEvalType evalType )
343  { this->operator=(obj); evalType_ = evalType; }
344  private:
345  EEvalType evalType_;
346  };
347 
354  };
355 
359  };
360 
364  public:
367  :supportsLinearOp_(false), supportsMVByCol_(false), supportsTransMVByRow_(false)
368  {}
371  :supportsLinearOp_(true), supportsMVByCol_(false), supportsTransMVByRow_(false)
372  {}
375  :supportsLinearOp_(false), supportsMVByCol_(mvOrientation==DERIV_MV_BY_COL)
376  ,supportsTransMVByRow_(mvOrientation==DERIV_TRANS_MV_BY_ROW)
377  {}
380  { supportsLinearOp_ = true; return *this; }
383  {
384  switch(mvOrientation) {
385  case DERIV_MV_BY_COL: supportsMVByCol_ = true; break;
386  case DERIV_TRANS_MV_BY_ROW: supportsTransMVByRow_ = true; break;
387  default: TEUCHOS_TEST_FOR_EXCEPT(true);
388  }
389  return *this;
390  }
392  bool none() const
393  { return ( !supportsLinearOp_ && !supportsMVByCol_ && !supportsTransMVByRow_ ); }
396  { return supportsLinearOp_; }
398  bool supports(EDerivativeMultiVectorOrientation mvOrientation) const
399  {
400  switch(mvOrientation) {
401  case DERIV_MV_BY_COL: return supportsMVByCol_;
402  case DERIV_TRANS_MV_BY_ROW: return supportsTransMVByRow_;
403  default: TEUCHOS_TEST_FOR_EXCEPT(true);
404  }
406  }
408  bool isSameSupport(const DerivativeSupport &derivSupport) const
409  {
410  return (
411  supportsLinearOp_ == derivSupport.supportsLinearOp_
412  && supportsMVByCol_ == derivSupport.supportsMVByCol_
413  && supportsTransMVByRow_ == derivSupport.supportsTransMVByRow_
414  );
415  }
417  std::string description() const;
418  private:
419  bool supportsLinearOp_;
420  bool supportsMVByCol_;
421  bool supportsTransMVByRow_;
422  public:
423  };
424 
430  };
431 
433  enum ERankStatus {
437  };
438 
452  {}
455  EDerivativeLinearity in_linearity, ERankStatus in_rank,
456  bool in_supportsAdjoint
457  )
458  :linearity(in_linearity),rank(in_rank),
459  supportsAdjoint(in_supportsAdjoint)
460  {}
461  };
462 
466  template<class Scalar>
468  public:
471  :orientation_(DERIV_MV_BY_COL)
472  {}
475  const RCP<MultiVectorBase<Scalar> > &mv
477  ) : mv_(mv.assert_not_null()), orientation_(orientation) {}
480  { orientation_ = orientation; };
483  { mv_.assert_not_null(); return *this; }
486  { return mv_; }
489  { return orientation_; }
491  std::string description() const;
493  void describe(
494  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
495  ) const;
496  private:
499  };
500 
504  template<class Scalar>
505  class Derivative {
506  public:
511  : lo_(lo.assert_not_null()) {}
514  const RCP<MultiVectorBase<Scalar> > &mv,
516  ) : dmv_(mv,orientation) {}
519  : dmv_(dmv) {}
521  bool isEmpty() const
522  { return ( lo_.get()==NULL && dmv_.getMultiVector().get()==NULL ); }
525  { dmv_.assert_not_null(); lo_.assert_not_null(); return *this; }
528  { return lo_; }
531  { return dmv_.getMultiVector(); }
534  { return dmv_.getOrientation(); }
537  { return dmv_; }
541  bool isSupportedBy( const DerivativeSupport &derivSupport ) const
542  {
543  // If there is not derivative support then we will return false!
544  if (derivSupport.none())
545  return false;
546  if (!is_null(getMultiVector())) {
547  return derivSupport.supports(getMultiVectorOrientation());
548  }
549  else if(!is_null(getLinearOp())) {
550  return derivSupport.supports(DERIV_LINEAR_OP);
551  }
552  // If nothing is set then of course we support that!
553  return true;
554  }
556  std::string description() const;
558  void describe(
559  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
560  ) const;
561  private:
564  };
565 
570  public:
573  :orientation_(DERIV_MV_BY_COL)
574  {}
579  ,const Teuchos::Array<int> &paramIndexes = Teuchos::Array<int>()
580  ) : mv_(mv.assert_not_null()), orientation_(orientation), paramIndexes_(paramIndexes) {}
583  { orientation_ = orientation; };
586  { mv_.assert_not_null(); return *this; }
589  { return mv_; }
592  { return orientation_; }
595  { return paramIndexes_; }
597  std::string description() const {return "\n";}
599  void describe(
600  Teuchos::FancyOStream &/* out */, const Teuchos::EVerbosityLevel /* verbLevel */
601  ) const {}
602  private:
605  Teuchos::Array<int> paramIndexes_;
606  };
607 
611  class MPDerivative {
612  public:
617  : lo_(lo.assert_not_null()) {}
622  ) : dmv_(mv,orientation) {}
625  : dmv_(dmv) {}
627  bool isEmpty() const
628  { return ( lo_.get()==NULL && dmv_.getMultiVector().get()==NULL ); }
631  { dmv_.assert_not_null(); lo_.assert_not_null(); return *this; }
634  { return lo_; }
637  { return dmv_.getMultiVector(); }
640  { return dmv_.getOrientation(); }
643  { return dmv_; }
647  bool isSupportedBy( const DerivativeSupport &derivSupport ) const
648  {
649  // If there is not derivative support then we will return false!
650  if (derivSupport.none())
651  return false;
652  if (!is_null(getMultiVector())) {
653  return derivSupport.supports(getMultiVectorOrientation());
654  }
655  else if(!is_null(getLinearOp())) {
656  return derivSupport.supports(DERIV_LINEAR_OP);
657  }
658  // If nothing is set then of course we support that!
659  return true;
660  }
662  std::string description() const {return "\n";}
664  void describe(
665  Teuchos::FancyOStream &/* out */, const Teuchos::EVerbosityLevel /* verbLevel */
666  ) const {}
667  private:
670  };
671 
681  };
683  static const int NUM_E_OUT_ARGS_MEMBERS=7;
684 
688  };
689 
693  };
694 
698  };
699 
703  };
704 
705 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
706 
707  enum EOutArgs_hess_vec_prod_f_xx {
708  OUT_ARG_hess_vec_prod_f_xx
709  };
710 
712  enum EOutArgs_hess_vec_prod_f_xp {
713  OUT_ARG_hess_vec_prod_f_xp
714  };
715 
717  enum EOutArgs_hess_vec_prod_f_px {
718  OUT_ARG_hess_vec_prod_f_px
719  };
720 
722  enum EOutArgs_hess_vec_prod_f_pp {
723  OUT_ARG_hess_vec_prod_f_pp
724  };
725 
727  enum EOutArgs_hess_vec_prod_g_xx {
728  OUT_ARG_hess_vec_prod_g_xx
729  };
730 
732  enum EOutArgs_hess_vec_prod_g_xp {
733  OUT_ARG_hess_vec_prod_g_xp
734  };
735 
737  enum EOutArgs_hess_vec_prod_g_px {
738  OUT_ARG_hess_vec_prod_g_px
739  };
740 
742  enum EOutArgs_hess_vec_prod_g_pp {
743  OUT_ARG_hess_vec_prod_g_pp
744  };
745 
747  enum EOutArgs_hess_f_xx {
748  OUT_ARG_hess_f_xx
749  };
750 
752  enum EOutArgs_hess_f_xp {
753  OUT_ARG_hess_f_xp
754  };
755 
757  enum EOutArgs_hess_f_pp {
758  OUT_ARG_hess_f_pp
759  };
760 
762  enum EOutArgs_hess_g_xx {
763  OUT_ARG_hess_g_xx
764  };
765 
767  enum EOutArgs_hess_g_xp {
768  OUT_ARG_hess_g_xp
769  };
770 
772  enum EOutArgs_hess_g_pp {
773  OUT_ARG_hess_g_pp
774  };
775 
777  enum EOutArgs_H_xx {
778  OUT_ARG_H_xx
779  };
780 
782  enum EOutArgs_H_xp {
783  OUT_ARG_H_xp
784  };
785 
787  enum EOutArgs_H_pp {
788  OUT_ARG_H_pp
789  };
790 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
791 
795  };
796 
800  };
801 
805  };
806 
810  };
811 
815  };
816 
869  template<class Scalar>
870  class OutArgs : public Teuchos::Describable {
871  public:
873  OutArgs();
876  int Np() const;
879  int Ng() const;
881  bool supports(EOutArgsMembers arg) const;
884  const DerivativeSupport& supports(EOutArgsDfDp arg, int l) const;
887  const DerivativeSupport& supports(EOutArgsDgDx_dot arg, int j) const;
890  const DerivativeSupport& supports(EOutArgsDgDx arg, int j) const;
893  const DerivativeSupport& supports(EOutArgsDgDp arg, int j, int l) const;
894 
895 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
896 
897  bool supports(EOutArgs_hess_vec_prod_f_xx arg) const;
900  bool supports(EOutArgs_hess_vec_prod_f_xp arg, int l) const;
903  bool supports(EOutArgs_hess_vec_prod_f_px arg, int l) const;
906  bool supports(EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2) const;
909  bool supports(EOutArgs_hess_vec_prod_g_xx arg, int j) const;
912  bool supports(EOutArgs_hess_vec_prod_g_xp arg, int j, int l) const;
915  bool supports(EOutArgs_hess_vec_prod_g_px arg, int j, int l) const;
918  bool supports(EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2) const;
920  bool supports(EOutArgs_hess_f_xx arg) const;
923  bool supports(EOutArgs_hess_f_xp arg, int l) const;
926  bool supports(EOutArgs_hess_f_pp arg, int l1, int l2) const;
929  bool supports(EOutArgs_hess_g_xx arg, int j) const;
932  bool supports(EOutArgs_hess_g_xp arg, int j, int l) const;
935  bool supports(EOutArgs_hess_g_pp arg, int j, int l1, int l2) const;
937  bool supports(EOutArgs_H_xx arg) const;
940  bool supports(EOutArgs_H_xp arg, int l) const;
943  bool supports(EOutArgs_H_pp arg, int l1, int l2) const;
944 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
945 
947  void set_f( const Evaluation<VectorBase<Scalar> > &f );
951  void set_g( int j, const Evaluation<VectorBase<Scalar> > &g_j );
953  Evaluation<VectorBase<Scalar> > get_g(int j) const;
955  void set_W( const RCP<LinearOpWithSolveBase<Scalar> > &W );
958 
960  template<typename ObjectType>
961  bool supports() const;
963  template<typename ObjectType>
964  void set(const RCP<const ObjectType>& uo);
966  template<typename ObjectType>
967  RCP<const ObjectType> get() const;
968 
969  const DerivativeSupport& supports(EOutArgsDfDp_mp arg, int l) const;
970  bool supports(EOutArgs_g_mp arg, int j) const;
971  const DerivativeSupport& supports(EOutArgsDgDx_dot_mp arg, int j) const;
972  const DerivativeSupport& supports(EOutArgsDgDx_mp arg, int j) const;
973  const DerivativeSupport& supports(EOutArgsDgDp_mp arg, int j, int l) const;
975  void set_f_mp( const RCP<Stokhos::ProductEpetraVector> &f_mp );
979  void set_g_mp( int j, const RCP<Stokhos::ProductEpetraVector> &g_mp_j );
983  void set_W_mp( const RCP<Stokhos::ProductEpetraOperator> &W_mp );
986 
988  void set_W_op( const RCP<LinearOpBase<Scalar> > &W_op );
992  void set_W_prec( const RCP<PreconditionerBase<Scalar> > &W_prec );
999  void set_DfDp(int l, const Derivative<Scalar> &DfDp_l);
1001  Derivative<Scalar> get_DfDp(int l) const;
1006  void set_DgDx_dot(int j, const Derivative<Scalar> &DgDx_dot_j);
1008  Derivative<Scalar> get_DgDx_dot(int j) const;
1013  void set_DgDx(int j, const Derivative<Scalar> &DgDx_j);
1015  Derivative<Scalar> get_DgDx(int j) const;
1020  void set_DgDp( int j, int l, const Derivative<Scalar> &DgDp_j_l );
1022  Derivative<Scalar> get_DgDp(int j, int l) const;
1025  DerivativeProperties get_DgDp_properties(int j, int l) const;
1026 
1027 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1028 
1030  void set_hess_vec_prod_f_xx(const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_xx);
1032  void set_hess_vec_prod_f_xp(int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_xp_l);
1034  void set_hess_vec_prod_f_px(int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_px_l);
1036  void set_hess_vec_prod_f_pp(int l1, int l2, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_pp_l1_l2);
1037 
1039  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_f_xx() const;
1041  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_f_xp(int l) const;
1043  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_f_px(int l) const;
1045  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_f_pp(int l1, int l2) const;
1046 
1048  void set_hess_vec_prod_g_xx(int j, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_xx_j);
1050  void set_hess_vec_prod_g_xp(int j, int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_xp_j_l);
1052  void set_hess_vec_prod_g_px(int j, int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_px_j_l);
1054  void set_hess_vec_prod_g_pp(int j, int l1, int l2, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_pp_j_l1_l2);
1055 
1057  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_g_xx(int j) const;
1059  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_g_xp(int j, int l) const;
1061  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_g_px(int j, int l) const;
1063  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_g_pp(int j, int l1, int l2) const;
1064 
1066  void set_hess_f_xx(const RCP<LinearOpBase<Scalar> > &hess_f_xx);
1068  void set_hess_f_xp(int l, const RCP<LinearOpBase<Scalar> > &hess_f_xp_l);
1070  void set_hess_f_pp(int l1, int l2, const RCP<LinearOpBase<Scalar> > &hess_f_pp_l1_l2);
1072  void set_hess_g_xx(int j, const RCP<LinearOpBase<Scalar> > &hess_g_xx_j);
1074  void set_hess_g_xp(int j, int l, const RCP<LinearOpBase<Scalar> > &hess_g_xp_j_l);
1076  void set_hess_g_pp(int j, int l1, int l2, const RCP<LinearOpBase<Scalar> > &hess_g_pp_j_l1_l2);
1078  void set_H_xx(const RCP<LinearOpBase<Scalar> > &H_xx);
1080  void set_H_xp(int l, const RCP<LinearOpBase<Scalar> > &H_xp_l);
1082  void set_H_pp(int l1, int l2, const RCP<LinearOpBase<Scalar> > &H_pp_l1_l2);
1083 
1085  RCP<LinearOpBase<Scalar> > get_hess_f_xx() const;
1087  RCP<LinearOpBase<Scalar> > get_hess_f_xp(int l) const;
1089  RCP<LinearOpBase<Scalar> > get_hess_f_pp(int l1, int l2) const;
1091  RCP<LinearOpBase<Scalar> > get_hess_g_xx(int j) const;
1093  RCP<LinearOpBase<Scalar> > get_hess_g_xp(int j, int l) const;
1095  RCP<LinearOpBase<Scalar> > get_hess_g_pp(int j, int l1, int l2) const;
1097  RCP<LinearOpBase<Scalar> > get_H_xx() const;
1099  RCP<LinearOpBase<Scalar> > get_H_xp(int l) const;
1101  RCP<LinearOpBase<Scalar> > get_H_pp(int l1, int l2) const;
1102 
1103 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1104 
1105  void set_DfDp_mp(int l, const MPDerivative &DfDp_mp_l);
1106  MPDerivative get_DfDp_mp(int l) const;
1107  DerivativeProperties get_DfDp_mp_properties(int l) const;
1108  void set_DgDx_dot_mp(int j, const MPDerivative &DgDx_dot_mp_j);
1109  MPDerivative get_DgDx_dot_mp(int j) const;
1110  DerivativeProperties get_DgDx_dot_mp_properties(int j) const;
1111  void set_DgDx_mp(int j, const MPDerivative &DgDx_mp_j);
1112  MPDerivative get_DgDx_mp(int j) const;
1113  DerivativeProperties get_DgDx_mp_properties(int j) const;
1114  void set_DgDp_mp( int j, int l, const MPDerivative &DgDp_mp_j_l );
1115  MPDerivative get_DgDp_mp(int j, int l) const;
1116  DerivativeProperties get_DgDp_mp_properties(int j, int l) const;
1117 
1118 #ifdef HAVE_THYRA_ME_POLYNOMIAL
1119 
1120  void set_f_poly( const RCP<Teuchos::Polynomial< VectorBase<Scalar> > > &f_poly );
1122  RCP<Teuchos::Polynomial< VectorBase<Scalar> > > get_f_poly() const;
1123 #endif // HAVE_THYRA_ME_POLYNOMIAL
1124 
1129  void setArgs( const OutArgs<Scalar>& outArgs, bool ignoreUnsupported = false );
1141  void setFailed() const;
1147  bool isFailed() const;
1149  bool isEmpty() const;
1151  void assertSameSupport( const OutArgs<Scalar> &outArgs ) const;
1153  std::string modelEvalDescription() const;
1155  std::string description() const;
1158  void describe(
1159  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
1160  ) const;
1161  protected:
1163  void _setModelEvalDescription( const std::string &modelEvalDescription );
1165  void _set_Np_Ng(int Np, int Ng);
1167  void _setSupports( EOutArgsMembers arg, bool supports );
1169  template<typename ObjectType>
1170  void _setSupports( const bool supports );
1172  void _setSupports( EOutArgsDfDp arg, int l, const DerivativeSupport& );
1174  void _setSupports( EOutArgsDgDx_dot arg, int j, const DerivativeSupport& );
1176  void _setSupports( EOutArgsDgDx arg, int j, const DerivativeSupport& );
1178  void _setSupports( EOutArgsDgDp arg, int j, int l, const DerivativeSupport& );
1179 
1180 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1181 
1183  void _setSupports( EOutArgs_hess_vec_prod_f_xx arg, bool supports );
1185  void _setSupports( EOutArgs_hess_vec_prod_f_xp arg, int l, bool supports );
1187  void _setSupports( EOutArgs_hess_vec_prod_f_px arg, int l, bool supports );
1189  void _setSupports( EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2, bool supports );
1191  void _setSupports( EOutArgs_hess_vec_prod_g_xx arg, int j, bool supports );
1193  void _setSupports( EOutArgs_hess_vec_prod_g_xp arg, int j, int l, bool supports );
1195  void _setSupports( EOutArgs_hess_vec_prod_g_px arg, int j, int l, bool supports );
1197  void _setSupports( EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2, bool supports );
1198 
1200  void _setSupports( EOutArgs_hess_f_xx arg, bool supports );
1202  void _setSupports( EOutArgs_hess_f_xp arg, int l, bool supports );
1204  void _setSupports( EOutArgs_hess_f_pp arg, int l1, int l2, bool supports );
1206  void _setSupports( EOutArgs_hess_g_xx arg, int j, bool supports );
1208  void _setSupports( EOutArgs_hess_g_xp arg, int j, int l, bool supports );
1210  void _setSupports( EOutArgs_hess_g_pp arg, int j, int l1, int l2, bool supports );
1212  void _setSupports( EOutArgs_H_xx arg, bool supports );
1214  void _setSupports( EOutArgs_H_xp arg, int l, bool supports );
1216  void _setSupports( EOutArgs_H_pp arg, int l1, int l2, bool supports );
1217 
1218 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1219 
1220  void _setSupports( EOutArgs_g_mp arg, int j, bool supports );
1221  void _setSupports( EOutArgsDfDp_mp arg, int l, const DerivativeSupport& );
1222  void _setSupports( EOutArgsDgDx_dot_mp arg, int j, const DerivativeSupport& );
1223  void _setSupports( EOutArgsDgDx_mp arg, int j, const DerivativeSupport& );
1224  void _setSupports( EOutArgsDgDp_mp arg, int j, int l, const DerivativeSupport& );
1225 
1227  void _set_W_properties( const DerivativeProperties &properties );
1229  void _set_DfDp_properties( int l, const DerivativeProperties &properties );
1231  void _set_DgDx_dot_properties( int j, const DerivativeProperties &properties );
1233  void _set_DgDx_properties( int j, const DerivativeProperties &properties );
1235  void _set_DgDp_properties( int j, int l, const DerivativeProperties &properties );
1236 
1237  void _set_DfDp_mp_properties( int l, const DerivativeProperties &properties );
1238  void _set_DgDx_dot_mp_properties( int j, const DerivativeProperties &properties );
1239  void _set_DgDx_mp_properties( int j, const DerivativeProperties &properties );
1240  void _set_DgDp_mp_properties( int j, int l, const DerivativeProperties &properties );
1241 
1243  void _setSupports( const OutArgs<Scalar>& inputOutArgs );
1248 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1249 
1250  void _setHessianSupports( const bool supports );
1251 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1252 
1253  private:
1254  // types
1259 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1260  typedef Teuchos::Array<RCP<LinearOpBase<Scalar> > > hess_t;
1261  typedef Teuchos::Array<RCP<MultiVectorBase<Scalar> > > hess_vec_t;
1262  typedef Teuchos::Array<bool> hess_supports_t;
1263 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1264 
1265  // data
1266  std::string modelEvalDescription_;
1267  bool supports_[NUM_E_OUT_ARGS_MEMBERS];
1268  supports_t supports_DfDp_; // Np
1269  supports_t supports_DgDx_dot_; // Ng
1270  supports_t supports_DgDx_; // Ng
1271  supports_t supports_DgDp_; // Ng x Np
1272 
1273 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1274 
1275  bool supports_hess_f_xx_;
1276  hess_supports_t supports_hess_f_xp_;
1277  hess_supports_t supports_hess_f_pp_;
1278  hess_supports_t supports_hess_g_xx_;
1279  hess_supports_t supports_hess_g_xp_;
1280  hess_supports_t supports_hess_g_pp_;
1281  bool supports_H_xx_;
1282  hess_supports_t supports_H_xp_;
1283  hess_supports_t supports_H_pp_;
1284 
1285  bool supports_hess_vec_prod_f_xx_;
1286  hess_supports_t supports_hess_vec_prod_f_xp_;
1287  hess_supports_t supports_hess_vec_prod_f_px_;
1288  hess_supports_t supports_hess_vec_prod_f_pp_;
1289  hess_supports_t supports_hess_vec_prod_g_xx_;
1290  hess_supports_t supports_hess_vec_prod_g_xp_;
1291  hess_supports_t supports_hess_vec_prod_g_px_;
1292  hess_supports_t supports_hess_vec_prod_g_pp_;
1293 
1294 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1295 
1297  g_t g_; // Ng
1299  RCP<LinearOpBase<Scalar> > W_op_;
1301  DerivativeProperties W_properties_;
1302  deriv_t DfDp_; // Np
1303  deriv_properties_t DfDp_properties_; // Np
1304  deriv_t DgDx_dot_; // Ng
1305  deriv_t DgDx_; // Ng
1306  deriv_properties_t DgDx_dot_properties_; // Ng
1307  deriv_properties_t DgDx_properties_; // Ng
1308  deriv_t DgDp_; // Ng x Np
1309  deriv_properties_t DgDp_properties_; // Ng x Np
1310 
1311 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1312 
1313  RCP<LinearOpBase<Scalar> > hess_f_xx_;
1314  hess_t hess_f_xp_;
1315  hess_t hess_f_pp_;
1316  hess_t hess_g_xx_;
1317  hess_t hess_g_xp_;
1318  hess_t hess_g_pp_;
1319  RCP<LinearOpBase<Scalar> > H_xx_;
1320  hess_t H_xp_;
1321  hess_t H_pp_;
1322 
1323  RCP<MultiVectorBase<Scalar> > hess_vec_prod_f_xx_;
1324  hess_vec_t hess_vec_prod_f_xp_; // Np
1325  hess_vec_t hess_vec_prod_f_px_; // Np
1326  hess_vec_t hess_vec_prod_f_pp_; // Np x Np
1327 
1328  hess_vec_t hess_vec_prod_g_xx_; // Ng
1329  hess_vec_t hess_vec_prod_g_xp_; // Ng x Np
1330  hess_vec_t hess_vec_prod_g_px_; // Ng x Np
1331  hess_vec_t hess_vec_prod_g_pp_; // Ng x Np x Np
1332 
1333 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1334 
1335  Teuchos::Array<bool> supports_g_mp_; //Ng
1336  supports_t supports_DfDp_mp_; // Np_mp
1337  supports_t supports_DgDx_dot_mp_; // Ng_mp
1338  supports_t supports_DgDx_mp_; // Ng_mp
1339  supports_t supports_DgDp_mp_; // Ng_mp x Np_mp
1344  Teuchos::Array<MPDerivative> DgDx_dot_mp_;
1347  deriv_properties_t DfDp_mp_properties_;
1348  deriv_properties_t DgDx_dot_mp_properties_;
1349  deriv_properties_t DgDx_mp_properties_;
1350  deriv_properties_t DgDp_mp_properties_;
1351 
1352 #ifdef HAVE_THYRA_ME_POLYNOMIAL
1354 #endif // HAVE_THYRA_ME_POLYNOMIAL
1355  mutable bool isFailed_;
1356 
1357  std::map<std::string,Teuchos::any> extended_outargs_;
1358 
1359  // functions
1360  void assert_supports(EOutArgsMembers arg) const;
1361  void assert_supports(
1362  EOutArgsDfDp arg, int l,
1363  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1364  ) const;
1365  void assert_supports(
1366  EOutArgsDgDx_dot arg, int j,
1367  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1368  ) const;
1369  void assert_supports(
1370  EOutArgsDgDx arg, int j,
1371  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1372  ) const;
1373  void assert_supports(
1374  EOutArgsDgDp arg, int j, int l,
1375  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1376  ) const;
1377 
1378 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1379 
1380  void assert_supports(
1381  EOutArgs_hess_vec_prod_f_xx arg
1382  ) const;
1383  void assert_supports(
1384  EOutArgs_hess_vec_prod_f_xp arg, int l
1385  ) const;
1386  void assert_supports(
1387  EOutArgs_hess_vec_prod_f_px arg, int l
1388  ) const;
1389  void assert_supports(
1390  EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2
1391  ) const;
1392  void assert_supports(
1393  EOutArgs_hess_vec_prod_g_xx arg, int j
1394  ) const;
1395  void assert_supports(
1396  EOutArgs_hess_vec_prod_g_xp arg, int j, int l
1397  ) const;
1398  void assert_supports(
1399  EOutArgs_hess_vec_prod_g_px arg, int j, int l
1400  ) const;
1401  void assert_supports(
1402  EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2
1403  ) const;
1404 
1405  void assert_supports(
1406  EOutArgs_hess_f_xx arg
1407  ) const;
1408  void assert_supports(
1409  EOutArgs_hess_f_xp arg, int l
1410  ) const;
1411  void assert_supports(
1412  EOutArgs_hess_f_pp arg, int l1, int l2
1413  ) const;
1414  void assert_supports(
1415  EOutArgs_hess_g_xx arg, int j
1416  ) const;
1417  void assert_supports(
1418  EOutArgs_hess_g_xp arg, int j, int l
1419  ) const;
1420  void assert_supports(
1421  EOutArgs_hess_g_pp arg, int j, int l1, int l2
1422  ) const;
1423  void assert_supports(
1424  EOutArgs_H_xx arg
1425  ) const;
1426  void assert_supports(
1427  EOutArgs_H_xp arg, int l
1428  ) const;
1429  void assert_supports(
1430  EOutArgs_H_pp arg, int l1, int l2
1431  ) const;
1432 
1433 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1434 
1435  void assert_supports(EOutArgs_g_mp arg, int j) const;
1436  void assert_supports(
1437  EOutArgsDfDp_mp arg, int l,
1438  const MPDerivative &deriv = MPDerivative()
1439  ) const;
1440  void assert_supports(
1441  EOutArgsDgDx_dot_mp arg, int j,
1442  const MPDerivative &deriv = MPDerivative()
1443  ) const;
1444  void assert_supports(
1445  EOutArgsDgDx_mp arg, int j,
1446  const MPDerivative &deriv = MPDerivative()
1447  ) const;
1448  void assert_supports(
1449  EOutArgsDgDp_mp arg, int j, int l,
1450  const MPDerivative &deriv = MPDerivative()
1451  ) const;
1452 
1453  void assert_l(int l) const;
1454  void assert_j(int j) const;
1455  };
1456 
1458 
1459 // Added since at least gcc 3.3.4 does not do the right thing here!
1460 #ifdef HAVE_PROTECTED_NESTED_TEMPLATE_CLASS_ACCESS
1461 protected:
1462 #endif
1463 
1466 
1474  template<class Scalar>
1475  class InArgsSetup : public InArgs<Scalar> {
1476  public:
1478  InArgsSetup();
1480  InArgsSetup( const InArgs<Scalar>& );
1482  void setModelEvalDescription( const std::string &modelEvalDescription );
1484  void set_Np(int Np);
1486  void set_Np_Ng(int Np, int Ng);
1488  void setSupports( EInArgsMembers arg, bool supports = true );
1490  void setSupports( const InArgs<Scalar>& inputInArgs, const int Np = -1 );
1492  template<typename ObjectType>
1493  void setSupports(const bool supports = true);
1496 
1497  void setSupports( EInArgs_p_mp arg, int l, bool supports);
1498  };
1499 
1507  template<class Scalar>
1508  class OutArgsSetup : public OutArgs<Scalar> {
1509  public:
1511  OutArgsSetup();
1513  OutArgsSetup( const OutArgs<Scalar>& );
1515  void setModelEvalDescription( const std::string &modelEvalDescription );
1517  void set_Np_Ng(int Np, int Ng);
1519  void setSupports( EOutArgsMembers arg, bool supports = true );
1521  void setSupports(EOutArgsDfDp arg, int l, const DerivativeSupport& );
1523  void setSupports(EOutArgsDgDx_dot arg, int j, const DerivativeSupport& );
1525  void setSupports(EOutArgsDgDx arg, int j, const DerivativeSupport& );
1527  void setSupports(EOutArgsDgDp arg, int j, int l, const DerivativeSupport& );
1528 
1529 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1530 
1531  void setSupports(EOutArgs_hess_vec_prod_f_xx arg, bool supports = true );
1533  void setSupports(EOutArgs_hess_vec_prod_f_xp arg, int l, bool supports = true );
1535  void setSupports(EOutArgs_hess_vec_prod_f_px arg, int l, bool supports = true );
1537  void setSupports(EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2, bool supports = true );
1539  void setSupports(EOutArgs_hess_vec_prod_g_xx arg, int j, bool supports = true );
1541  void setSupports(EOutArgs_hess_vec_prod_g_xp arg, int j, int l, bool supports = true );
1543  void setSupports(EOutArgs_hess_vec_prod_g_px arg, int j, int l, bool supports = true );
1545  void setSupports(EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2, bool supports = true );
1547  void setSupports(EOutArgs_hess_f_xx arg, bool supports = true );
1549  void setSupports(EOutArgs_hess_f_xp arg, int l, bool supports = true );
1551  void setSupports(EOutArgs_hess_f_pp arg, int l1, int l2, bool supports = true );
1553  void setSupports(EOutArgs_hess_g_xx arg, int j, bool supports = true );
1555  void setSupports(EOutArgs_hess_g_xp arg, int j, int l, bool supports = true );
1557  void setSupports(EOutArgs_hess_g_pp arg, int j, int l1, int l2, bool supports = true );
1559  void setSupports(EOutArgs_H_xx arg, bool supports = true );
1561  void setSupports(EOutArgs_H_xp arg, int l, bool supports = true );
1563  void setSupports(EOutArgs_H_pp arg, int l1, int l2, bool supports = true );
1564 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1565 
1567  template<typename ObjectType>
1568  void setSupports(const bool supports = true);
1569 
1570  void setSupports( EOutArgs_g_mp arg, int j, bool supports);
1571  void setSupports(EOutArgsDfDp_mp arg, int l, const DerivativeSupport& );
1572  void setSupports(EOutArgsDgDx_dot_mp arg, int j, const DerivativeSupport& );
1573  void setSupports(EOutArgsDgDx_mp arg, int j, const DerivativeSupport& );
1574  void setSupports(EOutArgsDgDp_mp arg, int j, int l, const DerivativeSupport& );
1575 
1577  void set_W_properties( const DerivativeProperties &properties );
1579  void set_DfDp_properties( int l, const DerivativeProperties &properties );
1581  void set_DgDx_dot_properties( int j, const DerivativeProperties &properties );
1583  void set_DgDx_properties( int j, const DerivativeProperties &properties );
1585  void set_DgDp_properties( int j, int l, const DerivativeProperties &properties );
1586 
1587  void set_DfDp_mp_properties( int l, const DerivativeProperties &properties );
1588  void set_DgDx_dot_mp_properties( int j, const DerivativeProperties &properties );
1589  void set_DgDx_mp_properties( int j, const DerivativeProperties &properties );
1590  void set_DgDp_mp_properties( int j, int l, const DerivativeProperties &properties );
1591 
1593  void setSupports( const OutArgs<Scalar>& inputOutArgs );
1598 
1599 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
1600 
1601  void setHessianSupports( const bool supports = true );
1602 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
1603  };
1604 
1606 
1609 
1612 
1614 
1615 private:
1616  // Not defined and not to be called
1618  ModelEvaluatorBase& operator=(const ModelEvaluatorBase&);
1619 
1620 }; // ModelEvaluatorBase
1621 
1622 
1625 
1626 
1629 
1630 
1632 std::string toString(
1634  );
1635 
1636 
1639 getOtherDerivativeMultiVectorOrientation(
1641  );
1642 
1643 
1644 } // namespace Thyra
1645 
1646 
1647 // //////////////////////////////////
1648 // Inline Defintions
1649 
1650 // Extended InArgs
1651 template<class Scalar>
1652 template<typename ObjectType>
1654 {
1655  std::map<std::string,Teuchos::any>::const_iterator search =
1656  extended_inargs_.find(typeid(ObjectType).name());
1657 
1658  if (search == extended_inargs_.end())
1659  return false;
1660 
1661  return true;
1662 }
1663 
1664 template<class Scalar>
1665 template<typename ObjectType>
1667 {
1668  std::map<std::string,Teuchos::any>::iterator search = extended_inargs_.find(typeid(ObjectType).name());
1669  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_inargs_.end(),
1670  std::runtime_error,
1671  "ERROR: InArgs::set<ObjectType>() was called with unsupported extended data type \""
1672  << typeid(ObjectType).name() << "\"!");
1673 
1674  search->second = Teuchos::any(eo);
1675 }
1676 
1677 template<class Scalar>
1678 template<typename ObjectType>
1681 {
1682  std::map<std::string,Teuchos::any>::const_iterator search = extended_inargs_.find(typeid(ObjectType).name());
1683  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_inargs_.end(),
1684  std::runtime_error,
1685  "ERROR: InArgs::get<ObjectType>() was called with unsupported extended data type \""
1686  << typeid(ObjectType).name() << "\"!");
1687 
1688  return Teuchos::any_cast<Teuchos::RCP<const ObjectType> >(search->second);
1689 }
1690 
1691 template<class Scalar>
1692 template<class ObjectType>
1694 setSupports(const bool in_supports)
1695 {
1696  this->template _setSupports<ObjectType>(in_supports);
1697 }
1698 
1699 template<class Scalar>
1700 template<class ObjectType>
1702 _setSupports(const bool in_supports)
1703 {
1704  if (in_supports)
1705  // When supports() is called, the map is searched to check for
1706  // supporting a type. If we support the type, we will insert an
1707  // empty placholder for now so that the search is successful for
1708  // support checks.
1709  this->extended_inargs_[typeid(ObjectType).name()] = Teuchos::any();
1710  else {
1711  // if false, remove the entry
1712  std::map<std::string,Teuchos::any>::iterator search =
1713  this->extended_inargs_.find(typeid(ObjectType).name());
1714 
1715  if (search != this->extended_inargs_.end())
1716  this->extended_inargs_.erase(typeid(ObjectType).name());
1717  }
1718 }
1719 
1720 // Extended OutArgs
1721 template<class Scalar>
1722 template<typename ObjectType>
1724 {
1725  std::map<std::string,Teuchos::any>::const_iterator search =
1726  extended_outargs_.find(typeid(ObjectType).name());
1727 
1728  if (search == extended_outargs_.end())
1729  return false;
1730 
1731  return true;
1732 }
1733 
1734 template<class Scalar>
1735 template<typename ObjectType>
1737 {
1738  std::map<std::string,Teuchos::any>::iterator search = extended_outargs_.find(typeid(ObjectType).name());
1739  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_outargs_.end(),
1740  std::runtime_error,
1741  "ERROR: OutArgs::set<ObjectType>() was called with unsupported extended data type \""
1742  << typeid(ObjectType).name() << "\"!");
1743 
1744  search->second = Teuchos::any(eo);
1745 }
1746 
1747 template<class Scalar>
1748 template<typename ObjectType>
1751 {
1752  std::map<std::string,Teuchos::any>::const_iterator search = extended_outargs_.find(typeid(ObjectType).name());
1753  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_outargs_.end(),
1754  std::runtime_error,
1755  "ERROR: OutArgs::get<ObjectType>() was called with unsupported extended data type \""
1756  << typeid(ObjectType).name() << "\"!");
1757 
1758  return Teuchos::any_cast<Teuchos::RCP<const ObjectType> >(search->second);
1759 }
1760 
1761 template<class Scalar>
1762 template<class ObjectType>
1764 setSupports(const bool in_supports)
1765 {
1766  this->template _setSupports<ObjectType>(in_supports);
1767 }
1768 
1769 template<class Scalar>
1770 template<class ObjectType>
1772 _setSupports(const bool in_supports)
1773 {
1774  if (in_supports)
1775  // When supports() is called, the map is searched to check for
1776  // supporting a type. If we support the type, we will insert an
1777  // empty placholder for now so that the search is successful for
1778  // support checks.
1779  this->extended_outargs_[typeid(ObjectType).name()] = Teuchos::any();
1780  else {
1781  // if false, remove the entry
1782  std::map<std::string,Teuchos::any>::iterator search =
1783  this->extended_outargs_.find(typeid(ObjectType).name());
1784 
1785  if (search != this->extended_outargs_.end())
1786  this->extended_outargs_.erase(typeid(ObjectType).name());
1787  }
1788 }
1789 
1790 //
1791 // Thyra_MEB_helper_functions_grp
1792 //
1793 
1794 
1795 inline
1797 {
1798  switch(arg) {
1799  case ModelEvaluatorBase::IN_ARG_x_dot_dot:
1800  return "IN_ARG_x_dot_dot";
1801  case ModelEvaluatorBase::IN_ARG_x_dot:
1802  return "IN_ARG_x_dot";
1803  case ModelEvaluatorBase::IN_ARG_x:
1804  return "IN_ARG_x";
1805  case ModelEvaluatorBase::IN_ARG_x_dot_poly:
1806  return "IN_ARG_x_dot_poly";
1807  case ModelEvaluatorBase::IN_ARG_x_poly:
1808  return "IN_ARG_x_poly";
1809  case ModelEvaluatorBase::IN_ARG_x_dot_mp:
1810  return "IN_ARG_x_dot_mp";
1811  case ModelEvaluatorBase::IN_ARG_x_mp:
1812  return "IN_ARG_x_mp";
1813  case ModelEvaluatorBase::IN_ARG_t:
1814  return "IN_ARG_t";
1815  case ModelEvaluatorBase::IN_ARG_alpha:
1816  return "IN_ARG_alpha";
1817  case ModelEvaluatorBase::IN_ARG_beta:
1818  return "IN_ARG_beta";
1819  case ModelEvaluatorBase::IN_ARG_W_x_dot_dot_coeff:
1820  return "IN_ARG_W_x_dot_dot_coeff";
1821  case ModelEvaluatorBase::IN_ARG_step_size:
1822  return "IN_ARG_step_size";
1823  case ModelEvaluatorBase::IN_ARG_stage_number:
1824  return "IN_ARG_stage_number";
1825 #ifdef TEUCHOS_DEBUG
1826  default:
1828 #endif
1829  }
1830  return ""; // Will never be executed!
1831 }
1832 
1833 
1834 inline
1835 std::string Thyra::toString(ModelEvaluatorBase::EOutArgsMembers arg)
1836 {
1837  switch(arg) {
1838  case ModelEvaluatorBase::OUT_ARG_f:
1839  return "OUT_ARG_f";
1840  case ModelEvaluatorBase::OUT_ARG_W:
1841  return "OUT_ARG_W";
1842  case ModelEvaluatorBase::OUT_ARG_f_mp:
1843  return "OUT_ARG_f_mp";
1844  case ModelEvaluatorBase::OUT_ARG_W_mp:
1845  return "OUT_ARG_W_mp";
1846  case ModelEvaluatorBase::OUT_ARG_W_op:
1847  return "OUT_ARG_W_op";
1848  case ModelEvaluatorBase::OUT_ARG_W_prec:
1849  return "OUT_ARG_W_prec";
1850  case ModelEvaluatorBase::OUT_ARG_f_poly:
1851  return "OUT_ARG_f_poly";
1852 #ifdef TEUCHOS_DEBUG
1853  default:
1855 #endif
1856  }
1857  return ""; // Will never be executed!
1858 }
1859 
1860 
1861 inline
1862 std::string Thyra::toString(
1863  ModelEvaluatorBase::EDerivativeMultiVectorOrientation orientation
1864  )
1865 {
1866  switch(orientation) {
1867  case ModelEvaluatorBase::DERIV_MV_BY_COL:
1868  return "DERIV_MV_BY_COL";
1869  case ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW:
1870  return "DERIV_TRANS_MV_BY_ROW";
1871 #ifdef TEUCHOS_DEBUG
1872  default:
1874 #endif
1875  }
1876  return ""; // Should never execute this!
1877 }
1878 
1879 
1880 inline
1882 Thyra::getOtherDerivativeMultiVectorOrientation(
1883  ModelEvaluatorBase::EDerivativeMultiVectorOrientation orientation
1884  )
1885 {
1886  switch(orientation) {
1887  case ModelEvaluatorBase::DERIV_MV_BY_COL:
1888  return ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW;
1889  case ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW:
1890  return ModelEvaluatorBase::DERIV_MV_BY_COL;
1891 #ifdef TEUCHOS_DEBUG
1892  default:
1894 #endif
1895  }
1896  return ModelEvaluatorBase::DERIV_MV_BY_COL; // Should never execute this!
1897 }
1898 
1899 
1900 #endif // THYRA_MODEL_EVALUATOR_BASE_DECL_HPP
Protected subclass of InArgs that only ModelEvaluator subclasses can access to set up the selection o...
int Ng() const
Return the number of axillary response functions g(j)(...) supported (Ng &gt;= 0).
bool supports(EDerivativeMultiVectorOrientation mvOrientation) const
EDerivativeMultiVectorOrientation getOrientation() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Create a more detailed description along about this object and the ModelEvaluator that created it...
RCP< Stokhos::ProductEpetraMultiVector > getMultiVector() const
RCP< MultiVectorBase< Scalar > > getMultiVector() const
void set_DgDx_properties(int j, const DerivativeProperties &properties)
MPDerivative(const RCP< Stokhos::ProductEpetraOperator > &lo)
void set_DfDp_properties(int l, const DerivativeProperties &properties)
Base class for all linear operators that can support a high-level solve operation.
bool is_null(const boost::shared_ptr< T > &p)
void set_step_size(Scalar step_size)
Precondition: supports(IN_ARG_step_size)==true.
Scalar get_beta() const
Precondition: supports(IN_ARG_beta)==true.
RCP< const VectorBase< Scalar > > get_f_multiplier() const
Precondition: supports(IN_ARG_x)==true.
RCP< Stokhos::ProductEpetraVector > get_g_mp(int j) const
Precondition: supports(OUT_ARG_g_mp)==true..
void set_x_dot_dot(const RCP< const VectorBase< Scalar > > &x_dot_dot)
Precondition: supports(IN_ARG_x_dot_dot)==true.
void setArgs(const OutArgs< Scalar > &outArgs, bool ignoreUnsupported=false)
Set all arguments fron outArgs into *this.
bool supports() const
Determines if an extended input argument of type ObjectType is supported.
ScalarMag get_t() const
.Precondition: supports(IN_ARG_t)==true
void _set_DfDp_properties(int l, const DerivativeProperties &properties)
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.
void set_g(int j, const Evaluation< VectorBase< Scalar > > &g_j)
Precondition: supports(OUT_ARG_g)==true.
RCP< const VectorBase< Scalar > > get_x_dot() const
Precondition: supports(IN_ARG_x_dot)==true.
MPDerivative(const RCP< Stokhos::ProductEpetraMultiVector > &mv, const EDerivativeMultiVectorOrientation orientation=DERIV_MV_BY_COL)
void setModelEvalDescription(const std::string &modelEvalDescription)
void set_W_mp(const RCP< Stokhos::ProductEpetraOperator > &W_mp)
Precondition: supports(OUT_ARG_W_mp)==true.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
void _set_DgDx_dot_properties(int j, const DerivativeProperties &properties)
void set_W_prec(const RCP< PreconditionerBase< Scalar > > &W_prec)
Precondition: supports(OUT_ARG_W_op)==true.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Create a more detailed description along about this object and the ModelEvaluator that created it...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void set(const RCP< const ObjectType > &uo)
Set an extended output argument of type ObjectType in OutArgs. Precondition: supports()==true.
void changeOrientation(const EDerivativeMultiVectorOrientation orientation)
void describe(Teuchos::FancyOStream &, const Teuchos::EVerbosityLevel) const
void set_x_dot_mp(const RCP< const Stokhos::ProductEpetraVector > &x_dot_mp)
Precondition: supports(IN_ARG_x_dot_mp)==true.
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
void set(const RCP< const ObjectType > &uo)
Set an extended input object of type ObjectType in the InArgs. Precondition: supports()==true.
bool isSameSupport(const DerivativeSupport &derivSupport) const
Evaluation< VectorBase< Scalar > > get_g(int j) const
Precondition: supports(OUT_ARG_g)==true..
DerivativeMultiVector(const RCP< MultiVectorBase< Scalar > > &mv, const EDerivativeMultiVectorOrientation orientation=DERIV_MV_BY_COL)
Evaluation< VectorBase< Scalar > > get_f() const
Precondition: supports(OUT_ARG_f)==true.
Jacobian form DhDz (nz columns of h_space vectors)
T * get() const
RCP< const ObjectType > get() const
Get an extended input object of type ObjectType&gt;/tt&gt; from the InArgs. Precondition: supports()==true...
RCP< const Stokhos::ProductEpetraVector > get_x_mp() const
Precondition: supports(IN_ARG_x_mp)==true.
void _setSupports(EOutArgsMembers arg, bool supports)
MPDerivative(const MPDerivativeMultiVector &dmv)
Derivative(const RCP< MultiVectorBase< Scalar > > &mv, const EDerivativeMultiVectorOrientation orientation=DERIV_MV_BY_COL)
Evaluation(const RCP< ObjType > &obj)
Implicit conversion from RCP&lt;ObjType&gt;.
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
DerivativeProperties get_DgDx_dot_properties(int j) const
Return the know properties of DgDx_dot(j) (precondition: supports(OUT_ARG_DgDx_dot,j)==true).
DerivativeSupport & plus(EDerivativeMultiVectorOrientation mvOrientation)
Simple aggregate class for a derivative object represented as a column-wise multi-vector or its trans...
Derivative< Scalar > get_DgDp(int j, int l) const
Precondition: supports(OUT_ARG_DgDp,j,l)==true.
bool isSupportedBy(const DerivativeSupport &derivSupport) const
Returns true if the form of the derivative contained here is supported by deriveSupport.
void changeOrientation(const EDerivativeMultiVectorOrientation orientation)
RCP< const ObjectType > get() const
Get an extended output argument of type ObjectType from OutArgs. Precondition: supports()==true.
Gradient form DhDz^T (nh columns of z_space vectors)
bool isSupportedBy(const DerivativeSupport &derivSupport) const
Returns true if the form of the derivative contained here is supported by deriveSupport.
DerivativeProperties get_DgDx_properties(int j) const
Return the know properties of DgDx(j) (precondition: supports(OUT_ARG_DgDx,j)==true).
Evaluation(const RCP< ObjType > &obj, EEvalType evalType)
MPDerivativeMultiVector getDerivativeMultiVector() const
void set_W_properties(const DerivativeProperties &properties)
void setSupports(EInArgsMembers arg, bool supports=true)
int Np() const
Return the number of parameter subvectors p(l) supported (Np &gt;= 0).
void set_stage_number(Scalar stage_number)
Precondition: supports(IN_ARG_stage_number)==true.
void set_x(const RCP< const VectorBase< Scalar > > &x)
Precondition: supports(IN_ARG_x)==true.
Simple aggregate class for a derivative object represented as a column-wise multi-vector or its trans...
Interface for a collection of column vectors called a multi-vector.
void setArgs(const InArgs< Scalar > &inArgs, bool ignoreUnsupported=false, bool cloneObjects=false)
Set non-null arguments (does not overwrite non-NULLs with NULLs) .
void set_DgDp(int j, int l, const Derivative< Scalar > &DgDp_j_l)
Precondition: supports(OUT_ARG_DgDp,j,l)==true.
EDerivativeMultiVectorOrientation getMultiVectorOrientation() const
void set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
RCP< Stokhos::ProductEpetraOperator > getLinearOp() const
DerivativeSupport(EDerivativeMultiVectorOrientation mvOrientation)
DerivativeMultiVector< Scalar > getDerivativeMultiVector() const
RCP< const Stokhos::ProductEpetraVector > get_x_dot_mp() const
Precondition: supports(IN_ARG_x_dotmp)==true.
void set_g_multiplier(int j, const RCP< const VectorBase< Scalar > > &g_multiplier)
Precondition: supports(IN_ARG_x)==true.
Derivative(const DerivativeMultiVector< Scalar > &dmv)
void _setModelEvalDescription(const std::string &modelEvalDescription)
Abstract interface for finite-dimensional dense vectors.
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
Simple public strict containing properties of a derivative object.
void _setSupports(EInArgsMembers arg, bool supports)
void describe(Teuchos::FancyOStream &, const Teuchos::EVerbosityLevel) const
RCP< T > & operator=(const RCP< T > &r_ptr)
void assertSameSupport(const OutArgs< Scalar > &outArgs) const
Assert that two OutArgs objects have the same support.
Scalar get_W_x_dot_dot_coeff() const
Precondition: supports(IN_ARG_W_x_dot_dot_coeff)==true.
void set_x_dot(const RCP< const VectorBase< Scalar > > &x_dot)
Precondition: supports(IN_ARG_x_dot)==true.
Base class for all linear operators.
RCP< Stokhos::ProductEpetraOperator > get_W_mp() const
Precondition: supports(OUT_ARG_W_mp)==true.
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).
Derivative(const RCP< LinearOpBase< Scalar > > &lo)
void set_DgDx_dot_properties(int j, const DerivativeProperties &properties)
bool isFailed() const
Return if the evaluation failed or not.
const RCP< T > & assert_not_null() const
void _set_DgDx_properties(int j, const DerivativeProperties &properties)
void set_g_mp(int j, const RCP< Stokhos::ProductEpetraVector > &g_mp_j)
Precondition: supports(OUT_ARG_g_mp)==true.
DerivativeProperties(EDerivativeLinearity in_linearity, ERankStatus in_rank, bool in_supportsAdjoint)
Base subclass for ModelEvaluator that defines some basic types.
void set_t(ScalarMag t)
Precondition: supports(IN_ARG_t)==true.
void set_p_direction(int l, const RCP< const MultiVectorBase< Scalar > > &p_direction_l)
Precondition: supports(IN_ARG_x)==true.
void set_x_mp(const RCP< const Stokhos::ProductEpetraVector > &x_mp)
Precondition: supports(IN_ARG_x_mp)==true.
void set_DgDx_dot(int j, const Derivative< Scalar > &DgDx_dot_j)
Precondition: supports(OUT_ARG_DgDx_dot,j)==true.
void assertSameSupport(const InArgs< Scalar > &inArgs) const
Assert that two InArgs objects have the same support.
void set_p(int l, const RCP< const VectorBase< Scalar > > &p_l)
Set p(l) where 0 &lt;= l &amp;&amp; l &lt; this-&gt;Np().
void setSupports(EOutArgsMembers arg, bool supports=true)
RCP< LinearOpWithSolveBase< Scalar > > get_W() const
Precondition: supports(OUT_ARG_W)==true.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
void _set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
void set_W(const RCP< LinearOpWithSolveBase< Scalar > > &W)
Precondition: supports(OUT_ARG_W)==true.
int Ng() const
Return the number of axillary response functions g(j)(...) supported (Ng &gt;= 0).
Scalar get_alpha() const
Precondition: supports(IN_ARG_alpha)==true.
void setFailed() const
Set that the evaluation as a whole failed.
bool supports() const
Determines if an extended output argument of type ObjectType is supported.
RCP< Stokhos::ProductEpetraMultiVector > getMultiVector() const
Scalar get_stage_number() const
Precondition: supports(IN_ARG_stage_number)==true.
RCP< Stokhos::ProductEpetraVector > get_f_mp() const
Precondition: supports(OUT_ARG_f_mp)==true.
void set_alpha(Scalar alpha)
Precondition: supports(IN_ARG_alpha)==true.
void set_f_multiplier(const RCP< const VectorBase< Scalar > > &f_multiplier)
Precondition: supports(IN_ARG_x)==true.
void _set_W_properties(const DerivativeProperties &properties)
Derivative< Scalar > get_DgDx_dot(int j) const
Precondition: supports(OUT_ARG_DgDx_dot,j)==true.
void set_DfDp(int l, const Derivative< Scalar > &DfDp_l)
Precondition: supports(OUT_ARG_DfDp,l)==true.
EDerivativeMultiVectorOrientation getOrientation() const
RCP< PreconditionerBase< Scalar > > get_W_prec() const
Precondition: supports(OUT_ARG_W_op)==true.
const Derivative< Scalar > & assert_not_null() const
void set_f_mp(const RCP< Stokhos::ProductEpetraVector > &f_mp)
Precondition: supports(OUT_ARG_f_mp)==true.
void set_x_direction(const RCP< const MultiVectorBase< Scalar > > &x_direction)
Precondition: supports(IN_ARG_x)==true.
Determines the forms of a general derivative that are supported.
int Np() const
Return the number of parameter subvectors p(l) supported (Np &gt;= 0).
Scalar get_step_size() const
Precondition: supports(IN_ARG_step_size)==true.
RCP< const MultiVectorBase< Scalar > > get_p_direction(int l) const
Get p(l) where 0 &lt;= l &amp;&amp; l &lt; this-&gt;Np().
RCP< const VectorBase< Scalar > > get_x_dot_dot() const
Precondition: supports(IN_ARG_x_dot_dot)==true.
RCP< const VectorBase< Scalar > > get_g_multiplier(int j) const
Precondition: supports(IN_ARG_x)==true.
void set_f(const Evaluation< VectorBase< Scalar > > &f)
Precondition: supports(OUT_ARG_f)==true.
void set_beta(Scalar beta)
Precondition: supports(IN_ARG_beta)==true.
void set_DgDx(int j, const Derivative< Scalar > &DgDx_j)
Precondition: supports(OUT_ARG_DgDx,j)==true.
void setModelEvalDescription(const std::string &modelEvalDescription)
Type to embed evaluation accuracy with an RCP-managed object.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
const DerivativeMultiVector< Scalar > & assert_not_null() const
void set_W_x_dot_dot_coeff(Scalar W_x_dot_dot_coeff)
Precondition: supports(IN_ARG_W_x_dot_dot_coeff)==true.
MPDerivativeMultiVector(const RCP< Stokhos::ProductEpetraMultiVector > &mv, const EDerivativeMultiVectorOrientation orientation=DERIV_MV_BY_COL, const Teuchos::Array< int > &paramIndexes=Teuchos::Array< int >())
RCP< LinearOpBase< Scalar > > get_W_op() const
Precondition: supports(OUT_ARG_W_op)==true.
RCP< const MultiVectorBase< Scalar > > get_x_direction() const
Precondition: supports(IN_ARG_x)==true.
void set_W_op(const RCP< LinearOpBase< Scalar > > &W_op)
Precondition: supports(OUT_ARG_W_op)==true.
EDerivativeMultiVectorOrientation getMultiVectorOrientation() const
DerivativeProperties get_DfDp_properties(int l) const
Return the know properties of DfDp(l) (precondition: supports(OUT_ARG_DfDp,l)==true).
RCP< const VectorBase< Scalar > > get_x() const
Precondition: supports(IN_ARG_x)==true.
void _setModelEvalDescription(const std::string &modelEvalDescription)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
RCP< LinearOpBase< Scalar > > getLinearOp() const
RCP< const VectorBase< Scalar > > get_p(int l) const
Get p(l) where 0 &lt;= l &amp;&amp; l &lt; this-&gt;Np().
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).
RCP< MultiVectorBase< Scalar > > getMultiVector() const
Derivative< Scalar > get_DgDx(int j) const
Precondition: supports(OUT_ARG_DgDx,j)==true.
void reset(const RCP< ObjType > &obj, EEvalType evalType)
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...