EpetraExt Package Browser (Single Doxygen Collection) Development
EpetraExt_ModelEvaluator.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00005 //                 Copyright (2001) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include "EpetraExt_ModelEvaluator.h"
00030 #include "Teuchos_implicit_cast.hpp"
00031 
00032 
00033 namespace EpetraExt {
00034 
00035 
00036 //
00037 // ModelEvaluator::InArgs
00038 //
00039 
00040 
00041 ModelEvaluator::InArgs::InArgs()
00042   :modelEvalDescription_("WARNING!  THIS INARGS OBJECT IS UNINITALIZED!")
00043 {
00044   std::fill_n(&supports_[0],NUM_E_IN_ARGS_MEMBERS,false);
00045   t_     = 0.0;
00046   alpha_ = 0.0;
00047   beta_  = 0.0;
00048 }
00049 
00050 
00051 bool ModelEvaluator::InArgs::supports(EInArgsMembers arg) const
00052 {
00053   TEST_FOR_EXCEPTION(
00054     int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00055     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00056     );
00057   return supports_[arg];
00058 }
00059 
00060 
00061 void ModelEvaluator::InArgs::_setSupports( EInArgsMembers arg, bool supports )
00062 {
00063   TEST_FOR_EXCEPTION(
00064     int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00065     ,"model = \'"<<modelEvalDescription_<<"\':Error, arg="<<toString(arg)<<" is invalid!"
00066     );
00067   supports_[arg] = supports;
00068 }
00069 
00070 
00071 void ModelEvaluator::InArgs::assert_supports(EInArgsMembers arg) const
00072 {
00073   TEST_FOR_EXCEPTION(
00074     !supports_[arg], std::logic_error
00075     ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(arg): model = \'"<<modelEvalDescription_<<"\': Error, "
00076     "The argument arg = " << toString(arg) << " is not supported!"
00077     );
00078 }
00079 
00080 
00081 void ModelEvaluator::InArgs::assert_l(int l) const
00082 {
00083   TEST_FOR_EXCEPTION(
00084     !( 0 <= l && l < Np() ), std::logic_error
00085     ,"EpetraExt::ModelEvaluator::InArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\': Error, "
00086     "The parameter l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
00087     );
00088 }
00089 
00090 
00091 //
00092 // ModelEvaluator::OutArgs
00093 //
00094 
00095 
00096 ModelEvaluator::OutArgs::OutArgs()
00097   :modelEvalDescription_("WARNING!  THIS OUTARGS OBJECT IS UNINITALIZED!"),
00098   isFailed_( false )
00099 {
00100   std::fill_n(&supports_[0],NUM_E_OUT_ARGS_MEMBERS,false);
00101 }
00102 
00103 
00104 bool ModelEvaluator::OutArgs::supports(EOutArgsMembers arg) const
00105 {
00106   TEST_FOR_EXCEPTION(
00107     int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00108     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00109     );
00110   return supports_[arg];
00111 }
00112 
00113 
00114 const ModelEvaluator::DerivativeSupport&
00115 ModelEvaluator::OutArgs::supports(EOutArgsDfDp arg, int l) const
00116 {
00117   assert_l(l);
00118   return supports_DfDp_[l];
00119 }
00120 
00121 
00122 const ModelEvaluator::DerivativeSupport&
00123 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dot arg, int j) const
00124 {
00125   assert_j(j);
00126   return supports_DgDx_dot_[j];
00127 }
00128 
00129 
00130 const ModelEvaluator::DerivativeSupport&
00131 ModelEvaluator::OutArgs::supports(EOutArgsDgDx arg, int j) const
00132 {
00133   assert_j(j);
00134   return supports_DgDx_[j];
00135 }
00136 
00137 
00138 const ModelEvaluator::DerivativeSupport&
00139 ModelEvaluator::OutArgs::supports(EOutArgsDgDp arg, int j, int l) const
00140 {
00141   assert_j(j);
00142   assert_l(l);
00143   return supports_DgDp_[ j*Np() + l ];
00144 }
00145 
00146 const ModelEvaluator::DerivativeSupport&
00147 ModelEvaluator::OutArgs::supports(EOutArgsDfDp_sg arg, int l) const
00148 {
00149   assert_l_sg(l);
00150   return supports_DfDp_sg_[l];
00151 }
00152 
00153 
00154 const ModelEvaluator::DerivativeSupport&
00155 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dot_sg arg, int j) const
00156 {
00157   assert_j_sg(j);
00158   return supports_DgDx_dot_sg_[j];
00159 }
00160 
00161 
00162 const ModelEvaluator::DerivativeSupport&
00163 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_sg arg, int j) const
00164 {
00165   assert_j_sg(j);
00166   return supports_DgDx_sg_[j];
00167 }
00168 
00169 const ModelEvaluator::DerivativeSupport&
00170 ModelEvaluator::OutArgs::supports(EOutArgsDgDp_sg arg, int j, int l) const
00171 {
00172   assert_j_sg(j);
00173   assert_l_sg(l);
00174   return supports_DgDp_sg_[ j*Np_sg() + l ];
00175 }
00176 
00177 
00178 bool ModelEvaluator::OutArgs::funcOrDerivesAreSet(EOutArgsMembers arg) const
00179 {
00180   using Teuchos::implicit_cast;
00181   bool areSet = false;
00182   switch(arg) {
00183     case OUT_ARG_f: {
00184       if (!is_null(f_)) areSet = true;
00185       if (!is_null(W_)) areSet = true;
00186       for ( int l = 0; l < implicit_cast<int>(DfDp_.size()); ++l )
00187         if(!DfDp_[l].isEmpty()) areSet = true;
00188       break;
00189     }
00190     default:
00191       TEST_FOR_EXCEPTION(true,std::logic_error,
00192         "ModelEvaluator::OutArgs::funcOrDerivesAreSet(arg): Error, we can not handle"
00193         " the argument " << toString(arg) << "yet!");
00194   }
00195   return areSet;
00196 }
00197 
00198 void ModelEvaluator::OutArgs::setFailed() const
00199 {
00200   isFailed_ = true;
00201   // TODO: Set objects to NaN?
00202 }
00203 
00204 bool ModelEvaluator::OutArgs::isFailed() const
00205 {
00206   return isFailed_;
00207 }
00208 
00209 
00210 void ModelEvaluator::OutArgs::_setModelEvalDescription( const std::string &modelEvalDescription )
00211 {
00212   modelEvalDescription_ = modelEvalDescription;
00213 }
00214 
00215 
00216 void ModelEvaluator::OutArgs::_set_Np_Ng(int Np, int Ng)
00217 {
00218   if(Np) {
00219     supports_DfDp_.resize(Np);
00220     DfDp_.resize(Np);
00221     std::fill_n(DfDp_.begin(),Np,Derivative());
00222     DfDp_properties_.resize(Np);
00223     std::fill_n(DfDp_properties_.begin(),Np,DerivativeProperties());
00224   }
00225   if(Ng) {
00226     g_.resize(Ng);
00227     supports_DgDx_dot_.resize(Ng);
00228     DgDx_dot_.resize(Ng);
00229     std::fill_n(DgDx_dot_.begin(),Ng,Derivative());
00230     DgDx_dot_properties_.resize(Ng);
00231     std::fill_n(DgDx_dot_properties_.begin(),Ng,DerivativeProperties());
00232     supports_DgDx_.resize(Ng);
00233     DgDx_.resize(Ng);
00234     std::fill_n(DgDx_.begin(),Ng,Derivative());
00235     DgDx_properties_.resize(Ng);
00236     std::fill_n(DgDx_properties_.begin(),Ng,DerivativeProperties());
00237   }
00238   if(Np && Ng) {
00239     const int NpNg = Np*Ng;
00240     supports_DgDp_.resize(NpNg);
00241     DgDp_.resize(NpNg);
00242     std::fill_n(DgDp_.begin(),NpNg,Derivative());
00243     DgDp_properties_.resize(NpNg);
00244     std::fill_n(DgDp_properties_.begin(),NpNg,DerivativeProperties());
00245   }
00246 }
00247 
00248 void ModelEvaluator::OutArgs::_set_Np_Ng_sg(int Np_sg, int Ng_sg)
00249 {
00250   if(Np_sg) {
00251     supports_DfDp_sg_.resize(Np_sg);
00252     DfDp_sg_.resize(Np_sg);
00253     std::fill_n(DfDp_sg_.begin(),Np_sg,SGDerivative());
00254     DfDp_sg_properties_.resize(Np_sg);
00255     std::fill_n(DfDp_sg_properties_.begin(),Np_sg,DerivativeProperties());
00256   }
00257   if(Ng_sg) {
00258     g_sg_.resize(Ng_sg);
00259     supports_DgDx_dot_sg_.resize(Ng_sg);
00260     DgDx_dot_sg_.resize(Ng_sg);
00261     std::fill_n(DgDx_dot_sg_.begin(),Ng_sg,SGDerivative());
00262     DgDx_dot_sg_properties_.resize(Ng_sg);
00263     std::fill_n(DgDx_dot_sg_properties_.begin(),Ng_sg,DerivativeProperties());
00264     supports_DgDx_sg_.resize(Ng_sg);
00265     DgDx_sg_.resize(Ng_sg);
00266     std::fill_n(DgDx_sg_.begin(),Ng_sg,SGDerivative());
00267     DgDx_sg_properties_.resize(Ng_sg);
00268     std::fill_n(DgDx_sg_properties_.begin(),Ng_sg,DerivativeProperties());
00269   }
00270   if(Np_sg && Ng_sg) {
00271     const int NpNg_sg = Np_sg*Ng_sg;
00272     supports_DgDp_sg_.resize(NpNg_sg);
00273     DgDp_sg_.resize(NpNg_sg);
00274     std::fill_n(DgDp_sg_.begin(),NpNg_sg,SGDerivative());
00275     DgDp_sg_properties_.resize(NpNg_sg);
00276     std::fill_n(DgDp_sg_properties_.begin(),NpNg_sg,DerivativeProperties());
00277   }
00278 }
00279 
00280 
00281 void ModelEvaluator::OutArgs::_setSupports( EOutArgsMembers arg, bool supports )
00282 {
00283   TEST_FOR_EXCEPTION(
00284     int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00285     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00286     );
00287   supports_[arg] = supports;
00288 }
00289 
00290 
00291 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp arg, int l, const DerivativeSupport& supports )
00292 {
00293   assert_l(l);
00294   supports_DfDp_[l] = supports;
00295 }
00296 
00297 
00298 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dot arg, int j, const DerivativeSupport& supports )
00299 {
00300   assert_j(j);
00301   supports_DgDx_dot_[j] = supports;
00302 }
00303 
00304 
00305 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx arg, int j, const DerivativeSupport& supports )
00306 {
00307   assert_j(j);
00308   supports_DgDx_[j] = supports;
00309 }
00310 
00311 
00312 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp arg, int j, int l, const DerivativeSupport& supports )
00313 {
00314   assert_j(j);
00315   assert_l(l);
00316   supports_DgDp_[ j*Np() + l ] = supports;
00317 }
00318 
00319 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp_sg arg, int l, const DerivativeSupport& supports )
00320 {
00321   assert_l_sg(l);
00322   supports_DfDp_sg_[l] = supports;
00323 }
00324 
00325 
00326 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dot_sg arg, int j, const DerivativeSupport& supports )
00327 {
00328   assert_j_sg(j);
00329   supports_DgDx_dot_sg_[j] = supports;
00330 }
00331 
00332 
00333 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_sg arg, int j, const DerivativeSupport& supports )
00334 {
00335   assert_j_sg(j);
00336   supports_DgDx_sg_[j] = supports;
00337 }
00338 
00339 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp_sg arg, int j, int l, const DerivativeSupport& supports )
00340 {
00341   assert_j_sg(j);
00342   assert_l_sg(l);
00343   supports_DgDp_sg_[ j*Np_sg() + l ] = supports;
00344 }
00345 
00346 
00347 void ModelEvaluator::OutArgs::_set_W_properties( const DerivativeProperties &W_properties )
00348 {
00349   W_properties_ = W_properties;
00350 }
00351 
00352 void ModelEvaluator::OutArgs::_set_WPrec_properties( const DerivativeProperties &WPrec_properties )
00353 {
00354   WPrec_properties_ = WPrec_properties;
00355 }
00356 
00357 void ModelEvaluator::OutArgs::_set_DfDp_properties( int l, const DerivativeProperties &properties )
00358 {
00359   assert_supports(OUT_ARG_DfDp,l);
00360   DfDp_properties_[l] = properties;
00361 }
00362 
00363 
00364 void ModelEvaluator::OutArgs::_set_DgDx_dot_properties( int j, const DerivativeProperties &properties )
00365 {
00366   assert_supports(OUT_ARG_DgDx_dot,j);
00367   DgDx_dot_properties_[j] = properties;
00368 }
00369 
00370 
00371 void ModelEvaluator::OutArgs::_set_DgDx_properties( int j, const DerivativeProperties &properties )
00372 {
00373   assert_supports(OUT_ARG_DgDx,j);
00374   DgDx_properties_[j] = properties;
00375 }
00376 
00377 
00378 void ModelEvaluator::OutArgs::_set_DgDp_properties( int j, int l, const DerivativeProperties &properties )
00379 {
00380   assert_supports(OUT_ARG_DgDp,j,l);
00381   DgDp_properties_[ j*Np() + l ] = properties;
00382 }
00383 
00384 void ModelEvaluator::OutArgs::_set_DfDp_sg_properties( int l, const DerivativeProperties &properties )
00385 {
00386   assert_supports(OUT_ARG_DfDp_sg,l);
00387   DfDp_sg_properties_[l] = properties;
00388 }
00389 
00390 
00391 void ModelEvaluator::OutArgs::_set_DgDx_dot_sg_properties( int j, const DerivativeProperties &properties )
00392 {
00393   assert_supports(OUT_ARG_DgDx_dot_sg,j);
00394   DgDx_dot_sg_properties_[j] = properties;
00395 }
00396 
00397 
00398 void ModelEvaluator::OutArgs::_set_DgDx_sg_properties( int j, const DerivativeProperties &properties )
00399 {
00400   assert_supports(OUT_ARG_DgDx_sg,j);
00401   DgDx_sg_properties_[j] = properties;
00402 }
00403 
00404 void ModelEvaluator::OutArgs::_set_DgDp_sg_properties( int j, int l, const DerivativeProperties &properties )
00405 {
00406   assert_supports(OUT_ARG_DgDp_sg,j,l);
00407   DgDp_sg_properties_[ j*Np_sg() + l ] = properties;
00408 }
00409 
00410 
00411 void ModelEvaluator::OutArgs::assert_supports(EOutArgsMembers arg) const
00412 {
00413   TEST_FOR_EXCEPTION(
00414     !supports_[arg], std::logic_error
00415     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(arg): "
00416     "model = \'"<<modelEvalDescription_<<"\': Error, "
00417     "The argument arg = " << toString(arg) << " is not supported!"
00418     );
00419 }
00420 
00421 
00422 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDfDp arg, int l) const
00423 {
00424   assert_l(l);
00425   TEST_FOR_EXCEPTION(
00426     supports_DfDp_[l].none(), std::logic_error
00427     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp,l): "
00428     "model = \'"<<modelEvalDescription_<<"\': Error,"
00429     "The argument DfDp(l) with index l = " << l << " is not supported!"
00430     );
00431 }
00432 
00433 
00434 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dot arg, int j) const
00435 {
00436   assert_j(j);
00437   TEST_FOR_EXCEPTION(
00438     supports_DgDx_dot_[j].none(), std::logic_error
00439     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot,j): "
00440     "model = \'"<<modelEvalDescription_<<"\': Error,"
00441     "The argument DgDx_dot(j) with index j = " << j << " is not supported!"
00442     );
00443 }
00444 
00445 
00446 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx arg, int j) const
00447 {
00448   assert_j(j);
00449   TEST_FOR_EXCEPTION(
00450     supports_DgDx_[j].none(), std::logic_error
00451     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx,j): "
00452     "model = \'"<<modelEvalDescription_<<"\': Error,"
00453     "The argument DgDx(j) with index j = " << j << " is not supported!"
00454     );
00455 }
00456 
00457 
00458 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp arg, int j, int l) const
00459 {
00460   assert_j(j);
00461   TEST_FOR_EXCEPTION(
00462     supports_DgDp_[ j*Np() + l ].none(), std::logic_error
00463     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp,j,l): "
00464     "model = \'"<<modelEvalDescription_<<"\': Error,"
00465     "The argument DgDp(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00466     );
00467 }
00468 
00469 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDfDp_sg arg, int l) const
00470 {
00471   assert_l_sg(l);
00472   TEST_FOR_EXCEPTION(
00473     supports_DfDp_sg_[l].none(), std::logic_error
00474     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp_sg,l): "
00475     "model = \'"<<modelEvalDescription_<<"\': Error,"
00476     "The argument DfDp_sg(l) with index l = " << l << " is not supported!"
00477     );
00478 }
00479 
00480 
00481 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dot_sg arg, int j) const
00482 {
00483   assert_j_sg(j);
00484   TEST_FOR_EXCEPTION(
00485     supports_DgDx_dot_sg_[j].none(), std::logic_error
00486     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot_sg,j): "
00487     "model = \'"<<modelEvalDescription_<<"\': Error,"
00488     "The argument DgDx_dot_sg(j) with index j = " << j << " is not supported!"
00489     );
00490 }
00491 
00492 
00493 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_sg arg, int j) const
00494 {
00495   assert_j_sg(j);
00496   TEST_FOR_EXCEPTION(
00497     supports_DgDx_sg_[j].none(), std::logic_error
00498     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_sg,j): "
00499     "model = \'"<<modelEvalDescription_<<"\': Error,"
00500     "The argument DgDx_sg(j) with index j = " << j << " is not supported!"
00501     );
00502 }
00503 
00504 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp_sg arg, int j, int l) const
00505 {
00506   assert_j_sg(j);
00507   TEST_FOR_EXCEPTION(
00508     supports_DgDp_sg_[ j*Np_sg() + l ].none(), std::logic_error
00509     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp_sg,j,l): "
00510     "model = \'"<<modelEvalDescription_<<"\': Error,"
00511     "The argument DgDp_sg(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00512     );
00513 }
00514 
00515 
00516 void ModelEvaluator::OutArgs::assert_l(int l) const
00517 {
00518   TEST_FOR_EXCEPTION(
00519     Np()==0, std::logic_error
00520     ,"EpetraExt::ModelEvaluator::OutArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\':  Error, "
00521     "no auxiliary parameters subvectors p(l) are supported!!"
00522     );
00523   TEST_FOR_EXCEPTION(
00524     !( 0 <= l && l < Np() ), std::logic_error
00525     ,"Thyra::ModelEvaluator::OutArgs::assert_l(l): "
00526     "model = \'"<<modelEvalDescription_<<"\': Error, "
00527     "The parameter subvector p(l) index l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
00528     );
00529 }
00530 
00531 
00532 void ModelEvaluator::OutArgs::assert_j(int j) const
00533 {
00534   TEST_FOR_EXCEPTION(
00535     Ng()==0, std::logic_error
00536     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00537     "no auxiliary functions g(j) are supported!!"
00538     );
00539   TEST_FOR_EXCEPTION(
00540     !( 0 <= j && j < Ng() ), std::logic_error
00541     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00542     "The auxiliary function g(j) index j = " << j << " is not in the range [0,"<<Ng()-1<<"]!"
00543     );
00544 }
00545 
00546 void ModelEvaluator::OutArgs::assert_l_sg(int l) const
00547 {
00548   TEST_FOR_EXCEPTION(
00549     Np_sg()==0, std::logic_error
00550     ,"EpetraExt::ModelEvaluator::OutArgs::assert_l_sg(l): model = \'"<<modelEvalDescription_<<"\':  Error, "
00551     "no stochastic Galerkin auxiliary parameters subvectors p_sg(l) are supported!!"
00552     );
00553   TEST_FOR_EXCEPTION(
00554     !( 0 <= l && l < Np_sg() ), std::logic_error
00555     ,"Thyra::ModelEvaluator::OutArgs::assert_l_sg(l): "
00556     "model = \'"<<modelEvalDescription_<<"\': Error, "
00557     "The stochastic Galerkin parameter subvector p_sg(l) index l = " << l << " is not in the range [0,"<<Np_sg()-1<<"]!"
00558     );
00559 }
00560 
00561 void ModelEvaluator::OutArgs::assert_j_sg(int j) const
00562 {
00563   TEST_FOR_EXCEPTION(
00564     Ng_sg()==0, std::logic_error
00565     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j_sg(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00566     "no stochastic Galerkin auxiliary functions g_sg(j) are supported!!"
00567     );
00568   TEST_FOR_EXCEPTION(
00569     !( 0 <= j && j < Ng_sg() ), std::logic_error
00570     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j_sg(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00571     "The stochastic Galerkin auxiliary function g_sg(j) index j = " << j << " is not in the range [0,"<<Ng_sg()-1<<"]!"
00572     );
00573 }
00574 
00575 
00576 //
00577 // ModelEvaluator
00578 //
00579 
00580 
00581 // Destructor
00582 
00583 
00584 ModelEvaluator::~ModelEvaluator()
00585 {}
00586 
00587 
00588 // Vector maps
00589  
00590  
00591 Teuchos::RefCountPtr<const Epetra_Map>
00592 ModelEvaluator::get_p_map(int l) const
00593 { return Teuchos::null; }
00594 
00595 Teuchos::RefCountPtr<const Epetra_Map>
00596 ModelEvaluator::get_p_sg_map(int l) const
00597 { return Teuchos::null; }
00598 
00599 Teuchos::RefCountPtr<const Teuchos::Array<std::string> >
00600 ModelEvaluator::get_p_names(int l) const
00601 { return Teuchos::null; }
00602 
00603 Teuchos::RefCountPtr<const Teuchos::Array<std::string> >
00604 ModelEvaluator::get_p_sg_names(int l) const
00605 { return Teuchos::null; }
00606 
00607 Teuchos::RefCountPtr<const Epetra_Map>
00608 ModelEvaluator::get_g_map(int j) const
00609 { return Teuchos::null; }
00610 
00611 Teuchos::RefCountPtr<const Epetra_Map>
00612 ModelEvaluator::get_g_sg_map(int j) const
00613 { return Teuchos::null; }
00614 
00615 
00616 // Initial guesses for variables/parameters
00617 
00618 
00619 Teuchos::RefCountPtr<const Epetra_Vector>
00620 ModelEvaluator::get_x_init() const
00621 { return Teuchos::null; }
00622 
00623 Teuchos::RefCountPtr<const Stokhos::EpetraVectorOrthogPoly>
00624 ModelEvaluator::get_x_sg_init() const
00625 { return Teuchos::null; }
00626 
00627 
00628 Teuchos::RefCountPtr<const Epetra_Vector>
00629 ModelEvaluator::get_x_dot_init() const
00630 { return Teuchos::null; }
00631 
00632 Teuchos::RefCountPtr<const Stokhos::EpetraVectorOrthogPoly>
00633 ModelEvaluator::get_x_dot_sg_init() const
00634 { return Teuchos::null; }
00635 
00636 
00637 Teuchos::RefCountPtr<const Epetra_Vector>
00638 ModelEvaluator::get_p_init(int l) const
00639 { return Teuchos::null; }
00640 
00641 Teuchos::RefCountPtr<const Stokhos::EpetraVectorOrthogPoly>
00642 ModelEvaluator::get_p_sg_init(int l) const
00643 { return Teuchos::null; }
00644 
00645 
00646 double ModelEvaluator::get_t_init() const
00647 { return 0.0; }
00648 
00649 
00650 // Bounds for variables/parameters
00651 
00652 
00653 double ModelEvaluator::getInfBound() const
00654 {
00655   return 1e+50;
00656 }
00657 
00658 
00659 Teuchos::RefCountPtr<const Epetra_Vector>
00660 ModelEvaluator::get_x_lower_bounds() const
00661 { return Teuchos::null; }
00662 
00663 
00664 Teuchos::RefCountPtr<const Epetra_Vector>
00665 ModelEvaluator::get_x_upper_bounds() const
00666 { return Teuchos::null; }
00667 
00668 
00669 Teuchos::RefCountPtr<const Epetra_Vector>
00670 ModelEvaluator::get_p_lower_bounds(int l) const
00671 { return Teuchos::null; }
00672 
00673 
00674 Teuchos::RefCountPtr<const Epetra_Vector>
00675 ModelEvaluator::get_p_upper_bounds(int l) const
00676 { return Teuchos::null; }
00677 
00678 
00679 double ModelEvaluator::get_t_lower_bound() const
00680 { return 0.0; }
00681 
00682 
00683 double ModelEvaluator::get_t_upper_bound() const
00684 { return 0.0; }
00685 
00686 
00687 // Factory functions for creating derivative objects
00688 
00689 
00690 Teuchos::RefCountPtr<Epetra_Operator>
00691 ModelEvaluator::create_W() const
00692 { return Teuchos::null; }
00693 
00694 Teuchos::RefCountPtr<EpetraExt::ModelEvaluator::Preconditioner>
00695 ModelEvaluator::create_WPrec() const
00696 { return Teuchos::null; }
00697 
00698 Teuchos::RefCountPtr<Epetra_Operator>
00699 ModelEvaluator::create_DfDp_op(int l) const
00700 { return Teuchos::null; }
00701 
00702 Teuchos::RefCountPtr<Epetra_Operator>
00703 ModelEvaluator::create_DfDp_sg_op(int l) const
00704 { return Teuchos::null; }
00705 
00706 
00707 Teuchos::RefCountPtr<Epetra_Operator>
00708 ModelEvaluator::create_DgDx_dot_op(int j) const
00709 { return Teuchos::null; }
00710 
00711 Teuchos::RefCountPtr<Epetra_Operator>
00712 ModelEvaluator::create_DgDx_dot_sg_op(int j) const
00713 { return Teuchos::null; }
00714 
00715 
00716 Teuchos::RefCountPtr<Epetra_Operator>
00717 ModelEvaluator::create_DgDx_op(int j) const
00718 { return Teuchos::null; }
00719 
00720 Teuchos::RefCountPtr<Epetra_Operator>
00721 ModelEvaluator::create_DgDx_sg_op(int j) const
00722 { return Teuchos::null; }
00723 
00724 
00725 Teuchos::RefCountPtr<Epetra_Operator>
00726 ModelEvaluator::create_DgDp_op( int j, int l ) const
00727 { return Teuchos::null; }
00728 
00729 Teuchos::RefCountPtr<Epetra_Operator>
00730 ModelEvaluator::create_DgDp_sg_op( int j, int l ) const
00731 { return Teuchos::null; }
00732 
00733 
00734 } // namespace EpetraExt
00735 
00736 
00737 //
00738 // Helper functions
00739 //
00740 
00741 
00742 std::string EpetraExt::toString(
00743    ModelEvaluator::EDerivativeMultiVectorOrientation orientation
00744    )
00745 {
00746   switch(orientation) {
00747     case ModelEvaluator::DERIV_MV_BY_COL:
00748       return "DERIV_MV_BY_COL";
00749     case ModelEvaluator::DERIV_TRANS_MV_BY_ROW:
00750       return "DERIV_TRANS_MV_BY_ROW";
00751     default:
00752       TEST_FOR_EXCEPT(true);
00753   }
00754   return ""; // Should never be called
00755 }
00756 
00757 
00758 std::string EpetraExt::toString( ModelEvaluator::EInArgsMembers inArg )
00759 {
00760   switch(inArg) {
00761     case ModelEvaluator::IN_ARG_x_dot:
00762       return "IN_ARG_x_dot";
00763     case ModelEvaluator::IN_ARG_x:
00764       return "IN_ARG_x";
00765     case ModelEvaluator::IN_ARG_x_dot_poly:
00766       return "IN_ARG_x_dot_poly";
00767     case ModelEvaluator::IN_ARG_x_poly:
00768       return "IN_ARG_x_poly";
00769     case ModelEvaluator::IN_ARG_t:
00770       return "IN_ARG_t";
00771     case ModelEvaluator::IN_ARG_alpha:
00772       return "IN_ARG_alpha";
00773     case ModelEvaluator::IN_ARG_beta:
00774       return "IN_ARG_beta";
00775     default:
00776       TEST_FOR_EXCEPT("Invalid inArg!");
00777   }
00778   return ""; // Will never be executed!
00779 }
00780 
00781 
00782 std::string EpetraExt::toString( ModelEvaluator::EOutArgsMembers outArg )
00783 {
00784   switch(outArg) {
00785     case  ModelEvaluator::OUT_ARG_f:
00786       return "OUT_ARG_f";
00787     case ModelEvaluator::OUT_ARG_W:
00788       return "OUT_ARG_W";
00789     case ModelEvaluator::OUT_ARG_WPrec:
00790       return "OUT_ARG_WPrec";
00791     case ModelEvaluator::OUT_ARG_f_poly:
00792       return "OUT_ARG_f_poly";
00793     case ModelEvaluator::OUT_ARG_f_sg:
00794       return "OUT_ARG_f_sg";
00795     case ModelEvaluator::OUT_ARG_W_sg:
00796       return "OUT_ARG_W_sg";
00797     default:
00798       TEST_FOR_EXCEPT("Invalid outArg!");
00799   }
00800   return ""; // Will never be executed!
00801 }
00802 
00803 
00804 Teuchos::RefCountPtr<Epetra_Operator>
00805 EpetraExt::getLinearOp(
00806   const std::string &modelEvalDescription,
00807   const ModelEvaluator::Derivative &deriv,
00808   const std::string &derivName
00809   )
00810 {
00811   TEST_FOR_EXCEPTION(
00812     deriv.getMultiVector().get() != NULL, std::logic_error
00813     ,"For model \'" << modelEvalDescription << "\' the derivative \'"
00814     << derivName << "\' is of type Epetra_MultiVector and not of type Epetra_Operator!"
00815     );
00816   return deriv.getLinearOp();
00817 }
00818 
00819 
00820 Teuchos::RefCountPtr<Epetra_MultiVector>
00821 EpetraExt::getMultiVector(
00822   const std::string &modelEvalDescription,
00823   const ModelEvaluator::Derivative &deriv,
00824   const std::string &derivName,
00825   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00826   )
00827 {
00828   TEST_FOR_EXCEPTION(
00829     deriv.getLinearOp().get() != NULL, std::logic_error
00830     ,"For model \'" << modelEvalDescription << "\' the derivative \'"
00831     << derivName << "\' is of type Epetra_Operator and not of type Epetra_MultiVector!"
00832     );
00833   Teuchos::RefCountPtr<Epetra_MultiVector>
00834     mv = deriv.getMultiVector();
00835   if(mv.get()) {
00836     TEST_FOR_EXCEPTION(
00837       deriv.getMultiVectorOrientation()!=mvOrientation, std::logic_error
00838       ,"For model \'" << modelEvalDescription << "\' the derivative \'"
00839       << derivName << "\' if not the orientation \'" << toString(mvOrientation)
00840       << "\'"
00841       );
00842   }
00843   return mv;
00844 }
00845 
00846 
00847 Teuchos::RefCountPtr<Epetra_Operator>
00848 EpetraExt::get_DfDp_op(
00849   const int l,
00850   const ModelEvaluator::OutArgs &outArgs
00851   )
00852 {
00853   std::ostringstream derivName; derivName << "DfDp("<<l<<")";
00854   return getLinearOp(
00855     outArgs.modelEvalDescription()
00856     ,outArgs.get_DfDp(l)
00857     ,derivName.str()
00858     );
00859 }
00860 
00861 
00862 Teuchos::RefCountPtr<Epetra_MultiVector>
00863 EpetraExt::get_DfDp_mv(
00864   const int l,
00865   const ModelEvaluator::OutArgs &outArgs
00866   )
00867 {
00868   std::ostringstream derivName; derivName << "DfDp("<<l<<")";
00869   return getMultiVector(
00870     outArgs.modelEvalDescription()
00871     ,outArgs.get_DfDp(l)
00872     ,derivName.str()
00873     ,ModelEvaluator::DERIV_MV_BY_COL
00874     );
00875 }
00876 
00877 
00878 Teuchos::RefCountPtr<Epetra_MultiVector>
00879 EpetraExt::get_DgDx_dot_mv(
00880   const int j,
00881   const ModelEvaluator::OutArgs &outArgs,
00882   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00883   )
00884 {
00885   std::ostringstream derivName; derivName << "DgDx_dot("<<j<<")";
00886   return getMultiVector(
00887     outArgs.modelEvalDescription(),
00888     outArgs.get_DgDx_dot(j),
00889     derivName.str(),
00890     mvOrientation
00891     );
00892 }
00893 
00894 
00895 Teuchos::RefCountPtr<Epetra_MultiVector>
00896 EpetraExt::get_DgDx_mv(
00897   const int j,
00898   const ModelEvaluator::OutArgs &outArgs,
00899   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00900   )
00901 {
00902   std::ostringstream derivName; derivName << "DgDx("<<j<<")";
00903   return getMultiVector(
00904     outArgs.modelEvalDescription(),
00905     outArgs.get_DgDx(j),
00906     derivName.str(),
00907     mvOrientation
00908     );
00909 }
00910 
00911 
00912 Teuchos::RefCountPtr<Epetra_MultiVector>
00913 EpetraExt::get_DgDp_mv(
00914   const int j,
00915   const int l,
00916   const ModelEvaluator::OutArgs &outArgs,
00917   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00918   )
00919 {
00920   std::ostringstream derivName; derivName << "DgDp("<<j<<","<<l<<")";
00921   return getMultiVector(
00922     outArgs.modelEvalDescription(),
00923     outArgs.get_DgDp(j,l),
00924     derivName.str(),
00925     mvOrientation
00926     );
00927 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines