EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_ModelEvaluator.cpp
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
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 Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 
44 
45 
46 namespace EpetraExt {
47 
48 
49 //
50 // ModelEvaluator::InArgs
51 //
52 
53 
55  :modelEvalDescription_("WARNING! THIS INARGS OBJECT IS UNINITALIZED!")
56 {
57  std::fill_n(&supports_[0],NUM_E_IN_ARGS_MEMBERS,false);
58  t_ = 0.0;
59  alpha_ = 0.0;
60  omega_ = 0.0;
61  beta_ = 0.0;
62 }
63 
64 
66 {
68  int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
69  ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
70  );
71  return supports_[arg];
72 }
73 
74 bool ModelEvaluator::InArgs::supports(EInArgs_p_sg /* arg */, int l) const
75 {
76  assert_l(l);
77  return supports_p_sg_[l];
78 }
79 
80 bool ModelEvaluator::InArgs::supports(EInArgs_p_mp /* arg */, int l) const
81 {
82  assert_l(l);
83  return supports_p_mp_[l];
84 }
85 
87 {
89  int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
90  ,"model = \'"<<modelEvalDescription_<<"\':Error, arg="<<toString(arg)<<" is invalid!"
91  );
92  supports_[arg] = supportsIt;
93 }
94 
95 void ModelEvaluator::InArgs::_setSupports(EInArgs_p_sg /* arg */, int l, bool supportsIt)
96 {
97  assert_l(l);
98  supports_p_sg_[l] = supportsIt;
99 }
100 
101 void ModelEvaluator::InArgs::_setSupports(EInArgs_p_mp /* arg */, int l, bool supportsIt)
102 {
103  assert_l(l);
104  supports_p_mp_[l] = supportsIt;
105 }
106 
107 
109 {
111  !supports_[arg], std::logic_error
112  ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(arg): model = \'"<<modelEvalDescription_<<"\': Error, "
113  "The argument arg = " << toString(arg) << " is not supported!"
114  );
115 }
116 
118 {
119  assert_l(l);
121  !supports_p_sg_[l], std::logic_error
122  ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(IN_ARG_p_sg,l): "
123  "model = \'"<<modelEvalDescription_<<"\': Error,"
124  "The argument p_sg(l) with index l = " << l << " is not supported!"
125  );
126 }
127 
129 {
130  assert_l(l);
132  !supports_p_mp_[l], std::logic_error
133  ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(IN_ARG_p_mp,l): "
134  "model = \'"<<modelEvalDescription_<<"\': Error,"
135  "The argument p_mp(l) with index l = " << l << " is not supported!"
136  );
137 }
138 
139 
141 {
143  !( 0 <= l && l < Np() ), std::logic_error
144  ,"EpetraExt::ModelEvaluator::InArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\': Error, "
145  "The parameter l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
146  );
147 }
148 
149 
150 //
151 // ModelEvaluator::OutArgs
152 //
153 
154 
156  :modelEvalDescription_("WARNING! THIS OUTARGS OBJECT IS UNINITALIZED!"),
157  isFailed_( false )
158 {
159  std::fill_n(&supports_[0],NUM_E_OUT_ARGS_MEMBERS,false);
160 }
161 
162 
164 {
166  int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
167  ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
168  );
169  return supports_[arg];
170 }
171 
172 
175 {
176  assert_l(l);
177  return supports_DfDp_[l];
178 }
179 
180 
183 {
184  assert_j(j);
185  return supports_DgDx_dot_[j];
186 }
187 
188 
191 {
192  assert_j(j);
193  return supports_DgDx_dotdot_[j];
194 }
195 
196 
199 {
200  assert_j(j);
201  return supports_DgDx_[j];
202 }
203 
204 
206 ModelEvaluator::OutArgs::supports(EOutArgsDgDp /* arg */, int j, int l) const
207 {
208  assert_j(j);
209  assert_l(l);
210  return supports_DgDp_[ j*Np() + l ];
211 }
212 
214 {
215  assert_j(j);
216  return supports_g_sg_[j];
217 }
218 
221 {
222  assert_l(l);
223  return supports_DfDp_sg_[l];
224 }
225 
226 
229 {
230  assert_j(j);
231  return supports_DgDx_dot_sg_[j];
232 }
233 
234 
237 {
238  assert_j(j);
239  return supports_DgDx_dotdot_sg_[j];
240 }
241 
242 
245 {
246  assert_j(j);
247  return supports_DgDx_sg_[j];
248 }
249 
252 {
253  assert_j(j);
254  assert_l(l);
255  return supports_DgDp_sg_[ j*Np() + l ];
256 }
257 
259 {
260  assert_j(j);
261  return supports_g_mp_[j];
262 }
263 
266 {
267  assert_l(l);
268  return supports_DfDp_mp_[l];
269 }
270 
271 
274 {
275  assert_j(j);
276  return supports_DgDx_dot_mp_[j];
277 }
278 
279 
282 {
283  assert_j(j);
284  return supports_DgDx_dotdot_mp_[j];
285 }
286 
287 
290 {
291  assert_j(j);
292  return supports_DgDx_mp_[j];
293 }
294 
297 {
298  assert_j(j);
299  assert_l(l);
300  return supports_DgDp_mp_[ j*Np() + l ];
301 }
302 
303 
305 {
307  bool areSet = false;
308  switch(arg) {
309  case OUT_ARG_f: {
310  if (!is_null(f_)) areSet = true;
311  if (!is_null(W_)) areSet = true;
312  for ( int l = 0; l < implicit_cast<int>(DfDp_.size()); ++l )
313  if(!DfDp_[l].isEmpty()) areSet = true;
314  break;
315  }
316  default:
317  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
318  "ModelEvaluator::OutArgs::funcOrDerivesAreSet(arg): Error, we can not handle"
319  " the argument " << toString(arg) << "yet!");
320  }
321  return areSet;
322 }
323 
325 {
326  isFailed_ = true;
327  // TODO: Set objects to NaN?
328 }
329 
331 {
332  return isFailed_;
333 }
334 
335 
336 void ModelEvaluator::OutArgs::_setModelEvalDescription( const std::string &theModelEvalDescription )
337 {
338  modelEvalDescription_ = theModelEvalDescription;
339 }
340 
341 
342 void ModelEvaluator::OutArgs::_set_Np_Ng(int Np_in, int Ng_in)
343 {
344  if(Np_in) {
345  supports_DfDp_.resize(Np_in);
346  DfDp_.resize(Np_in);
347  std::fill_n(DfDp_.begin(),Np_in,Derivative());
348  DfDp_properties_.resize(Np_in);
349  std::fill_n(DfDp_properties_.begin(),Np_in,DerivativeProperties());
350 
351  supports_DfDp_sg_.resize(Np_in);
352  DfDp_sg_.resize(Np_in);
353  std::fill_n(DfDp_sg_.begin(),Np_in,SGDerivative());
354  DfDp_sg_properties_.resize(Np_in);
355  std::fill_n(DfDp_sg_properties_.begin(),Np_in,DerivativeProperties());
356 
357  supports_DfDp_mp_.resize(Np_in);
358  DfDp_mp_.resize(Np_in);
359  std::fill_n(DfDp_mp_.begin(),Np_in,MPDerivative());
360  DfDp_mp_properties_.resize(Np_in);
361  std::fill_n(DfDp_mp_properties_.begin(),Np_in,DerivativeProperties());
362  }
363  if(Ng_in) {
364  g_.resize(Ng_in);
365  supports_DgDx_dot_.resize(Ng_in);
366  DgDx_dot_.resize(Ng_in);
367  std::fill_n(DgDx_dot_.begin(),Ng_in,Derivative());
368  DgDx_dot_properties_.resize(Ng_in);
369  std::fill_n(DgDx_dot_properties_.begin(),Ng_in,DerivativeProperties());
370  supports_DgDx_dotdot_.resize(Ng_in);
371  DgDx_dotdot_.resize(Ng_in);
372  std::fill_n(DgDx_dotdot_.begin(),Ng_in,Derivative());
373  DgDx_dotdot_properties_.resize(Ng_in);
374  std::fill_n(DgDx_dotdot_properties_.begin(),Ng_in,DerivativeProperties());
375  supports_DgDx_.resize(Ng_in);
376  DgDx_.resize(Ng_in);
377  std::fill_n(DgDx_.begin(),Ng_in,Derivative());
378  DgDx_properties_.resize(Ng_in);
379  std::fill_n(DgDx_properties_.begin(),Ng_in,DerivativeProperties());
380 
381  g_sg_.resize(Ng_in);
382  supports_g_sg_.resize(Ng_in);
383  supports_DgDx_dot_sg_.resize(Ng_in);
384  DgDx_dot_sg_.resize(Ng_in);
385  std::fill_n(DgDx_dot_sg_.begin(),Ng_in,SGDerivative());
386  DgDx_dot_sg_properties_.resize(Ng_in);
387  std::fill_n(DgDx_dot_sg_properties_.begin(),Ng_in,DerivativeProperties());
388  supports_DgDx_dotdot_sg_.resize(Ng_in);
389  DgDx_dotdot_sg_.resize(Ng_in);
390  std::fill_n(DgDx_dotdot_sg_.begin(),Ng_in,SGDerivative());
391  DgDx_dotdot_sg_properties_.resize(Ng_in);
392  std::fill_n(DgDx_dotdot_sg_properties_.begin(),Ng_in,DerivativeProperties());
393  supports_DgDx_sg_.resize(Ng_in);
394  DgDx_sg_.resize(Ng_in);
395  std::fill_n(DgDx_sg_.begin(),Ng_in,SGDerivative());
396  DgDx_sg_properties_.resize(Ng_in);
397  std::fill_n(DgDx_sg_properties_.begin(),Ng_in,DerivativeProperties());
398 
399  g_mp_.resize(Ng_in);
400  supports_g_mp_.resize(Ng_in);
401  supports_DgDx_dot_mp_.resize(Ng_in);
402  DgDx_dot_mp_.resize(Ng_in);
403  std::fill_n(DgDx_dot_mp_.begin(),Ng_in,MPDerivative());
404  DgDx_dot_mp_properties_.resize(Ng_in);
405  std::fill_n(DgDx_dot_mp_properties_.begin(),Ng_in,DerivativeProperties());
406  supports_DgDx_dotdot_mp_.resize(Ng_in);
407  DgDx_dotdot_mp_.resize(Ng_in);
408  std::fill_n(DgDx_dotdot_mp_.begin(),Ng_in,MPDerivative());
409  DgDx_dotdot_mp_properties_.resize(Ng_in);
410  std::fill_n(DgDx_dotdot_mp_properties_.begin(),Ng_in,DerivativeProperties());
411  supports_DgDx_mp_.resize(Ng_in);
412  DgDx_mp_.resize(Ng_in);
413  std::fill_n(DgDx_mp_.begin(),Ng_in,MPDerivative());
414  DgDx_mp_properties_.resize(Ng_in);
415  std::fill_n(DgDx_mp_properties_.begin(),Ng_in,DerivativeProperties());
416  }
417  if(Np_in && Ng_in) {
418  const int NpNg = Np_in*Ng_in;
419  supports_DgDp_.resize(NpNg);
420  DgDp_.resize(NpNg);
421  std::fill_n(DgDp_.begin(),NpNg,Derivative());
422  DgDp_properties_.resize(NpNg);
423  std::fill_n(DgDp_properties_.begin(),NpNg,DerivativeProperties());
424 
425  supports_DgDp_sg_.resize(NpNg);
426  DgDp_sg_.resize(NpNg);
427  std::fill_n(DgDp_sg_.begin(),NpNg,SGDerivative());
428  DgDp_sg_properties_.resize(NpNg);
429  std::fill_n(DgDp_sg_properties_.begin(),NpNg,DerivativeProperties());
430 
431  supports_DgDp_mp_.resize(NpNg);
432  DgDp_mp_.resize(NpNg);
433  std::fill_n(DgDp_mp_.begin(),NpNg,MPDerivative());
434  DgDp_mp_properties_.resize(NpNg);
435  std::fill_n(DgDp_mp_properties_.begin(),NpNg,DerivativeProperties());
436  }
437 }
438 
440 {
442  int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
443  ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
444  );
445  supports_[arg] = supportsIt;
446 }
447 
448 
449 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp /* arg */, int l, const DerivativeSupport& theSupports )
450 {
451  assert_l(l);
452  supports_DfDp_[l] = theSupports;
453 }
454 
455 
457 {
458  assert_j(j);
459  supports_DgDx_dot_[j] = theSupports;
460 }
461 
462 
464 {
465  assert_j(j);
466  supports_DgDx_dotdot_[j] = theSupports;
467 }
468 
469 
470 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx /* arg */, int j, const DerivativeSupport& theSupports )
471 {
472  assert_j(j);
473  supports_DgDx_[j] = theSupports;
474 }
475 
476 
477 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp /* arg */, int j, int l, const DerivativeSupport& theSupports )
478 {
479  assert_j(j);
480  assert_l(l);
481  supports_DgDp_[ j*Np() + l ] = theSupports;
482 }
483 
484 void ModelEvaluator::OutArgs::_setSupports( EOutArgs_g_sg /* arg */, int j, bool supportsIt )
485 {
486  assert_j(j);
487  supports_g_sg_[j] = supportsIt;
488 }
489 
490 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp_sg /* arg */, int l, const DerivativeSupport& theSupports )
491 {
492  assert_l(l);
493  supports_DfDp_sg_[l] = theSupports;
494 }
495 
496 
498 {
499  assert_j(j);
500  supports_DgDx_dot_sg_[j] = theSupports;
501 }
502 
504 {
505  assert_j(j);
506  supports_DgDx_dotdot_sg_[j] = theSupports;
507 }
508 
509 
510 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_sg /* arg */, int j, const DerivativeSupport& theSupports )
511 {
512  assert_j(j);
513  supports_DgDx_sg_[j] = theSupports;
514 }
515 
516 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp_sg /* arg */, int j, int l, const DerivativeSupport& theSupports )
517 {
518  assert_j(j);
519  assert_l(l);
520  supports_DgDp_sg_[ j*Np() + l ] = theSupports;
521 }
522 
523 void ModelEvaluator::OutArgs::_setSupports( EOutArgs_g_mp /* arg */, int j, bool supportsIt )
524 {
525  assert_j(j);
526  supports_g_mp_[j] = supportsIt;
527 }
528 
529 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp_mp /* arg */, int l, const DerivativeSupport& theSupports )
530 {
531  assert_l(l);
532  supports_DfDp_mp_[l] = theSupports;
533 }
534 
535 
537 {
538  assert_j(j);
539  supports_DgDx_dot_mp_[j] = theSupports;
540 }
541 
543 {
544  assert_j(j);
545  supports_DgDx_dotdot_mp_[j] = theSupports;
546 }
547 
548 
549 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_mp /* arg */, int j, const DerivativeSupport& theSupports )
550 {
551  assert_j(j);
552  supports_DgDx_mp_[j] = theSupports;
553 }
554 
555 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp_mp /* arg */, int j, int l, const DerivativeSupport& theSupports )
556 {
557  assert_j(j);
558  assert_l(l);
559  supports_DgDp_mp_[ j*Np() + l ] = theSupports;
560 }
561 
562 
564 {
565  W_properties_ = W_properties;
566 }
567 
569 {
570  WPrec_properties_ = WPrec_properties;
571 }
572 
574 {
575  assert_supports(OUT_ARG_DfDp,l);
576  DfDp_properties_[l] = properties;
577 }
578 
579 
581 {
582  assert_supports(OUT_ARG_DgDx_dot,j);
583  DgDx_dot_properties_[j] = properties;
584 }
585 
587 {
588  assert_supports(OUT_ARG_DgDx_dotdot,j);
589  DgDx_dotdot_properties_[j] = properties;
590 }
591 
592 
594 {
595  assert_supports(OUT_ARG_DgDx,j);
596  DgDx_properties_[j] = properties;
597 }
598 
599 
601 {
602  assert_supports(OUT_ARG_DgDp,j,l);
603  DgDp_properties_[ j*Np() + l ] = properties;
604 }
605 
607 {
608  assert_supports(OUT_ARG_DfDp_sg,l);
609  DfDp_sg_properties_[l] = properties;
610 }
611 
612 
614 {
615  assert_supports(OUT_ARG_DgDx_dot_sg,j);
616  DgDx_dot_sg_properties_[j] = properties;
617 }
618 
620 {
621  assert_supports(OUT_ARG_DgDx_dotdot_sg,j);
622  DgDx_dotdot_sg_properties_[j] = properties;
623 }
624 
625 
627 {
628  assert_supports(OUT_ARG_DgDx_sg,j);
629  DgDx_sg_properties_[j] = properties;
630 }
631 
633 {
634  assert_supports(OUT_ARG_DgDp_sg,j,l);
635  DgDp_sg_properties_[ j*Np() + l ] = properties;
636 }
637 
638 
640 {
641  assert_supports(OUT_ARG_DfDp_mp,l);
642  DfDp_mp_properties_[l] = properties;
643 }
644 
645 
647 {
648  assert_supports(OUT_ARG_DgDx_dot_mp,j);
649  DgDx_dot_mp_properties_[j] = properties;
650 }
651 
653 {
654  assert_supports(OUT_ARG_DgDx_dotdot_mp,j);
655  DgDx_dotdot_mp_properties_[j] = properties;
656 }
657 
658 
660 {
661  assert_supports(OUT_ARG_DgDx_mp,j);
662  DgDx_mp_properties_[j] = properties;
663 }
664 
666 {
667  assert_supports(OUT_ARG_DgDp_mp,j,l);
668  DgDp_mp_properties_[ j*Np() + l ] = properties;
669 }
670 
671 
673 {
675  !supports_[arg], std::logic_error
676  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(arg): "
677  "model = \'"<<modelEvalDescription_<<"\': Error, "
678  "The argument arg = " << toString(arg) << " is not supported!"
679  );
680 }
681 
682 
684 {
685  assert_l(l);
687  supports_DfDp_[l].none(), std::logic_error
688  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp,l): "
689  "model = \'"<<modelEvalDescription_<<"\': Error,"
690  "The argument DfDp(l) with index l = " << l << " is not supported!"
691  );
692 }
693 
694 
696 {
697  assert_j(j);
699  supports_DgDx_dot_[j].none(), std::logic_error
700  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot,j): "
701  "model = \'"<<modelEvalDescription_<<"\': Error,"
702  "The argument DgDx_dot(j) with index j = " << j << " is not supported!"
703  );
704 }
705 
706 
708 {
709  assert_j(j);
711  supports_DgDx_dotdot_[j].none(), std::logic_error
712  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dotdot,j): "
713  "model = \'"<<modelEvalDescription_<<"\': Error,"
714  "The argument DgDx_dotdot(j) with index j = " << j << " is not supported!"
715  );
716 }
717 
718 
720 {
721  assert_j(j);
723  supports_DgDx_[j].none(), std::logic_error
724  ,"TEpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx,j): "
725  "model = \'"<<modelEvalDescription_<<"\': Error,"
726  "The argument DgDx(j) with index j = " << j << " is not supported!"
727  );
728 }
729 
730 
731 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp /* arg */, int j, int l) const
732 {
733  assert_j(j);
734  assert_l(l);
736  supports_DgDp_[ j*Np() + l ].none(), std::logic_error
737  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp,j,l): "
738  "model = \'"<<modelEvalDescription_<<"\': Error,"
739  "The argument DgDp(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
740  );
741 }
742 
744 {
745  assert_j(j);
747  !supports_g_sg_[j], std::logic_error
748  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_g_sg,j): "
749  "model = \'"<<modelEvalDescription_<<"\': Error,"
750  "The argument g_sg(j) with index j = " << j << " is not supported!"
751  );
752 }
753 
755 {
756  assert_l(l);
758  supports_DfDp_sg_[l].none(), std::logic_error
759  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp_sg,l): "
760  "model = \'"<<modelEvalDescription_<<"\': Error,"
761  "The argument DfDp_sg(l) with index l = " << l << " is not supported!"
762  );
763 }
764 
765 
767 {
768  assert_j(j);
770  supports_DgDx_dot_sg_[j].none(), std::logic_error
771  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot_sg,j): "
772  "model = \'"<<modelEvalDescription_<<"\': Error,"
773  "The argument DgDx_dot_sg(j) with index j = " << j << " is not supported!"
774  );
775 }
776 
777 
779 {
780  assert_j(j);
782  supports_DgDx_dotdot_sg_[j].none(), std::logic_error
783  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dotdot_sg,j): "
784  "model = \'"<<modelEvalDescription_<<"\': Error,"
785  "The argument DgDx_dotdot_sg(j) with index j = " << j << " is not supported!"
786  );
787 }
788 
789 
791 {
792  assert_j(j);
794  supports_DgDx_sg_[j].none(), std::logic_error
795  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_sg,j): "
796  "model = \'"<<modelEvalDescription_<<"\': Error,"
797  "The argument DgDx_sg(j) with index j = " << j << " is not supported!"
798  );
799 }
800 
802 {
803  assert_j(j);
804  assert_l(l);
806  supports_DgDp_sg_[ j*Np() + l ].none(), std::logic_error
807  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp_sg,j,l): "
808  "model = \'"<<modelEvalDescription_<<"\': Error,"
809  "The argument DgDp_sg(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
810  );
811 }
812 
814 {
815  assert_j(j);
817  !supports_g_mp_[j], std::logic_error
818  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_g_mp,j): "
819  "model = \'"<<modelEvalDescription_<<"\': Error,"
820  "The argument g_mp(j) with index j = " << j << " is not supported!"
821  );
822 }
823 
825 {
826  assert_l(l);
828  supports_DfDp_mp_[l].none(), std::logic_error
829  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp_mp,l): "
830  "model = \'"<<modelEvalDescription_<<"\': Error,"
831  "The argument DfDp_mp(l) with index l = " << l << " is not supported!"
832  );
833 }
834 
835 
837 {
838  assert_j(j);
840  supports_DgDx_dot_mp_[j].none(), std::logic_error
841  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot_mp,j): "
842  "model = \'"<<modelEvalDescription_<<"\': Error,"
843  "The argument DgDx_dot_mp(j) with index j = " << j << " is not supported!"
844  );
845 }
846 
847 
849 {
850  assert_j(j);
852  supports_DgDx_dotdot_mp_[j].none(), std::logic_error
853  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dotdot_mp,j): "
854  "model = \'"<<modelEvalDescription_<<"\': Error,"
855  "The argument DgDx_dotdot_mp(j) with index j = " << j << " is not supported!"
856  );
857 }
858 
859 
861 {
862  assert_j(j);
864  supports_DgDx_mp_[j].none(), std::logic_error
865  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_mp,j): "
866  "model = \'"<<modelEvalDescription_<<"\': Error,"
867  "The argument DgDx_mp(j) with index j = " << j << " is not supported!"
868  );
869 }
870 
872 {
873  assert_j(j);
874  assert_l(l);
876  supports_DgDp_mp_[ j*Np() + l ].none(), std::logic_error
877  ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp_mp,j,l): "
878  "model = \'"<<modelEvalDescription_<<"\': Error,"
879  "The argument DgDp_mp(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
880  );
881 }
882 
883 
885 {
887  Np()==0, std::logic_error
888  ,"EpetraExt::ModelEvaluator::OutArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\': Error, "
889  "no auxiliary parameters subvectors p(l) are supported!!"
890  );
892  !( 0 <= l && l < Np() ), std::logic_error
893  ,"EpetraExt::ModelEvaluator::OutArgs::assert_l(l): "
894  "model = \'"<<modelEvalDescription_<<"\': Error, "
895  "The parameter subvector p(l) index l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
896  );
897 }
898 
899 
901 {
903  Ng()==0, std::logic_error
904  ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\': Error, "
905  "no auxiliary functions g(j) are supported!!"
906  );
908  !( 0 <= j && j < Ng() ), std::logic_error
909  ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\': Error, "
910  "The auxiliary function g(j) index j = " << j << " is not in the range [0,"<<Ng()-1<<"]!"
911  );
912 }
913 
914 
915 //
916 // ModelEvaluator
917 //
918 
919 
920 // Destructor
921 
922 
924 {}
925 
926 
927 // Vector maps
928 
929 
931 ModelEvaluator::get_p_map(int /* l */) const
932 { return Teuchos::null; }
933 
935 ModelEvaluator::get_p_names(int /* l */) const
936 { return Teuchos::null; }
937 
939 ModelEvaluator::get_g_map(int /* j */) const
940 { return Teuchos::null; }
941 
943 ModelEvaluator::get_g_names(int /* j */) const
944 { return Teuchos::null; }
945 
946 
947 // Initial guesses for variables/parameters
948 
949 
952 { return Teuchos::null; }
953 
956 { return Teuchos::null; }
957 
960 { return Teuchos::null; }
961 
963 ModelEvaluator::get_p_init(int /* l */) const
964 { return Teuchos::null; }
965 
967 { return 0.0; }
968 
969 
970 // Bounds for variables/parameters
971 
972 
974 {
975  return 1e+50;
976 }
977 
978 
981 { return Teuchos::null; }
982 
983 
986 { return Teuchos::null; }
987 
988 
991 { return Teuchos::null; }
992 
993 
996 { return Teuchos::null; }
997 
998 
1000 { return 0.0; }
1001 
1002 
1004 { return 0.0; }
1005 
1006 
1007 // Factory functions for creating derivative objects
1008 
1009 
1012 { return Teuchos::null; }
1013 
1016 { return Teuchos::null; }
1017 
1020 { return Teuchos::null; }
1021 
1024 { return Teuchos::null; }
1025 
1028 { return Teuchos::null; }
1029 
1032 { return Teuchos::null; }
1033 
1035 ModelEvaluator::create_DgDp_op( int /* j */, int /* l */ ) const
1036 { return Teuchos::null; }
1037 
1038 } // namespace EpetraExt
1039 
1040 
1041 //
1042 // Helper functions
1043 //
1044 
1045 
1048  )
1049 {
1050  switch(orientation) {
1052  return "DERIV_MV_BY_COL";
1054  return "DERIV_TRANS_MV_BY_ROW";
1055  default:
1057  }
1058  TEUCHOS_UNREACHABLE_RETURN(""); // Should never be called
1059 }
1060 
1061 
1063 {
1064  switch(inArg) {
1066  return "IN_ARG_x_dot";
1068  return "IN_ARG_x_dotdot";
1070  return "IN_ARG_x";
1072  return "IN_ARG_x_dot_poly";
1074  return "IN_ARG_x_dotdot_poly";
1076  return "IN_ARG_x_poly";
1078  return "IN_ARG_x_dot_sg";
1080  return "IN_ARG_x_dotdot_sg";
1082  return "IN_ARG_x_sg";
1084  return "IN_ARG_x_dot_mp";
1086  return "IN_ARG_x_dotdot_mp";
1088  return "IN_ARG_x_mp";
1090  return "IN_ARG_t";
1092  return "IN_ARG_alpha";
1094  return "IN_ARG_omega";
1096  return "IN_ARG_beta";
1098  return "IN_ARG_step_size";
1100  return "IN_ARG_stage_number";
1101  default:
1102  TEUCHOS_TEST_FOR_EXCEPT("Invalid inArg!");
1103  }
1104  TEUCHOS_UNREACHABLE_RETURN(""); // Will never be executed!
1105 }
1106 
1107 
1109 {
1110  switch(outArg) {
1112  return "OUT_ARG_f";
1114  return "OUT_ARG_W";
1116  return "OUT_ARG_WPrec";
1118  return "OUT_ARG_f_poly";
1120  return "OUT_ARG_f_sg";
1122  return "OUT_ARG_W_sg";
1124  return "OUT_ARG_f_mp";
1126  return "OUT_ARG_W_mp";
1127  default:
1128  TEUCHOS_TEST_FOR_EXCEPT("Invalid outArg!");
1129  }
1130  TEUCHOS_UNREACHABLE_RETURN(""); // Will never be executed!
1131 }
1132 
1133 
1136  const std::string &modelEvalDescription,
1137  const ModelEvaluator::Derivative &deriv,
1138  const std::string &derivName
1139  )
1140 {
1142  deriv.getMultiVector().get() != NULL, std::logic_error
1143  ,"For model \'" << modelEvalDescription << "\' the derivative \'"
1144  << derivName << "\' is of type Epetra_MultiVector and not of type Epetra_Operator!"
1145  );
1146  return deriv.getLinearOp();
1147 }
1148 
1149 
1152  const std::string &modelEvalDescription,
1153  const ModelEvaluator::Derivative &deriv,
1154  const std::string &derivName,
1156  )
1157 {
1159  deriv.getLinearOp().get() != NULL, std::logic_error
1160  ,"For model \'" << modelEvalDescription << "\' the derivative \'"
1161  << derivName << "\' is of type Epetra_Operator and not of type Epetra_MultiVector!"
1162  );
1164  mv = deriv.getMultiVector();
1165  if(mv.get()) {
1167  deriv.getMultiVectorOrientation()!=mvOrientation, std::logic_error
1168  ,"For model \'" << modelEvalDescription << "\' the derivative \'"
1169  << derivName << "\' if not the orientation \'" << toString(mvOrientation)
1170  << "\'"
1171  );
1172  }
1173  return mv;
1174 }
1175 
1176 
1179  const int l,
1180  const ModelEvaluator::OutArgs &outArgs
1181  )
1182 {
1183  std::ostringstream derivName; derivName << "DfDp("<<l<<")";
1184  return getLinearOp(
1185  outArgs.modelEvalDescription()
1186  ,outArgs.get_DfDp(l)
1187  ,derivName.str()
1188  );
1189 }
1190 
1191 
1194  const int l,
1195  const ModelEvaluator::OutArgs &outArgs
1196  )
1197 {
1198  std::ostringstream derivName; derivName << "DfDp("<<l<<")";
1199  return getMultiVector(
1200  outArgs.modelEvalDescription()
1201  ,outArgs.get_DfDp(l)
1202  ,derivName.str()
1204  );
1205 }
1206 
1207 
1210  const int j,
1211  const ModelEvaluator::OutArgs &outArgs,
1213  )
1214 {
1215  std::ostringstream derivName; derivName << "DgDx_dot("<<j<<")";
1216  return getMultiVector(
1217  outArgs.modelEvalDescription(),
1218  outArgs.get_DgDx_dot(j),
1219  derivName.str(),
1220  mvOrientation
1221  );
1222 }
1223 
1224 
1227  const int j,
1228  const ModelEvaluator::OutArgs &outArgs,
1230  )
1231 {
1232  std::ostringstream derivName; derivName << "DgDx_dotdot("<<j<<")";
1233  return getMultiVector(
1234  outArgs.modelEvalDescription(),
1235  outArgs.get_DgDx_dotdot(j),
1236  derivName.str(),
1237  mvOrientation
1238  );
1239 }
1240 
1241 
1244  const int j,
1245  const ModelEvaluator::OutArgs &outArgs,
1247  )
1248 {
1249  std::ostringstream derivName; derivName << "DgDx("<<j<<")";
1250  return getMultiVector(
1251  outArgs.modelEvalDescription(),
1252  outArgs.get_DgDx(j),
1253  derivName.str(),
1254  mvOrientation
1255  );
1256 }
1257 
1258 
1261  const int j,
1262  const int l,
1263  const ModelEvaluator::OutArgs &outArgs,
1265  )
1266 {
1267  std::ostringstream derivName; derivName << "DgDp("<<j<<","<<l<<")";
1268  return getMultiVector(
1269  outArgs.modelEvalDescription(),
1270  outArgs.get_DgDp(j,l),
1271  derivName.str(),
1272  mvOrientation
1273  );
1274 }
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
bool supports(EOutArgsMembers arg) const
virtual Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
.
virtual Teuchos::RCP< Epetra_Operator > create_DgDx_op(int j) const
bool is_null(const boost::shared_ptr< T > &p)
Time second derivative vector Taylor polynomial.
void _setSupports(EOutArgsMembers arg, bool supports)
void _set_DfDp_properties(int l, const DerivativeProperties &properties)
virtual Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
virtual Teuchos::RCP< const Epetra_Vector > get_p_upper_bounds(int l) const
Teuchos::RCP< Epetra_Operator > getLinearOp(const std::string &modelEvalDescription, const ModelEvaluator::Derivative &deriv, const std::string &derivName)
Teuchos::RCP< Epetra_MultiVector > get_DgDp_mv(const int j, const int l, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
virtual double get_t_upper_bound() const
virtual Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Get the names of the parameters associated with parameter subvector l if available.
bool funcOrDerivesAreSet(EOutArgsMembers arg) const
Return true if the function or its derivatives are set.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< Epetra_MultiVector > get_DgDx_dot_mv(const int j, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
void _set_DgDp_mp_properties(int j, int l, const DerivativeProperties &properties)
Teuchos::RCP< Epetra_Operator > getLinearOp() const
T * get() const
void setFailed() const
Set that the evaluation as a whole failed.
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
Teuchos::RCP< Epetra_MultiVector > getMultiVector(const std::string &modelEvalDescription, const ModelEvaluator::Derivative &deriv, const std::string &derivName, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
virtual Teuchos::RCP< Epetra_Operator > create_DgDx_dot_op(int j) const
virtual Teuchos::RCP< const Epetra_Vector > get_x_upper_bounds() const
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
Multi-point &quot;W&quot; operator.
Stochastic Galerkin solution vector polynomial.
Teuchos::RCP< Epetra_MultiVector > getMultiVector() const
void _set_DgDx_dotdot_mp_properties(int j, const DerivativeProperties &properties)
virtual Teuchos::ArrayView< const std::string > get_g_names(int j) const
Get the names of the response functions associated with response subvector j if available.
virtual Teuchos::RCP< const Epetra_Vector > get_x_lower_bounds() const
virtual Teuchos::RCP< const Epetra_Vector > get_x_dotdot_init() const
Teuchos::RCP< Epetra_MultiVector > get_DfDp_mv(const int l, const ModelEvaluator::OutArgs &outArgs)
void _set_DgDx_mp_properties(int j, const DerivativeProperties &properties)
Derivative get_DgDp(int j, int l) const
Teuchos::RCP< Epetra_Operator > get_DfDp_op(const int l, const ModelEvaluator::OutArgs &outArgs)
Multi-point time second derivative vector.
Preconditioner operator (approx Jacobian)
bool supports(EInArgsMembers arg) const
void assert_supports(EInArgsMembers arg) const
Teuchos::RCP< Epetra_MultiVector > get_DgDx_mv(const int j, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
void _set_WPrec_properties(const DerivativeProperties &WPrec_properties)
void _set_DgDx_dot_mp_properties(int j, const DerivativeProperties &properties)
virtual Teuchos::RCP< const Epetra_Vector > get_x_dot_init() const
virtual Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
.
void _set_DgDx_dot_properties(int j, const DerivativeProperties &properties)
virtual Teuchos::RCP< Epetra_Operator > create_DgDp_op(int j, int l) const
virtual Teuchos::RCP< Epetra_Operator > create_DgDx_dotdot_op(int j) const
void _set_DgDx_dot_sg_properties(int j, const DerivativeProperties &properties)
TypeTo implicit_cast(const TypeFrom &t)
Multi-point time derivative vector.
EDerivativeMultiVectorOrientation getMultiVectorOrientation() const
bool isFailed() const
Return if the evaluation failed or not.
virtual Teuchos::RCP< const Epetra_Vector > get_p_lower_bounds(int l) const
void _set_DfDp_mp_properties(int l, const DerivativeProperties &properties)
Solution vector Taylor polynomial.
Stochastic Galerkin time derivative vector polynomial.
virtual double getInfBound() const
Return the value of an infinite bound.
void _set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
Stochastic Galerkin residual vector polynomial.
virtual double get_t_lower_bound() const
Stochastic Galerkin &quot;W&quot; operator polyomial.
Teuchos::RCP< Epetra_MultiVector > get_DgDx_dotdot_mv(const int j, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
virtual Teuchos::RCP< const Epetra_Vector > get_x_init() const
virtual double get_t_init() const
Time derivative vector Taylor polynomial.
void _set_DgDx_properties(int j, const DerivativeProperties &properties)
virtual Teuchos::RCP< EpetraExt::ModelEvaluator::Preconditioner > create_WPrec() const
void _set_DgDp_sg_properties(int j, int l, const DerivativeProperties &properties)
virtual Teuchos::RCP< Epetra_Operator > create_DfDp_op(int l) const
Stochastic Galerkin time second derivative vector polynomial.
void _set_DgDx_dotdot_properties(int j, const DerivativeProperties &properties)
void _setSupports(EInArgsMembers arg, bool supports)
void assert_supports(EOutArgsMembers arg) const
virtual Teuchos::RCP< Epetra_Operator > create_W() const
If supported, create a Epetra_Operator object for W to be evaluated.
void _set_DgDx_sg_properties(int j, const DerivativeProperties &properties)
void _set_W_properties(const DerivativeProperties &W_properties)
void _set_DgDx_dotdot_sg_properties(int j, const DerivativeProperties &properties)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void _set_DfDp_sg_properties(int l, const DerivativeProperties &properties)
std::string toString(const int &x)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
void _setModelEvalDescription(const std::string &modelEvalDescription)