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

Generated on Tue Jul 13 09:23:06 2010 for EpetraExt by  doxygen 1.4.7