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 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_MODEL_EVALUATOR_BASE_DECL_HPP
43 #define THYRA_MODEL_EVALUATOR_BASE_DECL_HPP
44 
45 
46 #include "Thyra_LinearOpWithSolveBase.hpp"
47 #include "Teuchos_Describable.hpp"
48 #include "Teuchos_any.hpp"
49 #include "Teuchos_Assert.hpp"
50 
51 #ifdef HAVE_THYRA_ME_POLYNOMIAL
52 # include "Teuchos_Polynomial.hpp"
53 #endif
54 
55 namespace Stokhos {
56  class ProductEpetraVector;
57  class ProductEpetraMultiVector;
58  class ProductEpetraOperator;
59 }
60 
61 namespace Thyra {
62 
63 
84  : virtual public Teuchos::Describable,
85  virtual public Teuchos::VerboseObject<ModelEvaluatorBase>
86 {
87 public:
88 
91 
107  };
109  static const int NUM_E_IN_ARGS_MEMBERS=13;
110 
114  };
115 
158  template<class Scalar>
159  class InArgs : public Teuchos::Describable {
160  public:
164  InArgs();
167  int Np() const;
170  int Ng() const;
172  bool supports(EInArgsMembers arg) const;
174  void set_x_dot_dot( const RCP<const VectorBase<Scalar> > &x_dot_dot );
178  void set_x_dot( const RCP<const VectorBase<Scalar> > &x_dot );
182  void set_x( const RCP<const VectorBase<Scalar> > &x );
185 
187  void set_x_direction( const RCP<const MultiVectorBase<Scalar> > &x_direction );
189  void set_p_direction( int l, const RCP<const MultiVectorBase<Scalar> > &p_direction_l );
194 
196  void set_f_multiplier( const RCP<const VectorBase<Scalar> > &f_multiplier );
200  void set_g_multiplier( int j, const RCP<const VectorBase<Scalar> > &g_multiplier );
203 
205  template<typename ObjectType>
206  bool supports() const;
208  template<typename ObjectType>
209  void set(const RCP<const ObjectType>& uo);
211  template<typename ObjectType>
212  RCP<const ObjectType> get() const;
213 
214 #ifdef HAVE_THYRA_ME_POLYNOMIAL
215 
216  void set_x_poly(
217  const RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > &x_poly );
221  void set_x_dot_poly(
222  const RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > &x_dot_poly );
224  RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > get_x_dot_poly() const;
225 #endif // HAVE_THYRA_ME_POLYNOMIAL
226 
227  void set_p( int l, const RCP<const VectorBase<Scalar> > &p_l );
229  RCP<const VectorBase<Scalar> > get_p(int l) const;
230 
231 
236 
241 
242  void set_p_mp( int l, const RCP<const Stokhos::ProductEpetraVector > &p_mp_l );
243  RCP<const Stokhos::ProductEpetraVector > get_p_mp(int l) const;
245  bool supports(EInArgs_p_mp arg, int l) const;
246 
247 
249  void set_t( ScalarMag t );
251  ScalarMag get_t() const;
253  void set_alpha( Scalar alpha );
255  Scalar get_alpha() const;
257  void set_beta( Scalar beta );
259  Scalar get_beta() const;
261  void set_W_x_dot_dot_coeff( Scalar W_x_dot_dot_coeff );
263  Scalar get_W_x_dot_dot_coeff() const;
265  void set_step_size( Scalar step_size);
267  Scalar get_step_size() const;
269  void set_stage_number( Scalar stage_number);
271  Scalar get_stage_number() const;
274  void setArgs(
275  const InArgs<Scalar>& inArgs, bool ignoreUnsupported = false,
276  bool cloneObjects = false
277  );
279  void assertSameSupport( const InArgs<Scalar> &inArgs ) const;
281  std::string modelEvalDescription() const;
283  std::string description() const;
286  void describe(
287  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
288  ) const;
289  protected:
291  void _setModelEvalDescription( const std::string &modelEvalDescription );
293  void _set_Np_Ng(int Np, int Ng);
295  void _setSupports( EInArgsMembers arg, bool supports );
297  void _setSupports( EInArgs_p_mp arg, int l, bool supports );
299  void _setSupports( const InArgs<Scalar>& inputInArgs, const int Np );
301  template<typename ObjectType>
302  void _setSupports( const bool supports );
305  private:
306  // types
309  // data
310  std::string modelEvalDescription_;
311  RCP<const VectorBase<Scalar> > x_dot_dot_;
314  RCP<const MultiVectorBase<Scalar> > x_direction_;
317 
318  RCP<const VectorBase<Scalar> > f_multiplier_;
319  p_t g_multiplier_;
321 #ifdef HAVE_THYRA_ME_POLYNOMIAL
324 #endif // HAVE_THYRA_ME_POLYNOMIAL
325  p_t p_;
326  p_direction_t p_direction_;
327  ScalarMag t_;
328  Scalar alpha_;
329  Scalar beta_;
330  Scalar W_x_dot_dot_coeff_;
331  Scalar step_size_;
332  Scalar stage_number_;
333  bool supports_[NUM_E_IN_ARGS_MEMBERS];
334  Teuchos::Array<bool> supports_p_mp_; //Np
335  // functions
336  void assert_supports(EInArgsMembers arg) const;
337  void assert_supports(EInArgs_p_mp arg, int l) const;
338  void assert_l(int l) const;
339  void assert_j(int j) const;
340 
341  std::map<std::string,Teuchos::any> extended_inargs_;
342  };
343 
345  enum EEvalType {
346  EVAL_TYPE_EXACT = 0,
349  };
350 
357  template<class ObjType>
358  class Evaluation : public RCP<ObjType> {
359  public:
362  : evalType_(EVAL_TYPE_EXACT) {}
364  Evaluation() : evalType_(EVAL_TYPE_EXACT) {}
366  Evaluation( const RCP<ObjType> &obj )
367  : RCP<ObjType>(obj), evalType_(EVAL_TYPE_EXACT) {}
369  Evaluation( const RCP<ObjType> &obj, EEvalType evalType )
370  : RCP<ObjType>(obj), evalType_(evalType) {}
372  EEvalType getType() const { return evalType_; }
374  void reset( const RCP<ObjType> &obj, EEvalType evalType )
375  { this->operator=(obj); evalType_ = evalType; }
376  private:
377  EEvalType evalType_;
378  };
379 
386  };
387 
391  };
392 
396  public:
399  :supportsLinearOp_(false), supportsMVByCol_(false), supportsTransMVByRow_(false)
400  {}
403  :supportsLinearOp_(true), supportsMVByCol_(false), supportsTransMVByRow_(false)
404  {}
407  :supportsLinearOp_(false), supportsMVByCol_(mvOrientation==DERIV_MV_BY_COL)
408  ,supportsTransMVByRow_(mvOrientation==DERIV_TRANS_MV_BY_ROW)
409  {}
412  { supportsLinearOp_ = true; return *this; }
415  {
416  switch(mvOrientation) {
417  case DERIV_MV_BY_COL: supportsMVByCol_ = true; break;
418  case DERIV_TRANS_MV_BY_ROW: supportsTransMVByRow_ = true; break;
419  default: TEUCHOS_TEST_FOR_EXCEPT(true);
420  }
421  return *this;
422  }
424  bool none() const
425  { return ( !supportsLinearOp_ && !supportsMVByCol_ && !supportsTransMVByRow_ ); }
428  { return supportsLinearOp_; }
430  bool supports(EDerivativeMultiVectorOrientation mvOrientation) const
431  {
432  switch(mvOrientation) {
433  case DERIV_MV_BY_COL: return supportsMVByCol_;
434  case DERIV_TRANS_MV_BY_ROW: return supportsTransMVByRow_;
435  default: TEUCHOS_TEST_FOR_EXCEPT(true);
436  }
438  }
440  bool isSameSupport(const DerivativeSupport &derivSupport) const
441  {
442  return (
443  supportsLinearOp_ == derivSupport.supportsLinearOp_
444  && supportsMVByCol_ == derivSupport.supportsMVByCol_
445  && supportsTransMVByRow_ == derivSupport.supportsTransMVByRow_
446  );
447  }
449  std::string description() const;
450  private:
451  bool supportsLinearOp_;
452  bool supportsMVByCol_;
453  bool supportsTransMVByRow_;
454  public:
455  };
456 
462  };
463 
465  enum ERankStatus {
469  };
470 
484  {}
487  EDerivativeLinearity in_linearity, ERankStatus in_rank,
488  bool in_supportsAdjoint
489  )
490  :linearity(in_linearity),rank(in_rank),
491  supportsAdjoint(in_supportsAdjoint)
492  {}
493  };
494 
498  template<class Scalar>
500  public:
503  :orientation_(DERIV_MV_BY_COL)
504  {}
507  const RCP<MultiVectorBase<Scalar> > &mv
509  ) : mv_(mv.assert_not_null()), orientation_(orientation) {}
512  { orientation_ = orientation; };
515  { mv_.assert_not_null(); return *this; }
518  { return mv_; }
521  { return orientation_; }
523  std::string description() const;
525  void describe(
526  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
527  ) const;
528  private:
531  };
532 
536  template<class Scalar>
537  class Derivative {
538  public:
543  : lo_(lo.assert_not_null()) {}
546  const RCP<MultiVectorBase<Scalar> > &mv,
548  ) : dmv_(mv,orientation) {}
551  : dmv_(dmv) {}
553  bool isEmpty() const
554  { return ( lo_.get()==NULL && dmv_.getMultiVector().get()==NULL ); }
557  { dmv_.assert_not_null(); lo_.assert_not_null(); return *this; }
560  { return lo_; }
563  { return dmv_.getMultiVector(); }
566  { return dmv_.getOrientation(); }
569  { return dmv_; }
573  bool isSupportedBy( const DerivativeSupport &derivSupport ) const
574  {
575  // If there is not derivative support then we will return false!
576  if (derivSupport.none())
577  return false;
578  if (!is_null(getMultiVector())) {
579  return derivSupport.supports(getMultiVectorOrientation());
580  }
581  else if(!is_null(getLinearOp())) {
582  return derivSupport.supports(DERIV_LINEAR_OP);
583  }
584  // If nothing is set then of course we support that!
585  return true;
586  }
588  std::string description() const;
590  void describe(
591  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
592  ) const;
593  private:
596  };
597 
602  public:
605  :orientation_(DERIV_MV_BY_COL)
606  {}
611  ,const Teuchos::Array<int> &paramIndexes = Teuchos::Array<int>()
612  ) : mv_(mv.assert_not_null()), orientation_(orientation), paramIndexes_(paramIndexes) {}
615  { orientation_ = orientation; };
618  { mv_.assert_not_null(); return *this; }
621  { return mv_; }
624  { return orientation_; }
627  { return paramIndexes_; }
629  std::string description() const {return "\n";}
631  void describe(
632  Teuchos::FancyOStream &/* out */, const Teuchos::EVerbosityLevel /* verbLevel */
633  ) const {}
634  private:
637  Teuchos::Array<int> paramIndexes_;
638  };
639 
643  class MPDerivative {
644  public:
649  : lo_(lo.assert_not_null()) {}
654  ) : dmv_(mv,orientation) {}
657  : dmv_(dmv) {}
659  bool isEmpty() const
660  { return ( lo_.get()==NULL && dmv_.getMultiVector().get()==NULL ); }
663  { dmv_.assert_not_null(); lo_.assert_not_null(); return *this; }
666  { return lo_; }
669  { return dmv_.getMultiVector(); }
672  { return dmv_.getOrientation(); }
675  { return dmv_; }
679  bool isSupportedBy( const DerivativeSupport &derivSupport ) const
680  {
681  // If there is not derivative support then we will return false!
682  if (derivSupport.none())
683  return false;
684  if (!is_null(getMultiVector())) {
685  return derivSupport.supports(getMultiVectorOrientation());
686  }
687  else if(!is_null(getLinearOp())) {
688  return derivSupport.supports(DERIV_LINEAR_OP);
689  }
690  // If nothing is set then of course we support that!
691  return true;
692  }
694  std::string description() const {return "\n";}
696  void describe(
697  Teuchos::FancyOStream &/* out */, const Teuchos::EVerbosityLevel /* verbLevel */
698  ) const {}
699  private:
702  };
703 
713  };
715  static const int NUM_E_OUT_ARGS_MEMBERS=7;
716 
720  };
721 
725  };
726 
730  };
731 
735  };
736 
740  };
741 
745  };
746 
750  };
751 
755  };
756 
760  };
761 
765  };
766 
770  };
771 
775  };
776 
780  };
781 
785  };
786 
790  };
791 
795  };
796 
800  };
801 
805  };
806 
810  };
811 
815  };
816 
820  };
821 
825  };
826 
830  };
831 
835  };
836 
840  };
841 
845  };
846 
899  template<class Scalar>
900  class OutArgs : public Teuchos::Describable {
901  public:
903  OutArgs();
906  int Np() const;
909  int Ng() const;
911  bool supports(EOutArgsMembers arg) const;
914  const DerivativeSupport& supports(EOutArgsDfDp arg, int l) const;
917  const DerivativeSupport& supports(EOutArgsDgDx_dot arg, int j) const;
920  const DerivativeSupport& supports(EOutArgsDgDx arg, int j) const;
923  const DerivativeSupport& supports(EOutArgsDgDp arg, int j, int l) const;
925  bool supports(EOutArgs_hess_vec_prod_f_xx arg) const;
928  bool supports(EOutArgs_hess_vec_prod_f_xp arg, int l) const;
931  bool supports(EOutArgs_hess_vec_prod_f_px arg, int l) const;
934  bool supports(EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2) const;
937  bool supports(EOutArgs_hess_vec_prod_g_xx arg, int j) const;
940  bool supports(EOutArgs_hess_vec_prod_g_xp arg, int j, int l) const;
943  bool supports(EOutArgs_hess_vec_prod_g_px arg, int j, int l) const;
946  bool supports(EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2) const;
948  bool supports(EOutArgs_hess_f_xx arg) const;
951  bool supports(EOutArgs_hess_f_xp arg, int l) const;
954  bool supports(EOutArgs_hess_f_pp arg, int l1, int l2) const;
957  bool supports(EOutArgs_hess_g_xx arg, int j) const;
960  bool supports(EOutArgs_hess_g_xp arg, int j, int l) const;
963  bool supports(EOutArgs_hess_g_pp arg, int j, int l1, int l2) const;
965  bool supports(EOutArgs_H_xx arg) const;
968  bool supports(EOutArgs_H_xp arg, int l) const;
971  bool supports(EOutArgs_H_pp arg, int l1, int l2) const;
973  void set_f( const Evaluation<VectorBase<Scalar> > &f );
977  void set_g( int j, const Evaluation<VectorBase<Scalar> > &g_j );
979  Evaluation<VectorBase<Scalar> > get_g(int j) const;
981  void set_W( const RCP<LinearOpWithSolveBase<Scalar> > &W );
984 
986  template<typename ObjectType>
987  bool supports() const;
989  template<typename ObjectType>
990  void set(const RCP<const ObjectType>& uo);
992  template<typename ObjectType>
993  RCP<const ObjectType> get() const;
994 
995  const DerivativeSupport& supports(EOutArgsDfDp_mp arg, int l) const;
996  bool supports(EOutArgs_g_mp arg, int j) const;
997  const DerivativeSupport& supports(EOutArgsDgDx_dot_mp arg, int j) const;
998  const DerivativeSupport& supports(EOutArgsDgDx_mp arg, int j) const;
999  const DerivativeSupport& supports(EOutArgsDgDp_mp arg, int j, int l) const;
1001  void set_f_mp( const RCP<Stokhos::ProductEpetraVector> &f_mp );
1005  void set_g_mp( int j, const RCP<Stokhos::ProductEpetraVector> &g_mp_j );
1009  void set_W_mp( const RCP<Stokhos::ProductEpetraOperator> &W_mp );
1012 
1014  void set_W_op( const RCP<LinearOpBase<Scalar> > &W_op );
1018  void set_W_prec( const RCP<PreconditionerBase<Scalar> > &W_prec );
1025  void set_DfDp(int l, const Derivative<Scalar> &DfDp_l);
1027  Derivative<Scalar> get_DfDp(int l) const;
1032  void set_DgDx_dot(int j, const Derivative<Scalar> &DgDx_dot_j);
1034  Derivative<Scalar> get_DgDx_dot(int j) const;
1039  void set_DgDx(int j, const Derivative<Scalar> &DgDx_j);
1041  Derivative<Scalar> get_DgDx(int j) const;
1046  void set_DgDp( int j, int l, const Derivative<Scalar> &DgDp_j_l );
1048  Derivative<Scalar> get_DgDp(int j, int l) const;
1051  DerivativeProperties get_DgDp_properties(int j, int l) const;
1052 
1054  void set_hess_vec_prod_f_xx(const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_xx);
1056  void set_hess_vec_prod_f_xp(int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_xp_l);
1058  void set_hess_vec_prod_f_px(int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_px_l);
1060  void set_hess_vec_prod_f_pp(int l1, int l2, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_pp_l1_l2);
1061 
1069  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_f_pp(int l1, int l2) const;
1070 
1072  void set_hess_vec_prod_g_xx(int j, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_xx_j);
1074  void set_hess_vec_prod_g_xp(int j, int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_xp_j_l);
1076  void set_hess_vec_prod_g_px(int j, int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_px_j_l);
1078  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);
1079 
1087  RCP<MultiVectorBase<Scalar> > get_hess_vec_prod_g_pp(int j, int l1, int l2) const;
1088 
1090  void set_hess_f_xx(const RCP<LinearOpBase<Scalar> > &hess_f_xx);
1092  void set_hess_f_xp(int l, const RCP<LinearOpBase<Scalar> > &hess_f_xp_l);
1094  void set_hess_f_pp(int l1, int l2, const RCP<LinearOpBase<Scalar> > &hess_f_pp_l1_l2);
1096  void set_hess_g_xx(int j, const RCP<LinearOpBase<Scalar> > &hess_g_xx_j);
1098  void set_hess_g_xp(int j, int l, const RCP<LinearOpBase<Scalar> > &hess_g_xp_j_l);
1100  void set_hess_g_pp(int j, int l1, int l2, const RCP<LinearOpBase<Scalar> > &hess_g_pp_j_l1_l2);
1102  void set_H_xx(const RCP<LinearOpBase<Scalar> > &H_xx);
1104  void set_H_xp(int l, const RCP<LinearOpBase<Scalar> > &H_xp_l);
1106  void set_H_pp(int l1, int l2, const RCP<LinearOpBase<Scalar> > &H_pp_l1_l2);
1107 
1111  RCP<LinearOpBase<Scalar> > get_hess_f_xp(int l) const;
1113  RCP<LinearOpBase<Scalar> > get_hess_f_pp(int l1, int l2) const;
1115  RCP<LinearOpBase<Scalar> > get_hess_g_xx(int j) const;
1117  RCP<LinearOpBase<Scalar> > get_hess_g_xp(int j, int l) const;
1119  RCP<LinearOpBase<Scalar> > get_hess_g_pp(int j, int l1, int l2) const;
1123  RCP<LinearOpBase<Scalar> > get_H_xp(int l) const;
1125  RCP<LinearOpBase<Scalar> > get_H_pp(int l1, int l2) const;
1126 
1127  void set_DfDp_mp(int l, const MPDerivative &DfDp_mp_l);
1128  MPDerivative get_DfDp_mp(int l) const;
1129  DerivativeProperties get_DfDp_mp_properties(int l) const;
1130  void set_DgDx_dot_mp(int j, const MPDerivative &DgDx_dot_mp_j);
1131  MPDerivative get_DgDx_dot_mp(int j) const;
1132  DerivativeProperties get_DgDx_dot_mp_properties(int j) const;
1133  void set_DgDx_mp(int j, const MPDerivative &DgDx_mp_j);
1134  MPDerivative get_DgDx_mp(int j) const;
1135  DerivativeProperties get_DgDx_mp_properties(int j) const;
1136  void set_DgDp_mp( int j, int l, const MPDerivative &DgDp_mp_j_l );
1137  MPDerivative get_DgDp_mp(int j, int l) const;
1138  DerivativeProperties get_DgDp_mp_properties(int j, int l) const;
1139 
1140 #ifdef HAVE_THYRA_ME_POLYNOMIAL
1141 
1142  void set_f_poly( const RCP<Teuchos::Polynomial< VectorBase<Scalar> > > &f_poly );
1144  RCP<Teuchos::Polynomial< VectorBase<Scalar> > > get_f_poly() const;
1145 #endif // HAVE_THYRA_ME_POLYNOMIAL
1146 
1151  void setArgs( const OutArgs<Scalar>& outArgs, bool ignoreUnsupported = false );
1163  void setFailed() const;
1169  bool isFailed() const;
1171  bool isEmpty() const;
1173  void assertSameSupport( const OutArgs<Scalar> &outArgs ) const;
1175  std::string modelEvalDescription() const;
1177  std::string description() const;
1180  void describe(
1181  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
1182  ) const;
1183  protected:
1185  void _setModelEvalDescription( const std::string &modelEvalDescription );
1187  void _set_Np_Ng(int Np, int Ng);
1189  void _setSupports( EOutArgsMembers arg, bool supports );
1191  template<typename ObjectType>
1192  void _setSupports( const bool supports );
1194  void _setSupports( EOutArgsDfDp arg, int l, const DerivativeSupport& );
1196  void _setSupports( EOutArgsDgDx_dot arg, int j, const DerivativeSupport& );
1198  void _setSupports( EOutArgsDgDx arg, int j, const DerivativeSupport& );
1200  void _setSupports( EOutArgsDgDp arg, int j, int l, const DerivativeSupport& );
1201 
1203  void _setSupports( EOutArgs_hess_vec_prod_f_xx arg, bool supports );
1205  void _setSupports( EOutArgs_hess_vec_prod_f_xp arg, int l, bool supports );
1207  void _setSupports( EOutArgs_hess_vec_prod_f_px arg, int l, bool supports );
1209  void _setSupports( EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2, bool supports );
1211  void _setSupports( EOutArgs_hess_vec_prod_g_xx arg, int j, bool supports );
1213  void _setSupports( EOutArgs_hess_vec_prod_g_xp arg, int j, int l, bool supports );
1215  void _setSupports( EOutArgs_hess_vec_prod_g_px arg, int j, int l, bool supports );
1217  void _setSupports( EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2, bool supports );
1218 
1220  void _setSupports( EOutArgs_hess_f_xx arg, bool supports );
1222  void _setSupports( EOutArgs_hess_f_xp arg, int l, bool supports );
1224  void _setSupports( EOutArgs_hess_f_pp arg, int l1, int l2, bool supports );
1226  void _setSupports( EOutArgs_hess_g_xx arg, int j, bool supports );
1228  void _setSupports( EOutArgs_hess_g_xp arg, int j, int l, bool supports );
1230  void _setSupports( EOutArgs_hess_g_pp arg, int j, int l1, int l2, bool supports );
1232  void _setSupports( EOutArgs_H_xx arg, bool supports );
1234  void _setSupports( EOutArgs_H_xp arg, int l, bool supports );
1236  void _setSupports( EOutArgs_H_pp arg, int l1, int l2, bool supports );
1237 
1238  void _setSupports( EOutArgs_g_mp arg, int j, bool supports );
1239  void _setSupports( EOutArgsDfDp_mp arg, int l, const DerivativeSupport& );
1240  void _setSupports( EOutArgsDgDx_dot_mp arg, int j, const DerivativeSupport& );
1241  void _setSupports( EOutArgsDgDx_mp arg, int j, const DerivativeSupport& );
1242  void _setSupports( EOutArgsDgDp_mp arg, int j, int l, const DerivativeSupport& );
1243 
1245  void _set_W_properties( const DerivativeProperties &properties );
1247  void _set_DfDp_properties( int l, const DerivativeProperties &properties );
1249  void _set_DgDx_dot_properties( int j, const DerivativeProperties &properties );
1251  void _set_DgDx_properties( int j, const DerivativeProperties &properties );
1253  void _set_DgDp_properties( int j, int l, const DerivativeProperties &properties );
1254 
1255  void _set_DfDp_mp_properties( int l, const DerivativeProperties &properties );
1256  void _set_DgDx_dot_mp_properties( int j, const DerivativeProperties &properties );
1257  void _set_DgDx_mp_properties( int j, const DerivativeProperties &properties );
1258  void _set_DgDp_mp_properties( int j, int l, const DerivativeProperties &properties );
1259 
1261  void _setSupports( const OutArgs<Scalar>& inputOutArgs );
1267  void _setHessianSupports( const bool supports );
1268  private:
1269  // types
1277  // data
1278  std::string modelEvalDescription_;
1279  bool supports_[NUM_E_OUT_ARGS_MEMBERS];
1280  supports_t supports_DfDp_; // Np
1281  supports_t supports_DgDx_dot_; // Ng
1282  supports_t supports_DgDx_; // Ng
1283  supports_t supports_DgDp_; // Ng x Np
1284 
1285  bool supports_hess_f_xx_;
1286  hess_supports_t supports_hess_f_xp_;
1287  hess_supports_t supports_hess_f_pp_;
1288  hess_supports_t supports_hess_g_xx_;
1289  hess_supports_t supports_hess_g_xp_;
1290  hess_supports_t supports_hess_g_pp_;
1291  bool supports_H_xx_;
1292  hess_supports_t supports_H_xp_;
1293  hess_supports_t supports_H_pp_;
1294 
1295  bool supports_hess_vec_prod_f_xx_;
1296  hess_supports_t supports_hess_vec_prod_f_xp_;
1297  hess_supports_t supports_hess_vec_prod_f_px_;
1298  hess_supports_t supports_hess_vec_prod_f_pp_;
1299  hess_supports_t supports_hess_vec_prod_g_xx_;
1300  hess_supports_t supports_hess_vec_prod_g_xp_;
1301  hess_supports_t supports_hess_vec_prod_g_px_;
1302  hess_supports_t supports_hess_vec_prod_g_pp_;
1304  g_t g_; // Ng
1306  RCP<LinearOpBase<Scalar> > W_op_;
1308  DerivativeProperties W_properties_;
1309  deriv_t DfDp_; // Np
1310  deriv_properties_t DfDp_properties_; // Np
1311  deriv_t DgDx_dot_; // Ng
1312  deriv_t DgDx_; // Ng
1313  deriv_properties_t DgDx_dot_properties_; // Ng
1314  deriv_properties_t DgDx_properties_; // Ng
1315  deriv_t DgDp_; // Ng x Np
1316  deriv_properties_t DgDp_properties_; // Ng x Np
1317 
1318  RCP<LinearOpBase<Scalar> > hess_f_xx_;
1319  hess_t hess_f_xp_;
1320  hess_t hess_f_pp_;
1321  hess_t hess_g_xx_;
1322  hess_t hess_g_xp_;
1323  hess_t hess_g_pp_;
1324  RCP<LinearOpBase<Scalar> > H_xx_;
1325  hess_t H_xp_;
1326  hess_t H_pp_;
1327 
1328  RCP<MultiVectorBase<Scalar> > hess_vec_prod_f_xx_;
1329  hess_vec_t hess_vec_prod_f_xp_; // Np
1330  hess_vec_t hess_vec_prod_f_px_; // Np
1331  hess_vec_t hess_vec_prod_f_pp_; // Np x Np
1332 
1333  hess_vec_t hess_vec_prod_g_xx_; // Ng
1334  hess_vec_t hess_vec_prod_g_xp_; // Ng x Np
1335  hess_vec_t hess_vec_prod_g_px_; // Ng x Np
1336  hess_vec_t hess_vec_prod_g_pp_; // Ng x Np x Np
1337 
1338  Teuchos::Array<bool> supports_g_mp_; //Ng
1339  supports_t supports_DfDp_mp_; // Np_mp
1340  supports_t supports_DgDx_dot_mp_; // Ng_mp
1341  supports_t supports_DgDx_mp_; // Ng_mp
1342  supports_t supports_DgDp_mp_; // Ng_mp x Np_mp
1347  Teuchos::Array<MPDerivative> DgDx_dot_mp_;
1350  deriv_properties_t DfDp_mp_properties_;
1351  deriv_properties_t DgDx_dot_mp_properties_;
1352  deriv_properties_t DgDx_mp_properties_;
1353  deriv_properties_t DgDp_mp_properties_;
1354 
1355 #ifdef HAVE_THYRA_ME_POLYNOMIAL
1357 #endif // HAVE_THYRA_ME_POLYNOMIAL
1358  mutable bool isFailed_;
1359 
1360  std::map<std::string,Teuchos::any> extended_outargs_;
1361 
1362  // functions
1363  void assert_supports(EOutArgsMembers arg) const;
1364  void assert_supports(
1365  EOutArgsDfDp arg, int l,
1366  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1367  ) const;
1368  void assert_supports(
1369  EOutArgsDgDx_dot arg, int j,
1370  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1371  ) const;
1372  void assert_supports(
1373  EOutArgsDgDx arg, int j,
1374  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1375  ) const;
1376  void assert_supports(
1377  EOutArgsDgDp arg, int j, int l,
1378  const Derivative<Scalar> &deriv = Derivative<Scalar>()
1379  ) const;
1380 
1381  void assert_supports(
1383  ) const;
1384  void assert_supports(
1385  EOutArgs_hess_vec_prod_f_xp arg, int l
1386  ) const;
1387  void assert_supports(
1388  EOutArgs_hess_vec_prod_f_px arg, int l
1389  ) const;
1390  void assert_supports(
1391  EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2
1392  ) const;
1393  void assert_supports(
1394  EOutArgs_hess_vec_prod_g_xx arg, int j
1395  ) const;
1396  void assert_supports(
1397  EOutArgs_hess_vec_prod_g_xp arg, int j, int l
1398  ) const;
1399  void assert_supports(
1400  EOutArgs_hess_vec_prod_g_px arg, int j, int l
1401  ) const;
1402  void assert_supports(
1403  EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2
1404  ) const;
1405 
1406  void assert_supports(
1407  EOutArgs_hess_f_xx arg
1408  ) const;
1409  void assert_supports(
1410  EOutArgs_hess_f_xp arg, int l
1411  ) const;
1412  void assert_supports(
1413  EOutArgs_hess_f_pp arg, int l1, int l2
1414  ) const;
1415  void assert_supports(
1416  EOutArgs_hess_g_xx arg, int j
1417  ) const;
1418  void assert_supports(
1419  EOutArgs_hess_g_xp arg, int j, int l
1420  ) const;
1421  void assert_supports(
1422  EOutArgs_hess_g_pp arg, int j, int l1, int l2
1423  ) const;
1424  void assert_supports(
1425  EOutArgs_H_xx arg
1426  ) const;
1427  void assert_supports(
1428  EOutArgs_H_xp arg, int l
1429  ) const;
1430  void assert_supports(
1431  EOutArgs_H_pp arg, int l1, int l2
1432  ) const;
1433 
1434  void assert_supports(EOutArgs_g_mp arg, int j) const;
1435  void assert_supports(
1436  EOutArgsDfDp_mp arg, int l,
1437  const MPDerivative &deriv = MPDerivative()
1438  ) const;
1439  void assert_supports(
1440  EOutArgsDgDx_dot_mp arg, int j,
1441  const MPDerivative &deriv = MPDerivative()
1442  ) const;
1443  void assert_supports(
1444  EOutArgsDgDx_mp arg, int j,
1445  const MPDerivative &deriv = MPDerivative()
1446  ) const;
1447  void assert_supports(
1448  EOutArgsDgDp_mp arg, int j, int l,
1449  const MPDerivative &deriv = MPDerivative()
1450  ) const;
1451 
1452  void assert_l(int l) const;
1453  void assert_j(int j) const;
1454  };
1455 
1457 
1458 // Added since at least gcc 3.3.4 does not do the right thing here!
1459 #ifdef HAVE_PROTECTED_NESTED_TEMPLATE_CLASS_ACCESS
1460 protected:
1461 #endif
1462 
1465 
1473  template<class Scalar>
1474  class InArgsSetup : public InArgs<Scalar> {
1475  public:
1477  InArgsSetup();
1479  InArgsSetup( const InArgs<Scalar>& );
1481  void setModelEvalDescription( const std::string &modelEvalDescription );
1483  void set_Np(int Np);
1485  void set_Np_Ng(int Np, int Ng);
1487  void setSupports( EInArgsMembers arg, bool supports = true );
1489  void setSupports( const InArgs<Scalar>& inputInArgs, const int Np = -1 );
1491  template<typename ObjectType>
1492  void setSupports(const bool supports = true);
1495 
1496  void setSupports( EInArgs_p_mp arg, int l, bool supports);
1497  };
1498 
1506  template<class Scalar>
1507  class OutArgsSetup : public OutArgs<Scalar> {
1508  public:
1510  OutArgsSetup();
1512  OutArgsSetup( const OutArgs<Scalar>& );
1514  void setModelEvalDescription( const std::string &modelEvalDescription );
1516  void set_Np_Ng(int Np, int Ng);
1518  void setSupports( EOutArgsMembers arg, bool supports = true );
1520  void setSupports(EOutArgsDfDp arg, int l, const DerivativeSupport& );
1522  void setSupports(EOutArgsDgDx_dot arg, int j, const DerivativeSupport& );
1524  void setSupports(EOutArgsDgDx arg, int j, const DerivativeSupport& );
1526  void setSupports(EOutArgsDgDp arg, int j, int l, const DerivativeSupport& );
1528  void setSupports(EOutArgs_hess_vec_prod_f_xx arg, bool supports = true );
1530  void setSupports(EOutArgs_hess_vec_prod_f_xp arg, int l, bool supports = true );
1532  void setSupports(EOutArgs_hess_vec_prod_f_px arg, int l, bool supports = true );
1534  void setSupports(EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2, bool supports = true );
1536  void setSupports(EOutArgs_hess_vec_prod_g_xx arg, int j, bool supports = true );
1538  void setSupports(EOutArgs_hess_vec_prod_g_xp arg, int j, int l, bool supports = true );
1540  void setSupports(EOutArgs_hess_vec_prod_g_px arg, int j, int l, bool supports = true );
1542  void setSupports(EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2, bool supports = true );
1544  void setSupports(EOutArgs_hess_f_xx arg, bool supports = true );
1546  void setSupports(EOutArgs_hess_f_xp arg, int l, bool supports = true );
1548  void setSupports(EOutArgs_hess_f_pp arg, int l1, int l2, bool supports = true );
1550  void setSupports(EOutArgs_hess_g_xx arg, int j, bool supports = true );
1552  void setSupports(EOutArgs_hess_g_xp arg, int j, int l, bool supports = true );
1554  void setSupports(EOutArgs_hess_g_pp arg, int j, int l1, int l2, bool supports = true );
1556  void setSupports(EOutArgs_H_xx arg, bool supports = true );
1558  void setSupports(EOutArgs_H_xp arg, int l, bool supports = true );
1560  void setSupports(EOutArgs_H_pp arg, int l1, int l2, bool supports = true );
1562  template<typename ObjectType>
1563  void setSupports(const bool supports = true);
1564 
1565  void setSupports( EOutArgs_g_mp arg, int j, bool supports);
1566  void setSupports(EOutArgsDfDp_mp arg, int l, const DerivativeSupport& );
1567  void setSupports(EOutArgsDgDx_dot_mp arg, int j, const DerivativeSupport& );
1568  void setSupports(EOutArgsDgDx_mp arg, int j, const DerivativeSupport& );
1569  void setSupports(EOutArgsDgDp_mp arg, int j, int l, const DerivativeSupport& );
1570 
1572  void set_W_properties( const DerivativeProperties &properties );
1574  void set_DfDp_properties( int l, const DerivativeProperties &properties );
1576  void set_DgDx_dot_properties( int j, const DerivativeProperties &properties );
1578  void set_DgDx_properties( int j, const DerivativeProperties &properties );
1580  void set_DgDp_properties( int j, int l, const DerivativeProperties &properties );
1581 
1582  void set_DfDp_mp_properties( int l, const DerivativeProperties &properties );
1583  void set_DgDx_dot_mp_properties( int j, const DerivativeProperties &properties );
1584  void set_DgDx_mp_properties( int j, const DerivativeProperties &properties );
1585  void set_DgDp_mp_properties( int j, int l, const DerivativeProperties &properties );
1586 
1588  void setSupports( const OutArgs<Scalar>& inputOutArgs );
1594  void setHessianSupports( const bool supports = true );
1595  };
1596 
1598 
1601 
1604 
1606 
1607 private:
1608  // Not defined and not to be called
1610  ModelEvaluatorBase& operator=(const ModelEvaluatorBase&);
1611 
1612 }; // ModelEvaluatorBase
1613 
1614 
1617 
1618 
1621 
1622 
1624 std::string toString(
1626  );
1627 
1628 
1631 getOtherDerivativeMultiVectorOrientation(
1633  );
1634 
1635 
1636 } // namespace Thyra
1637 
1638 
1639 // //////////////////////////////////
1640 // Inline Defintions
1641 
1642 // Extended InArgs
1643 template<class Scalar>
1644 template<typename ObjectType>
1646 {
1647  std::map<std::string,Teuchos::any>::const_iterator search =
1648  extended_inargs_.find(typeid(ObjectType).name());
1649 
1650  if (search == extended_inargs_.end())
1651  return false;
1652 
1653  return true;
1654 }
1655 
1656 template<class Scalar>
1657 template<typename ObjectType>
1659 {
1660  std::map<std::string,Teuchos::any>::iterator search = extended_inargs_.find(typeid(ObjectType).name());
1661  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_inargs_.end(),
1662  std::runtime_error,
1663  "ERROR: InArgs::set<ObjectType>() was called with unsupported extended data type \""
1664  << typeid(ObjectType).name() << "\"!");
1665 
1666  search->second = Teuchos::any(eo);
1667 }
1668 
1669 template<class Scalar>
1670 template<typename ObjectType>
1673 {
1674  std::map<std::string,Teuchos::any>::const_iterator search = extended_inargs_.find(typeid(ObjectType).name());
1675  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_inargs_.end(),
1676  std::runtime_error,
1677  "ERROR: InArgs::get<ObjectType>() was called with unsupported extended data type \""
1678  << typeid(ObjectType).name() << "\"!");
1679 
1680  return Teuchos::any_cast<Teuchos::RCP<const ObjectType> >(search->second);
1681 }
1682 
1683 template<class Scalar>
1684 template<class ObjectType>
1686 setSupports(const bool in_supports)
1687 {
1688  this->template _setSupports<ObjectType>(in_supports);
1689 }
1690 
1691 template<class Scalar>
1692 template<class ObjectType>
1694 _setSupports(const bool in_supports)
1695 {
1696  if (in_supports)
1697  // When supports() is called, the map is searched to check for
1698  // supporting a type. If we support the type, we will insert an
1699  // empty placholder for now so that the search is successful for
1700  // support checks.
1701  this->extended_inargs_[typeid(ObjectType).name()] = Teuchos::any();
1702  else {
1703  // if false, remove the entry
1704  std::map<std::string,Teuchos::any>::iterator search =
1705  this->extended_inargs_.find(typeid(ObjectType).name());
1706 
1707  if (search != this->extended_inargs_.end())
1708  this->extended_inargs_.erase(typeid(ObjectType).name());
1709  }
1710 }
1711 
1712 // Extended OutArgs
1713 template<class Scalar>
1714 template<typename ObjectType>
1716 {
1717  std::map<std::string,Teuchos::any>::const_iterator search =
1718  extended_outargs_.find(typeid(ObjectType).name());
1719 
1720  if (search == extended_outargs_.end())
1721  return false;
1722 
1723  return true;
1724 }
1725 
1726 template<class Scalar>
1727 template<typename ObjectType>
1729 {
1730  std::map<std::string,Teuchos::any>::iterator search = extended_outargs_.find(typeid(ObjectType).name());
1731  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_outargs_.end(),
1732  std::runtime_error,
1733  "ERROR: OutArgs::set<ObjectType>() was called with unsupported extended data type \""
1734  << typeid(ObjectType).name() << "\"!");
1735 
1736  search->second = Teuchos::any(eo);
1737 }
1738 
1739 template<class Scalar>
1740 template<typename ObjectType>
1743 {
1744  std::map<std::string,Teuchos::any>::const_iterator search = extended_outargs_.find(typeid(ObjectType).name());
1745  TEUCHOS_TEST_FOR_EXCEPTION(search == extended_outargs_.end(),
1746  std::runtime_error,
1747  "ERROR: OutArgs::get<ObjectType>() was called with unsupported extended data type \""
1748  << typeid(ObjectType).name() << "\"!");
1749 
1750  return Teuchos::any_cast<Teuchos::RCP<const ObjectType> >(search->second);
1751 }
1752 
1753 template<class Scalar>
1754 template<class ObjectType>
1756 setSupports(const bool in_supports)
1757 {
1758  this->template _setSupports<ObjectType>(in_supports);
1759 }
1760 
1761 template<class Scalar>
1762 template<class ObjectType>
1764 _setSupports(const bool in_supports)
1765 {
1766  if (in_supports)
1767  // When supports() is called, the map is searched to check for
1768  // supporting a type. If we support the type, we will insert an
1769  // empty placholder for now so that the search is successful for
1770  // support checks.
1771  this->extended_outargs_[typeid(ObjectType).name()] = Teuchos::any();
1772  else {
1773  // if false, remove the entry
1774  std::map<std::string,Teuchos::any>::iterator search =
1775  this->extended_outargs_.find(typeid(ObjectType).name());
1776 
1777  if (search != this->extended_outargs_.end())
1778  this->extended_outargs_.erase(typeid(ObjectType).name());
1779  }
1780 }
1781 
1782 //
1783 // Thyra_MEB_helper_functions_grp
1784 //
1785 
1786 
1787 inline
1789 {
1790  switch(arg) {
1791  case ModelEvaluatorBase::IN_ARG_x_dot_dot:
1792  return "IN_ARG_x_dot_dot";
1793  case ModelEvaluatorBase::IN_ARG_x_dot:
1794  return "IN_ARG_x_dot";
1795  case ModelEvaluatorBase::IN_ARG_x:
1796  return "IN_ARG_x";
1797  case ModelEvaluatorBase::IN_ARG_x_dot_poly:
1798  return "IN_ARG_x_dot_poly";
1799  case ModelEvaluatorBase::IN_ARG_x_poly:
1800  return "IN_ARG_x_poly";
1801  case ModelEvaluatorBase::IN_ARG_x_dot_mp:
1802  return "IN_ARG_x_dot_mp";
1803  case ModelEvaluatorBase::IN_ARG_x_mp:
1804  return "IN_ARG_x_mp";
1805  case ModelEvaluatorBase::IN_ARG_t:
1806  return "IN_ARG_t";
1807  case ModelEvaluatorBase::IN_ARG_alpha:
1808  return "IN_ARG_alpha";
1809  case ModelEvaluatorBase::IN_ARG_beta:
1810  return "IN_ARG_beta";
1811  case ModelEvaluatorBase::IN_ARG_W_x_dot_dot_coeff:
1812  return "IN_ARG_W_x_dot_dot_coeff";
1813  case ModelEvaluatorBase::IN_ARG_step_size:
1814  return "IN_ARG_step_size";
1815  case ModelEvaluatorBase::IN_ARG_stage_number:
1816  return "IN_ARG_stage_number";
1817 #ifdef TEUCHOS_DEBUG
1818  default:
1820 #endif
1821  }
1822  return ""; // Will never be executed!
1823 }
1824 
1825 
1826 inline
1827 std::string Thyra::toString(ModelEvaluatorBase::EOutArgsMembers arg)
1828 {
1829  switch(arg) {
1830  case ModelEvaluatorBase::OUT_ARG_f:
1831  return "OUT_ARG_f";
1832  case ModelEvaluatorBase::OUT_ARG_W:
1833  return "OUT_ARG_W";
1834  case ModelEvaluatorBase::OUT_ARG_f_mp:
1835  return "OUT_ARG_f_mp";
1836  case ModelEvaluatorBase::OUT_ARG_W_mp:
1837  return "OUT_ARG_W_mp";
1838  case ModelEvaluatorBase::OUT_ARG_W_op:
1839  return "OUT_ARG_W_op";
1840  case ModelEvaluatorBase::OUT_ARG_W_prec:
1841  return "OUT_ARG_W_prec";
1842  case ModelEvaluatorBase::OUT_ARG_f_poly:
1843  return "OUT_ARG_f_poly";
1844 #ifdef TEUCHOS_DEBUG
1845  default:
1847 #endif
1848  }
1849  return ""; // Will never be executed!
1850 }
1851 
1852 
1853 inline
1854 std::string Thyra::toString(
1855  ModelEvaluatorBase::EDerivativeMultiVectorOrientation orientation
1856  )
1857 {
1858  switch(orientation) {
1859  case ModelEvaluatorBase::DERIV_MV_BY_COL:
1860  return "DERIV_MV_BY_COL";
1861  case ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW:
1862  return "DERIV_TRANS_MV_BY_ROW";
1863 #ifdef TEUCHOS_DEBUG
1864  default:
1866 #endif
1867  }
1868  return ""; // Should never execute this!
1869 }
1870 
1871 
1872 inline
1874 Thyra::getOtherDerivativeMultiVectorOrientation(
1875  ModelEvaluatorBase::EDerivativeMultiVectorOrientation orientation
1876  )
1877 {
1878  switch(orientation) {
1879  case ModelEvaluatorBase::DERIV_MV_BY_COL:
1880  return ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW;
1881  case ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW:
1882  return ModelEvaluatorBase::DERIV_MV_BY_COL;
1883 #ifdef TEUCHOS_DEBUG
1884  default:
1886 #endif
1887  }
1888  return ModelEvaluatorBase::DERIV_MV_BY_COL; // Should never execute this!
1889 }
1890 
1891 
1892 #endif // THYRA_MODEL_EVALUATOR_BASE_DECL_HPP
RCP< LinearOpBase< Scalar > > get_H_xx() const
Precondition: supports(OUT_ARG_H_xx)==true.
Protected subclass of InArgs that only ModelEvaluator subclasses can access to set up the selection o...
void set_hess_vec_prod_g_px(int j, int l, const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_g_px_j_l)
Precondition: supports(OUT_ARG_hess_vec_prod_g_px,j,l)==true.
int Ng() const
Return the number of axillary response functions g(j)(...) supported (Ng &gt;= 0).
bool supports(EDerivativeMultiVectorOrientation mvOrientation) const
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_f_pp(int l1, int l2) const
Precondition: supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2)==true.
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 set_hess_f_pp(int l1, int l2, const RCP< LinearOpBase< Scalar > > &hess_f_pp_l1_l2)
Precondition: supports(OUT_ARG_hess_f_pp,l1,l2)==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)
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_f_xp(int l) const
Precondition: supports(OUT_ARG_hess_vec_prod_f_xp,l)==true.
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...
RCP< LinearOpBase< Scalar > > get_hess_g_xp(int j, int l) const
Precondition: supports(OUT_ARG_hess_g_xp,j,l)==true.
#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.
RCP< LinearOpBase< Scalar > > get_H_pp(int l1, int l2) const
Precondition: supports(OUT_ARG_H_pp,l1,l2)==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...
void set_hess_f_xp(int l, const RCP< LinearOpBase< Scalar > > &hess_f_xp_l)
Precondition: supports(OUT_ARG_hess_f_xp,l)==true.
RCP< const Stokhos::ProductEpetraVector > get_x_mp() const
Precondition: supports(IN_ARG_x_mp)==true.
void set_hess_vec_prod_g_xx(int j, const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_g_xx_j)
Precondition: supports(OUT_ARG_hess_vec_prod_g_xx,j)==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)
void set_hess_f_xx(const RCP< LinearOpBase< Scalar > > &hess_f_xx)
Precondition: supports(OUT_ARG_hess_f_xx)==true.
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)
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_g_xx(int j) const
Precondition: supports(OUT_ARG_hess_vec_prod_g_xx,j)==true.
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_f_px(int l) const
Precondition: supports(OUT_ARG_hess_vec_prod_f_px,l)==true.
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 set_hess_vec_prod_f_xx(const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_f_xx)
Precondition: supports(OUT_ARG_hess_vec_prod_f_xx)==true.
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 set_hess_vec_prod_f_pp(int l1, int l2, const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_f_pp_l1_l2)
Precondition: supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2)==true.
void set_hess_g_xp(int j, int l, const RCP< LinearOpBase< Scalar > > &hess_g_xp_j_l)
Precondition: supports(OUT_ARG_hess_g_xp,j,l)==true.
void _setModelEvalDescription(const std::string &modelEvalDescription)
Abstract interface for finite-dimensional dense vectors.
RCP< LinearOpBase< Scalar > > get_hess_g_xx(int j) const
Precondition: supports(OUT_ARG_hess_g_xx,j)==true.
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_hess_g_xx(int j, const RCP< LinearOpBase< Scalar > > &hess_g_xx_j)
Precondition: supports(OUT_ARG_hess_g_xx,j)==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< MultiVectorBase< Scalar > > get_hess_vec_prod_g_px(int j, int l) const
Precondition: supports(OUT_ARG_hess_vec_prod_g_px,j,l)==true.
RCP< LinearOpBase< Scalar > > get_hess_f_pp(int l1, int l2) const
Precondition: supports(OUT_ARG_hess_f_pp,l1,l2)==true.
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.
void set_hess_vec_prod_f_px(int l, const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_f_px_l)
Precondition: supports(OUT_ARG_hess_vec_prod_f_px,l)==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_H_xx(const RCP< LinearOpBase< Scalar > > &H_xx)
Precondition: supports(OUT_ARG_H_xx)==true.
void set_hess_vec_prod_f_xp(int l, const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_f_xp_l)
Precondition: supports(OUT_ARG_hess_vec_prod_f_xp,l)==true.
void set_DgDx_dot(int j, const Derivative< Scalar > &DgDx_dot_j)
Precondition: supports(OUT_ARG_DgDx_dot,j)==true.
RCP< LinearOpBase< Scalar > > get_hess_g_pp(int j, int l1, int l2) const
Precondition: supports(OUT_ARG_hess_g_pp,j,l1,l2)==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.
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_f_xx() const
Precondition: supports(OUT_ARG_hess_vec_prod_f_xx)==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.
void set_hess_g_pp(int j, int l1, int l2, const RCP< LinearOpBase< Scalar > > &hess_g_pp_j_l1_l2)
Precondition: supports(OUT_ARG_hess_g_pp,j,l1,l2)==true.
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.
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_g_pp(int j, int l1, int l2) const
Precondition: supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2)==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)
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)
Precondition: supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2)==true.
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.
void set_H_pp(int l1, int l2, const RCP< LinearOpBase< Scalar > > &H_pp_l1_l2)
Precondition: supports(OUT_ARG_H_pp,l1,l2)==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< LinearOpBase< Scalar > > get_hess_f_xx() const
Precondition: supports(OUT_ARG_hess_f_xx)==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_H_xp(int l, const RCP< LinearOpBase< Scalar > > &H_xp_l)
Precondition: supports(OUT_ARG_H_xp,l)==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.
RCP< LinearOpBase< Scalar > > get_hess_f_xp(int l) const
Precondition: supports(OUT_ARG_hess_f_xp,l)==true.
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
void set_hess_vec_prod_g_xp(int j, int l, const RCP< MultiVectorBase< Scalar > > &hess_vec_prod_g_xp_j_l)
Precondition: supports(OUT_ARG_hess_vec_prod_g_xp,j,l)==true.
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 ...
RCP< MultiVectorBase< Scalar > > get_hess_vec_prod_g_xp(int j, int l) const
Precondition: supports(OUT_ARG_hess_vec_prod_g_xp,j,l)==true.
DerivativeProperties get_W_properties() const
Return the known properties of W (precondition: supports(OUT_ARG_f)==true).
RCP< LinearOpBase< Scalar > > get_H_xp(int l) const
Precondition: supports(OUT_ARG_H_xp,l)==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...