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    Np_sg_(0)
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(EOutArgsDgDp_sg arg, int j, int l) const
00148 {
00149   assert_j_sg(j);
00150   assert_l_sg(l);
00151   return supports_DgDp_sg_[ j*Np_sg() + l ];
00152 }
00153 
00154 
00155 bool ModelEvaluator::OutArgs::funcOrDerivesAreSet(EOutArgsMembers arg) const
00156 {
00157   using Teuchos::implicit_cast;
00158   bool areSet = false;
00159   switch(arg) {
00160     case OUT_ARG_f: {
00161       if (!is_null(f_)) areSet = true;
00162       if (!is_null(W_)) areSet = true;
00163       for ( int l = 0; l < implicit_cast<int>(DfDp_.size()); ++l )
00164         if(!DfDp_[l].isEmpty()) areSet = true;
00165       break;
00166     }
00167     default:
00168       TEST_FOR_EXCEPTION(true,std::logic_error,
00169         "ModelEvaluator::OutArgs::funcOrDerivesAreSet(arg): Error, we can not handle"
00170         " the argument " << toString(arg) << "yet!");
00171   }
00172   return areSet;
00173 }
00174 
00175 
00176 void ModelEvaluator::OutArgs::_setModelEvalDescription( const std::string &modelEvalDescription )
00177 {
00178   modelEvalDescription_ = modelEvalDescription;
00179 }
00180 
00181 
00182 void ModelEvaluator::OutArgs::_set_Np_Ng(int Np, int Ng)
00183 {
00184   if(Np) {
00185     supports_DfDp_.resize(Np);
00186     DfDp_.resize(Np);
00187     std::fill_n(DfDp_.begin(),Np,Derivative());
00188     DfDp_properties_.resize(Np);
00189     std::fill_n(DfDp_properties_.begin(),Np,DerivativeProperties());
00190   }
00191   if(Ng) {
00192     g_.resize(Ng);
00193     supports_DgDx_dot_.resize(Ng);
00194     DgDx_dot_.resize(Ng);
00195     std::fill_n(DgDx_dot_.begin(),Ng,Derivative());
00196     DgDx_dot_properties_.resize(Ng);
00197     std::fill_n(DgDx_dot_properties_.begin(),Ng,DerivativeProperties());
00198     supports_DgDx_.resize(Ng);
00199     DgDx_.resize(Ng);
00200     std::fill_n(DgDx_.begin(),Ng,Derivative());
00201     DgDx_properties_.resize(Ng);
00202     std::fill_n(DgDx_properties_.begin(),Ng,DerivativeProperties());
00203   }
00204   if(Np && Ng) {
00205     const int NpNg = Np*Ng;
00206     supports_DgDp_.resize(NpNg);
00207     DgDp_.resize(NpNg);
00208     std::fill_n(DgDp_.begin(),NpNg,Derivative());
00209     DgDp_properties_.resize(NpNg);
00210     std::fill_n(DgDp_properties_.begin(),NpNg,DerivativeProperties());
00211   }
00212 }
00213 
00214 void ModelEvaluator::OutArgs::_set_Np_Ng_sg(int Np_sg, int Ng_sg)
00215 {
00216   if(Ng_sg) {
00217     g_sg_.resize(Ng_sg);
00218   }
00219   if(Np_sg && Ng_sg) {
00220     Np_sg_ = Np_sg;
00221     const int NpNg_sg = Np_sg*Ng_sg;
00222     supports_DgDp_sg_.resize(NpNg_sg);
00223     DgDp_sg_.resize(NpNg_sg);
00224     std::fill_n(DgDp_sg_.begin(),NpNg_sg,sg_deriv_t());
00225     DgDp_sg_properties_.resize(NpNg_sg);
00226     std::fill_n(DgDp_sg_properties_.begin(),NpNg_sg,DerivativeProperties());
00227   }
00228 }
00229 
00230 
00231 void ModelEvaluator::OutArgs::_setSupports( EOutArgsMembers arg, bool supports )
00232 {
00233   TEST_FOR_EXCEPTION(
00234     int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00235     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00236     );
00237   supports_[arg] = supports;
00238 }
00239 
00240 
00241 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp arg, int l, const DerivativeSupport& supports )
00242 {
00243   assert_l(l);
00244   supports_DfDp_[l] = supports;
00245 }
00246 
00247 
00248 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dot arg, int j, const DerivativeSupport& supports )
00249 {
00250   assert_j(j);
00251   supports_DgDx_dot_[j] = supports;
00252 }
00253 
00254 
00255 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx arg, int j, const DerivativeSupport& supports )
00256 {
00257   assert_j(j);
00258   supports_DgDx_[j] = supports;
00259 }
00260 
00261 
00262 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp arg, int j, int l, const DerivativeSupport& supports )
00263 {
00264   assert_j(j);
00265   assert_l(l);
00266   supports_DgDp_[ j*Np() + l ] = supports;
00267 }
00268 
00269 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp_sg arg, int j, int l, const DerivativeSupport& supports )
00270 {
00271   assert_j_sg(j);
00272   assert_l_sg(l);
00273   supports_DgDp_sg_[ j*Np_sg() + l ] = supports;
00274 }
00275 
00276 
00277 void ModelEvaluator::OutArgs::_set_W_properties( const DerivativeProperties &W_properties )
00278 {
00279   W_properties_ = W_properties;
00280 }
00281 
00282 
00283 void ModelEvaluator::OutArgs::_set_DfDp_properties( int l, const DerivativeProperties &properties )
00284 {
00285   assert_supports(OUT_ARG_DfDp,l);
00286   DfDp_properties_[l] = properties;
00287 }
00288 
00289 
00290 void ModelEvaluator::OutArgs::_set_DgDx_dot_properties( int j, const DerivativeProperties &properties )
00291 {
00292   assert_supports(OUT_ARG_DgDx_dot,j);
00293   DgDx_dot_properties_[j] = properties;
00294 }
00295 
00296 
00297 void ModelEvaluator::OutArgs::_set_DgDx_properties( int j, const DerivativeProperties &properties )
00298 {
00299   assert_supports(OUT_ARG_DgDx,j);
00300   DgDx_properties_[j] = properties;
00301 }
00302 
00303 
00304 void ModelEvaluator::OutArgs::_set_DgDp_properties( int j, int l, const DerivativeProperties &properties )
00305 {
00306   assert_supports(OUT_ARG_DgDp,j,l);
00307   DgDp_properties_[ j*Np() + l ] = properties;
00308 }
00309 
00310 void ModelEvaluator::OutArgs::_set_DgDp_sg_properties( int j, int l, const DerivativeProperties &properties )
00311 {
00312   assert_supports(OUT_ARG_DgDp_sg,j,l);
00313   DgDp_sg_properties_[ j*Np_sg() + l ] = properties;
00314 }
00315 
00316 
00317 void ModelEvaluator::OutArgs::assert_supports(EOutArgsMembers arg) const
00318 {
00319   TEST_FOR_EXCEPTION(
00320     !supports_[arg], std::logic_error
00321     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(arg): "
00322     "model = \'"<<modelEvalDescription_<<"\': Error, "
00323     "The argument arg = " << toString(arg) << " is not supported!"
00324     );
00325 }
00326 
00327 
00328 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDfDp arg, int l) const
00329 {
00330   assert_l(l);
00331   TEST_FOR_EXCEPTION(
00332     supports_DfDp_[l].none(), std::logic_error
00333     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp,l): "
00334     "model = \'"<<modelEvalDescription_<<"\': Error,"
00335     "The argument DfDp(l) with index l = " << l << " is not supported!"
00336     );
00337 }
00338 
00339 
00340 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dot arg, int j) const
00341 {
00342   assert_j(j);
00343   TEST_FOR_EXCEPTION(
00344     supports_DgDx_dot_[j].none(), std::logic_error
00345     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot,j): "
00346     "model = \'"<<modelEvalDescription_<<"\': Error,"
00347     "The argument DgDx_dot(j) with index j = " << j << " is not supported!"
00348     );
00349 }
00350 
00351 
00352 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx arg, int j) const
00353 {
00354   assert_j(j);
00355   TEST_FOR_EXCEPTION(
00356     supports_DgDx_[j].none(), std::logic_error
00357     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx,j): "
00358     "model = \'"<<modelEvalDescription_<<"\': Error,"
00359     "The argument DgDx(j) with index j = " << j << " is not supported!"
00360     );
00361 }
00362 
00363 
00364 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp arg, int j, int l) const
00365 {
00366   assert_j(j);
00367   TEST_FOR_EXCEPTION(
00368     supports_DgDp_[ j*Np() + l ].none(), std::logic_error
00369     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp,j,l): "
00370     "model = \'"<<modelEvalDescription_<<"\': Error,"
00371     "The argument DgDp(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00372     );
00373 }
00374 
00375 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp_sg arg, int j, int l) const
00376 {
00377   assert_j_sg(j);
00378   TEST_FOR_EXCEPTION(
00379     supports_DgDp_sg_[ j*Np_sg() + l ].none(), std::logic_error
00380     ,"Thyra::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp_sg,j,l): "
00381     "model = \'"<<modelEvalDescription_<<"\': Error,"
00382     "The argument DgDp_sg(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00383     );
00384 }
00385 
00386 
00387 void ModelEvaluator::OutArgs::assert_l(int l) const
00388 {
00389   TEST_FOR_EXCEPTION(
00390     Np()==0, std::logic_error
00391     ,"EpetraExt::ModelEvaluator::OutArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\':  Error, "
00392     "no auxiliary parameters subvectors p(l) are supported!!"
00393     );
00394   TEST_FOR_EXCEPTION(
00395     !( 0 <= l && l < Np() ), std::logic_error
00396     ,"Thyra::ModelEvaluator::OutArgs::assert_l(l): "
00397     "model = \'"<<modelEvalDescription_<<"\': Error, "
00398     "The parameter subvector p(l) index l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
00399     );
00400 }
00401 
00402 
00403 void ModelEvaluator::OutArgs::assert_j(int j) const
00404 {
00405   TEST_FOR_EXCEPTION(
00406     Ng()==0, std::logic_error
00407     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00408     "no auxiliary functions g(j) are supported!!"
00409     );
00410   TEST_FOR_EXCEPTION(
00411     !( 0 <= j && j < Ng() ), std::logic_error
00412     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00413     "The auxiliary function g(j) index j = " << j << " is not in the range [0,"<<Ng()-1<<"]!"
00414     );
00415 }
00416 
00417 void ModelEvaluator::OutArgs::assert_l_sg(int l) const
00418 {
00419   TEST_FOR_EXCEPTION(
00420     Np_sg()==0, std::logic_error
00421     ,"EpetraExt::ModelEvaluator::OutArgs::assert_l_sg(l): model = \'"<<modelEvalDescription_<<"\':  Error, "
00422     "no stochastic Galerkin auxiliary parameters subvectors p_sg(l) are supported!!"
00423     );
00424   TEST_FOR_EXCEPTION(
00425     !( 0 <= l && l < Np_sg() ), std::logic_error
00426     ,"Thyra::ModelEvaluator::OutArgs::assert_l_sg(l): "
00427     "model = \'"<<modelEvalDescription_<<"\': Error, "
00428     "The stochastic Galerkin parameter subvector p_sg(l) index l = " << l << " is not in the range [0,"<<Np_sg()-1<<"]!"
00429     );
00430 }
00431 
00432 void ModelEvaluator::OutArgs::assert_j_sg(int j) const
00433 {
00434   TEST_FOR_EXCEPTION(
00435     Ng_sg()==0, std::logic_error
00436     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j_sg(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00437     "no stochastic Galerkin auxiliary functions g_sg(j) are supported!!"
00438     );
00439   TEST_FOR_EXCEPTION(
00440     !( 0 <= j && j < Ng_sg() ), std::logic_error
00441     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j_sg(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00442     "The stochastic Galerkin auxiliary function g_sg(j) index j = " << j << " is not in the range [0,"<<Ng_sg()-1<<"]!"
00443     );
00444 }
00445 
00446 
00447 //
00448 // ModelEvaluator
00449 //
00450 
00451 
00452 // Destructor
00453 
00454 
00455 ModelEvaluator::~ModelEvaluator()
00456 {}
00457 
00458 
00459 // Vector maps
00460  
00461  
00462 Teuchos::RefCountPtr<const Epetra_Map>
00463 ModelEvaluator::get_p_map(int l) const
00464 { return Teuchos::null; }
00465  
00466 
00467 Teuchos::RefCountPtr<const Teuchos::Array<std::string> >
00468 ModelEvaluator::get_p_names(int l) const
00469 { return Teuchos::null; }
00470 
00471 
00472 Teuchos::RefCountPtr<const Epetra_Map>
00473 ModelEvaluator::get_g_map(int j) const
00474 { return Teuchos::null; }
00475 
00476 
00477 // Initial guesses for variables/parameters
00478 
00479 
00480 Teuchos::RefCountPtr<const Epetra_Vector>
00481 ModelEvaluator::get_x_init() const
00482 { return Teuchos::null; }
00483 
00484 
00485 Teuchos::RefCountPtr<const Epetra_Vector>
00486 ModelEvaluator::get_x_dot_init() const
00487 { return Teuchos::null; }
00488 
00489 
00490 Teuchos::RefCountPtr<const Epetra_Vector>
00491 ModelEvaluator::get_p_init(int l) const
00492 { return Teuchos::null; }
00493 
00494 
00495 double ModelEvaluator::get_t_init() const
00496 { return 0.0; }
00497 
00498 
00499 // Bounds for variables/parameters
00500 
00501 
00502 double ModelEvaluator::getInfBound() const
00503 {
00504   return 1e+50;
00505 }
00506 
00507 
00508 Teuchos::RefCountPtr<const Epetra_Vector>
00509 ModelEvaluator::get_x_lower_bounds() const
00510 { return Teuchos::null; }
00511 
00512 
00513 Teuchos::RefCountPtr<const Epetra_Vector>
00514 ModelEvaluator::get_x_upper_bounds() const
00515 { return Teuchos::null; }
00516 
00517 
00518 Teuchos::RefCountPtr<const Epetra_Vector>
00519 ModelEvaluator::get_p_lower_bounds(int l) const
00520 { return Teuchos::null; }
00521 
00522 
00523 Teuchos::RefCountPtr<const Epetra_Vector>
00524 ModelEvaluator::get_p_upper_bounds(int l) const
00525 { return Teuchos::null; }
00526 
00527 
00528 double ModelEvaluator::get_t_lower_bound() const
00529 { return 0.0; }
00530 
00531 
00532 double ModelEvaluator::get_t_upper_bound() const
00533 { return 0.0; }
00534 
00535 
00536 // Factory functions for creating derivative objects
00537 
00538 
00539 Teuchos::RefCountPtr<Epetra_Operator>
00540 ModelEvaluator::create_W() const
00541 { return Teuchos::null; }
00542 
00543 
00544 Teuchos::RefCountPtr<Epetra_Operator>
00545 ModelEvaluator::create_DfDp_op(int l) const
00546 { return Teuchos::null; }
00547 
00548 
00549 Teuchos::RefCountPtr<Epetra_Operator>
00550 ModelEvaluator::create_DgDx_dot_op(int j) const
00551 { return Teuchos::null; }
00552 
00553 
00554 Teuchos::RefCountPtr<Epetra_Operator>
00555 ModelEvaluator::create_DgDx_op(int j) const
00556 { return Teuchos::null; }
00557 
00558 
00559 Teuchos::RefCountPtr<Epetra_Operator>
00560 ModelEvaluator::create_DgDp_op( int j, int l ) const
00561 { return Teuchos::null; }
00562 
00563 
00564 } // namespace EpetraExt
00565 
00566 
00567 //
00568 // Helper functions
00569 //
00570 
00571 
00572 std::string EpetraExt::toString(
00573    ModelEvaluator::EDerivativeMultiVectorOrientation orientation
00574    )
00575 {
00576   switch(orientation) {
00577     case ModelEvaluator::DERIV_MV_BY_COL:
00578       return "DERIV_MV_BY_COL";
00579     case ModelEvaluator::DERIV_TRANS_MV_BY_ROW:
00580       return "DERIV_TRANS_MV_BY_ROW";
00581     default:
00582       TEST_FOR_EXCEPT(true);
00583   }
00584   return ""; // Should never be called
00585 }
00586 
00587 
00588 std::string EpetraExt::toString( ModelEvaluator::EInArgsMembers inArg )
00589 {
00590   switch(inArg) {
00591     case ModelEvaluator::IN_ARG_x_dot:
00592       return "IN_ARG_x_dot";
00593     case ModelEvaluator::IN_ARG_x:
00594       return "IN_ARG_x";
00595     case ModelEvaluator::IN_ARG_x_dot_poly:
00596       return "IN_ARG_x_dot_poly";
00597     case ModelEvaluator::IN_ARG_x_poly:
00598       return "IN_ARG_x_poly";
00599     case ModelEvaluator::IN_ARG_t:
00600       return "IN_ARG_t";
00601     case ModelEvaluator::IN_ARG_alpha:
00602       return "IN_ARG_alpha";
00603     case ModelEvaluator::IN_ARG_beta:
00604       return "IN_ARG_beta";
00605     default:
00606       TEST_FOR_EXCEPT("Invalid outArg!");
00607   }
00608   return ""; // Will never be executed!
00609 }
00610 
00611 
00612 std::string EpetraExt::toString( ModelEvaluator::EOutArgsMembers outArg )
00613 {
00614   switch(outArg) {
00615     case  ModelEvaluator::OUT_ARG_f:
00616       return "OUT_ARG_f";
00617     case ModelEvaluator::OUT_ARG_W:
00618       return "OUT_ARG_W";
00619     case ModelEvaluator::OUT_ARG_f_poly:
00620       return "OUT_ARG_f_poly";
00621     default:
00622       TEST_FOR_EXCEPT("Invalid outArg!");
00623   }
00624   return ""; // Will never be executed!
00625 }
00626 
00627 
00628 Teuchos::RefCountPtr<Epetra_Operator>
00629 EpetraExt::getLinearOp(
00630   const std::string &modelEvalDescription,
00631   const ModelEvaluator::Derivative &deriv,
00632   const std::string &derivName
00633   )
00634 {
00635   TEST_FOR_EXCEPTION(
00636     deriv.getMultiVector().get() != NULL, std::logic_error
00637     ,"For model \'" << modelEvalDescription << "\' the derivative \'"
00638     << derivName << "\' is of type Epetra_MultiVector and not of type Epetra_Operator!"
00639     );
00640   return deriv.getLinearOp();
00641 }
00642 
00643 
00644 Teuchos::RefCountPtr<Epetra_MultiVector>
00645 EpetraExt::getMultiVector(
00646   const std::string &modelEvalDescription,
00647   const ModelEvaluator::Derivative &deriv,
00648   const std::string &derivName,
00649   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00650   )
00651 {
00652   TEST_FOR_EXCEPTION(
00653     deriv.getLinearOp().get() != NULL, std::logic_error
00654     ,"For model \'" << modelEvalDescription << "\' the derivative \'"
00655     << derivName << "\' is of type Epetra_Operator and not of type Epetra_MultiVector!"
00656     );
00657   Teuchos::RefCountPtr<Epetra_MultiVector>
00658     mv = deriv.getMultiVector();
00659   if(mv.get()) {
00660     TEST_FOR_EXCEPTION(
00661       deriv.getMultiVectorOrientation()!=mvOrientation, std::logic_error
00662       ,"For model \'" << modelEvalDescription << "\' the derivative \'"
00663       << derivName << "\' if not the orientation \'" << toString(mvOrientation)
00664       << "\'"
00665       );
00666   }
00667   return mv;
00668 }
00669 
00670 
00671 Teuchos::RefCountPtr<Epetra_Operator>
00672 EpetraExt::get_DfDp_op(
00673   const int l,
00674   const ModelEvaluator::OutArgs &outArgs
00675   )
00676 {
00677   std::ostringstream derivName; derivName << "DfDp("<<l<<")";
00678   return getLinearOp(
00679     outArgs.modelEvalDescription()
00680     ,outArgs.get_DfDp(l)
00681     ,derivName.str()
00682     );
00683 }
00684 
00685 
00686 Teuchos::RefCountPtr<Epetra_MultiVector>
00687 EpetraExt::get_DfDp_mv(
00688   const int l,
00689   const ModelEvaluator::OutArgs &outArgs
00690   )
00691 {
00692   std::ostringstream derivName; derivName << "DfDp("<<l<<")";
00693   return getMultiVector(
00694     outArgs.modelEvalDescription()
00695     ,outArgs.get_DfDp(l)
00696     ,derivName.str()
00697     ,ModelEvaluator::DERIV_MV_BY_COL
00698     );
00699 }
00700 
00701 
00702 Teuchos::RefCountPtr<Epetra_MultiVector>
00703 EpetraExt::get_DgDx_dot_mv(
00704   const int j,
00705   const ModelEvaluator::OutArgs &outArgs,
00706   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00707   )
00708 {
00709   std::ostringstream derivName; derivName << "DgDx_dot("<<j<<")";
00710   return getMultiVector(
00711     outArgs.modelEvalDescription(),
00712     outArgs.get_DgDx_dot(j),
00713     derivName.str(),
00714     mvOrientation
00715     );
00716 }
00717 
00718 
00719 Teuchos::RefCountPtr<Epetra_MultiVector>
00720 EpetraExt::get_DgDx_mv(
00721   const int j,
00722   const ModelEvaluator::OutArgs &outArgs,
00723   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00724   )
00725 {
00726   std::ostringstream derivName; derivName << "DgDx("<<j<<")";
00727   return getMultiVector(
00728     outArgs.modelEvalDescription(),
00729     outArgs.get_DgDx(j),
00730     derivName.str(),
00731     mvOrientation
00732     );
00733 }
00734 
00735 
00736 Teuchos::RefCountPtr<Epetra_MultiVector>
00737 EpetraExt::get_DgDp_mv(
00738   const int j,
00739   const int l,
00740   const ModelEvaluator::OutArgs &outArgs,
00741   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
00742   )
00743 {
00744   std::ostringstream derivName; derivName << "DgDp("<<j<<","<<l<<")";
00745   return getMultiVector(
00746     outArgs.modelEvalDescription(),
00747     outArgs.get_DgDp(j,l),
00748     derivName.str(),
00749     mvOrientation
00750     );
00751 }

Generated on Wed May 12 21:24:46 2010 for EpetraExt by  doxygen 1.4.7