Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_ModelEvaluatorBase_def.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_DEF_HPP
43 #define THYRA_MODEL_EVALUATOR_BASE_DEF_HPP
44 
45 
46 #include "Thyra_ModelEvaluatorBase_decl.hpp"
47 #include "Thyra_MultiVectorBase.hpp"
48 #include "Thyra_VectorBase.hpp"
49 #include "Thyra_MultiVectorStdOps.hpp"
50 #include "Thyra_VectorStdOps.hpp"
51 
52 
53 namespace Thyra {
54 
55 
56 namespace ModelEvaluatorHelperPack {
57 
58 
59 template<class Scalar>
60 inline
61 RCP<const Thyra::VectorBase<Scalar> >
62 condCloneVec(
63  const RCP<const Thyra::VectorBase<Scalar> > &vec,
64  bool cloneObject
65  )
66 {
67  if(cloneObject)
68  return vec->clone_v();
69  return vec;
70 }
71 
72 template<class Scalar>
73 inline
74 RCP<const Thyra::MultiVectorBase<Scalar> >
75 condCloneMultiVec(
76  const RCP<const Thyra::MultiVectorBase<Scalar> > &vec,
77  bool cloneObject
78  )
79 {
80  if(cloneObject)
81  return vec->clone_mv();
82  return vec;
83 }
84 
85 inline
86 RCP<const Stokhos::ProductEpetraVector >
87 condCloneVec_mp(
88  const RCP<const Stokhos::ProductEpetraVector > &vec,
89  bool cloneObject
90  )
91 {
92  if(cloneObject)
93  {
94  printf("Warning: clone_v not implemented for ProductEpetraVector: %s %d\n",__FILE__,__LINE__);
95  //return vec->clone_v(); //JF clone_v not implemented for ProductEpetraVector
96  }
97  return vec;
98 }
99 
100 } // namespace ModelEvaluatorHelperPack
101 
102 
103 //
104 // ModelEvaluatorBase::InArgs
105 //
106 
107 
108 template<class Scalar>
110  :modelEvalDescription_("WARNING! THIS INARGS OBJECT IS UNINITIALIZED!")
111 {
114  std::fill_n(&supports_[0],NUM_E_IN_ARGS_MEMBERS,false);
115  t_ = SMT::zero();
116  alpha_ = ST::zero();
117  beta_ = ST::zero();
118  step_size_ = ST::zero();
119  stage_number_ = ST::one();
120 }
121 
122 
123 template<class Scalar>
125 { return p_.size(); }
126 
127 template<class Scalar>
129 { return g_multiplier_.size(); }
130 
131 template<class Scalar>
133 {
135  int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
136  ,"model = \'"<<modelEvalDescription_
137  <<"\': Error, arg="<<toString(arg)<<" is invalid!"
138  );
139  return supports_[arg];
140 }
141 
142 template<class Scalar>
144 {
145  assert_l(l);
146  return supports_p_mp_[l];
147 }
148 
149 template<class Scalar>
151  const RCP<const VectorBase<Scalar> > &x_dot_dot
152  )
153 { assert_supports(IN_ARG_x_dot_dot); x_dot_dot_ = x_dot_dot; }
154 
155 template<class Scalar>
158 { assert_supports(IN_ARG_x_dot_dot); return x_dot_dot_; }
159 
160 template<class Scalar>
162  const RCP<const VectorBase<Scalar> > &x_dot
163  )
164 { assert_supports(IN_ARG_x_dot); x_dot_ = x_dot; }
165 
166 
167 template<class Scalar>
170 { assert_supports(IN_ARG_x_dot); return x_dot_; }
171 
172 
173 template<class Scalar>
175  const RCP<const VectorBase<Scalar> > &x
176  )
177 { assert_supports(IN_ARG_x); x_ = x; }
178 
179 
180 template<class Scalar>
183 { assert_supports(IN_ARG_x); return x_; }
184 
185 
186 template<class Scalar>
188  const RCP<const MultiVectorBase<Scalar> > &x_direction
189  )
190 { assert_supports(IN_ARG_x); x_direction_ = x_direction; }
191 
192 
193 template<class Scalar>
195  int l, const RCP<const MultiVectorBase<Scalar> > &p_direction_l
196  )
197 { assert_l(l); p_direction_[l] = p_direction_l; }
198 
199 
200 template<class Scalar>
203 { assert_supports(IN_ARG_x); return x_direction_; }
204 
205 
206 template<class Scalar>
209 { assert_l(l); return p_direction_[l]; }
210 
211 
212 template<class Scalar>
215  )
216 { assert_supports(IN_ARG_x_dot_mp); x_dot_mp_ = x_dot_mp; }
217 
218 
219 template<class Scalar>
222 { assert_supports(IN_ARG_x_dot_mp); return x_dot_mp_; }
223 
224 
225 template<class Scalar>
228  )
229 { assert_supports(IN_ARG_x_mp); x_mp_ = x_mp; }
230 
231 
232 template<class Scalar>
235 { assert_supports(IN_ARG_x_mp); return x_mp_; }
236 
237 template<class Scalar>
239  const RCP<const VectorBase<Scalar> > &f_multiplier
240  )
241 { assert_supports(IN_ARG_x); f_multiplier_ = f_multiplier; }
242 
243 template<class Scalar>
246 { assert_supports(IN_ARG_x); return f_multiplier_; }
247 
248 template<class Scalar>
250  int j, const RCP<const VectorBase<Scalar> > &g_multiplier
251  )
252 {
253  assert_j(j);
254  assert_supports(IN_ARG_x);
255  g_multiplier_[j] = g_multiplier;
256 }
257 
258 template<class Scalar>
261 {
262  assert_j(j);
263  assert_supports(IN_ARG_x);
264  return g_multiplier_[j];
265 }
266 
267 #ifdef HAVE_THYRA_ME_POLYNOMIAL
268 
269 template<class Scalar>
271  const RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > &x_dot_poly
272  )
273 { assert_supports(IN_ARG_x_dot_poly); x_dot_poly_ = x_dot_poly; }
274 
275 
276 template<class Scalar>
279 { assert_supports(IN_ARG_x_dot_poly); return x_dot_poly_; }
280 
281 
282 template<class Scalar>
283 void ModelEvaluatorBase::InArgs<Scalar>::set_x_poly(
284  const RCP<const Teuchos::Polynomial< VectorBase<Scalar> > > &x_poly
285  )
286 { assert_supports(IN_ARG_x_poly); x_poly_ = x_poly; }
287 
288 
289 template<class Scalar>
290 RCP<const Teuchos::Polynomial< VectorBase<Scalar> > >
291 ModelEvaluatorBase::InArgs<Scalar>::get_x_poly() const
292 { assert_supports(IN_ARG_x_poly); return x_poly_; }
293 
294 
295 #endif // HAVE_THYRA_ME_POLYNOMIAL
296 
297 template<class Scalar>
299  int l, const RCP<const VectorBase<Scalar> > &p_l
300  )
301 { assert_l(l); p_[l] = p_l; }
302 
303 
304 template<class Scalar>
307 { assert_l(l); return p_[l]; }
308 
309 
310 template<class Scalar>
312  int l, const RCP<const Stokhos::ProductEpetraVector > &p_mp_l
313  )
314 { assert_supports(IN_ARG_p_mp, l); p_mp_[l] = p_mp_l; }
315 
316 template<class Scalar>
319 { assert_supports(IN_ARG_p_mp, l); return p_mp_[l]; }
320 
321 
322 template<class Scalar>
324 { assert_supports(IN_ARG_t); t_ = t; }
325 
326 
327 template<class Scalar>
330 { assert_supports(IN_ARG_t); return t_; }
331 
332 
333 template<class Scalar>
335 { assert_supports(IN_ARG_alpha); alpha_ = alpha; }
336 
337 
338 template<class Scalar>
340 { assert_supports(IN_ARG_alpha); return alpha_; }
341 
342 
343 template<class Scalar>
345 { assert_supports(IN_ARG_beta); beta_ = beta; }
346 
347 
348 template<class Scalar>
350 { assert_supports(IN_ARG_beta); return beta_; }
351 
352 template<class Scalar>
354 { assert_supports(IN_ARG_W_x_dot_dot_coeff); W_x_dot_dot_coeff_ = W_x_dot_dot_coeff; }
355 
356 
357 template<class Scalar>
359 { assert_supports(IN_ARG_W_x_dot_dot_coeff); return W_x_dot_dot_coeff_; }
360 
361 template<class Scalar>
363 { assert_supports(IN_ARG_step_size); step_size_ = step_size; }
364 
365 template<class Scalar>
367 { assert_supports(IN_ARG_step_size); return step_size_; }
368 
369 template<class Scalar>
371 { assert_supports(IN_ARG_stage_number); return stage_number_; }
372 
373 
374 template<class Scalar>
376 { assert_supports(IN_ARG_stage_number); stage_number_ = stage_number; }
377 
378 
379 template<class Scalar>
381  const InArgs<Scalar>& inArgs, bool ignoreUnsupported, bool cloneObjects
382  )
383 {
384  using ModelEvaluatorHelperPack::condCloneVec;
385  using ModelEvaluatorHelperPack::condCloneMultiVec;
386  using ModelEvaluatorHelperPack::condCloneVec_mp;
387  if( inArgs.supports(IN_ARG_x_dot_dot) && nonnull(inArgs.get_x_dot_dot()) ) {
388  if(supports(IN_ARG_x_dot_dot) || !ignoreUnsupported)
389  set_x_dot_dot(condCloneVec(inArgs.get_x_dot_dot(),cloneObjects));
390  }
391  if( inArgs.supports(IN_ARG_x_dot) && nonnull(inArgs.get_x_dot()) ) {
392  if(supports(IN_ARG_x_dot) || !ignoreUnsupported)
393  set_x_dot(condCloneVec(inArgs.get_x_dot(),cloneObjects));
394  }
395  if( inArgs.supports(IN_ARG_x_dot_mp) && nonnull(inArgs.get_x_dot_mp()) ) {
396  if(supports(IN_ARG_x_dot_mp) || !ignoreUnsupported)
397  set_x_dot_mp(condCloneVec_mp(inArgs.get_x_dot_mp(),cloneObjects));
398  }
399  if( inArgs.supports(IN_ARG_x) && nonnull(inArgs.get_x()) ) {
400  if(supports(IN_ARG_x) || !ignoreUnsupported)
401  set_x(condCloneVec(inArgs.get_x(),cloneObjects));
402  }
403  if( inArgs.supports(IN_ARG_x_mp) && nonnull(inArgs.get_x_mp()) ) {
404  if(supports(IN_ARG_x_mp) || !ignoreUnsupported)
405  set_x_mp(condCloneVec_mp(inArgs.get_x_mp(),cloneObjects));
406  }
407  if( inArgs.supports(IN_ARG_x) && nonnull(inArgs.get_x_direction()) ) {
408  if(supports(IN_ARG_x) || !ignoreUnsupported)
409  set_x_direction(condCloneMultiVec(inArgs.get_x_direction(),cloneObjects));
410  }
411  if( inArgs.supports(IN_ARG_x) && nonnull(inArgs.get_f_multiplier()) ) {
412  if(supports(IN_ARG_x) || !ignoreUnsupported)
413  set_f_multiplier(condCloneVec(inArgs.get_f_multiplier(),cloneObjects));
414  }
415  const int min_Ng = TEUCHOS_MIN(this->Ng(),inArgs.Ng());
416  for (int j = 0; j < min_Ng; ++j) {
417  if (nonnull(inArgs.get_g_multiplier(j)))
418  set_g_multiplier(j,condCloneVec(inArgs.get_g_multiplier(j),cloneObjects));
419  }
420 #ifdef HAVE_THYRA_ME_POLYNOMIAL
421  if( inArgs.supports(IN_ARG_x_dot_poly) && nonnull(inArgs.get_x_dot_poly()) ) {
422  if(supports(IN_ARG_x_dot_poly) || !ignoreUnsupported) {
424  cloneObjects && "Have not implemented cloning for x_dot_poly yet!" );
425  set_x_dot_poly(inArgs.get_x_dot_poly());
426  }
427  }
428  if( inArgs.supports(IN_ARG_x_poly) && nonnull(inArgs.get_x_poly()) ) {
429  if(supports(IN_ARG_x_poly) || !ignoreUnsupported) {
431  cloneObjects && "Have not implemented cloning for x_poly yet!" );
432  set_x_poly(inArgs.get_x_poly());
433  }
434  }
435 #endif // HAVE_THYRA_ME_POLYNOMIAL
436  const int min_Np = TEUCHOS_MIN(this->Np(),inArgs.Np());
437  for (int l = 0; l < min_Np; ++l) {
438  if (nonnull(inArgs.get_p(l)))
439  set_p(l,condCloneVec(inArgs.get_p(l),cloneObjects));
440  }
441  for (int l = 0; l < min_Np; ++l) {
442  if (nonnull(inArgs.get_p_direction(l)))
443  set_p_direction(l,condCloneMultiVec(inArgs.get_p_direction(l),cloneObjects));
444  }
445  for (int l = 0; l < min_Np; ++l) {
446  if (inArgs.supports(IN_ARG_p_mp,l)) {
447  if (nonnull(inArgs.get_p_mp(l)))
448  set_p_mp(l,condCloneVec_mp(inArgs.get_p_mp(l),cloneObjects));
449  }
450  }
451  if (inArgs.supports(IN_ARG_t)) {
452  if(supports(IN_ARG_t) || !ignoreUnsupported)
453  set_t(inArgs.get_t());
454  }
455  if (inArgs.supports(IN_ARG_alpha)) {
456  if(supports(IN_ARG_alpha) || !ignoreUnsupported)
457  set_alpha(inArgs.get_alpha());
458  }
459  if (inArgs.supports(IN_ARG_beta)) {
460  if(supports(IN_ARG_beta) || !ignoreUnsupported)
461  set_beta(inArgs.get_beta());
462  }
463  if (inArgs.supports(IN_ARG_W_x_dot_dot_coeff)) {
464  if(supports(IN_ARG_W_x_dot_dot_coeff) || !ignoreUnsupported)
465  set_W_x_dot_dot_coeff(inArgs.get_W_x_dot_dot_coeff());
466  }
467  if (inArgs.supports(IN_ARG_step_size)) {
468  if(supports(IN_ARG_step_size) || !ignoreUnsupported)
469  set_step_size(inArgs.get_step_size());
470  }
471  if (inArgs.supports(IN_ARG_stage_number)) {
472  if(supports(IN_ARG_stage_number) || !ignoreUnsupported)
473  set_stage_number(inArgs.get_stage_number());
474  }
475  // Extended inArgs
476  if (extended_inargs_.size() > 0)
477  TEUCHOS_TEST_FOR_EXCEPTION(cloneObjects,
478  std::runtime_error,
479  "Extended InArgs does not support cloning!");
480  this->extended_inargs_ = inArgs.extended_inargs_;
481 }
482 
483 
484 template<class Scalar>
486  const InArgs<Scalar> &inArgs
487  ) const
488 {
489  for ( int inArg_i = 0; inArg_i < NUM_E_IN_ARGS_MEMBERS; ++inArg_i ) {
490  const EInArgsMembers inArg_arg = static_cast<EInArgsMembers>(inArg_i);
491  const std::string inArg_name = toString(inArg_arg);
493  supports(inArg_arg) != inArgs.supports(inArg_arg), std::logic_error,
494  "Error, the input argument "<<inArg_name<<" with support "<<inArgs.supports(inArg_arg)<<"\n"
495  "in the InArgs object for the model:\n\n"
496  " "<<inArgs.modelEvalDescription()<<"\n\n"
497  "is not the same the argument "<<inArg_name<<" with support "<<supports(inArg_arg)<<"\n"
498  "in the InArgs object for the model:\n\n"
499  " "<<modelEvalDescription()<<"\n\n"
500  "and these two InArgs objects are not compatible!"
501  );
502  }
503  TEUCHOS_ASSERT_EQUALITY( this->Np(), inArgs.Np() );
504 }
505 
506 
507 template<class Scalar>
509 {
510  return modelEvalDescription_;
511 }
512 
513 
514 template<class Scalar>
516 {
518  std::ostringstream oss;
519  oss
520  << "Thyra::ModelEvaluatorBase::InArgs<"<<ST::name()<<">"
521  << "{"
522  << "model="<<modelEvalDescription_
523  << ",Np="<<Np()
524  << "}";
525  return oss.str();
526 }
527 
528 
529 template<class Scalar>
531  Teuchos::FancyOStream &out_arg, const Teuchos::EVerbosityLevel verbLevel
532  ) const
533 {
534  using std::endl;
536  using Teuchos::OSTab;
537  using Teuchos::describe;
539  typedef RCP<const VectorBase<Scalar> > CV_ptr;
540 
541  if(verbLevel == Teuchos::VERB_NONE)
542  return;
543 
545  out = Teuchos::rcp(&out_arg,false);
546  const bool dump_x = includesVerbLevel(verbLevel,Teuchos::VERB_HIGH);
547  const Teuchos::EVerbosityLevel x_verbLevel =
548  dump_x?Teuchos::VERB_EXTREME:verbLevel;
549  const bool print_x_nrm = includesVerbLevel(verbLevel,Teuchos::VERB_LOW);
550  const bool dump_p = includesVerbLevel(verbLevel,Teuchos::VERB_MEDIUM);
551  const Teuchos::EVerbosityLevel p_verbLevel =
552  dump_p?Teuchos::VERB_EXTREME:verbLevel;
553  const bool print_p_nrm = includesVerbLevel(verbLevel,Teuchos::VERB_LOW);
554  OSTab tab(out);
555 
556  *out <<"Thyra::ModelEvaluatorBase::InArgs<"<<ST::name()<<">:\n";
557  tab.incrTab();
558 
559  *out <<"model = " << modelEvalDescription_ << "\n";
560  *out <<"Np = " << Np() << "\n";
561 
562  CV_ptr x_dot_dot;
563  if ( this->supports(IN_ARG_x_dot_dot) && !is_null(x_dot_dot=get_x_dot_dot()) ) {
564  *out << "x_dot_dot = " << Teuchos::describe(*x_dot_dot,x_verbLevel);
565  if (print_x_nrm)
566  *out << "||x_dot_dot|| = " << norm(*x_dot_dot) << endl;
567  }
568 
569  CV_ptr x_dot;
570  if ( this->supports(IN_ARG_x_dot) && !is_null(x_dot=get_x_dot()) ) {
571  *out << "x_dot = " << Teuchos::describe(*x_dot,x_verbLevel);
572  if (print_x_nrm)
573  *out << "||x_dot|| = " << norm(*x_dot) << endl;
574  }
575 
576  CV_ptr x;
577  if ( this->supports(IN_ARG_x) && !is_null(x=get_x()) ) {
578  *out << "x = " << Teuchos::describe(*x,x_verbLevel);
579  if (print_x_nrm)
580  *out << "||x|| = " << norm(*x) << endl;
581  }
582 
583  if (print_x_nrm) {
584  for( int l = 0; l < Np(); ++l ) {
585  CV_ptr p_l;
586  if ( !is_null(p_l = this->get_p(l)) ) {
587  *out << "p("<<l<<") = " << Teuchos::describe(*p_l,p_verbLevel);
588  if (print_p_nrm)
589  *out << "||p("<<l<<")|| = " << norm(*p_l) << endl;
590  }
591  }
592  }
593 
594  if (includesVerbLevel(verbLevel,Teuchos::VERB_MEDIUM)) {
595  if (this->supports(IN_ARG_t)) {
596  *out << "t = " << t_ << endl;
597  }
598  if (this->supports(IN_ARG_alpha)) {
599  *out << "alpha = " << alpha_ << endl;
600  }
601  if (this->supports(IN_ARG_beta)) {
602  *out << "beta = " << beta_ << endl;
603  }
604  if (this->supports(IN_ARG_W_x_dot_dot_coeff)) {
605  *out << "W_x_dot_dot_coeff = " << W_x_dot_dot_coeff_ << endl;
606  }
607  if (this->supports(IN_ARG_step_size)) {
608  *out << "step_size = " << step_size_ << endl;
609  }
610  if (this->supports(IN_ARG_stage_number)) {
611  *out << "stage_number = " << stage_number_ << endl;
612  }
613  }
614 
615 }
616 
617 
618 template<class Scalar>
620  const std::string &modelEvalDescription_in
621  )
622 {
623  modelEvalDescription_ = modelEvalDescription_in;
624 }
625 
626 
627 template<class Scalar>
629 {
630  p_.resize(Np_in);
631  p_direction_.resize(Np_in);
632  p_mp_.resize(Np_in);
633  supports_p_mp_.resize(Np_in);
634  g_multiplier_.resize(Ng_in);
635 }
636 
637 
638 template<class Scalar>
640  EInArgsMembers arg, bool supports_in
641  )
642 {
644  int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
645  ,"model = \'"<<modelEvalDescription_
646  <<"\': Error, arg="<<toString(arg)<<" is invalid!");
647  supports_[arg] = supports_in;
648 }
649 
650 template<class Scalar>
652  EInArgs_p_mp /* arg */, int l, bool supports_in
653  )
654 {
655  assert_l(l);
656  supports_p_mp_[l] = supports_in;
657 }
658 
659 
660 template<class Scalar>
662  const InArgs<Scalar>& inArgs, const int Np_in
663  )
664 {
665  std::copy(
666  &inArgs.supports_[0],
667  &inArgs.supports_[0] + NUM_E_IN_ARGS_MEMBERS, &supports_[0] );
668  this->_set_Np_Ng( Np_in >= 0 ? Np_in : inArgs.Np(), inArgs.Ng() );
669 }
670 
671 
672 template<class Scalar>
674  EInArgsMembers arg
675  )
676 {
677  switch(arg) {
678  case IN_ARG_x: {
679  this->_setSupports(IN_ARG_x_dot_dot,false);
680  this->_setSupports(IN_ARG_x_dot,false);
681  this->_setSupports(IN_ARG_x_dot_poly,false);
682  this->_setSupports(IN_ARG_alpha,false);
683  this->_setSupports(IN_ARG_beta,false);
684  this->_setSupports(IN_ARG_W_x_dot_dot_coeff,false);
685  this->_setSupports(IN_ARG_step_size,false);
686  this->_setSupports(IN_ARG_stage_number,false);
687  break;
688  }
689  default:
691  true ,std::logic_error,
692  "Error, can not handle args other than IN_ARG_x yet!"
693  );
694  }
695  this->_setSupports(arg,false);
696 }
697 
698 
699 template<class Scalar>
701  EInArgsMembers arg
702  ) const
703 {
705  !supports_[arg], std::logic_error
706  ,"Thyra::ModelEvaluatorBase::InArgs<"
707  << Teuchos::ScalarTraits<Scalar>::name() <<">::assert_supports(arg): "
708  "model = \'"<<modelEvalDescription_<<"\': Error, "
709  "The argument arg = " << toString(arg) << " is not supported!"
710  );
711 }
712 
713 template<class Scalar>
715  EInArgs_p_mp /* arg */, int l
716  ) const
717 {
718  assert_l(l);
720  !supports_p_mp_[l], std::logic_error
721  ,"Thyra::ModelEvaluatorBase::InArgs<"
722  << Teuchos::ScalarTraits<Scalar>::name() <<">::assert_supports(IN_ARG_p_mp,1): "
723  "model = \'"<<modelEvalDescription_<<"\': Error, "
724  "The argument p_mp(l) with index l = " << l << " is not supported!"
725  );
726 }
727 
728 
729 template<class Scalar>
730 void ModelEvaluatorBase::InArgs<Scalar>::assert_l(int l) const
731 {
733  !( 0 <= l && l < Np() ), std::logic_error
734  ,"Thyra::ModelEvaluatorBase::InArgs<Scalar>::assert_l(l):\n\n"
735  " model = \'"<<modelEvalDescription_<<"\':\n\n"
736  "Error, The parameter l = " << l << " is not in the range [0,"<<Np()<<")!"
737  );
738 }
739 
740 template<class Scalar>
741 void ModelEvaluatorBase::InArgs<Scalar>::assert_j(int j) const
742 {
744  !( 0 <= j && j < Ng() ), std::logic_error
745  ,"Thyra::ModelEvaluatorBase::InArgs<Scalar>::assert_j(j):\n\n"
746  "model = \'"<<modelEvalDescription_<<"\':\n\n"
747  "Error, The auxiliary function g("<<j<<")"
748  " is not in the range [0,"<<Ng()<<")!"
749  );
750 }
751 
752 //
753 // ModelEvaluatorBase::DerivativeMultiVector
754 //
755 
756 
757 template<class Scalar>
759 {
760  using std::endl;
761  std::ostringstream oss;
762  oss << "DerivativeMultiVector{";
763  if (is_null(getMultiVector())) {
764  oss << "NULL";
765  }
766  else {
767  oss
768  << "multiVec=" << getMultiVector()->description()
769  << ",orientation=" << toString(getOrientation());
770  }
771  oss << "}";
772  return oss.str();
773 }
774 
775 
776 template<class Scalar>
778  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
779  ) const
780 {
781  using std::endl;
782  using Teuchos::describe;
783  Teuchos::OSTab tab1(out);
784  out << "DerivativeMultiVector\n";
785  Teuchos::OSTab tab2(out);
786  out
787  << "multiVec = "
788  << describe(*getMultiVector(),verbLevel)
789  << "orientation = "
790  << toString(getOrientation()) << endl;
791 }
792 
793 
794 // 2007/06/12: rabartl: The above description() and describe(...) functions
795 // have to be defined here and not in the class DerivativeMultiVector since it
796 // relies on the non-member function
797 // toString(ModelEvaluatorBase::EDerivativeMultiVectorOrientation) which is
798 // defined after the class definition for ModelEvaluatorBase. This was caught
799 // by the intel compiler. I am not sure why this worked with gcc.
800 
801 
802 //
803 // ModelEvaluatorBase::Derivative
804 //
805 
806 
807 template<class Scalar>
808 std::string
810 {
811  using std::endl;
812  std::ostringstream oss;
813  oss << "Derivative{";
814  if (isEmpty()) {
815  oss << "NULL";
816  }
817  else if (!is_null(getLinearOp())) {
818  oss << "linearOp=" << getLinearOp()->description();
819  }
820  else {
821  oss << "derivMultiVec=" << getDerivativeMultiVector().description();
822  }
823  oss << "}";
824  return oss.str();
825 }
826 
827 
828 template<class Scalar>
830  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel
831  ) const
832 {
833  using std::endl;
834  using Teuchos::describe;
835  Teuchos::OSTab tab1(out);
836  out << "Derivative:";
837  if (isEmpty()) {
838  out << " NULL\n";
839  }
840  else if (!is_null(getLinearOp())) {
841  out
842  << endl
843  << "linearOp = " << describe(*getLinearOp(),verbLevel);
844  }
845  else {
846  out
847  << endl
848  << "derivMultiVec = ";
849  getDerivativeMultiVector().describe(out,verbLevel);
850  }
851 }
852 
853 
854 //
855 // ModelEvaluatorBase::OutArgs
856 //
857 
858 
859 template<class Scalar>
861  :modelEvalDescription_("WARNING! THIS OUTARGS OBJECT IS UNINITIALIZED!"),
862  isFailed_(false)
863 {
864  std::fill_n(&supports_[0],NUM_E_OUT_ARGS_MEMBERS,false);
865  this->_setHessianSupports(false);
866 }
867 
868 
869 template<class Scalar>
871 { return DfDp_.size(); }
872 
873 
874 template<class Scalar>
876 { return g_.size(); }
877 
878 
879 template<class Scalar>
881  EOutArgsMembers arg
882  ) const
883 {
885  int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
886  ,"model = \'"<<modelEvalDescription_
887  <<"\': Error, arg="<<toString(arg)<<" is invalid!"
888  );
889  return supports_[arg];
890 }
891 
892 
893 template<class Scalar>
896  EOutArgsDfDp /* arg */, int l
897  ) const
898 {
899  assert_l(l);
900  return supports_DfDp_[l];
901 }
902 
903 
904 template<class Scalar>
907  EOutArgsDgDx_dot /* arg */, int j
908  ) const
909 {
910  assert_j(j);
911  return supports_DgDx_dot_[j];
912 }
913 
914 
915 template<class Scalar>
918  EOutArgsDgDx /* arg */, int j
919  ) const
920 {
921  assert_j(j);
922  return supports_DgDx_[j];
923 }
924 
925 
926 template<class Scalar>
929  EOutArgsDgDp /* arg */, int j, int l
930  ) const
931 {
932  assert_j(j);
933  assert_l(l);
934  return supports_DgDp_[ j*Np() + l ];
935 }
936 
937 
938 template<class Scalar>
941  ) const
942 {
943  return supports_hess_vec_prod_f_xx_;
944 }
945 
946 template<class Scalar>
948  EOutArgs_hess_vec_prod_f_xp /* arg */, int l
949  ) const
950 {
951  assert_l(l);
952  return supports_hess_vec_prod_f_xp_[l];
953 }
954 
955 template<class Scalar>
957  EOutArgs_hess_vec_prod_f_px /* arg */, int l
958  ) const
959 {
960  assert_l(l);
961  return supports_hess_vec_prod_f_px_[l];
962 }
963 
964 template<class Scalar>
966  EOutArgs_hess_vec_prod_f_pp /* arg */, int l1, int l2
967  ) const
968 {
969  assert_l(l1);
970  assert_l(l2);
971  return supports_hess_vec_prod_f_pp_[ l1*Np() + l2 ];
972 }
973 
974 template<class Scalar>
976  EOutArgs_hess_vec_prod_g_xx /* arg */, int j
977  ) const
978 {
979  assert_j(j);
980  return supports_hess_vec_prod_g_xx_[j];
981 }
982 
983 template<class Scalar>
985  EOutArgs_hess_vec_prod_g_xp /* arg */, int j, int l
986  ) const
987 {
988  assert_j(j);
989  assert_l(l);
990  return supports_hess_vec_prod_g_xp_[ j*Np() + l ];
991 }
992 
993 template<class Scalar>
995  EOutArgs_hess_vec_prod_g_px /* arg */, int j, int l
996  ) const
997 {
998  assert_j(j);
999  assert_l(l);
1000  return supports_hess_vec_prod_g_px_[ j*Np() + l ];
1001 }
1002 
1003 template<class Scalar>
1005  EOutArgs_hess_vec_prod_g_pp /* arg */, int j, int l1, int l2
1006  ) const
1007 {
1008  assert_j(j);
1009  assert_l(l1);
1010  assert_l(l2);
1011  return supports_hess_vec_prod_g_pp_[ j*Np()*Np() + l1*Np() + l2 ];
1012 }
1013 
1014 template<class Scalar>
1016  EOutArgs_hess_f_xx /* arg */
1017  ) const
1018 {
1019  return supports_hess_f_xx_;
1020 }
1021 
1022 template<class Scalar>
1024  EOutArgs_hess_f_xp /* arg */, int l
1025  ) const
1026 {
1027  assert_l(l);
1028  return supports_hess_f_xp_[l];
1029 }
1030 
1031 template<class Scalar>
1033  EOutArgs_hess_f_pp /* arg */, int l1, int l2
1034  ) const
1035 {
1036  assert_l(l1);
1037  assert_l(l2);
1038  return supports_hess_f_pp_[ l1*Np() + l2 ];
1039 }
1040 
1041 template<class Scalar>
1043  EOutArgs_H_xx /* arg */
1044  ) const
1045 {
1046  return supports_H_xx_;
1047 }
1048 
1049 template<class Scalar>
1051  EOutArgs_H_xp /* arg */, int l
1052  ) const
1053 {
1054  assert_l(l);
1055  return supports_H_xp_[l];
1056 }
1057 
1058 template<class Scalar>
1060  EOutArgs_H_pp /* arg */, int l1, int l2
1061  ) const
1062 {
1063  assert_l(l1);
1064  assert_l(l2);
1065  return supports_H_pp_[ l1*Np() + l2 ];
1066 }
1067 
1068 template<class Scalar>
1070  EOutArgs_hess_g_xx /* arg */, int j
1071  ) const
1072 {
1073  assert_j(j);
1074  return supports_hess_g_xx_[j];
1075 }
1076 
1077 template<class Scalar>
1079  EOutArgs_hess_g_xp /* arg */, int j, int l
1080  ) const
1081 {
1082  assert_j(j);
1083  assert_l(l);
1084  return supports_hess_g_xp_[ j*Np() + l ];
1085 }
1086 
1087 template<class Scalar>
1089  EOutArgs_hess_g_pp /* arg */, int j, int l1, int l2
1090  ) const
1091 {
1092  assert_j(j);
1093  assert_l(l1);
1094  assert_l(l2);
1095  return supports_hess_g_pp_[ j*Np()*Np() + l1*Np() + l2 ];
1096 }
1097 
1098 
1099 template<class Scalar>
1100 bool
1102  EOutArgs_g_mp /* arg */, int j
1103  ) const
1104 {
1105  assert_j(j);
1106  return supports_g_mp_[j];
1107 }
1108 
1109 template<class Scalar>
1112  EOutArgsDfDp_mp /* arg */, int l
1113  ) const
1114 {
1115  assert_l(l);
1116  return supports_DfDp_mp_[l];
1117 }
1118 
1119 
1120 template<class Scalar>
1121 const ModelEvaluatorBase::DerivativeSupport&
1123  EOutArgsDgDx_dot_mp /* arg */, int j
1124  ) const
1125 {
1126  assert_j(j);
1127  return supports_DgDx_dot_mp_[j];
1128 }
1129 
1130 
1131 template<class Scalar>
1132 const ModelEvaluatorBase::DerivativeSupport&
1134  EOutArgsDgDx_mp /* arg */, int j
1135  ) const
1136 {
1137  assert_j(j);
1138  return supports_DgDx_mp_[j];
1139 }
1140 
1141 
1142 template<class Scalar>
1143 const ModelEvaluatorBase::DerivativeSupport&
1145  EOutArgsDgDp_mp /* arg */, int j, int l
1146  ) const
1147 {
1148  assert_j(j);
1149  assert_l(l);
1150  return supports_DgDp_mp_[ j*Np() + l ];
1151 }
1152 
1153 
1154 
1155 template<class Scalar>
1157  const Evaluation<VectorBase<Scalar> > &f
1158  )
1159 {
1160  assert_supports(OUT_ARG_f);
1161  f_ = f;
1162 }
1163 
1164 
1165 template<class Scalar>
1168 {
1169  assert_supports(OUT_ARG_f);
1170  return f_;
1171 }
1172 
1173 
1174 template<class Scalar>
1176  int j, const Evaluation<VectorBase<Scalar> > &g_j
1177  )
1178 {
1179  assert_j(j);
1180  g_[j] = g_j;
1181 }
1182 
1183 
1184 template<class Scalar>
1187 {
1188  assert_j(j);
1189  return g_[j];
1190 }
1191 
1192 
1193 template<class Scalar>
1196  )
1197 {
1198  assert_supports(OUT_ARG_f_mp);
1199  f_mp_ = f_mp;
1200 }
1201 
1202 
1203 template<class Scalar>
1206 {
1207  assert_supports(OUT_ARG_f_mp);
1208  return f_mp_;
1209 }
1210 
1211 
1212 template<class Scalar>
1214  int j, const RCP<Stokhos::ProductEpetraVector> &g_mp_j
1215  )
1216 {
1217  assert_supports(OUT_ARG_g_mp,j);
1218  g_mp_[j] = g_mp_j;
1219 }
1220 
1221 
1222 template<class Scalar>
1225 {
1226  assert_supports(OUT_ARG_g_mp,j);
1227  return g_mp_[j];
1228 }
1229 
1230 
1231 template<class Scalar>
1234  )
1235 {
1236  assert_supports(OUT_ARG_W);
1237  W_ = W;
1238 }
1239 
1240 
1241 template<class Scalar>
1244 {
1245  assert_supports(OUT_ARG_W);
1246  return W_;
1247 }
1248 
1249 
1250 template<class Scalar>
1253  )
1254 {
1255  assert_supports(OUT_ARG_W_mp);
1256  W_mp_ = W_mp;
1257 }
1258 
1259 
1260 template<class Scalar>
1263 {
1264  assert_supports(OUT_ARG_W_mp);
1265  return W_mp_;
1266 }
1267 
1268 
1269 template<class Scalar>
1271  const RCP<LinearOpBase<Scalar> > &W_op
1272  )
1273 {
1274  assert_supports(OUT_ARG_W_op);
1275  W_op_ = W_op;
1276 }
1277 
1278 
1279 template<class Scalar>
1282 {
1283  assert_supports(OUT_ARG_W_op);
1284  return W_op_;
1285 }
1286 
1287 
1288 template<class Scalar>
1290  const RCP<PreconditionerBase<Scalar> > &W_prec
1291  )
1292 {
1293  assert_supports(OUT_ARG_W_prec);
1294  W_prec_ = W_prec;
1295 }
1296 
1297 
1298 template<class Scalar>
1301 {
1302  assert_supports(OUT_ARG_W_prec);
1303  return W_prec_;
1304 }
1305 
1306 
1307 template<class Scalar>
1310 {
1311  assert_supports(OUT_ARG_f);
1312  return W_properties_;
1313 }
1314 
1315 
1316 template<class Scalar>
1318  int l, const Derivative<Scalar> &DfDp_l
1319  )
1320 {
1321  assert_supports(OUT_ARG_DfDp,l,DfDp_l);
1322  DfDp_[l] = DfDp_l;
1323 }
1324 
1325 
1326 template<class Scalar>
1329 {
1330  assert_supports(OUT_ARG_DfDp,l);
1331  return DfDp_[l];
1332 }
1333 
1334 
1335 template<class Scalar>
1338 {
1339  assert_supports(OUT_ARG_DfDp,l);
1340  return DfDp_properties_[l];
1341 }
1342 
1343 
1344 template<class Scalar>
1346  int l, const MPDerivative &DfDp_mp_l
1347  )
1348 {
1349  assert_supports(OUT_ARG_DfDp_mp,l,DfDp_mp_l);
1350  DfDp_mp_[l] = DfDp_mp_l;
1351 }
1352 
1353 
1354 template<class Scalar>
1357 {
1358  assert_supports(OUT_ARG_DfDp_mp,l);
1359  return DfDp_mp_[l];
1360 }
1361 
1362 
1363 template<class Scalar>
1364 ModelEvaluatorBase::DerivativeProperties
1365 ModelEvaluatorBase::OutArgs<Scalar>::get_DfDp_mp_properties(int l) const
1366 {
1367  assert_supports(OUT_ARG_DfDp_mp,l);
1368  return DfDp_mp_properties_[l];
1369 }
1370 
1371 
1372 template<class Scalar>
1374  int j, const Derivative<Scalar> &DgDx_dot_j
1375  )
1376 {
1377  assert_supports(OUT_ARG_DgDx_dot,j,DgDx_dot_j);
1378  DgDx_dot_[j] = DgDx_dot_j;
1379 }
1380 
1381 
1382 template<class Scalar>
1385 {
1386  assert_supports(OUT_ARG_DgDx_dot,j);
1387  return DgDx_dot_[j];
1388 }
1389 
1390 
1391 template<class Scalar>
1394 {
1395  assert_supports(OUT_ARG_DgDx_dot,j);
1396  return DgDx_dot_properties_[j];
1397 }
1398 
1399 
1400 template<class Scalar>
1402  int j, const MPDerivative &DgDx_dot_mp_j
1403  )
1404 {
1405  assert_supports(OUT_ARG_DgDx_dot_mp,j,DgDx_dot_mp_j);
1406  DgDx_dot_mp_[j] = DgDx_dot_mp_j;
1407 }
1408 
1409 
1410 template<class Scalar>
1413 {
1414  assert_supports(OUT_ARG_DgDx_dot_mp,j);
1415  return DgDx_dot_mp_[j];
1416 }
1417 
1418 
1419 template<class Scalar>
1420 ModelEvaluatorBase::DerivativeProperties
1421 ModelEvaluatorBase::OutArgs<Scalar>::get_DgDx_dot_mp_properties(int j) const
1422 {
1423  assert_supports(OUT_ARG_DgDx_dot_mp,j);
1424  return DgDx_dot_mp_properties_[j];
1425 }
1426 
1427 
1428 template<class Scalar>
1430  int j, const Derivative<Scalar> &DgDx_j
1431  )
1432 {
1433  assert_supports(OUT_ARG_DgDx,j,DgDx_j);
1434  DgDx_[j] = DgDx_j;
1435 }
1436 
1437 
1438 template<class Scalar>
1441 {
1442  assert_supports(OUT_ARG_DgDx,j);
1443  return DgDx_[j];
1444 }
1445 
1446 
1447 template<class Scalar>
1450 {
1451  assert_supports(OUT_ARG_DgDx,j);
1452  return DgDx_properties_[j];
1453 }
1454 
1455 
1456 template<class Scalar>
1458  int j, const MPDerivative &DgDx_mp_j
1459  )
1460 {
1461  assert_supports(OUT_ARG_DgDx_mp,j,DgDx_mp_j);
1462  DgDx_mp_[j] = DgDx_mp_j;
1463 }
1464 
1465 
1466 template<class Scalar>
1469 {
1470  assert_supports(OUT_ARG_DgDx_mp,j);
1471  return DgDx_mp_[j];
1472 }
1473 
1474 
1475 template<class Scalar>
1476 ModelEvaluatorBase::DerivativeProperties
1477 ModelEvaluatorBase::OutArgs<Scalar>::get_DgDx_mp_properties(int j) const
1478 {
1479  assert_supports(OUT_ARG_DgDx_mp,j);
1480  return DgDx_mp_properties_[j];
1481 }
1482 
1483 
1484 template<class Scalar>
1486  int j, int l, const Derivative<Scalar> &DgDp_j_l
1487  )
1488 {
1489  assert_supports(OUT_ARG_DgDp,j,l,DgDp_j_l);
1490  DgDp_[ j*Np() + l ] = DgDp_j_l;
1491 }
1492 
1493 
1494 template<class Scalar>
1497 {
1498  assert_supports(OUT_ARG_DgDp,j,l);
1499  return DgDp_[ j*Np() + l ];
1500 }
1501 
1502 
1503 template<class Scalar>
1506 {
1507  assert_supports(OUT_ARG_DgDp,j,l);
1508  return DgDp_properties_[ j*Np() + l ];
1509 }
1510 
1511 
1512 template<class Scalar>
1514  int j, int l, const MPDerivative &DgDp_mp_j_l
1515  )
1516 {
1517  assert_supports(OUT_ARG_DgDp_mp,j,l,DgDp_mp_j_l);
1518  DgDp_mp_[ j*Np() + l ] = DgDp_mp_j_l;
1519 }
1520 
1521 
1522 template<class Scalar>
1525 {
1526  assert_supports(OUT_ARG_DgDp_mp,j,l);
1527  return DgDp_mp_[ j*Np() + l ];
1528 }
1529 
1530 
1531 template<class Scalar>
1532 ModelEvaluatorBase::DerivativeProperties
1533 ModelEvaluatorBase::OutArgs<Scalar>::get_DgDp_mp_properties(int j, int l) const
1534 {
1535  assert_supports(OUT_ARG_DgDp_mp,j,l);
1536  return DgDp_mp_properties_[ j*Np() + l ];
1537 }
1538 
1539 
1540 template<class Scalar>
1542  const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_xx
1543  )
1544 {
1545  assert_supports(OUT_ARG_hess_vec_prod_f_xx);
1546  hess_vec_prod_f_xx_ = hess_vec_prod_f_xx;
1547 }
1548 
1549 template<class Scalar>
1551  int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_xp_l
1552  )
1553 {
1554  assert_supports(OUT_ARG_hess_vec_prod_f_xp,l);
1555  hess_vec_prod_f_xp_[l] = hess_vec_prod_f_xp_l;
1556 }
1557 
1558 template<class Scalar>
1560  int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_px_l
1561  )
1562 {
1563  assert_supports(OUT_ARG_hess_vec_prod_f_px,l);
1564  hess_vec_prod_f_px_[l] = hess_vec_prod_f_px_l;
1565 }
1566 
1567 template<class Scalar>
1569  int l1, int l2, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_f_pp_l1_l2
1570  )
1571 {
1572  assert_supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2);
1573  hess_vec_prod_f_pp_[ l1*Np() + l2 ] = hess_vec_prod_f_pp_l1_l2;
1574 }
1575 
1576 template<class Scalar>
1579 {
1580  assert_supports(OUT_ARG_hess_vec_prod_f_xx);
1581  return hess_vec_prod_f_xx_;
1582 }
1583 
1584 template<class Scalar>
1587 {
1588  assert_supports(OUT_ARG_hess_vec_prod_f_xp,l);
1589  return hess_vec_prod_f_xp_[l];
1590 }
1591 
1592 template<class Scalar>
1595 {
1596  assert_supports(OUT_ARG_hess_vec_prod_f_px,l);
1597  return hess_vec_prod_f_px_[l];
1598 }
1599 
1600 template<class Scalar>
1603 {
1604  assert_supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2);
1605  return hess_vec_prod_f_pp_[ l1*Np() + l2 ];
1606 }
1607 
1608 
1609 template<class Scalar>
1611  int j, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_xx_j
1612  )
1613 {
1614  assert_supports(OUT_ARG_hess_vec_prod_g_xx,j);
1615  hess_vec_prod_g_xx_[j] = hess_vec_prod_g_xx_j;
1616 }
1617 
1618 template<class Scalar>
1620  int j, int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_xp_j_l
1621  )
1622 {
1623  assert_supports(OUT_ARG_hess_vec_prod_g_xp,j,l);
1624  hess_vec_prod_g_xp_[ j*Np() + l ] = hess_vec_prod_g_xp_j_l;
1625 }
1626 
1627 template<class Scalar>
1629  int j, int l, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_px_j_l
1630  )
1631 {
1632  assert_supports(OUT_ARG_hess_vec_prod_g_px,j,l);
1633  hess_vec_prod_g_px_[ j*Np() + l ] = hess_vec_prod_g_px_j_l;
1634 }
1635 
1636 template<class Scalar>
1638  int j, int l1, int l2, const RCP<MultiVectorBase<Scalar> > &hess_vec_prod_g_pp_j_l1_l2
1639  )
1640 {
1641  assert_supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2);
1642  hess_vec_prod_g_pp_[ j*Np()*Np() + l1*Np() + l2 ] = hess_vec_prod_g_pp_j_l1_l2;
1643 }
1644 
1645 template<class Scalar>
1648 {
1649  assert_supports(OUT_ARG_hess_vec_prod_g_xx,j);
1650  return hess_vec_prod_g_xx_[j];
1651 }
1652 
1653 template<class Scalar>
1656 {
1657  assert_supports(OUT_ARG_hess_vec_prod_g_xp,j,l);
1658  return hess_vec_prod_g_xp_[ j*Np() + l ];
1659 }
1660 
1661 template<class Scalar>
1664 {
1665  assert_supports(OUT_ARG_hess_vec_prod_g_px,j,l);
1666  return hess_vec_prod_g_px_[ j*Np() + l ];
1667 }
1668 
1669 template<class Scalar>
1672 {
1673  assert_supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2);
1674  return hess_vec_prod_g_pp_[ j*Np()*Np() + l1*Np() + l2 ];
1675 }
1676 
1677 template<class Scalar>
1679  const RCP<LinearOpBase<Scalar> > &hess_f_xx
1680  )
1681 {
1682  assert_supports(OUT_ARG_hess_f_xx);
1683  hess_f_xx_ = hess_f_xx;
1684 }
1685 
1686 template<class Scalar>
1688  int l, const RCP<LinearOpBase<Scalar> > &hess_f_xp_l
1689  )
1690 {
1691  assert_supports(OUT_ARG_hess_f_xp,l);
1692  hess_f_xp_[l] = hess_f_xp_l;
1693 }
1694 
1695 template<class Scalar>
1697  int l1, int l2, const RCP<LinearOpBase<Scalar> > &hess_f_pp_l1_l2
1698  )
1699 {
1700  assert_supports(OUT_ARG_hess_f_pp,l1,l2);
1701  hess_f_pp_[ l1*Np() + l2 ] = hess_f_pp_l1_l2;
1702 }
1703 
1704 template<class Scalar>
1707 {
1708  assert_supports(OUT_ARG_hess_f_xx);
1709  return hess_f_xx_;
1710 }
1711 
1712 template<class Scalar>
1715 {
1716  assert_supports(OUT_ARG_hess_f_xp,l);
1717  return hess_f_xp_[l];
1718 }
1719 
1720 template<class Scalar>
1723 {
1724  assert_supports(OUT_ARG_hess_f_pp,l1,l2);
1725  return hess_f_pp_[ l1*Np() + l2 ];
1726 }
1727 
1728 template<class Scalar>
1730  int j, const RCP<LinearOpBase<Scalar> > &hess_g_xx_j
1731  )
1732 {
1733  assert_supports(OUT_ARG_hess_g_xx,j);
1734  hess_g_xx_[j] = hess_g_xx_j;
1735 }
1736 
1737 template<class Scalar>
1739  int j, int l, const RCP<LinearOpBase<Scalar> > &hess_g_xp_j_l
1740  )
1741 {
1742  assert_supports(OUT_ARG_hess_g_xp,j,l);
1743  hess_g_xp_[ j*Np() + l ] = hess_g_xp_j_l;
1744 }
1745 
1746 template<class Scalar>
1748  int j, int l1, int l2, const RCP<LinearOpBase<Scalar> > &hess_g_pp_j_l1_l2
1749  )
1750 {
1751  assert_supports(OUT_ARG_hess_g_pp,j,l1,l2);
1752  hess_g_pp_[ j*Np()*Np() + l1*Np() + l2 ] = hess_g_pp_j_l1_l2;
1753 }
1754 
1755 template<class Scalar>
1758 {
1759  assert_supports(OUT_ARG_hess_g_xx,j);
1760  return hess_g_xx_[j];
1761 }
1762 
1763 template<class Scalar>
1766 {
1767  assert_supports(OUT_ARG_hess_g_xp,j,l);
1768  return hess_g_xp_[ j*Np() + l ];
1769 }
1770 
1771 template<class Scalar>
1774 {
1775  assert_supports(OUT_ARG_hess_g_pp,j,l1,l2);
1776  return hess_g_pp_[ j*Np()*Np() + l1*Np() + l2 ];
1777 }
1778 
1779 template<class Scalar>
1781  const RCP<LinearOpBase<Scalar> > &H_xx
1782  )
1783 {
1784  assert_supports(OUT_ARG_H_xx);
1785  H_xx_ = H_xx;
1786 }
1787 
1788 template<class Scalar>
1790  int l, const RCP<LinearOpBase<Scalar> > &H_xp_l
1791  )
1792 {
1793  assert_supports(OUT_ARG_H_xp,l);
1794  H_xp_[l] = H_xp_l;
1795 }
1796 
1797 template<class Scalar>
1799  int l1, int l2, const RCP<LinearOpBase<Scalar> > &H_pp_l1_l2
1800  )
1801 {
1802  assert_supports(OUT_ARG_H_pp,l1,l2);
1803  H_pp_[ l1*Np() + l2 ] = H_pp_l1_l2;
1804 }
1805 
1806 template<class Scalar>
1809 {
1810  assert_supports(OUT_ARG_H_xx);
1811  return H_xx_;
1812 }
1813 
1814 template<class Scalar>
1817 {
1818  assert_supports(OUT_ARG_H_xp,l);
1819  return H_xp_[l];
1820 }
1821 
1822 template<class Scalar>
1825 {
1826  assert_supports(OUT_ARG_H_pp,l1,l2);
1827  return H_pp_[ l1*Np() + l2 ];
1828 }
1829 
1830 
1831 #ifdef HAVE_THYRA_ME_POLYNOMIAL
1832 
1833 
1834 template<class Scalar>
1836  const RCP<Teuchos::Polynomial< VectorBase<Scalar> > > &f_poly
1837  )
1838 {
1839  f_poly_ = f_poly;
1840 }
1841 
1842 
1843 template<class Scalar>
1846 {
1847  return f_poly_;
1848 }
1849 
1850 
1851 #endif // HAVE_THYRA_ME_POLYNOMIAL
1852 
1853 
1854 template<class Scalar>
1856  const OutArgs<Scalar>& inputOutArgs, bool ignoreUnsupported
1857  )
1858 {
1859  typedef ModelEvaluatorBase MEB;
1860  const int min_Np = TEUCHOS_MIN(this->Np(),inputOutArgs.Np());
1861  const int min_Ng = TEUCHOS_MIN(this->Ng(),inputOutArgs.Ng());
1862  // f
1863  if ( inputOutArgs.supports(OUT_ARG_f) && nonnull(inputOutArgs.get_f()) ) {
1864  if ( supports(OUT_ARG_f) || !ignoreUnsupported )
1865  set_f(inputOutArgs.get_f());
1866  }
1867  if ( inputOutArgs.supports(OUT_ARG_f_mp) && nonnull(inputOutArgs.get_f_mp()) ) {
1868  if ( supports(OUT_ARG_f_mp) || !ignoreUnsupported )
1869  set_f_mp(inputOutArgs.get_f_mp());
1870  }
1871 #ifdef HAVE_THYRA_ME_POLYNOMIAL
1872  // f_poly
1873  if ( inputOutArgs.supports(OUT_ARG_f_poly) && nonnull(inputOutArgs.get_f_poly()) ) {
1874  if ( supports(OUT_ARG_f_poly) || !ignoreUnsupported )
1875  set_f_poly(inputOutArgs.get_f_poly());
1876  }
1877 #endif // HAVE_THYRA_ME_POLYNOMIAL
1878  // g(j)
1879  for ( int j = 0; j < min_Ng; ++j ) {
1880  if ( nonnull(inputOutArgs.get_g(j)) )
1881  set_g(j,inputOutArgs.get_g(j));
1882  }
1883  for ( int j = 0; j < min_Ng; ++j ) {
1884  if ( inputOutArgs.supports(OUT_ARG_g_mp,j) && nonnull(inputOutArgs.get_g_mp(j)) ) {
1885  if ( supports(OUT_ARG_g_mp,j) || !ignoreUnsupported )
1886  set_g_mp(j,inputOutArgs.get_g_mp(j));
1887  }
1888  }
1889  // W
1890  if( inputOutArgs.supports(OUT_ARG_W) && nonnull(inputOutArgs.get_W()) ) {
1891  if ( supports(OUT_ARG_W) || !ignoreUnsupported )
1892  set_W(inputOutArgs.get_W());
1893  }
1894  if( inputOutArgs.supports(OUT_ARG_W_mp) && nonnull(inputOutArgs.get_W_mp()) ) {
1895  if ( supports(OUT_ARG_W_mp) || !ignoreUnsupported )
1896  set_W_mp(inputOutArgs.get_W_mp());
1897  }
1898  // W_op
1899  if( inputOutArgs.supports(OUT_ARG_W_op) && nonnull(inputOutArgs.get_W_op()) ) {
1900  if ( supports(OUT_ARG_W_op) || !ignoreUnsupported )
1901  set_W_op(inputOutArgs.get_W_op());
1902  }
1903  // W_prec
1904  if( inputOutArgs.supports(OUT_ARG_W_prec) && nonnull(inputOutArgs.get_W_prec()) ) {
1905  if ( supports(OUT_ARG_W_prec) || !ignoreUnsupported )
1906  set_W_prec(inputOutArgs.get_W_prec());
1907  }
1908  // DfDp(l)
1909  for ( int l = 0; l < min_Np; ++l ) {
1910  MEB::Derivative<Scalar> DfDp_l;
1911  if ( !inputOutArgs.supports(OUT_ARG_DfDp,l).none()
1912  && !(DfDp_l=inputOutArgs.get_DfDp(l)).isEmpty() )
1913  {
1914  if ( DfDp_l.isSupportedBy(supports(OUT_ARG_DfDp,l)) || !ignoreUnsupported )
1915  set_DfDp(l,DfDp_l);
1916  }
1917  }
1918  for ( int l = 0; l < min_Np; ++l ) {
1919  MEB::MPDerivative DfDp_mp_l;
1920  if ( !inputOutArgs.supports(OUT_ARG_DfDp_mp,l).none()
1921  && !(DfDp_mp_l=inputOutArgs.get_DfDp_mp(l)).isEmpty() )
1922  {
1923  if ( DfDp_mp_l.isSupportedBy(supports(OUT_ARG_DfDp_mp,l)) || !ignoreUnsupported )
1924  set_DfDp_mp(l,DfDp_mp_l);
1925  }
1926  }
1927  // DgDx_dot(j) and DgDx(j)
1928  for ( int j = 0; j < min_Ng; ++j ) {
1929  // DgDx_dot(j)
1930  MEB::Derivative<Scalar> DgDx_dot_j;
1931  if ( !inputOutArgs.supports(OUT_ARG_DgDx_dot,j).none()
1932  && !(DgDx_dot_j=inputOutArgs.get_DgDx_dot(j)).isEmpty() )
1933  {
1934  if( DgDx_dot_j.isSupportedBy(supports(OUT_ARG_DgDx_dot,j)) || !ignoreUnsupported )
1935  set_DgDx_dot(j,DgDx_dot_j);
1936  }
1937  // DgDx(j)
1938  MEB::Derivative<Scalar> DgDx_j;
1939  if ( !inputOutArgs.supports(OUT_ARG_DgDx,j).none()
1940  && !(DgDx_j=inputOutArgs.get_DgDx(j)).isEmpty() ) {
1941  if ( DgDx_j.isSupportedBy(supports(OUT_ARG_DgDx,j)) || !ignoreUnsupported )
1942  set_DgDx(j,DgDx_j);
1943  }
1944  }
1945  for ( int j = 0; j < min_Ng; ++j ) {
1946  // DgDx_dot(j)
1947  MEB::MPDerivative DgDx_dot_mp_j;
1948  if ( !inputOutArgs.supports(OUT_ARG_DgDx_dot_mp,j).none()
1949  && !(DgDx_dot_mp_j=inputOutArgs.get_DgDx_dot_mp(j)).isEmpty() )
1950  {
1951  if( DgDx_dot_mp_j.isSupportedBy(supports(OUT_ARG_DgDx_dot_mp,j)) || !ignoreUnsupported )
1952  set_DgDx_dot_mp(j,DgDx_dot_mp_j);
1953  }
1954  // DgDx(j)
1955  MEB::MPDerivative DgDx_mp_j;
1956  if ( !inputOutArgs.supports(OUT_ARG_DgDx_mp,j).none()
1957  && !(DgDx_mp_j=inputOutArgs.get_DgDx_mp(j)).isEmpty() ) {
1958  if ( DgDx_mp_j.isSupportedBy(supports(OUT_ARG_DgDx_mp,j)) || !ignoreUnsupported )
1959  set_DgDx_mp(j,DgDx_mp_j);
1960  }
1961  }
1962  // DgDp(j,l)
1963  for ( int l = 0; l < min_Np; ++l ) {
1964  for ( int j = 0; j < min_Ng; ++j ) {
1965  MEB::Derivative<Scalar> DgDp_j_l;
1966  if ( !inputOutArgs.supports(OUT_ARG_DgDp,j,l).none()
1967  && !(DgDp_j_l=inputOutArgs.get_DgDp(j,l)).isEmpty() )
1968  {
1969  if ( DgDp_j_l.isSupportedBy(supports(OUT_ARG_DgDp,j,l)) || !ignoreUnsupported )
1970  set_DgDp(j,l,DgDp_j_l);
1971  }
1972  }
1973  }
1974  for ( int l = 0; l < min_Np; ++l ) {
1975  for ( int j = 0; j < min_Ng; ++j ) {
1976  MEB::MPDerivative DgDp_mp_j_l;
1977  if ( !inputOutArgs.supports(OUT_ARG_DgDp_mp,j,l).none()
1978  && !(DgDp_mp_j_l=inputOutArgs.get_DgDp_mp(j,l)).isEmpty() )
1979  {
1980  if ( DgDp_mp_j_l.isSupportedBy(supports(OUT_ARG_DgDp_mp,j,l)) || !ignoreUnsupported )
1981  set_DgDp_mp(j,l,DgDp_mp_j_l);
1982  }
1983  }
1984  }
1985 
1986  // hess_vec_prod_f
1987  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_f_xx) && nonnull(inputOutArgs.get_hess_vec_prod_f_xx()) ) {
1988  if ( supports(OUT_ARG_hess_vec_prod_f_xx) || !ignoreUnsupported )
1989  set_hess_vec_prod_f_xx(inputOutArgs.get_hess_vec_prod_f_xx());
1990  }
1991  for ( int l1 = 0; l1 < min_Np; ++l1 ) {
1992  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_f_xp,l1) && nonnull(inputOutArgs.get_hess_vec_prod_f_xp(l1)) ) {
1993  if ( supports(OUT_ARG_hess_vec_prod_f_xp,l1) || !ignoreUnsupported )
1994  set_hess_vec_prod_f_xp(l1,inputOutArgs.get_hess_vec_prod_f_xp(l1));
1995  }
1996  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_f_px,l1) && nonnull(inputOutArgs.get_hess_vec_prod_f_px(l1)) ) {
1997  if ( supports(OUT_ARG_hess_vec_prod_f_px,l1) || !ignoreUnsupported )
1998  set_hess_vec_prod_f_px(l1,inputOutArgs.get_hess_vec_prod_f_px(l1));
1999  }
2000  for ( int l2 = 0; l2 < min_Np; ++l2 ) {
2001  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2) && nonnull(inputOutArgs.get_hess_vec_prod_f_pp(l1,l2)) ) {
2002  if ( supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2) || !ignoreUnsupported )
2003  set_hess_vec_prod_f_pp(l1,l2,inputOutArgs.get_hess_vec_prod_f_pp(l1,l2));
2004  }
2005  }
2006  }
2007 
2008  // hess_vec_prod_g
2009  for ( int j = 0; j < min_Ng; ++j ) {
2010  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_g_xx,j) && nonnull(inputOutArgs.get_hess_vec_prod_g_xx(j)) ) {
2011  if ( supports(OUT_ARG_hess_vec_prod_g_xx,j) || !ignoreUnsupported )
2012  set_hess_vec_prod_g_xx(j,inputOutArgs.get_hess_vec_prod_g_xx(j));
2013  }
2014  for ( int l1 = 0; l1 < min_Np; ++l1 ) {
2015  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_g_xp,j,l1) && nonnull(inputOutArgs.get_hess_vec_prod_g_xp(j,l1)) ) {
2016  if ( supports(OUT_ARG_hess_vec_prod_g_xp,j,l1) || !ignoreUnsupported )
2017  set_hess_vec_prod_g_xp(j,l1,inputOutArgs.get_hess_vec_prod_g_xp(j,l1));
2018  }
2019  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_g_px,j,l1) && nonnull(inputOutArgs.get_hess_vec_prod_g_px(j,l1)) ) {
2020  if ( supports(OUT_ARG_hess_vec_prod_g_px,j,l1) || !ignoreUnsupported )
2021  set_hess_vec_prod_g_px(j,l1,inputOutArgs.get_hess_vec_prod_g_px(j,l1));
2022  }
2023  for ( int l2 = 0; l2 < min_Np; ++l2 ) {
2024  if( inputOutArgs.supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2) && nonnull(inputOutArgs.get_hess_vec_prod_g_pp(j,l1,l2)) ) {
2025  if ( supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2) || !ignoreUnsupported )
2026  set_hess_vec_prod_g_pp(j,l1,l2,inputOutArgs.get_hess_vec_prod_g_pp(j,l1,l2));
2027  }
2028  }
2029  }
2030  }
2031 
2032  // hess_f
2033  if( inputOutArgs.supports(OUT_ARG_hess_f_xx) && nonnull(inputOutArgs.get_hess_f_xx()) ) {
2034  if ( supports(OUT_ARG_hess_f_xx) || !ignoreUnsupported )
2035  set_hess_f_xx(inputOutArgs.get_hess_f_xx());
2036  }
2037  for ( int l1 = 0; l1 < min_Np; ++l1 ) {
2038  if( inputOutArgs.supports(OUT_ARG_hess_f_xp,l1) && nonnull(inputOutArgs.get_hess_f_xp(l1)) ) {
2039  if ( supports(OUT_ARG_hess_f_xp,l1) || !ignoreUnsupported )
2040  set_hess_f_xp(l1,inputOutArgs.get_hess_f_xp(l1));
2041  }
2042  for ( int l2 = 0; l2 < min_Np; ++l2 ) {
2043  if( inputOutArgs.supports(OUT_ARG_hess_f_pp,l1,l2) && nonnull(inputOutArgs.get_hess_f_pp(l1,l2)) ) {
2044  if ( supports(OUT_ARG_hess_f_pp,l1,l2) || !ignoreUnsupported )
2045  set_hess_f_pp(l1,l2,inputOutArgs.get_hess_f_pp(l1,l2));
2046  }
2047  }
2048  }
2049 
2050  // hess_g
2051  for ( int j = 0; j < min_Ng; ++j ) {
2052  if( inputOutArgs.supports(OUT_ARG_hess_g_xx,j) && nonnull(inputOutArgs.get_hess_g_xx(j)) ) {
2053  if ( supports(OUT_ARG_hess_g_xx,j) || !ignoreUnsupported )
2054  set_hess_g_xx(j,inputOutArgs.get_hess_g_xx(j));
2055  }
2056  for ( int l1 = 0; l1 < min_Np; ++l1 ) {
2057  if( inputOutArgs.supports(OUT_ARG_hess_g_xp,j,l1) && nonnull(inputOutArgs.get_hess_g_xp(j,l1)) ) {
2058  if ( supports(OUT_ARG_hess_g_xp,j,l1) || !ignoreUnsupported )
2059  set_hess_g_xp(j,l1,inputOutArgs.get_hess_g_xp(j,l1));
2060  }
2061  for ( int l2 = 0; l2 < min_Np; ++l2 ) {
2062  if( inputOutArgs.supports(OUT_ARG_hess_g_pp,j,l1,l2) && nonnull(inputOutArgs.get_hess_g_pp(j,l1,l2)) ) {
2063  if ( supports(OUT_ARG_hess_g_pp,j,l1,l2) || !ignoreUnsupported )
2064  set_hess_g_pp(j,l1,l2,inputOutArgs.get_hess_g_pp(j,l1,l2));
2065  }
2066  }
2067  }
2068  }
2069 
2070  // H
2071  if( inputOutArgs.supports(OUT_ARG_H_xx) && nonnull(inputOutArgs.get_H_xx()) ) {
2072  if ( supports(OUT_ARG_H_xx) || !ignoreUnsupported )
2073  set_H_xx(inputOutArgs.get_H_xx());
2074  }
2075  for ( int l1 = 0; l1 < min_Np; ++l1 ) {
2076  if( inputOutArgs.supports(OUT_ARG_H_xp,l1) && nonnull(inputOutArgs.get_H_xp(l1)) ) {
2077  if ( supports(OUT_ARG_H_xp,l1) || !ignoreUnsupported )
2078  set_H_xp(l1,inputOutArgs.get_H_xp(l1));
2079  }
2080  for ( int l2 = 0; l2 < min_Np; ++l2 ) {
2081  if( inputOutArgs.supports(OUT_ARG_H_pp,l1,l2) && nonnull(inputOutArgs.get_H_pp(l1,l2)) ) {
2082  if ( supports(OUT_ARG_H_pp,l1,l2) || !ignoreUnsupported )
2083  set_H_pp(l1,l2,inputOutArgs.get_H_pp(l1,l2));
2084  }
2085  }
2086  }
2087 
2088  // Extended outArgs
2089  this->extended_outargs_ = inputOutArgs.extended_outargs_;
2090 
2091  // ToDo: Add more args as needed!
2092 }
2093 
2094 
2095 template<class Scalar>
2097 {
2098  typedef Teuchos::ScalarTraits<Scalar> ST;
2099  isFailed_ = true;
2100  if( this->supports(OUT_ARG_f) && nonnull(this->get_f()) ) {
2101  assign(this->get_f().ptr(),ST::nan());
2102  }
2103  for( int j = 0; j < this->Ng(); ++j ) {
2104  if (nonnull(this->get_g(j)))
2105  assign(this->get_g(j).ptr(),ST::nan());
2106  }
2107  // ToDo: Set other objects to NaN as well!
2108 }
2109 
2110 
2111 template<class Scalar>
2113 {
2114  return isFailed_;
2115 }
2116 
2117 
2118 template<class Scalar>
2120 {
2121  if (!is_null(f_))
2122  return false;
2123  if (!is_null(W_))
2124  return false;
2125  if (!is_null(W_op_))
2126  return false;
2127  for ( int l = 0; l < Np(); ++l ) {
2128  if (!DfDp_[l].isEmpty())
2129  return false;
2130  }
2131 #ifdef HAVE_THYRA_ME_POLYNOMIAL
2132  if (!is_null(f_poly_))
2133  return false;
2134 #endif // HAVE_THYRA_ME_POLYNOMIAL
2135  for ( int j = 0; j < Ng(); ++j ) {
2136  if (!is_null(g_[j]))
2137  return false;
2138  if (!DgDx_dot_[j].isEmpty())
2139  return false;
2140  if (!DgDx_[j].isEmpty())
2141  return false;
2142  for ( int l = 0; l < Np(); ++l ) {
2143  if (!DgDp_[j*Np()+l].isEmpty())
2144  return false;
2145  }
2146  }
2147  return true;
2148 }
2149 
2150 
2151 template<class Scalar>
2153  const OutArgs<Scalar> &outArgs
2154  ) const
2155 {
2156 
2157  for ( int outArg_i = 0; outArg_i < NUM_E_OUT_ARGS_MEMBERS; ++outArg_i ) {
2158  const EOutArgsMembers outArg_arg = static_cast<EOutArgsMembers>(outArg_i);
2159  const std::string outArg_name = toString(outArg_arg);
2161  supports(outArg_arg) != outArgs.supports(outArg_arg), std::logic_error,
2162  "Error, the output argument "<<outArg_name<<" with support "<<outArgs.supports(outArg_arg)<<"\n"
2163  "in the OutArgs object for the model:\n\n"
2164  " "<<outArgs.modelEvalDescription()<<"\n\n"
2165  "is not the same the argument "<<outArg_name<<" with support "<<supports(outArg_arg)<<"\n"
2166  "in the OutArgs object for the model:\n\n"
2167  " "<<modelEvalDescription()<<"\n\n"
2168  "and these two OutArgs objects are not compatible!"
2169  );
2170  }
2171 
2172  const int l_Np = this->Np();
2173  const int l_Ng = this->Ng();
2174  TEUCHOS_ASSERT_EQUALITY( l_Np, outArgs.Np() );
2175  TEUCHOS_ASSERT_EQUALITY( l_Ng, outArgs.Ng() );
2176 
2177  if (supports(OUT_ARG_f)) {
2178  for ( int l = 0; l < l_Np; ++l ) {
2180  !supports(OUT_ARG_DfDp,l).isSameSupport(outArgs.supports(OUT_ARG_DfDp,l)),
2181  std::logic_error,
2182  "Error, the support for DfDp("<<l<<") is not the same for the models\n\n"
2183  " "<<outArgs.modelEvalDescription()<<"\n\n"
2184  "and:\n\n"
2185  " "<<modelEvalDescription()<<"\n\n"
2186  "and these two OutArgs objects are not compatible!"
2187  );
2188  }
2189  }
2190 
2191  for ( int j = 0; j < l_Ng; ++j ) {
2193  !supports(OUT_ARG_DgDx_dot,j).isSameSupport(outArgs.supports(OUT_ARG_DgDx_dot,j)),
2194  std::logic_error,
2195  "Error, the support for DgDx_dot("<<j<<") is not the same for the models\n\n"
2196  " "<<outArgs.modelEvalDescription()<<"\n\n"
2197  "and:\n\n"
2198  " "<<modelEvalDescription()<<"\n\n"
2199  "and these two OutArgs objects are not compatible!"
2200  );
2202  !supports(OUT_ARG_DgDx,j).isSameSupport(outArgs.supports(OUT_ARG_DgDx,j)),
2203  std::logic_error,
2204  "Error, the support for DgDx("<<j<<") is not the same for the models\n\n"
2205  " "<<outArgs.modelEvalDescription()<<"\n\n"
2206  "and:\n\n"
2207  " "<<modelEvalDescription()<<"\n\n"
2208  "and these two OutArgs objects are not compatible!"
2209  );
2210  for ( int l = 0; l < l_Np; ++l ) {
2212  !supports(OUT_ARG_DgDp,j,l).isSameSupport(outArgs.supports(OUT_ARG_DgDp,j,l)),
2213  std::logic_error,
2214  "Error, the support for DgDp("<<j<<","<<l<<") is not the same for the models\n\n"
2215  " "<<outArgs.modelEvalDescription()<<"\n\n"
2216  "and:\n\n"
2217  " "<<modelEvalDescription()<<"\n\n"
2218  "and these two OutArgs objects are not compatible!"
2219  );
2220  }
2221  }
2222 }
2223 
2224 
2225 template<class Scalar>
2227 {
2228  return modelEvalDescription_;
2229 }
2230 
2231 
2232 template<class Scalar>
2234 {
2235  typedef Teuchos::ScalarTraits<Scalar> ST;
2236  std::ostringstream oss;
2237  oss
2238  << "Thyra::ModelEvaluatorBase::OutArgs<"<<ST::name()<<">"
2239  << "{"
2240  << "model="<<modelEvalDescription_
2241  << ",Np="<<Np()
2242  << ",Ng="<<Ng()
2243  << "}";
2244  return oss.str();
2245 }
2246 
2247 
2248 template<class Scalar>
2250  Teuchos::FancyOStream &out_arg, const Teuchos::EVerbosityLevel verbLevel
2251  ) const
2252 {
2253 
2254  using Teuchos::OSTab;
2255  using Teuchos::describe;
2256  typedef Teuchos::ScalarTraits<Scalar> ST;
2257  typedef RCP<const VectorBase<Scalar> > CV_ptr;
2258  typedef RCP<const LinearOpBase<Scalar> > CLO_ptr;
2259  typedef RCP<const LinearOpWithSolveBase<Scalar> > CLOWS_ptr;
2260  typedef ModelEvaluatorBase MEB;
2261  typedef MEB::Derivative<Scalar> Deriv;
2262 
2263  if( verbLevel == Teuchos::VERB_NONE && verbLevel == Teuchos::VERB_DEFAULT )
2264  return;
2265 
2267  out = Teuchos::rcp(&out_arg,false);
2268  OSTab tab(out);
2269 
2270  *out <<"Thyra::ModelEvaluatorBase::OutArgs<"<<ST::name()<<">:\n";
2271  tab.incrTab();
2272 
2273  *out <<"model = " << modelEvalDescription_ << "\n";
2274  *out <<"Np = " << Np() << "\n";
2275  *out <<"Ng = " << Ng() << "\n";
2276 
2277  CV_ptr f;
2278  if (this->supports(OUT_ARG_f) && !is_null(f=get_f()) ) {
2279  *out << "f = " << Teuchos::describe(*f,verbLevel);
2280  }
2281 
2282  for( int j = 0; j < Ng(); ++j ) {
2283  CV_ptr g_j;
2284  if (!is_null(g_j=this->get_g(j)))
2285  *out << "g("<<j<<") = " << Teuchos::describe(*g_j,verbLevel);
2286  }
2287 
2288  CLOWS_ptr W;
2289  if ( this->supports(OUT_ARG_W) && !is_null(W=get_W()) ) {
2290  *out << "W = " << Teuchos::describe(*W,verbLevel);
2291  }
2292 
2293  CLO_ptr W_op;
2294  if ( this->supports(OUT_ARG_W_op) && !is_null(W_op=get_W_op()) ) {
2295  *out << "W_op = " << Teuchos::describe(*W_op,verbLevel);
2296  }
2297 
2298  for( int l = 0; l < Np(); ++l ) {
2299  Deriv DfDp_l;
2300  if (
2301  !this->supports(OUT_ARG_DfDp,l).none()
2302  && !(DfDp_l=get_DfDp(l)).isEmpty()
2303  )
2304  {
2305  *out << "DfDp("<<l<<") = ";
2306  DfDp_l.describe(*out,verbLevel);
2307  }
2308  }
2309 
2310  for( int j = 0; j < Ng(); ++j ) {
2311 
2312  Deriv DgDx_dot_j;
2313  if (
2314  !this->supports(OUT_ARG_DgDx_dot,j).none()
2315  && !(DgDx_dot_j=get_DgDx_dot(j)).isEmpty()
2316  )
2317  {
2318  *out << "DgDx_dot("<<j<<") = ";
2319  DgDx_dot_j.describe(*out,verbLevel);
2320  }
2321 
2322  Deriv DgDx_j;
2323  if (
2324  !this->supports(OUT_ARG_DgDx,j).none()
2325  && !(DgDx_j=get_DgDx(j)).isEmpty()
2326  )
2327  {
2328  *out << "DgDx("<<j<<") = ";
2329  DgDx_j.describe(*out,verbLevel);
2330  }
2331 
2332  for( int l = 0; l < Np(); ++l ) {
2333 
2334  Deriv DgDp_j_l;
2335  if (
2336  !this->supports(OUT_ARG_DgDp,j,l).none()
2337  && !(DgDp_j_l=get_DgDp(j,l)).isEmpty()
2338  )
2339  {
2340  *out << "DgDp("<<j<<","<<l<<") = ";
2341  DgDp_j_l.describe(*out,verbLevel);
2342  }
2343  }
2344 
2345  }
2346 
2347  // ToDo: Add output for more objects?
2348 
2349 }
2350 
2351 
2352 // protected
2353 
2354 
2355 template<class Scalar>
2357  const std::string &modelEvalDescription_in
2358  )
2359 {
2360  modelEvalDescription_ = modelEvalDescription_in;
2361 }
2362 
2363 template<class Scalar>
2365 {
2366  if(Np_in) {
2367  supports_DfDp_.resize(Np_in);
2368  DfDp_.resize(Np_in); std::fill_n(DfDp_.begin(),Np_in,Derivative<Scalar>());
2369  DfDp_properties_.resize(Np_in); std::fill_n(DfDp_properties_.begin(),Np_in,DerivativeProperties());
2370 
2371  supports_DfDp_mp_.resize(Np_in);
2372  DfDp_mp_.resize(Np_in); std::fill_n(DfDp_mp_.begin(),Np_in,MPDerivative());
2373  DfDp_mp_properties_.resize(Np_in); std::fill_n(DfDp_mp_properties_.begin(),Np_in,DerivativeProperties());
2374  }
2375  if(Ng_in) {
2376  g_.resize(Ng_in); std::fill_n(g_.begin(),Ng_in,Teuchos::null);
2377  supports_DgDx_dot_.resize(Ng_in);
2378  DgDx_dot_.resize(Ng_in); std::fill_n(DgDx_dot_.begin(),Ng_in,Derivative<Scalar>());
2379  DgDx_dot_properties_.resize(Ng_in); std::fill_n(DgDx_dot_properties_.begin(),Ng_in,DerivativeProperties());
2380  supports_DgDx_.resize(Ng_in);
2381  DgDx_.resize(Ng_in); std::fill_n(DgDx_.begin(),Ng_in,Derivative<Scalar>());
2382  DgDx_properties_.resize(Ng_in); std::fill_n(DgDx_properties_.begin(),Ng_in,DerivativeProperties());
2383 
2384  supports_hess_vec_prod_g_xx_.resize(Ng_in);
2385  hess_vec_prod_g_xx_.resize(Ng_in); std::fill_n(hess_vec_prod_g_xx_.begin(),Ng_in,RCP<MultiVectorBase<Scalar> >());
2386 
2387  supports_hess_g_xx_.resize(Ng_in);
2388  hess_g_xx_.resize(Ng_in); std::fill_n(hess_g_xx_.begin(),Ng_in,RCP<LinearOpBase<Scalar> >());
2389 
2390  g_mp_.resize(Ng_in); std::fill_n(g_mp_.begin(),Ng_in,Teuchos::null);
2391  supports_g_mp_.resize(Ng_in);
2392  supports_DgDx_dot_mp_.resize(Ng_in);
2393  DgDx_dot_mp_.resize(Ng_in); std::fill_n(DgDx_dot_mp_.begin(),Ng_in,MPDerivative());
2394  DgDx_dot_mp_properties_.resize(Ng_in); std::fill_n(DgDx_dot_mp_properties_.begin(),Ng_in,DerivativeProperties());
2395  supports_DgDx_mp_.resize(Ng_in);
2396  DgDx_mp_.resize(Ng_in); std::fill_n(DgDx_mp_.begin(),Ng_in,MPDerivative());
2397  DgDx_mp_properties_.resize(Ng_in); std::fill_n(DgDx_mp_properties_.begin(),Ng_in,DerivativeProperties());
2398  }
2399  if(Np_in) {
2400  const int Np = Np_in;
2401  const int NpNp = Np_in*Np_in;
2402 
2403  supports_hess_vec_prod_f_xp_.resize(Np);
2404  hess_vec_prod_f_xp_.resize(Np); std::fill_n(hess_vec_prod_f_xp_.begin(),Np,RCP<MultiVectorBase<Scalar> >());
2405 
2406  supports_hess_vec_prod_f_px_.resize(Np);
2407  hess_vec_prod_f_px_.resize(Np); std::fill_n(hess_vec_prod_f_px_.begin(),Np,RCP<MultiVectorBase<Scalar> >());
2408 
2409  supports_hess_vec_prod_f_pp_.resize(NpNp);
2410  hess_vec_prod_f_pp_.resize(NpNp); std::fill_n(hess_vec_prod_f_pp_.begin(),NpNp,RCP<MultiVectorBase<Scalar> >());
2411 
2412  supports_hess_f_xp_.resize(Np);
2413  hess_f_xp_.resize(Np); std::fill_n(hess_f_xp_.begin(),Np,RCP<LinearOpBase<Scalar> >());
2414 
2415  supports_hess_f_pp_.resize(NpNp);
2416  hess_f_pp_.resize(NpNp); std::fill_n(hess_f_pp_.begin(),NpNp,RCP<LinearOpBase<Scalar> >());
2417 
2418  supports_H_xp_.resize(Np);
2419  H_xp_.resize(Np); std::fill_n(H_xp_.begin(),Np,RCP<LinearOpBase<Scalar> >());
2420 
2421  supports_H_pp_.resize(NpNp);
2422  H_pp_.resize(NpNp); std::fill_n(H_pp_.begin(),NpNp,RCP<LinearOpBase<Scalar> >());
2423  }
2424  if(Np_in && Ng_in) {
2425  const int NpNg = Np_in*Ng_in;
2426  const int NpNpNg = Np_in*Np_in*Ng_in;
2427  supports_DgDp_.resize(NpNg);
2428  DgDp_.resize(NpNg); std::fill_n(DgDp_.begin(),NpNg,Derivative<Scalar>());
2429  DgDp_properties_.resize(NpNg); std::fill_n(DgDp_properties_.begin(),NpNg,DerivativeProperties());
2430 
2431  supports_hess_vec_prod_g_xp_.resize(NpNg);
2432  hess_vec_prod_g_xp_.resize(NpNg); std::fill_n(hess_vec_prod_g_xp_.begin(),NpNg,RCP<MultiVectorBase<Scalar> >());
2433 
2434  supports_hess_vec_prod_g_px_.resize(NpNg);
2435  hess_vec_prod_g_px_.resize(NpNg); std::fill_n(hess_vec_prod_g_px_.begin(),NpNg,RCP<MultiVectorBase<Scalar> >());
2436 
2437  supports_hess_vec_prod_g_pp_.resize(NpNpNg);
2438  hess_vec_prod_g_pp_.resize(NpNpNg); std::fill_n(hess_vec_prod_g_pp_.begin(),NpNpNg,RCP<MultiVectorBase<Scalar> >());
2439 
2440  supports_hess_g_xp_.resize(NpNg);
2441  hess_g_xp_.resize(NpNg); std::fill_n(hess_g_xp_.begin(),NpNg,RCP<LinearOpBase<Scalar> >());
2442 
2443  supports_hess_g_pp_.resize(NpNpNg);
2444  hess_g_pp_.resize(NpNpNg); std::fill_n(hess_g_pp_.begin(),NpNpNg,RCP<LinearOpBase<Scalar> >());
2445 
2446  supports_DgDp_mp_.resize(NpNg);
2447  DgDp_mp_.resize(NpNg); std::fill_n(DgDp_mp_.begin(),NpNg,MPDerivative());
2448  DgDp_mp_properties_.resize(NpNg); std::fill_n(DgDp_mp_properties_.begin(),NpNg,DerivativeProperties());
2449  }
2450 }
2451 
2452 
2453 template<class Scalar>
2455  EOutArgsMembers arg, bool supports_in )
2456 {
2458  int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
2459  ,"model = \'"<<modelEvalDescription_
2460  <<"\': Error, arg="<<toString(arg)<<" is invalid!"
2461  );
2462  supports_[arg] = supports_in;
2463 }
2464 
2465 
2466 template<class Scalar>
2468  EOutArgsDfDp /* arg */, int l, const DerivativeSupport& supports_in
2469  )
2470 {
2471  assert_supports(OUT_ARG_f);
2472  assert_l(l);
2473  supports_DfDp_[l] = supports_in;
2474 }
2475 
2476 
2477 template<class Scalar>
2479  EOutArgsDgDx_dot /* arg */, int j, const DerivativeSupport& supports_in
2480  )
2481 {
2482  assert_j(j);
2483  supports_DgDx_dot_[j] = supports_in;
2484 }
2485 
2486 
2487 template<class Scalar>
2489  EOutArgsDgDx /* arg */, int j, const DerivativeSupport& supports_in
2490  )
2491 {
2492  assert_j(j);
2493  supports_DgDx_[j] = supports_in;
2494 }
2495 
2496 
2497 template<class Scalar>
2499  EOutArgs_hess_vec_prod_f_xx /* arg */, bool supports_in
2500  )
2501 {
2502  supports_hess_vec_prod_f_xx_ = supports_in;
2503 }
2504 
2505 template<class Scalar>
2507  EOutArgs_hess_vec_prod_f_xp /* arg */, int l, bool supports_in
2508  )
2509 {
2510  assert_l(l);
2511  supports_hess_vec_prod_f_xp_[l] = supports_in;
2512 }
2513 
2514 template<class Scalar>
2516  EOutArgs_hess_vec_prod_f_px /* arg */, int l, bool supports_in
2517  )
2518 {
2519  assert_l(l);
2520  supports_hess_vec_prod_f_px_[l] = supports_in;
2521 }
2522 
2523 template<class Scalar>
2525  EOutArgs_hess_vec_prod_f_pp /* arg */, int l1, int l2, bool supports_in
2526  )
2527 {
2528  assert_l(l1);
2529  assert_l(l2);
2530  supports_hess_vec_prod_f_pp_[ l1*Np()+ l2 ] = supports_in;
2531 }
2532 
2533 template<class Scalar>
2535  EOutArgsDgDp /* arg */, int j, int l, const DerivativeSupport& supports_in
2536  )
2537 {
2538  assert_j(j);
2539  assert_l(l);
2540  supports_DgDp_[ j*Np()+ l ] = supports_in;
2541 }
2542 
2543 
2544 template<class Scalar>
2546  EOutArgs_hess_vec_prod_g_xx /* arg */, int j, bool supports_in
2547  )
2548 {
2549  assert_j(j);
2550  supports_hess_vec_prod_g_xx_[j] = supports_in;
2551 }
2552 
2553 template<class Scalar>
2555  EOutArgs_hess_vec_prod_g_xp /* arg */, int j, int l, bool supports_in
2556  )
2557 {
2558  assert_j(j);
2559  assert_l(l);
2560  supports_hess_vec_prod_g_xp_[ j*Np()+ l ] = supports_in;
2561 }
2562 
2563 template<class Scalar>
2565  EOutArgs_hess_vec_prod_g_px /* arg */, int j, int l, bool supports_in
2566  )
2567 {
2568  assert_j(j);
2569  assert_l(l);
2570  supports_hess_vec_prod_g_px_[ j*Np()+ l ] = supports_in;
2571 }
2572 
2573 template<class Scalar>
2575  EOutArgs_hess_vec_prod_g_pp /* arg */, int j, int l1, int l2, bool supports_in
2576  )
2577 {
2578  assert_j(j);
2579  assert_l(l1);
2580  assert_l(l2);
2581  supports_hess_vec_prod_g_pp_[ j*Np()*Np()+ l1*Np() + l2 ] = supports_in;
2582 }
2583 
2584 
2585 template<class Scalar>
2587  EOutArgs_hess_f_xx /* arg */, bool supports_in
2588  )
2589 {
2590  supports_hess_f_xx_ = supports_in;
2591 }
2592 
2593 template<class Scalar>
2595  EOutArgs_hess_f_xp /* arg */, int l, bool supports_in
2596  )
2597 {
2598  assert_l(l);
2599  supports_hess_f_xp_[l] = supports_in;
2600 }
2601 
2602 template<class Scalar>
2604  EOutArgs_hess_f_pp /* arg */, int l1, int l2, bool supports_in
2605  )
2606 {
2607  assert_l(l1);
2608  assert_l(l2);
2609  supports_hess_f_pp_[ l1*Np()+ l2 ] = supports_in;
2610 }
2611 
2612 template<class Scalar>
2614  EOutArgs_hess_g_xx /* arg */, int j, bool supports_in
2615  )
2616 {
2617  assert_j(j);
2618  supports_hess_g_xx_[j] = supports_in;
2619 }
2620 
2621 template<class Scalar>
2623  EOutArgs_hess_g_xp /* arg */, int j, int l, bool supports_in
2624  )
2625 {
2626  assert_j(j);
2627  assert_l(l);
2628  supports_hess_g_xp_[ j*Np()+ l ] = supports_in;
2629 }
2630 
2631 template<class Scalar>
2633  EOutArgs_hess_g_pp /* arg */, int j, int l1, int l2, bool supports_in
2634  )
2635 {
2636  assert_j(j);
2637  assert_l(l1);
2638  assert_l(l2);
2639  supports_hess_g_pp_[ j*Np()*Np()+ l1*Np() + l2 ] = supports_in;
2640 }
2641 
2642 template<class Scalar>
2644  EOutArgs_H_xx /* arg */, bool supports_in
2645  )
2646 {
2647  supports_H_xx_ = supports_in;
2648 }
2649 
2650 template<class Scalar>
2652  EOutArgs_H_xp /* arg */, int l, bool supports_in
2653  )
2654 {
2655  assert_l(l);
2656  supports_H_xp_[l] = supports_in;
2657 }
2658 
2659 template<class Scalar>
2661  EOutArgs_H_pp /* arg */, int l1, int l2, bool supports_in
2662  )
2663 {
2664  assert_l(l1);
2665  assert_l(l2);
2666  supports_H_pp_[ l1*Np()+ l2 ] = supports_in;
2667 }
2668 
2669 
2670 template<class Scalar>
2672  EOutArgs_g_mp /* arg */, int j, bool supports_in
2673  )
2674 {
2675  //assert_supports(OUT_ARG_g_mp,j);
2676  assert_j(j);
2677  supports_g_mp_[j] = supports_in;
2678 }
2679 
2680 
2681 template<class Scalar>
2683  EOutArgsDfDp_mp /* arg */, int l, const DerivativeSupport& supports_in
2684  )
2685 {
2686  assert_supports(OUT_ARG_f_mp); //JF this is not in epetraext ME
2687  assert_l(l);
2688  supports_DfDp_mp_[l] = supports_in;
2689 }
2690 
2691 
2692 template<class Scalar>
2694  EOutArgsDgDx_dot_mp /* arg */, int j, const DerivativeSupport& supports_in
2695  )
2696 {
2697  assert_j(j);
2698  supports_DgDx_dot_mp_[j] = supports_in;
2699 }
2700 
2701 
2702 template<class Scalar>
2704  EOutArgsDgDx_mp /* arg */, int j, const DerivativeSupport& supports_in
2705  )
2706 {
2707  assert_j(j);
2708  supports_DgDx_mp_[j] = supports_in;
2709 }
2710 
2711 
2712 template<class Scalar>
2714  EOutArgsDgDp_mp /* arg */, int j, int l, const DerivativeSupport& supports_in
2715  )
2716 {
2717  assert_j(j);
2718  assert_l(l);
2719  supports_DgDp_mp_[ j*Np()+ l ] = supports_in;
2720 }
2721 
2722 
2723 template<class Scalar>
2725  const DerivativeProperties &properties
2726  )
2727 {
2728  W_properties_ = properties;
2729 }
2730 
2731 
2732 template<class Scalar>
2734  int l, const DerivativeProperties &properties
2735  )
2736 {
2737  assert_supports(OUT_ARG_DfDp,l);
2738  DfDp_properties_[l] = properties;
2739 }
2740 
2741 
2742 template<class Scalar>
2744  int j, const DerivativeProperties &properties
2745  )
2746 {
2747  assert_supports(OUT_ARG_DgDx_dot,j);
2748  DgDx_dot_properties_[j] = properties;
2749 }
2750 
2751 
2752 template<class Scalar>
2754  int j, const DerivativeProperties &properties
2755  )
2756 {
2757  assert_supports(OUT_ARG_DgDx,j);
2758  DgDx_properties_[j] = properties;
2759 }
2760 
2761 
2762 template<class Scalar>
2764  int j, int l, const DerivativeProperties &properties
2765  )
2766 {
2767  assert_supports(OUT_ARG_DgDp,j,l);
2768  DgDp_properties_[ j*Np()+ l ] = properties;
2769 }
2770 
2771 
2772 template<class Scalar>
2774  int l, const DerivativeProperties &properties
2775  )
2776 {
2777  assert_supports(OUT_ARG_DfDp_mp,l);
2778  DfDp_mp_properties_[l] = properties;
2779 }
2780 
2781 
2782 template<class Scalar>
2784  int j, const DerivativeProperties &properties
2785  )
2786 {
2787  assert_supports(OUT_ARG_DgDx_dot_mp,j);
2788  DgDx_dot_mp_properties_[j] = properties;
2789 }
2790 
2791 
2792 template<class Scalar>
2793 void ModelEvaluatorBase::OutArgs<Scalar>::_set_DgDx_mp_properties(
2794  int j, const DerivativeProperties &properties
2795  )
2796 {
2797  assert_supports(OUT_ARG_DgDx_mp,j);
2798  DgDx_mp_properties_[j] = properties;
2799 }
2800 
2801 
2802 template<class Scalar>
2803 void ModelEvaluatorBase::OutArgs<Scalar>::_set_DgDp_mp_properties(
2804  int j, int l, const DerivativeProperties &properties
2805  )
2806 {
2807  assert_supports(OUT_ARG_DgDp_mp,j,l);
2808  DgDp_mp_properties_[ j*Np()+ l ] = properties;
2809 }
2810 
2811 
2812 template<class Scalar>
2814  const OutArgs<Scalar>& inputOutArgs
2815  )
2816 {
2817  typedef ModelEvaluatorBase MEB;
2818  const int l_Np = TEUCHOS_MIN(this->Np(),inputOutArgs.Np());
2819  const int l_Ng = TEUCHOS_MIN(this->Ng(),inputOutArgs.Ng());
2820  std::copy(
2821  &inputOutArgs.supports_[0],
2822  &inputOutArgs.supports_[0] + NUM_E_OUT_ARGS_MEMBERS, &supports_[0] );
2823  for( int l = 0; l < l_Np; ++l ) {
2824  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DfDp,l);
2825  if (!ds.none()) {
2826  this->_setSupports(MEB::OUT_ARG_DfDp,l,ds);
2827  this->_set_DfDp_properties(l,inputOutArgs.get_DfDp_properties(l));
2828  }
2829  }
2830  for( int l = 0; l < l_Np; ++l ) {
2831  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DfDp_mp,l);
2832  if (!ds.none()) {
2833  this->_setSupports(MEB::OUT_ARG_DfDp_mp,l,ds);
2834  this->_set_DfDp_mp_properties(l,inputOutArgs.get_DfDp_mp_properties(l));
2835  }
2836  }
2837  for( int j = 0; j < l_Ng; ++j ) {
2838  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DgDx_dot,j);
2839  this->_setSupports(MEB::OUT_ARG_DgDx_dot,j,ds);
2840  if(!ds.none()) this->_set_DgDx_dot_properties(j,inputOutArgs.get_DgDx_dot_properties(j));
2841  }
2842  for( int j = 0; j < l_Ng; ++j ) {
2843  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DgDx_dot_mp,j);
2844  this->_setSupports(MEB::OUT_ARG_DgDx_dot_mp,j,ds);
2845  if(!ds.none()) this->_set_DgDx_dot_mp_properties(j,inputOutArgs.get_DgDx_dot_mp_properties(j));
2846  }
2847  for( int j = 0; j < l_Ng; ++j ) {
2848  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DgDx,j);
2849  this->_setSupports(MEB::OUT_ARG_DgDx,j,ds);
2850  if(!ds.none()) this->_set_DgDx_properties(j,inputOutArgs.get_DgDx_properties(j));
2851  }
2852  for( int j = 0; j < l_Ng; ++j ) {
2853  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DgDx_mp,j);
2854  this->_setSupports(MEB::OUT_ARG_DgDx_mp,j,ds);
2855  if(!ds.none()) this->_set_DgDx_mp_properties(j,inputOutArgs.get_DgDx_mp_properties(j));
2856  }
2857  for( int j = 0; j < l_Ng; ++j ) for( int l = 0; l < l_Np; ++l ) {
2858  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DgDp,j,l);
2859  this->_setSupports(MEB::OUT_ARG_DgDp,j,l,ds);
2860  if(!ds.none()) this->_set_DgDp_properties(j,l,inputOutArgs.get_DgDp_properties(j,l));
2861  }
2862  for( int j = 0; j < l_Ng; ++j ) for( int l = 0; l < l_Np; ++l ) {
2863  DerivativeSupport ds = inputOutArgs.supports(MEB::OUT_ARG_DgDp_mp,j,l);
2864  this->_setSupports(MEB::OUT_ARG_DgDp_mp,j,l,ds);
2865  if(!ds.none()) this->_set_DgDp_mp_properties(j,l,inputOutArgs.get_DgDp_mp_properties(j,l));
2866  }
2867  if(this->supports(OUT_ARG_W) || this->supports(OUT_ARG_W_op))
2868  this->_set_W_properties(inputOutArgs.get_W_properties());
2869  if(this->supports(OUT_ARG_W_mp))
2870  this->_set_W_properties(inputOutArgs.get_W_properties()); //JF should this be W_mp_properties?
2871 
2872  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_xx,inputOutArgs.supports(OUT_ARG_hess_vec_prod_f_xx));
2873  for( int l1 = 0; l1 < l_Np; ++l1 ) {
2874  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_xp,l1,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_f_xp,l1));
2875  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_px,l1,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_f_px,l1));
2876  for( int l2 = 0; l2 < l_Np; ++l2 ) {
2877  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_pp,l1,l2,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_f_pp,l1,l2));
2878  }
2879  }
2880  for( int j = 0; j < l_Ng; ++j ) {
2881  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_xx,j,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_g_xx,j));
2882  for( int l1 = 0; l1 < l_Np; ++l1 ) {
2883  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_xp,j,l1,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_g_xp,j,l1));
2884  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_px,j,l1,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_g_px,j,l1));
2885  for( int l2 = 0; l2 < l_Np; ++l2 ) {
2886  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_pp,j,l1,l2,inputOutArgs.supports(MEB::OUT_ARG_hess_vec_prod_g_pp,j,l1,l2));
2887  }
2888  }
2889  }
2890  this->_setSupports(MEB::OUT_ARG_hess_f_xx,inputOutArgs.supports(OUT_ARG_hess_f_xx));
2891  for( int l1 = 0; l1 < l_Np; ++l1 ) {
2892  this->_setSupports(MEB::OUT_ARG_hess_f_xp,l1,inputOutArgs.supports(MEB::OUT_ARG_hess_f_xp,l1));
2893  for( int l2 = 0; l2 < l_Np; ++l2 ) {
2894  this->_setSupports(MEB::OUT_ARG_hess_f_pp,l1,l2,inputOutArgs.supports(MEB::OUT_ARG_hess_f_pp,l1,l2));
2895  }
2896  }
2897  for( int j = 0; j < l_Ng; ++j ) {
2898  this->_setSupports(MEB::OUT_ARG_hess_g_xx,j,inputOutArgs.supports(MEB::OUT_ARG_hess_g_xx,j));
2899  for( int l1 = 0; l1 < l_Np; ++l1 ) {
2900  this->_setSupports(MEB::OUT_ARG_hess_g_xp,j,l1,inputOutArgs.supports(MEB::OUT_ARG_hess_g_xp,j,l1));
2901  for( int l2 = 0; l2 < l_Np; ++l2 ) {
2902  this->_setSupports(MEB::OUT_ARG_hess_g_pp,j,l1,l2,inputOutArgs.supports(MEB::OUT_ARG_hess_g_pp,j,l1,l2));
2903  }
2904  }
2905  }
2906  this->_setSupports(MEB::OUT_ARG_H_xx,inputOutArgs.supports(OUT_ARG_H_xx));
2907  for( int l1 = 0; l1 < l_Np; ++l1 ) {
2908  this->_setSupports(MEB::OUT_ARG_H_xp,l1,inputOutArgs.supports(MEB::OUT_ARG_H_xp,l1));
2909  for( int l2 = 0; l2 < l_Np; ++l2 ) {
2910  this->_setSupports(MEB::OUT_ARG_H_pp,l1,l2,inputOutArgs.supports(MEB::OUT_ARG_H_pp,l1,l2));
2911  }
2912  }
2913 
2914  extended_outargs_ = inputOutArgs.extended_outargs_;
2915 }
2916 
2917 
2918 template<class Scalar>
2920  EInArgsMembers arg
2921  )
2922 {
2923  switch(arg) {
2924  case IN_ARG_x: {
2925  const int l_Ng = this->Ng();
2926  for( int j = 0; j < l_Ng; ++j ) {
2927  this->_setSupports(OUT_ARG_DgDx_dot,j,DerivativeSupport());
2928  this->_setSupports(OUT_ARG_DgDx,j,DerivativeSupport());
2929  }
2930  break;
2931  }
2932  case IN_ARG_x_mp: {
2933  const int l_Ng = this->Ng();
2934  for( int j = 0; j < l_Ng; ++j ) {
2935  this->_setSupports(OUT_ARG_DgDx_dot_mp,j,DerivativeSupport());
2936  this->_setSupports(OUT_ARG_DgDx_mp,j,DerivativeSupport());
2937  }
2938  break;
2939  }
2940  default:
2942  true ,std::logic_error,
2943  "Error, can not handle args other than IN_ARG_x yet!"
2944  );
2945  }
2946 }
2947 
2948 
2949 template<class Scalar>
2951  EOutArgsMembers arg
2952  )
2953 {
2954  switch(arg) {
2955  case OUT_ARG_f: {
2956  this->_setSupports(OUT_ARG_W,false);
2957  this->_setSupports(OUT_ARG_W_op,false);
2958  this->_setSupports(OUT_ARG_f_poly,false);
2959  const int l_Np = this->Np();
2960  for( int l = 0; l < l_Np; ++l )
2961  this->_setSupports(OUT_ARG_DfDp,l,DerivativeSupport());
2962  break;
2963  }
2964  case OUT_ARG_f_mp: {
2965  this->_setSupports(OUT_ARG_W_mp,false);
2966  this->_setSupports(OUT_ARG_W_op,false);
2967  this->_setSupports(OUT_ARG_f_poly,false);
2968  const int l_Np = this->Np();
2969  for( int l = 0; l < l_Np; ++l )
2970  this->_setSupports(OUT_ARG_DfDp_mp,l,DerivativeSupport());
2971  break;
2972  }
2973  default:
2975  true ,std::logic_error,
2976  "Error, can not handle args other than OUT_ARG_f yet!"
2977  );
2978  }
2979  this->_setSupports(arg,false);
2980 }
2981 
2982 template<class Scalar>
2984  const bool supports
2985  )
2986 {
2987  typedef ModelEvaluatorBase MEB;
2988  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_xx,supports);
2989  this->_setSupports(MEB::OUT_ARG_hess_f_xx,supports);
2990  this->_setSupports(MEB::OUT_ARG_H_xx,supports);
2991  for (int l1=0; l1<this->Np(); ++l1)
2992  {
2993  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_xp,l1,supports);
2994  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_px,l1,supports);
2995  this->_setSupports(MEB::OUT_ARG_hess_f_xp,l1,supports);
2996  this->_setSupports(MEB::OUT_ARG_H_xp,l1,supports);
2997  for (int l2=0; l2<this->Np(); ++l2)
2998  {
2999  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_f_pp,l1,l2,supports);
3000  this->_setSupports(MEB::OUT_ARG_hess_f_pp,l1,l2,supports);
3001  this->_setSupports(MEB::OUT_ARG_H_pp,l1,l2,supports);
3002  }
3003  }
3004 
3005  for (int j=0; j<this->Ng(); ++j)
3006  {
3007  this->_setSupports(MEB::OUT_ARG_hess_g_xx,j,supports);
3008  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_xx,j,supports);
3009  for (int l1=0; l1<this->Np(); ++l1)
3010  {
3011  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_xp,j,l1,supports);
3012  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_px,j,l1,supports);
3013  this->_setSupports(MEB::OUT_ARG_hess_g_xp,j,l1,supports);
3014  for (int l2=0; l2<this->Np(); ++l2)
3015  {
3016  this->_setSupports(MEB::OUT_ARG_hess_vec_prod_g_pp,j,l1,l2,supports);
3017  this->_setSupports(MEB::OUT_ARG_hess_g_pp,j,l1,l2,supports);
3018  }
3019  }
3020  }
3021 }
3022 
3023 // private
3024 
3025 
3026 template<class Scalar>
3028 {
3030  !this->supports(arg), std::logic_error
3031  ,"Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(arg):\n\n"
3032  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3033  "Error, The argument arg = " << toString(arg) << " is not supported!"
3034  );
3035 }
3036 
3037 
3038 template<class Scalar>
3040  EOutArgsDfDp arg, int l, const Derivative<Scalar> &deriv
3041  ) const
3042 {
3043  const DerivativeSupport derivSupport = this->supports(arg,l);
3045  !deriv.isSupportedBy(derivSupport), std::logic_error,
3046  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DfDp,l):\n\n"
3047  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3048  "Error, The argument DfDp("<<l<<") = " << deriv.description() << "\n"
3049  "is not supported!\n\n"
3050  "The supported types include " << derivSupport.description() << "!"
3051  );
3052 }
3053 
3054 
3055 template<class Scalar>
3056 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3057  EOutArgsDgDx_dot arg, int j, const Derivative<Scalar> &deriv
3058  ) const
3059 {
3060  const DerivativeSupport derivSupport = this->supports(arg,j);
3062  !deriv.isSupportedBy(derivSupport), std::logic_error,
3063  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx_dot,j):\n\n"
3064  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3065  "Error, The argument DgDx_dot("<<j<<") = " << deriv.description() << "\n"
3066  "is not supported!\n\n"
3067  "The supported types include " << derivSupport.description() << "!"
3068  );
3069 }
3070 
3071 
3072 template<class Scalar>
3073 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3074  EOutArgsDgDx arg, int j, const Derivative<Scalar> &deriv
3075  ) const
3076 {
3077  const DerivativeSupport derivSupport = this->supports(arg,j);
3079  !deriv.isSupportedBy(derivSupport), std::logic_error,
3080  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx,j):\n\n"
3081  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3082  "Error, The argument DgDx("<<j<<") = " << deriv.description() << "\n"
3083  "is not supported!\n\n"
3084  "The supported types include " << derivSupport.description() << "!"
3085  );
3086 }
3087 
3088 
3089 template<class Scalar>
3090 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3091  EOutArgsDgDp arg, int j, int l, const Derivative<Scalar> &deriv
3092  ) const
3093 {
3094  const DerivativeSupport derivSupport = this->supports(arg,j,l);
3096  !deriv.isSupportedBy(derivSupport), std::logic_error,
3097  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDp,j,l):\n\n"
3098  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3099  "Error, The argument DgDp("<<j<<","<<l<<") = " << deriv.description() << "\n"
3100  "is not supported!\n\n"
3101  "The supported types include " << derivSupport.description() << "!"
3102  );
3103 }
3104 
3105 
3106 template<class Scalar>
3107 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3109  ) const
3110 {
3111  const bool support = this->supports(arg);
3113  !support, std::logic_error,
3114  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_f_xx):\n\n"
3115  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3116  "Error, The argument hess_vec_prod_f_xx() is not supported!"
3117  );
3118 }
3119 
3120 template<class Scalar>
3121 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3122  EOutArgs_hess_vec_prod_f_xp arg, int l
3123  ) const
3124 {
3125  const bool support = this->supports(arg,l);
3127  !support, std::logic_error,
3128  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_f_xp,l):\n\n"
3129  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3130  "Error, The argument hess_vec_prod_f_xp("<<l<<") is not supported!"
3131  );
3132 }
3133 
3134 template<class Scalar>
3135 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3136  EOutArgs_hess_vec_prod_f_px arg, int l
3137  ) const
3138 {
3139  const bool support = this->supports(arg,l);
3141  !support, std::logic_error,
3142  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_f_px,l):\n\n"
3143  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3144  "Error, The argument hess_vec_prod_f_px("<<l<<") is not supported!"
3145  );
3146 }
3147 
3148 template<class Scalar>
3149 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3150  EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2
3151  ) const
3152 {
3153  const bool support = this->supports(arg,l1,l2);
3155  !support, std::logic_error,
3156  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_f_pp,l1,l2):\n\n"
3157  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3158  "Error, The argument hess_vec_prod_f_pp("<<l1<<","<<l2<<") is not supported!"
3159  );
3160 }
3161 
3162 template<class Scalar>
3163 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3164  EOutArgs_hess_vec_prod_g_xx arg, int j
3165  ) const
3166 {
3167  const bool support = this->supports(arg,j);
3169  !support, std::logic_error,
3170  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_g_xx,j):\n\n"
3171  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3172  "Error, The argument hess_vec_prod_g_xx("<<j<<") is not supported!"
3173  );
3174 }
3175 
3176 template<class Scalar>
3177 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3178  EOutArgs_hess_vec_prod_g_xp arg, int j, int l
3179  ) const
3180 {
3181  const bool support = this->supports(arg,j,l);
3183  !support, std::logic_error,
3184  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_g_xp,j,l):\n\n"
3185  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3186  "Error, The argument hess_vec_prod_g_xp("<<j<<","<<l<<") is not supported!"
3187  );
3188 }
3189 
3190 template<class Scalar>
3191 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3192  EOutArgs_hess_vec_prod_g_px arg, int j, int l
3193  ) const
3194 {
3195  const bool support = this->supports(arg,j,l);
3197  !support, std::logic_error,
3198  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_g_px,j,l):\n\n"
3199  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3200  "Error, The argument hess_vec_prod_g_px("<<j<<","<<l<<") is not supported!"
3201  );
3202 }
3203 
3204 template<class Scalar>
3205 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3206  EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2
3207  ) const
3208 {
3209  const bool support = this->supports(arg,j,l1,l2);
3211  !support, std::logic_error,
3212  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_vec_prod_g_pp,j,l1,l2):\n\n"
3213  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3214  "Error, The argument hess_vec_prod_g_pp("<<j<<","<<l1<<","<<l2<<") is not supported!"
3215  );
3216 }
3217 
3218 template<class Scalar>
3219 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3220  EOutArgs_hess_f_xx arg
3221  ) const
3222 {
3223  const bool support = this->supports(arg);
3225  !support, std::logic_error,
3226  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_f_xx):\n\n"
3227  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3228  "Error, The argument hess_f_xx() is not supported!"
3229  );
3230 }
3231 
3232 template<class Scalar>
3233 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3234  EOutArgs_hess_f_xp arg, int l
3235  ) const
3236 {
3237  const bool support = this->supports(arg,l);
3239  !support, std::logic_error,
3240  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_f_xp,l):\n\n"
3241  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3242  "Error, The argument hess_f_xp() is not supported!"
3243  );
3244 }
3245 
3246 template<class Scalar>
3247 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3248  EOutArgs_hess_f_pp arg, int l1, int l2
3249  ) const
3250 {
3251  const bool support = this->supports(arg,l1,l2);
3253  !support, std::logic_error,
3254  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_f_pp,l1,l2):\n\n"
3255  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3256  "Error, The argument hess_f_pp() is not supported!"
3257  );
3258 }
3259 
3260 template<class Scalar>
3261 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3262  EOutArgs_hess_g_xx arg, int j
3263  ) const
3264 {
3265  const bool support = this->supports(arg,j);
3267  !support, std::logic_error,
3268  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_g_xx,j):\n\n"
3269  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3270  "Error, The argument hess_g_xx() is not supported!"
3271  );
3272 }
3273 
3274 template<class Scalar>
3275 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3276  EOutArgs_hess_g_xp arg, int j, int l
3277  ) const
3278 {
3279  const bool support = this->supports(arg,j,l);
3281  !support, std::logic_error,
3282  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_g_xp,j,l):\n\n"
3283  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3284  "Error, The argument hess_g_xp() is not supported!"
3285  );
3286 }
3287 
3288 template<class Scalar>
3289 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3290  EOutArgs_hess_g_pp arg, int j, int l1, int l2
3291  ) const
3292 {
3293  const bool support = this->supports(arg,j,l1,l2);
3295  !support, std::logic_error,
3296  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_hess_g_pp,j,l1,l2):\n\n"
3297  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3298  "Error, The argument hess_g_pp() is not supported!"
3299  );
3300 }
3301 
3302 template<class Scalar>
3303 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3304  EOutArgs_H_xx arg
3305  ) const
3306 {
3307  const bool support = this->supports(arg);
3309  !support, std::logic_error,
3310  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_H_xx):\n\n"
3311  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3312  "Error, The argument H_xx() is not supported!"
3313  );
3314 }
3315 
3316 template<class Scalar>
3317 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3318  EOutArgs_H_xp arg, int l
3319  ) const
3320 {
3321  const bool support = this->supports(arg,l);
3323  !support, std::logic_error,
3324  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_H_xp,l):\n\n"
3325  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3326  "Error, The argument H_xp() is not supported!"
3327  );
3328 }
3329 
3330 template<class Scalar>
3331 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3332  EOutArgs_H_pp arg, int l1, int l2
3333  ) const
3334 {
3335  const bool support = this->supports(arg,l1,l2);
3337  !support, std::logic_error,
3338  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_H_pp,l1,l2):\n\n"
3339  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3340  "Error, The argument H_pp() is not supported!"
3341  );
3342 }
3343 
3344 
3345 template<class Scalar>
3346 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3347  EOutArgs_g_mp /* arg */, int j
3348  ) const
3349 {
3350  assert_j(j);
3352  !supports_g_mp_[j], std::logic_error,
3353  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_g_mp,j):\n\n"
3354  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3355  "Error, The argument g_mp("<<j<<") \n"
3356  "is not supported!\n\n"
3357  );
3358 }
3359 
3360 
3361 template<class Scalar>
3362 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3363  EOutArgsDfDp_mp arg, int l, const MPDerivative &deriv
3364  ) const
3365 {
3366  const DerivativeSupport derivSupport = this->supports(arg,l);
3368  !deriv.isSupportedBy(derivSupport), std::logic_error,
3369  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DfDp_mp,l):\n\n"
3370  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3371  "Error, The argument DfDp_mp("<<l<<") = " << deriv.description() << "\n"
3372  "is not supported!\n\n"
3373  "The supported types include " << derivSupport.description() << "!"
3374  );
3375 }
3376 
3377 
3378 template<class Scalar>
3379 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3380  EOutArgsDgDx_dot_mp arg, int j, const MPDerivative &deriv
3381  ) const
3382 {
3383  const DerivativeSupport derivSupport = this->supports(arg,j);
3385  !deriv.isSupportedBy(derivSupport), std::logic_error,
3386  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx_dot_mp,j):\n\n"
3387  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3388  "Error, The argument DgDx_dot_mp("<<j<<") = " << deriv.description() << "\n"
3389  "is not supported!\n\n"
3390  "The supported types include " << derivSupport.description() << "!"
3391  );
3392 }
3393 
3394 
3395 template<class Scalar>
3396 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3397  EOutArgsDgDx_mp arg, int j, const MPDerivative &deriv
3398  ) const
3399 {
3400  const DerivativeSupport derivSupport = this->supports(arg,j);
3402  !deriv.isSupportedBy(derivSupport), std::logic_error,
3403  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDx_mp,j):\n\n"
3404  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3405  "Error, The argument DgDx_mp("<<j<<") = " << deriv.description() << "\n"
3406  "is not supported!\n\n"
3407  "The supported types include " << derivSupport.description() << "!"
3408  );
3409 }
3410 
3411 
3412 template<class Scalar>
3413 void ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(
3414  EOutArgsDgDp_mp arg, int j, int l, const MPDerivative &deriv
3415  ) const
3416 {
3417  const DerivativeSupport derivSupport = this->supports(arg,j,l);
3419  !deriv.isSupportedBy(derivSupport), std::logic_error,
3420  "Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_supports(OUT_ARG_DgDp_mp,j,l):\n\n"
3421  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3422  "Error, The argument DgDp_mp("<<j<<","<<l<<") = " << deriv.description() << "\n"
3423  "is not supported!\n\n"
3424  "The supported types include " << derivSupport.description() << "!"
3425  );
3426 }
3427 
3428 
3429 template<class Scalar>
3430 void ModelEvaluatorBase::OutArgs<Scalar>::assert_l(int l) const
3431 {
3433  !( 0 <= l && l < Np() ), std::logic_error
3434  ,"Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_l(l):\n\n"
3435  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3436  "Error, The parameter subvector p("<<l<<")"
3437  " is not in the range [0,"<<Np()<<")!"
3438  );
3439 }
3440 
3441 
3442 template<class Scalar>
3443 void ModelEvaluatorBase::OutArgs<Scalar>::assert_j(int j) const
3444 {
3446  !( 0 <= j && j < Ng() ), std::logic_error
3447  ,"Thyra::ModelEvaluatorBase::OutArgs<Scalar>::assert_j(j):\n\n"
3448  "model = \'"<<modelEvalDescription_<<"\':\n\n"
3449  "Error, The auxiliary function g("<<j<<")"
3450  " is not in the range [0,"<<Ng()<<")!"
3451  );
3452 }
3453 
3454 
3455 //
3456 // ModelEvaluatorBase::InArgsSetup
3457 //
3458 
3459 
3460 template<class Scalar>
3462 {}
3463 
3464 
3465 template<class Scalar>
3467  :InArgs<Scalar>(inArgs)
3468 {}
3469 
3470 
3471 template<class Scalar>
3473  const std::string &modelEvalDescription_in )
3474 {
3475  this->_setModelEvalDescription(modelEvalDescription_in);
3476 }
3477 
3478 
3479 template<class Scalar>
3481 { this->_set_Np_Ng(Np_in, 0); }
3482 
3483 template<class Scalar>
3485 { this->_set_Np_Ng(Np_in, Ng_in); }
3486 
3487 template<class Scalar>
3489 { this->_setSupports(arg,supports_in); }
3490 
3491 
3492 template<class Scalar>
3493 void ModelEvaluatorBase::InArgsSetup<Scalar>::setSupports( EInArgs_p_mp arg, int l, bool supports_in )
3494 { this->_setSupports(arg,l,supports_in); }
3495 
3496 
3497 template<class Scalar>
3499  const InArgs<Scalar>& inArgs, const int Np_in
3500  )
3501 {
3502  this->_setSupports(inArgs, Np_in);
3503 }
3504 
3505 
3506 template<class Scalar>
3508  EInArgsMembers arg
3509  )
3510 {
3511  this->_setUnsupportsAndRelated(arg);
3512 }
3513 
3514 
3515 //
3516 // ModelEvaluatorBase::OutArgsSetup
3517 //
3518 
3519 
3520 template<class Scalar>
3522 {}
3523 
3524 
3525 template<class Scalar>
3527  const OutArgs<Scalar>& inputOutArgs
3528  )
3529  :OutArgs<Scalar>(inputOutArgs)
3530 {}
3531 
3532 
3533 template<class Scalar>
3535  const std::string &modelEvalDescription_in
3536  )
3537 { this->_setModelEvalDescription(modelEvalDescription_in); }
3538 
3539 
3540 template<class Scalar>
3542 { this->_set_Np_Ng(Np_in, Ng_in); }
3543 
3544 
3545 template<class Scalar>
3547  EOutArgsMembers arg, bool supports_in
3548  )
3549 { this->_setSupports(arg,supports_in); }
3550 
3551 
3552 template<class Scalar>
3554  EOutArgsDfDp arg, int l, const DerivativeSupport& supports_in
3555  )
3556 { this->_setSupports(arg,l,supports_in); }
3557 
3558 
3559 template<class Scalar>
3561  EOutArgsDgDx_dot arg, int j, const DerivativeSupport& supports_in
3562  )
3563 { this->_setSupports(arg,j,supports_in); }
3564 
3565 
3566 template<class Scalar>
3568  EOutArgsDgDx arg, int j, const DerivativeSupport& supports_in
3569  )
3570 { this->_setSupports(arg,j,supports_in); }
3571 
3572 
3573 template<class Scalar>
3575  EOutArgs_hess_vec_prod_f_xx arg, bool supports_in
3576  )
3577 { this->_setSupports(arg,supports_in); }
3578 
3579 template<class Scalar>
3581  EOutArgs_hess_vec_prod_f_xp arg, int l, bool supports_in
3582  )
3583 { this->_setSupports(arg,l,supports_in); }
3584 
3585 template<class Scalar>
3587  EOutArgs_hess_vec_prod_f_px arg, int l, bool supports_in
3588  )
3589 { this->_setSupports(arg,l,supports_in); }
3590 
3591 template<class Scalar>
3593  EOutArgs_hess_vec_prod_f_pp arg, int l1, int l2, bool supports_in
3594  )
3595 { this->_setSupports(arg,l1,l2,supports_in); }
3596 
3597 
3598 template<class Scalar>
3600  EOutArgsDgDp arg, int j, int l, const DerivativeSupport& supports_in
3601  )
3602 { this->_setSupports(arg,j,l,supports_in); }
3603 
3604 
3605 template<class Scalar>
3607  EOutArgs_hess_vec_prod_g_xx arg, int j, bool supports_in
3608  )
3609 { this->_setSupports(arg,j,supports_in); }
3610 
3611 template<class Scalar>
3613  EOutArgs_hess_vec_prod_g_xp arg, int j, int l, bool supports_in
3614  )
3615 { this->_setSupports(arg,j,l,supports_in); }
3616 
3617 template<class Scalar>
3619  EOutArgs_hess_vec_prod_g_px arg, int j, int l, bool supports_in
3620  )
3621 { this->_setSupports(arg,j,l,supports_in); }
3622 
3623 template<class Scalar>
3625  EOutArgs_hess_vec_prod_g_pp arg, int j, int l1, int l2, bool supports_in
3626  )
3627 { this->_setSupports(arg,j,l1,l2,supports_in); }
3628 
3629 template<class Scalar>
3631  EOutArgs_hess_f_xx arg, bool supports_in
3632  )
3633 { this->_setSupports(arg,supports_in); }
3634 
3635 template<class Scalar>
3637  EOutArgs_hess_f_xp arg, int l, bool supports_in
3638  )
3639 { this->_setSupports(arg,l,supports_in); }
3640 
3641 template<class Scalar>
3643  EOutArgs_hess_f_pp arg, int l1, int l2, bool supports_in
3644  )
3645 { this->_setSupports(arg,l1,l2,supports_in); }
3646 
3647 template<class Scalar>
3649  EOutArgs_hess_g_xx arg, int j, bool supports_in
3650  )
3651 { this->_setSupports(arg,j,supports_in); }
3652 
3653 template<class Scalar>
3655  EOutArgs_hess_g_xp arg, int j, int l, bool supports_in
3656  )
3657 { this->_setSupports(arg,j,l,supports_in); }
3658 
3659 template<class Scalar>
3661  EOutArgs_hess_g_pp arg, int j, int l1, int l2, bool supports_in
3662  )
3663 { this->_setSupports(arg,j,l1,l2,supports_in); }
3664 
3665 template<class Scalar>
3667  EOutArgs_H_xx arg, bool supports_in
3668  )
3669 { this->_setSupports(arg,supports_in); }
3670 
3671 template<class Scalar>
3673  EOutArgs_H_xp arg, int l, bool supports_in
3674  )
3675 { this->_setSupports(arg,l,supports_in); }
3676 
3677 template<class Scalar>
3679  EOutArgs_H_pp arg, int l1, int l2, bool supports_in
3680  )
3681 { this->_setSupports(arg,l1,l2,supports_in); }
3682 
3683 template<class Scalar>
3685  EOutArgs_g_mp arg, int j, bool supports_in
3686  )
3687 { this->_setSupports(arg,j,supports_in); }
3688 
3689 
3690 template<class Scalar>
3692  EOutArgsDfDp_mp arg, int l, const DerivativeSupport& supports_in
3693  )
3694 { this->_setSupports(arg,l,supports_in); }
3695 
3696 
3697 template<class Scalar>
3699  EOutArgsDgDx_dot_mp arg, int j, const DerivativeSupport& supports_in
3700  )
3701 { this->_setSupports(arg,j,supports_in); }
3702 
3703 
3704 template<class Scalar>
3706  EOutArgsDgDx_mp arg, int j, const DerivativeSupport& supports_in
3707  )
3708 { this->_setSupports(arg,j,supports_in); }
3709 
3710 
3711 template<class Scalar>
3713  EOutArgsDgDp_mp arg, int j, int l, const DerivativeSupport& supports_in
3714  )
3715 { this->_setSupports(arg,j,l,supports_in); }
3716 
3717 
3718 template<class Scalar>
3720  const DerivativeProperties &properties
3721  )
3722 { this->_set_W_properties(properties); }
3723 
3724 
3725 template<class Scalar>
3727  int l, const DerivativeProperties &properties
3728  )
3729 { this->_set_DfDp_properties(l,properties); }
3730 
3731 
3732 template<class Scalar>
3734  int j, const DerivativeProperties &properties
3735  )
3736 { this->_set_DgDx_dot_properties(j,properties); }
3737 
3738 
3739 template<class Scalar>
3741  int j, const DerivativeProperties &properties
3742  )
3743 { this->_set_DgDx_properties(j,properties); }
3744 
3745 
3746 template<class Scalar>
3748  int j, int l, const DerivativeProperties &properties
3749  )
3750 { this->_set_DgDp_properties(j,l,properties); }
3751 
3752 
3753 template<class Scalar>
3755  int l, const DerivativeProperties &properties
3756  )
3757 { this->_set_DfDp_mp_properties(l,properties); }
3758 
3759 
3760 template<class Scalar>
3762  int j, const DerivativeProperties &properties
3763  )
3764 { this->_set_DgDx_dot_mp_properties(j,properties); }
3765 
3766 
3767 template<class Scalar>
3768 void ModelEvaluatorBase::OutArgsSetup<Scalar>::set_DgDx_mp_properties(
3769  int j, const DerivativeProperties &properties
3770  )
3771 { this->_set_DgDx_mp_properties(j,properties); }
3772 
3773 
3774 template<class Scalar>
3775 void ModelEvaluatorBase::OutArgsSetup<Scalar>::set_DgDp_mp_properties(
3776  int j, int l, const DerivativeProperties &properties
3777  )
3778 { this->_set_DgDp_mp_properties(j,l,properties); }
3779 
3780 
3781 template<class Scalar>
3783  const OutArgs<Scalar>& inputOutArgs
3784  )
3785 { this->_setSupports(inputOutArgs); }
3786 
3787 
3788 template<class Scalar>
3790  EInArgsMembers arg
3791  )
3792 { this->_setUnsupportsAndRelated(arg); }
3793 
3794 
3795 template<class Scalar>
3797  EOutArgsMembers arg
3798  )
3799 { this->_setUnsupportsAndRelated(arg); }
3800 
3801 
3802 template<class Scalar>
3804  const bool supports
3805  )
3806 { this->_setHessianSupports(supports); }
3807 
3808 } // namespace Thyra
3809 
3810 
3811 
3812 //
3813 // Explicit instantiation macro
3814 //
3815 // Must be expanded from within the Thyra namespace!
3816 //
3817 
3818 
3819 #define THYRA_MODEL_EVALUATOR_BASE_INSTANT(SCALAR) \
3820  \
3821  template class ModelEvaluatorBase::InArgs<SCALAR >; \
3822  \
3823  template std::string \
3824  ModelEvaluatorBase::Derivative<SCALAR >::description() const; \
3825  \
3826  template \
3827  void ModelEvaluatorBase::Derivative<SCALAR >::describe( \
3828  Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel \
3829  ) const; \
3830  \
3831  template class ModelEvaluatorBase::OutArgs<SCALAR >; \
3832  \
3833  template class ModelEvaluatorBase::InArgsSetup<SCALAR >; \
3834  \
3835  template class ModelEvaluatorBase::OutArgsSetup<SCALAR >;
3836 
3837 
3838 #endif // THYRA_MODEL_EVALUATOR_BASE_DEF_HPP
RCP< LinearOpBase< Scalar > > get_H_xx() const
Precondition: supports(OUT_ARG_H_xx)==true.
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).
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.
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...
void set_DgDx_properties(int j, const DerivativeProperties &properties)
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)
std::string toString(ModelEvaluatorBase::EInArgsMembers)
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.
basic_OSTab< char > OSTab
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.
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_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...
RCP< LinearOpBase< Scalar > > get_H_pp(int l1, int l2) const
Precondition: supports(OUT_ARG_H_pp,l1,l2)==true.
Evaluation< VectorBase< Scalar > > get_g(int j) const
Precondition: supports(OUT_ARG_g)==true..
Evaluation< VectorBase< Scalar > > get_f() const
Precondition: supports(OUT_ARG_f)==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)
bool supports(EOutArgsMembers arg) const
Determine if an input argument is supported or not.
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).
Derivative< Scalar > get_DgDp(int j, int l) const
Precondition: supports(OUT_ARG_DgDp,j,l)==true.
void set_hess_f_xx(const RCP< LinearOpBase< Scalar > > &hess_f_xx)
Precondition: supports(OUT_ARG_hess_f_xx)==true.
DerivativeProperties get_DgDx_properties(int j) const
Return the know properties of DgDx(j) (precondition: supports(OUT_ARG_DgDx,j)==true).
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
void set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
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.
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.
Simple public strict containing properties of a derivative object.
void _setSupports(EInArgsMembers arg, bool supports)
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).
TEUCHOSCORE_LIB_DLL_EXPORT bool includesVerbLevel(const EVerbosityLevel verbLevel, const EVerbosityLevel requestedVerbLevel, const bool isDefaultLevel=false)
void set_DgDx_dot_properties(int j, const DerivativeProperties &properties)
bool isFailed() const
Return if the evaluation failed or not.
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.
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.
bool nonnull(const boost::shared_ptr< T > &p)
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.
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.
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.
RCP< PreconditionerBase< Scalar > > get_W_prec() const
Precondition: supports(OUT_ARG_W_op)==true.
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.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
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
bool supports(EInArgsMembers arg) const
Determines if an input argument is supported or not.
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
void set_W_x_dot_dot_coeff(Scalar W_x_dot_dot_coeff)
Precondition: supports(IN_ARG_W_x_dot_dot_coeff)==true.
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.
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)
virtual void describe(FancyOStream &out, const EVerbosityLevel verbLevel=verbLevel_default) 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.
Derivative< Scalar > get_DgDx(int j) const
Precondition: supports(OUT_ARG_DgDx,j)==true.
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...