EpetraExt 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 (2011) Sandia Corporation
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 
00042 #include "EpetraExt_ModelEvaluator.h"
00043 #include "Teuchos_implicit_cast.hpp"
00044 
00045 
00046 namespace EpetraExt {
00047 
00048 
00049 //
00050 // ModelEvaluator::InArgs
00051 //
00052 
00053 
00054 ModelEvaluator::InArgs::InArgs()
00055   :modelEvalDescription_("WARNING!  THIS INARGS OBJECT IS UNINITALIZED!")
00056 {
00057   std::fill_n(&supports_[0],NUM_E_IN_ARGS_MEMBERS,false);
00058   t_     = 0.0;
00059   alpha_ = 0.0;
00060   omega_ = 0.0;
00061   beta_  = 0.0;
00062 }
00063 
00064 
00065 bool ModelEvaluator::InArgs::supports(EInArgsMembers arg) const
00066 {
00067   TEUCHOS_TEST_FOR_EXCEPTION(
00068     int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00069     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00070     );
00071   return supports_[arg];
00072 }
00073 
00074 bool ModelEvaluator::InArgs::supports(EInArgs_p_sg arg, int l) const
00075 {
00076   assert_l(l);
00077   return supports_p_sg_[l];
00078 }
00079 
00080 bool ModelEvaluator::InArgs::supports(EInArgs_p_mp arg, int l) const
00081 {
00082   assert_l(l);
00083   return supports_p_mp_[l];
00084 }
00085 
00086 void ModelEvaluator::InArgs::_setSupports( EInArgsMembers arg, bool supports )
00087 {
00088   TEUCHOS_TEST_FOR_EXCEPTION(
00089     int(arg)>=NUM_E_IN_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00090     ,"model = \'"<<modelEvalDescription_<<"\':Error, arg="<<toString(arg)<<" is invalid!"
00091     );
00092   supports_[arg] = supports;
00093 }
00094 
00095 void ModelEvaluator::InArgs::_setSupports(EInArgs_p_sg arg, int l, bool supports)
00096 {
00097   assert_l(l);
00098   supports_p_sg_[l] = supports;
00099 }
00100 
00101 void ModelEvaluator::InArgs::_setSupports(EInArgs_p_mp arg, int l, bool supports)
00102 {
00103   assert_l(l);
00104   supports_p_mp_[l] = supports;
00105 }
00106 
00107 
00108 void ModelEvaluator::InArgs::assert_supports(EInArgsMembers arg) const
00109 {
00110   TEUCHOS_TEST_FOR_EXCEPTION(
00111     !supports_[arg], std::logic_error
00112     ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(arg): model = \'"<<modelEvalDescription_<<"\': Error, "
00113     "The argument arg = " << toString(arg) << " is not supported!"
00114     );
00115 }
00116 
00117 void ModelEvaluator::InArgs::assert_supports(EInArgs_p_sg arg, int l) const
00118 {
00119   assert_l(l);
00120   TEUCHOS_TEST_FOR_EXCEPTION(
00121     !supports_p_sg_[l], std::logic_error
00122     ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(IN_ARG_p_sg,l): "
00123     "model = \'"<<modelEvalDescription_<<"\': Error,"
00124     "The argument p_sg(l) with index l = " << l << " is not supported!"
00125     );
00126 }
00127 
00128 void ModelEvaluator::InArgs::assert_supports(EInArgs_p_mp arg, int l) const
00129 {
00130   assert_l(l);
00131   TEUCHOS_TEST_FOR_EXCEPTION(
00132     !supports_p_mp_[l], std::logic_error
00133     ,"EpetraExt::ModelEvaluator::InArgs::assert_supports(IN_ARG_p_mp,l): "
00134     "model = \'"<<modelEvalDescription_<<"\': Error,"
00135     "The argument p_mp(l) with index l = " << l << " is not supported!"
00136     );
00137 }
00138 
00139 
00140 void ModelEvaluator::InArgs::assert_l(int l) const
00141 {
00142   TEUCHOS_TEST_FOR_EXCEPTION(
00143     !( 0 <= l && l < Np() ), std::logic_error
00144     ,"EpetraExt::ModelEvaluator::InArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\': Error, "
00145     "The parameter l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
00146     );
00147 }
00148 
00149 
00150 //
00151 // ModelEvaluator::OutArgs
00152 //
00153 
00154 
00155 ModelEvaluator::OutArgs::OutArgs()
00156   :modelEvalDescription_("WARNING!  THIS OUTARGS OBJECT IS UNINITALIZED!"),
00157   isFailed_( false )
00158 {
00159   std::fill_n(&supports_[0],NUM_E_OUT_ARGS_MEMBERS,false);
00160 }
00161 
00162 
00163 bool ModelEvaluator::OutArgs::supports(EOutArgsMembers arg) const
00164 {
00165   TEUCHOS_TEST_FOR_EXCEPTION(
00166     int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00167     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00168     );
00169   return supports_[arg];
00170 }
00171 
00172 
00173 const ModelEvaluator::DerivativeSupport&
00174 ModelEvaluator::OutArgs::supports(EOutArgsDfDp arg, int l) const
00175 {
00176   assert_l(l);
00177   return supports_DfDp_[l];
00178 }
00179 
00180 
00181 const ModelEvaluator::DerivativeSupport&
00182 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dot arg, int j) const
00183 {
00184   assert_j(j);
00185   return supports_DgDx_dot_[j];
00186 }
00187 
00188 
00189 const ModelEvaluator::DerivativeSupport&
00190 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dotdot arg, int j) const
00191 {
00192   assert_j(j);
00193   return supports_DgDx_dotdot_[j];
00194 }
00195 
00196 
00197 const ModelEvaluator::DerivativeSupport&
00198 ModelEvaluator::OutArgs::supports(EOutArgsDgDx arg, int j) const
00199 {
00200   assert_j(j);
00201   return supports_DgDx_[j];
00202 }
00203 
00204 
00205 const ModelEvaluator::DerivativeSupport&
00206 ModelEvaluator::OutArgs::supports(EOutArgsDgDp arg, int j, int l) const
00207 {
00208   assert_j(j);
00209   assert_l(l);
00210   return supports_DgDp_[ j*Np() + l ];
00211 }
00212 
00213 bool ModelEvaluator::OutArgs::supports(EOutArgs_g_sg arg, int j) const
00214 {
00215   assert_j(j);
00216   return supports_g_sg_[j];
00217 }
00218 
00219 const ModelEvaluator::DerivativeSupport&
00220 ModelEvaluator::OutArgs::supports(EOutArgsDfDp_sg arg, int l) const
00221 {
00222   assert_l(l);
00223   return supports_DfDp_sg_[l];
00224 }
00225 
00226 
00227 const ModelEvaluator::DerivativeSupport&
00228 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dot_sg arg, int j) const
00229 {
00230   assert_j(j);
00231   return supports_DgDx_dot_sg_[j];
00232 }
00233 
00234 
00235 const ModelEvaluator::DerivativeSupport&
00236 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dotdot_sg arg, int j) const
00237 {
00238   assert_j(j);
00239   return supports_DgDx_dotdot_sg_[j];
00240 }
00241 
00242 
00243 const ModelEvaluator::DerivativeSupport&
00244 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_sg arg, int j) const
00245 {
00246   assert_j(j);
00247   return supports_DgDx_sg_[j];
00248 }
00249 
00250 const ModelEvaluator::DerivativeSupport&
00251 ModelEvaluator::OutArgs::supports(EOutArgsDgDp_sg arg, int j, int l) const
00252 {
00253   assert_j(j);
00254   assert_l(l);
00255   return supports_DgDp_sg_[ j*Np() + l ];
00256 }
00257 
00258 bool ModelEvaluator::OutArgs::supports(EOutArgs_g_mp arg, int j) const
00259 {
00260   assert_j(j);
00261   return supports_g_mp_[j];
00262 }
00263 
00264 const ModelEvaluator::DerivativeSupport&
00265 ModelEvaluator::OutArgs::supports(EOutArgsDfDp_mp arg, int l) const
00266 {
00267   assert_l(l);
00268   return supports_DfDp_mp_[l];
00269 }
00270 
00271 
00272 const ModelEvaluator::DerivativeSupport&
00273 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dot_mp arg, int j) const
00274 {
00275   assert_j(j);
00276   return supports_DgDx_dot_mp_[j];
00277 }
00278 
00279 
00280 const ModelEvaluator::DerivativeSupport&
00281 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_dotdot_mp arg, int j) const
00282 {
00283   assert_j(j);
00284   return supports_DgDx_dotdot_mp_[j];
00285 }
00286 
00287 
00288 const ModelEvaluator::DerivativeSupport&
00289 ModelEvaluator::OutArgs::supports(EOutArgsDgDx_mp arg, int j) const
00290 {
00291   assert_j(j);
00292   return supports_DgDx_mp_[j];
00293 }
00294 
00295 const ModelEvaluator::DerivativeSupport&
00296 ModelEvaluator::OutArgs::supports(EOutArgsDgDp_mp arg, int j, int l) const
00297 {
00298   assert_j(j);
00299   assert_l(l);
00300   return supports_DgDp_mp_[ j*Np() + l ];
00301 }
00302 
00303 
00304 bool ModelEvaluator::OutArgs::funcOrDerivesAreSet(EOutArgsMembers arg) const
00305 {
00306   using Teuchos::implicit_cast;
00307   bool areSet = false;
00308   switch(arg) {
00309     case OUT_ARG_f: {
00310       if (!is_null(f_)) areSet = true;
00311       if (!is_null(W_)) areSet = true;
00312       for ( int l = 0; l < implicit_cast<int>(DfDp_.size()); ++l )
00313         if(!DfDp_[l].isEmpty()) areSet = true;
00314       break;
00315     }
00316     default:
00317       TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
00318         "ModelEvaluator::OutArgs::funcOrDerivesAreSet(arg): Error, we can not handle"
00319         " the argument " << toString(arg) << "yet!");
00320   }
00321   return areSet;
00322 }
00323 
00324 void ModelEvaluator::OutArgs::setFailed() const
00325 {
00326   isFailed_ = true;
00327   // TODO: Set objects to NaN?
00328 }
00329 
00330 bool ModelEvaluator::OutArgs::isFailed() const
00331 {
00332   return isFailed_;
00333 }
00334 
00335 
00336 void ModelEvaluator::OutArgs::_setModelEvalDescription( const std::string &modelEvalDescription )
00337 {
00338   modelEvalDescription_ = modelEvalDescription;
00339 }
00340 
00341 
00342 void ModelEvaluator::OutArgs::_set_Np_Ng(int Np, int Ng)
00343 {
00344   if(Np) {
00345     supports_DfDp_.resize(Np);
00346     DfDp_.resize(Np);
00347     std::fill_n(DfDp_.begin(),Np,Derivative());
00348     DfDp_properties_.resize(Np);
00349     std::fill_n(DfDp_properties_.begin(),Np,DerivativeProperties());
00350 
00351     supports_DfDp_sg_.resize(Np);
00352     DfDp_sg_.resize(Np);
00353     std::fill_n(DfDp_sg_.begin(),Np,SGDerivative());
00354     DfDp_sg_properties_.resize(Np);
00355     std::fill_n(DfDp_sg_properties_.begin(),Np,DerivativeProperties());
00356 
00357     supports_DfDp_mp_.resize(Np);
00358     DfDp_mp_.resize(Np);
00359     std::fill_n(DfDp_mp_.begin(),Np,MPDerivative());
00360     DfDp_mp_properties_.resize(Np);
00361     std::fill_n(DfDp_mp_properties_.begin(),Np,DerivativeProperties());
00362   }
00363   if(Ng) {
00364     g_.resize(Ng);
00365     supports_DgDx_dot_.resize(Ng);
00366     DgDx_dot_.resize(Ng);
00367     std::fill_n(DgDx_dot_.begin(),Ng,Derivative());
00368     DgDx_dot_properties_.resize(Ng);
00369     std::fill_n(DgDx_dot_properties_.begin(),Ng,DerivativeProperties());
00370     supports_DgDx_dotdot_.resize(Ng);
00371     DgDx_dotdot_.resize(Ng);
00372     std::fill_n(DgDx_dotdot_.begin(),Ng,Derivative());
00373     DgDx_dotdot_properties_.resize(Ng);
00374     std::fill_n(DgDx_dotdot_properties_.begin(),Ng,DerivativeProperties());
00375     supports_DgDx_.resize(Ng);
00376     DgDx_.resize(Ng);
00377     std::fill_n(DgDx_.begin(),Ng,Derivative());
00378     DgDx_properties_.resize(Ng);
00379     std::fill_n(DgDx_properties_.begin(),Ng,DerivativeProperties());
00380 
00381     g_sg_.resize(Ng);
00382     supports_g_sg_.resize(Ng);
00383     supports_DgDx_dot_sg_.resize(Ng);
00384     DgDx_dot_sg_.resize(Ng);
00385     std::fill_n(DgDx_dot_sg_.begin(),Ng,SGDerivative());
00386     DgDx_dot_sg_properties_.resize(Ng);
00387     std::fill_n(DgDx_dot_sg_properties_.begin(),Ng,DerivativeProperties());
00388     supports_DgDx_dotdot_sg_.resize(Ng);
00389     DgDx_dotdot_sg_.resize(Ng);
00390     std::fill_n(DgDx_dotdot_sg_.begin(),Ng,SGDerivative());
00391     DgDx_dotdot_sg_properties_.resize(Ng);
00392     std::fill_n(DgDx_dotdot_sg_properties_.begin(),Ng,DerivativeProperties());
00393     supports_DgDx_sg_.resize(Ng);
00394     DgDx_sg_.resize(Ng);
00395     std::fill_n(DgDx_sg_.begin(),Ng,SGDerivative());
00396     DgDx_sg_properties_.resize(Ng);
00397     std::fill_n(DgDx_sg_properties_.begin(),Ng,DerivativeProperties());
00398 
00399     g_mp_.resize(Ng);
00400     supports_g_mp_.resize(Ng);
00401     supports_DgDx_dot_mp_.resize(Ng);
00402     DgDx_dot_mp_.resize(Ng);
00403     std::fill_n(DgDx_dot_mp_.begin(),Ng,MPDerivative());
00404     DgDx_dot_mp_properties_.resize(Ng);
00405     std::fill_n(DgDx_dot_mp_properties_.begin(),Ng,DerivativeProperties());
00406     supports_DgDx_dotdot_mp_.resize(Ng);
00407     DgDx_dotdot_mp_.resize(Ng);
00408     std::fill_n(DgDx_dotdot_mp_.begin(),Ng,MPDerivative());
00409     DgDx_dotdot_mp_properties_.resize(Ng);
00410     std::fill_n(DgDx_dotdot_mp_properties_.begin(),Ng,DerivativeProperties());
00411     supports_DgDx_mp_.resize(Ng);
00412     DgDx_mp_.resize(Ng);
00413     std::fill_n(DgDx_mp_.begin(),Ng,MPDerivative());
00414     DgDx_mp_properties_.resize(Ng);
00415     std::fill_n(DgDx_mp_properties_.begin(),Ng,DerivativeProperties());
00416   }
00417   if(Np && Ng) {
00418     const int NpNg = Np*Ng;
00419     supports_DgDp_.resize(NpNg);
00420     DgDp_.resize(NpNg);
00421     std::fill_n(DgDp_.begin(),NpNg,Derivative());
00422     DgDp_properties_.resize(NpNg);
00423     std::fill_n(DgDp_properties_.begin(),NpNg,DerivativeProperties());
00424 
00425     supports_DgDp_sg_.resize(NpNg);
00426     DgDp_sg_.resize(NpNg);
00427     std::fill_n(DgDp_sg_.begin(),NpNg,SGDerivative());
00428     DgDp_sg_properties_.resize(NpNg);
00429     std::fill_n(DgDp_sg_properties_.begin(),NpNg,DerivativeProperties());
00430 
00431     supports_DgDp_mp_.resize(NpNg);
00432     DgDp_mp_.resize(NpNg);
00433     std::fill_n(DgDp_mp_.begin(),NpNg,MPDerivative());
00434     DgDp_mp_properties_.resize(NpNg);
00435     std::fill_n(DgDp_mp_properties_.begin(),NpNg,DerivativeProperties());
00436   }
00437 }
00438 
00439 void ModelEvaluator::OutArgs::_setSupports( EOutArgsMembers arg, bool supports )
00440 {
00441   TEUCHOS_TEST_FOR_EXCEPTION(
00442     int(arg)>=NUM_E_OUT_ARGS_MEMBERS || int(arg) < 0,std::logic_error
00443     ,"model = \'"<<modelEvalDescription_<<"\': Error, arg="<<toString(arg)<<" is invalid!"
00444     );
00445   supports_[arg] = supports;
00446 }
00447 
00448 
00449 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp arg, int l, const DerivativeSupport& supports )
00450 {
00451   assert_l(l);
00452   supports_DfDp_[l] = supports;
00453 }
00454 
00455 
00456 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dot arg, int j, const DerivativeSupport& supports )
00457 {
00458   assert_j(j);
00459   supports_DgDx_dot_[j] = supports;
00460 }
00461 
00462 
00463 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dotdot arg, int j, const DerivativeSupport& supports )
00464 {
00465   assert_j(j);
00466   supports_DgDx_dotdot_[j] = supports;
00467 }
00468 
00469 
00470 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx arg, int j, const DerivativeSupport& supports )
00471 {
00472   assert_j(j);
00473   supports_DgDx_[j] = supports;
00474 }
00475 
00476 
00477 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp arg, int j, int l, const DerivativeSupport& supports )
00478 {
00479   assert_j(j);
00480   assert_l(l);
00481   supports_DgDp_[ j*Np() + l ] = supports;
00482 }
00483 
00484 void ModelEvaluator::OutArgs::_setSupports( EOutArgs_g_sg arg, int j, bool supports )
00485 {
00486   assert_j(j);
00487   supports_g_sg_[j] = supports;
00488 }
00489 
00490 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp_sg arg, int l, const DerivativeSupport& supports )
00491 {
00492   assert_l(l);
00493   supports_DfDp_sg_[l] = supports;
00494 }
00495 
00496 
00497 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dot_sg arg, int j, const DerivativeSupport& supports )
00498 {
00499   assert_j(j);
00500   supports_DgDx_dot_sg_[j] = supports;
00501 }
00502 
00503 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dotdot_sg arg, int j, const DerivativeSupport& supports )
00504 {
00505   assert_j(j);
00506   supports_DgDx_dotdot_sg_[j] = supports;
00507 }
00508 
00509 
00510 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_sg arg, int j, const DerivativeSupport& supports )
00511 {
00512   assert_j(j);
00513   supports_DgDx_sg_[j] = supports;
00514 }
00515 
00516 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp_sg arg, int j, int l, const DerivativeSupport& supports )
00517 {
00518   assert_j(j);
00519   assert_l(l);
00520   supports_DgDp_sg_[ j*Np() + l ] = supports;
00521 }
00522 
00523 void ModelEvaluator::OutArgs::_setSupports( EOutArgs_g_mp arg, int j, bool supports )
00524 {
00525   assert_j(j);
00526   supports_g_mp_[j] = supports;
00527 }
00528 
00529 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDfDp_mp arg, int l, const DerivativeSupport& supports )
00530 {
00531   assert_l(l);
00532   supports_DfDp_mp_[l] = supports;
00533 }
00534 
00535 
00536 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dot_mp arg, int j, const DerivativeSupport& supports )
00537 {
00538   assert_j(j);
00539   supports_DgDx_dot_mp_[j] = supports;
00540 }
00541 
00542 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_dotdot_mp arg, int j, const DerivativeSupport& supports )
00543 {
00544   assert_j(j);
00545   supports_DgDx_dotdot_mp_[j] = supports;
00546 }
00547 
00548 
00549 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDx_mp arg, int j, const DerivativeSupport& supports )
00550 {
00551   assert_j(j);
00552   supports_DgDx_mp_[j] = supports;
00553 }
00554 
00555 void ModelEvaluator::OutArgs::_setSupports( EOutArgsDgDp_mp arg, int j, int l, const DerivativeSupport& supports )
00556 {
00557   assert_j(j);
00558   assert_l(l);
00559   supports_DgDp_mp_[ j*Np() + l ] = supports;
00560 }
00561 
00562 
00563 void ModelEvaluator::OutArgs::_set_W_properties( const DerivativeProperties &W_properties )
00564 {
00565   W_properties_ = W_properties;
00566 }
00567 
00568 void ModelEvaluator::OutArgs::_set_WPrec_properties( const DerivativeProperties &WPrec_properties )
00569 {
00570   WPrec_properties_ = WPrec_properties;
00571 }
00572 
00573 void ModelEvaluator::OutArgs::_set_DfDp_properties( int l, const DerivativeProperties &properties )
00574 {
00575   assert_supports(OUT_ARG_DfDp,l);
00576   DfDp_properties_[l] = properties;
00577 }
00578 
00579 
00580 void ModelEvaluator::OutArgs::_set_DgDx_dot_properties( int j, const DerivativeProperties &properties )
00581 {
00582   assert_supports(OUT_ARG_DgDx_dot,j);
00583   DgDx_dot_properties_[j] = properties;
00584 }
00585 
00586 void ModelEvaluator::OutArgs::_set_DgDx_dotdot_properties( int j, const DerivativeProperties &properties )
00587 {
00588   assert_supports(OUT_ARG_DgDx_dotdot,j);
00589   DgDx_dotdot_properties_[j] = properties;
00590 }
00591 
00592 
00593 void ModelEvaluator::OutArgs::_set_DgDx_properties( int j, const DerivativeProperties &properties )
00594 {
00595   assert_supports(OUT_ARG_DgDx,j);
00596   DgDx_properties_[j] = properties;
00597 }
00598 
00599 
00600 void ModelEvaluator::OutArgs::_set_DgDp_properties( int j, int l, const DerivativeProperties &properties )
00601 {
00602   assert_supports(OUT_ARG_DgDp,j,l);
00603   DgDp_properties_[ j*Np() + l ] = properties;
00604 }
00605 
00606 void ModelEvaluator::OutArgs::_set_DfDp_sg_properties( int l, const DerivativeProperties &properties )
00607 {
00608   assert_supports(OUT_ARG_DfDp_sg,l);
00609   DfDp_sg_properties_[l] = properties;
00610 }
00611 
00612 
00613 void ModelEvaluator::OutArgs::_set_DgDx_dot_sg_properties( int j, const DerivativeProperties &properties )
00614 {
00615   assert_supports(OUT_ARG_DgDx_dot_sg,j);
00616   DgDx_dot_sg_properties_[j] = properties;
00617 }
00618 
00619 void ModelEvaluator::OutArgs::_set_DgDx_dotdot_sg_properties( int j, const DerivativeProperties &properties )
00620 {
00621   assert_supports(OUT_ARG_DgDx_dotdot_sg,j);
00622   DgDx_dotdot_sg_properties_[j] = properties;
00623 }
00624 
00625 
00626 void ModelEvaluator::OutArgs::_set_DgDx_sg_properties( int j, const DerivativeProperties &properties )
00627 {
00628   assert_supports(OUT_ARG_DgDx_sg,j);
00629   DgDx_sg_properties_[j] = properties;
00630 }
00631 
00632 void ModelEvaluator::OutArgs::_set_DgDp_sg_properties( int j, int l, const DerivativeProperties &properties )
00633 {
00634   assert_supports(OUT_ARG_DgDp_sg,j,l);
00635   DgDp_sg_properties_[ j*Np() + l ] = properties;
00636 }
00637 
00638 
00639 void ModelEvaluator::OutArgs::_set_DfDp_mp_properties( int l, const DerivativeProperties &properties )
00640 {
00641   assert_supports(OUT_ARG_DfDp_mp,l);
00642   DfDp_mp_properties_[l] = properties;
00643 }
00644 
00645 
00646 void ModelEvaluator::OutArgs::_set_DgDx_dot_mp_properties( int j, const DerivativeProperties &properties )
00647 {
00648   assert_supports(OUT_ARG_DgDx_dot_mp,j);
00649   DgDx_dot_mp_properties_[j] = properties;
00650 }
00651 
00652 void ModelEvaluator::OutArgs::_set_DgDx_dotdot_mp_properties( int j, const DerivativeProperties &properties )
00653 {
00654   assert_supports(OUT_ARG_DgDx_dotdot_mp,j);
00655   DgDx_dotdot_mp_properties_[j] = properties;
00656 }
00657 
00658 
00659 void ModelEvaluator::OutArgs::_set_DgDx_mp_properties( int j, const DerivativeProperties &properties )
00660 {
00661   assert_supports(OUT_ARG_DgDx_mp,j);
00662   DgDx_mp_properties_[j] = properties;
00663 }
00664 
00665 void ModelEvaluator::OutArgs::_set_DgDp_mp_properties( int j, int l, const DerivativeProperties &properties )
00666 {
00667   assert_supports(OUT_ARG_DgDp_mp,j,l);
00668   DgDp_mp_properties_[ j*Np() + l ] = properties;
00669 }
00670 
00671 
00672 void ModelEvaluator::OutArgs::assert_supports(EOutArgsMembers arg) const
00673 {
00674   TEUCHOS_TEST_FOR_EXCEPTION(
00675     !supports_[arg], std::logic_error
00676     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(arg): "
00677     "model = \'"<<modelEvalDescription_<<"\': Error, "
00678     "The argument arg = " << toString(arg) << " is not supported!"
00679     );
00680 }
00681 
00682 
00683 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDfDp arg, int l) const
00684 {
00685   assert_l(l);
00686   TEUCHOS_TEST_FOR_EXCEPTION(
00687     supports_DfDp_[l].none(), std::logic_error
00688     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp,l): "
00689     "model = \'"<<modelEvalDescription_<<"\': Error,"
00690     "The argument DfDp(l) with index l = " << l << " is not supported!"
00691     );
00692 }
00693 
00694 
00695 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dot arg, int j) const
00696 {
00697   assert_j(j);
00698   TEUCHOS_TEST_FOR_EXCEPTION(
00699     supports_DgDx_dot_[j].none(), std::logic_error
00700     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot,j): "
00701     "model = \'"<<modelEvalDescription_<<"\': Error,"
00702     "The argument DgDx_dot(j) with index j = " << j << " is not supported!"
00703     );
00704 }
00705 
00706 
00707 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dotdot arg, int j) const
00708 {
00709   assert_j(j);
00710   TEUCHOS_TEST_FOR_EXCEPTION(
00711     supports_DgDx_dotdot_[j].none(), std::logic_error
00712     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dotdot,j): "
00713     "model = \'"<<modelEvalDescription_<<"\': Error,"
00714     "The argument DgDx_dotdot(j) with index j = " << j << " is not supported!"
00715     );
00716 }
00717 
00718 
00719 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx arg, int j) const
00720 {
00721   assert_j(j);
00722   TEUCHOS_TEST_FOR_EXCEPTION(
00723     supports_DgDx_[j].none(), std::logic_error
00724     ,"TEpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx,j): "
00725     "model = \'"<<modelEvalDescription_<<"\': Error,"
00726     "The argument DgDx(j) with index j = " << j << " is not supported!"
00727     );
00728 }
00729 
00730 
00731 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp arg, int j, int l) const
00732 {
00733   assert_j(j);
00734   assert_l(l);
00735   TEUCHOS_TEST_FOR_EXCEPTION(
00736     supports_DgDp_[ j*Np() + l ].none(), std::logic_error
00737     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp,j,l): "
00738     "model = \'"<<modelEvalDescription_<<"\': Error,"
00739     "The argument DgDp(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00740     );
00741 }
00742 
00743 void ModelEvaluator::OutArgs::assert_supports(EOutArgs_g_sg arg, int j) const
00744 {
00745   assert_j(j);
00746   TEUCHOS_TEST_FOR_EXCEPTION(
00747     !supports_g_sg_[j], std::logic_error
00748     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_g_sg,j): "
00749     "model = \'"<<modelEvalDescription_<<"\': Error,"
00750     "The argument g_sg(j) with index j = " << j << " is not supported!"
00751     );
00752 }
00753 
00754 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDfDp_sg arg, int l) const
00755 {
00756   assert_l(l);
00757   TEUCHOS_TEST_FOR_EXCEPTION(
00758     supports_DfDp_sg_[l].none(), std::logic_error
00759     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp_sg,l): "
00760     "model = \'"<<modelEvalDescription_<<"\': Error,"
00761     "The argument DfDp_sg(l) with index l = " << l << " is not supported!"
00762     );
00763 }
00764 
00765 
00766 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dot_sg arg, int j) const
00767 {
00768   assert_j(j);
00769   TEUCHOS_TEST_FOR_EXCEPTION(
00770     supports_DgDx_dot_sg_[j].none(), std::logic_error
00771     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot_sg,j): "
00772     "model = \'"<<modelEvalDescription_<<"\': Error,"
00773     "The argument DgDx_dot_sg(j) with index j = " << j << " is not supported!"
00774     );
00775 }
00776 
00777 
00778 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dotdot_sg arg, int j) const
00779 {
00780   assert_j(j);
00781   TEUCHOS_TEST_FOR_EXCEPTION(
00782     supports_DgDx_dotdot_sg_[j].none(), std::logic_error
00783     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dotdot_sg,j): "
00784     "model = \'"<<modelEvalDescription_<<"\': Error,"
00785     "The argument DgDx_dotdot_sg(j) with index j = " << j << " is not supported!"
00786     );
00787 }
00788 
00789 
00790 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_sg arg, int j) const
00791 {
00792   assert_j(j);
00793   TEUCHOS_TEST_FOR_EXCEPTION(
00794     supports_DgDx_sg_[j].none(), std::logic_error
00795     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_sg,j): "
00796     "model = \'"<<modelEvalDescription_<<"\': Error,"
00797     "The argument DgDx_sg(j) with index j = " << j << " is not supported!"
00798     );
00799 }
00800 
00801 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp_sg arg, int j, int l) const
00802 {
00803   assert_j(j);
00804   assert_l(l);
00805   TEUCHOS_TEST_FOR_EXCEPTION(
00806     supports_DgDp_sg_[ j*Np() + l ].none(), std::logic_error
00807     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp_sg,j,l): "
00808     "model = \'"<<modelEvalDescription_<<"\': Error,"
00809     "The argument DgDp_sg(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00810     );
00811 }
00812 
00813 void ModelEvaluator::OutArgs::assert_supports(EOutArgs_g_mp arg, int j) const
00814 {
00815   assert_j(j);
00816   TEUCHOS_TEST_FOR_EXCEPTION(
00817     !supports_g_mp_[j], std::logic_error
00818     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_g_mp,j): "
00819     "model = \'"<<modelEvalDescription_<<"\': Error,"
00820     "The argument g_mp(j) with index j = " << j << " is not supported!"
00821     );
00822 }
00823 
00824 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDfDp_mp arg, int l) const
00825 {
00826   assert_l(l);
00827   TEUCHOS_TEST_FOR_EXCEPTION(
00828     supports_DfDp_mp_[l].none(), std::logic_error
00829     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DfDp_mp,l): "
00830     "model = \'"<<modelEvalDescription_<<"\': Error,"
00831     "The argument DfDp_mp(l) with index l = " << l << " is not supported!"
00832     );
00833 }
00834 
00835 
00836 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dot_mp arg, int j) const
00837 {
00838   assert_j(j);
00839   TEUCHOS_TEST_FOR_EXCEPTION(
00840     supports_DgDx_dot_mp_[j].none(), std::logic_error
00841     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dot_mp,j): "
00842     "model = \'"<<modelEvalDescription_<<"\': Error,"
00843     "The argument DgDx_dot_mp(j) with index j = " << j << " is not supported!"
00844     );
00845 }
00846 
00847 
00848 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_dotdot_mp arg, int j) const
00849 {
00850   assert_j(j);
00851   TEUCHOS_TEST_FOR_EXCEPTION(
00852     supports_DgDx_dotdot_mp_[j].none(), std::logic_error
00853     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_dotdot_mp,j): "
00854     "model = \'"<<modelEvalDescription_<<"\': Error,"
00855     "The argument DgDx_dotdot_mp(j) with index j = " << j << " is not supported!"
00856     );
00857 }
00858 
00859 
00860 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDx_mp arg, int j) const
00861 {
00862   assert_j(j);
00863   TEUCHOS_TEST_FOR_EXCEPTION(
00864     supports_DgDx_mp_[j].none(), std::logic_error
00865     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDx_mp,j): "
00866     "model = \'"<<modelEvalDescription_<<"\': Error,"
00867     "The argument DgDx_mp(j) with index j = " << j << " is not supported!"
00868     );
00869 }
00870 
00871 void ModelEvaluator::OutArgs::assert_supports(EOutArgsDgDp_mp arg, int j, int l) const
00872 {
00873   assert_j(j);
00874   assert_l(l);
00875   TEUCHOS_TEST_FOR_EXCEPTION(
00876     supports_DgDp_mp_[ j*Np() + l ].none(), std::logic_error
00877     ,"EpetraExt::ModelEvaluator::OutArgs::assert_supports(OUT_ARG_DgDp_mp,j,l): "
00878     "model = \'"<<modelEvalDescription_<<"\': Error,"
00879     "The argument DgDp_mp(j,l) with indexes j = " << j << " and l = " << l << " is not supported!"
00880     );
00881 }
00882 
00883 
00884 void ModelEvaluator::OutArgs::assert_l(int l) const
00885 {
00886   TEUCHOS_TEST_FOR_EXCEPTION(
00887     Np()==0, std::logic_error
00888     ,"EpetraExt::ModelEvaluator::OutArgs::assert_l(l): model = \'"<<modelEvalDescription_<<"\':  Error, "
00889     "no auxiliary parameters subvectors p(l) are supported!!"
00890     );
00891   TEUCHOS_TEST_FOR_EXCEPTION(
00892     !( 0 <= l && l < Np() ), std::logic_error
00893     ,"EpetraExt::ModelEvaluator::OutArgs::assert_l(l): "
00894     "model = \'"<<modelEvalDescription_<<"\': Error, "
00895     "The parameter subvector p(l) index l = " << l << " is not in the range [0,"<<Np()-1<<"]!"
00896     );
00897 }
00898 
00899 
00900 void ModelEvaluator::OutArgs::assert_j(int j) const
00901 {
00902   TEUCHOS_TEST_FOR_EXCEPTION(
00903     Ng()==0, std::logic_error
00904     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00905     "no auxiliary functions g(j) are supported!!"
00906     );
00907   TEUCHOS_TEST_FOR_EXCEPTION(
00908     !( 0 <= j && j < Ng() ), std::logic_error
00909     ,"EpetraExt::ModelEvaluator::OutArgs::assert_j(j): model = \'"<<modelEvalDescription_<<"\':  Error, "
00910     "The auxiliary function g(j) index j = " << j << " is not in the range [0,"<<Ng()-1<<"]!"
00911     );
00912 }
00913 
00914 
00915 //
00916 // ModelEvaluator
00917 //
00918 
00919 
00920 // Destructor
00921 
00922 
00923 ModelEvaluator::~ModelEvaluator()
00924 {}
00925 
00926 
00927 // Vector maps
00928  
00929  
00930 Teuchos::RefCountPtr<const Epetra_Map>
00931 ModelEvaluator::get_p_map(int l) const
00932 { return Teuchos::null; }
00933 
00934 Teuchos::RefCountPtr<const Teuchos::Array<std::string> >
00935 ModelEvaluator::get_p_names(int l) const
00936 { return Teuchos::null; }
00937 
00938 Teuchos::RefCountPtr<const Epetra_Map>
00939 ModelEvaluator::get_g_map(int j) const
00940 { return Teuchos::null; }
00941 
00942 
00943 // Initial guesses for variables/parameters
00944 
00945 
00946 Teuchos::RefCountPtr<const Epetra_Vector>
00947 ModelEvaluator::get_x_init() const
00948 { return Teuchos::null; }
00949 
00950 Teuchos::RefCountPtr<const Epetra_Vector>
00951 ModelEvaluator::get_x_dot_init() const
00952 { return Teuchos::null; }
00953 
00954 Teuchos::RefCountPtr<const Epetra_Vector>
00955 ModelEvaluator::get_x_dotdot_init() const
00956 { return Teuchos::null; }
00957 
00958 Teuchos::RefCountPtr<const Epetra_Vector>
00959 ModelEvaluator::get_p_init(int l) const
00960 { return Teuchos::null; }
00961 
00962 double ModelEvaluator::get_t_init() const
00963 { return 0.0; }
00964 
00965 
00966 // Bounds for variables/parameters
00967 
00968 
00969 double ModelEvaluator::getInfBound() const
00970 {
00971   return 1e+50;
00972 }
00973 
00974 
00975 Teuchos::RefCountPtr<const Epetra_Vector>
00976 ModelEvaluator::get_x_lower_bounds() const
00977 { return Teuchos::null; }
00978 
00979 
00980 Teuchos::RefCountPtr<const Epetra_Vector>
00981 ModelEvaluator::get_x_upper_bounds() const
00982 { return Teuchos::null; }
00983 
00984 
00985 Teuchos::RefCountPtr<const Epetra_Vector>
00986 ModelEvaluator::get_p_lower_bounds(int l) const
00987 { return Teuchos::null; }
00988 
00989 
00990 Teuchos::RefCountPtr<const Epetra_Vector>
00991 ModelEvaluator::get_p_upper_bounds(int l) const
00992 { return Teuchos::null; }
00993 
00994 
00995 double ModelEvaluator::get_t_lower_bound() const
00996 { return 0.0; }
00997 
00998 
00999 double ModelEvaluator::get_t_upper_bound() const
01000 { return 0.0; }
01001 
01002 
01003 // Factory functions for creating derivative objects
01004 
01005 
01006 Teuchos::RefCountPtr<Epetra_Operator>
01007 ModelEvaluator::create_W() const
01008 { return Teuchos::null; }
01009 
01010 Teuchos::RefCountPtr<EpetraExt::ModelEvaluator::Preconditioner>
01011 ModelEvaluator::create_WPrec() const
01012 { return Teuchos::null; }
01013 
01014 Teuchos::RefCountPtr<Epetra_Operator>
01015 ModelEvaluator::create_DfDp_op(int l) const
01016 { return Teuchos::null; }
01017 
01018 Teuchos::RefCountPtr<Epetra_Operator>
01019 ModelEvaluator::create_DgDx_dot_op(int j) const
01020 { return Teuchos::null; }
01021 
01022 Teuchos::RefCountPtr<Epetra_Operator>
01023 ModelEvaluator::create_DgDx_dotdot_op(int j) const
01024 { return Teuchos::null; }
01025 
01026 Teuchos::RefCountPtr<Epetra_Operator>
01027 ModelEvaluator::create_DgDx_op(int j) const
01028 { return Teuchos::null; }
01029 
01030 Teuchos::RefCountPtr<Epetra_Operator>
01031 ModelEvaluator::create_DgDp_op( int j, int l ) const
01032 { return Teuchos::null; }
01033 
01034 } // namespace EpetraExt
01035 
01036 
01037 //
01038 // Helper functions
01039 //
01040 
01041 
01042 std::string EpetraExt::toString(
01043    ModelEvaluator::EDerivativeMultiVectorOrientation orientation
01044    )
01045 {
01046   switch(orientation) {
01047     case ModelEvaluator::DERIV_MV_BY_COL:
01048       return "DERIV_MV_BY_COL";
01049     case ModelEvaluator::DERIV_TRANS_MV_BY_ROW:
01050       return "DERIV_TRANS_MV_BY_ROW";
01051     default:
01052       TEUCHOS_TEST_FOR_EXCEPT(true);
01053   }
01054   return ""; // Should never be called
01055 }
01056 
01057 
01058 std::string EpetraExt::toString( ModelEvaluator::EInArgsMembers inArg )
01059 {
01060   switch(inArg) {
01061     case ModelEvaluator::IN_ARG_x_dot:
01062       return "IN_ARG_x_dot";
01063     case ModelEvaluator::IN_ARG_x_dotdot:
01064       return "IN_ARG_x_dotdot";
01065     case ModelEvaluator::IN_ARG_x:
01066       return "IN_ARG_x";
01067     case ModelEvaluator::IN_ARG_x_dot_poly:
01068       return "IN_ARG_x_dot_poly";
01069     case ModelEvaluator::IN_ARG_x_dotdot_poly:
01070       return "IN_ARG_x_dotdot_poly";
01071     case ModelEvaluator::IN_ARG_x_poly:
01072       return "IN_ARG_x_poly";
01073     case ModelEvaluator::IN_ARG_x_dot_sg:
01074       return "IN_ARG_x_dot_sg";
01075     case ModelEvaluator::IN_ARG_x_dotdot_sg:
01076       return "IN_ARG_x_dotdot_sg";
01077     case ModelEvaluator::IN_ARG_x_sg:
01078       return "IN_ARG_x_sg";
01079     case ModelEvaluator::IN_ARG_x_dot_mp:
01080       return "IN_ARG_x_dot_mp";
01081     case ModelEvaluator::IN_ARG_x_dotdot_mp:
01082       return "IN_ARG_x_dotdot_mp";
01083     case ModelEvaluator::IN_ARG_x_mp:
01084       return "IN_ARG_x_mp";
01085     case ModelEvaluator::IN_ARG_t:
01086       return "IN_ARG_t";
01087     case ModelEvaluator::IN_ARG_alpha:
01088       return "IN_ARG_alpha";
01089     case ModelEvaluator::IN_ARG_omega:
01090       return "IN_ARG_omega";
01091     case ModelEvaluator::IN_ARG_beta:
01092       return "IN_ARG_beta";
01093     default:
01094       TEUCHOS_TEST_FOR_EXCEPT("Invalid inArg!");
01095   }
01096   return ""; // Will never be executed!
01097 }
01098 
01099 
01100 std::string EpetraExt::toString( ModelEvaluator::EOutArgsMembers outArg )
01101 {
01102   switch(outArg) {
01103     case  ModelEvaluator::OUT_ARG_f:
01104       return "OUT_ARG_f";
01105     case ModelEvaluator::OUT_ARG_W:
01106       return "OUT_ARG_W";
01107     case ModelEvaluator::OUT_ARG_WPrec:
01108       return "OUT_ARG_WPrec";
01109     case ModelEvaluator::OUT_ARG_f_poly:
01110       return "OUT_ARG_f_poly";
01111     case ModelEvaluator::OUT_ARG_f_sg:
01112       return "OUT_ARG_f_sg";
01113     case ModelEvaluator::OUT_ARG_W_sg:
01114       return "OUT_ARG_W_sg";
01115     case ModelEvaluator::OUT_ARG_f_mp:
01116       return "OUT_ARG_f_mp";
01117     case ModelEvaluator::OUT_ARG_W_mp:
01118       return "OUT_ARG_W_mp";
01119     default:
01120       TEUCHOS_TEST_FOR_EXCEPT("Invalid outArg!");
01121   }
01122   return ""; // Will never be executed!
01123 }
01124 
01125 
01126 Teuchos::RefCountPtr<Epetra_Operator>
01127 EpetraExt::getLinearOp(
01128   const std::string &modelEvalDescription,
01129   const ModelEvaluator::Derivative &deriv,
01130   const std::string &derivName
01131   )
01132 {
01133   TEUCHOS_TEST_FOR_EXCEPTION(
01134     deriv.getMultiVector().get() != NULL, std::logic_error
01135     ,"For model \'" << modelEvalDescription << "\' the derivative \'"
01136     << derivName << "\' is of type Epetra_MultiVector and not of type Epetra_Operator!"
01137     );
01138   return deriv.getLinearOp();
01139 }
01140 
01141 
01142 Teuchos::RefCountPtr<Epetra_MultiVector>
01143 EpetraExt::getMultiVector(
01144   const std::string &modelEvalDescription,
01145   const ModelEvaluator::Derivative &deriv,
01146   const std::string &derivName,
01147   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
01148   )
01149 {
01150   TEUCHOS_TEST_FOR_EXCEPTION(
01151     deriv.getLinearOp().get() != NULL, std::logic_error
01152     ,"For model \'" << modelEvalDescription << "\' the derivative \'"
01153     << derivName << "\' is of type Epetra_Operator and not of type Epetra_MultiVector!"
01154     );
01155   Teuchos::RefCountPtr<Epetra_MultiVector>
01156     mv = deriv.getMultiVector();
01157   if(mv.get()) {
01158     TEUCHOS_TEST_FOR_EXCEPTION(
01159       deriv.getMultiVectorOrientation()!=mvOrientation, std::logic_error
01160       ,"For model \'" << modelEvalDescription << "\' the derivative \'"
01161       << derivName << "\' if not the orientation \'" << toString(mvOrientation)
01162       << "\'"
01163       );
01164   }
01165   return mv;
01166 }
01167 
01168 
01169 Teuchos::RefCountPtr<Epetra_Operator>
01170 EpetraExt::get_DfDp_op(
01171   const int l,
01172   const ModelEvaluator::OutArgs &outArgs
01173   )
01174 {
01175   std::ostringstream derivName; derivName << "DfDp("<<l<<")";
01176   return getLinearOp(
01177     outArgs.modelEvalDescription()
01178     ,outArgs.get_DfDp(l)
01179     ,derivName.str()
01180     );
01181 }
01182 
01183 
01184 Teuchos::RefCountPtr<Epetra_MultiVector>
01185 EpetraExt::get_DfDp_mv(
01186   const int l,
01187   const ModelEvaluator::OutArgs &outArgs
01188   )
01189 {
01190   std::ostringstream derivName; derivName << "DfDp("<<l<<")";
01191   return getMultiVector(
01192     outArgs.modelEvalDescription()
01193     ,outArgs.get_DfDp(l)
01194     ,derivName.str()
01195     ,ModelEvaluator::DERIV_MV_BY_COL
01196     );
01197 }
01198 
01199 
01200 Teuchos::RefCountPtr<Epetra_MultiVector>
01201 EpetraExt::get_DgDx_dot_mv(
01202   const int j,
01203   const ModelEvaluator::OutArgs &outArgs,
01204   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
01205   )
01206 {
01207   std::ostringstream derivName; derivName << "DgDx_dot("<<j<<")";
01208   return getMultiVector(
01209     outArgs.modelEvalDescription(),
01210     outArgs.get_DgDx_dot(j),
01211     derivName.str(),
01212     mvOrientation
01213     );
01214 }
01215 
01216 
01217 Teuchos::RefCountPtr<Epetra_MultiVector>
01218 EpetraExt::get_DgDx_dotdot_mv(
01219   const int j,
01220   const ModelEvaluator::OutArgs &outArgs,
01221   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
01222   )
01223 {
01224   std::ostringstream derivName; derivName << "DgDx_dotdot("<<j<<")";
01225   return getMultiVector(
01226     outArgs.modelEvalDescription(),
01227     outArgs.get_DgDx_dotdot(j),
01228     derivName.str(),
01229     mvOrientation
01230     );
01231 }
01232 
01233 
01234 Teuchos::RefCountPtr<Epetra_MultiVector>
01235 EpetraExt::get_DgDx_mv(
01236   const int j,
01237   const ModelEvaluator::OutArgs &outArgs,
01238   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
01239   )
01240 {
01241   std::ostringstream derivName; derivName << "DgDx("<<j<<")";
01242   return getMultiVector(
01243     outArgs.modelEvalDescription(),
01244     outArgs.get_DgDx(j),
01245     derivName.str(),
01246     mvOrientation
01247     );
01248 }
01249 
01250 
01251 Teuchos::RefCountPtr<Epetra_MultiVector>
01252 EpetraExt::get_DgDp_mv(
01253   const int j,
01254   const int l,
01255   const ModelEvaluator::OutArgs &outArgs,
01256   const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation
01257   )
01258 {
01259   std::ostringstream derivName; derivName << "DgDp("<<j<<","<<l<<")";
01260   return getMultiVector(
01261     outArgs.modelEvalDescription(),
01262     outArgs.get_DgDp(j,l),
01263     derivName.str(),
01264     mvOrientation
01265     );
01266 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines