Thyra_DefaultMultiPeriodModelEvaluator.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) 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 #ifndef THYRA_DEFAULT_MULTI_PERIOD_MODEL_EVALUATOR_HPP
00030 #define THYRA_DEFAULT_MULTI_PERIOD_MODEL_EVALUATOR_HPP
00031 
00032 #include "Thyra_ModelEvaluator.hpp"
00033 
00034 namespace Thyra {
00035 
00077 template<class Scalar>
00078 class DefaultMultiPeriodModelEvaluator : virtual public ModelEvaluator<Scalar> {
00079 public:
00080 
00083 
00085   DefaultMultiPeriodModelEvaluator();
00086 
00088   DefaultMultiPeriodModelEvaluator(
00089     const int                                                     N
00090     ,const Teuchos::RefCountPtr<ModelEvaluator<Scalar> >          models[]
00091     ,const Scalar                                                 weights[]
00092     ,const Teuchos::RefCountPtr<const VectorBase<Scalar> >        z[]
00093     ,const int                                                    z_index
00094     ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &x_bar_space = Teuchos::null
00095     ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &f_bar_space = Teuchos::null
00096     //,const AbstractFactory<BlockLinearOpWithSolveBase<Scalar> >   &blockLOWSFF = Teuchos::null
00097     );
00098 
00148   void initialize(
00149     const int                                                     N
00150     ,const Teuchos::RefCountPtr<ModelEvaluator<Scalar> >          models[]
00151     ,const Scalar                                                 weights[]
00152     ,const Teuchos::RefCountPtr<const VectorBase<Scalar> >        z[]
00153     ,const int                                                    z_index
00154     ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &x_bar_space = Teuchos::null
00155     ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &f_bar_space = Teuchos::null
00156     //,const AbstractFactory<BlockLinearOpWithSolveBase<Scalar> >   &blockLOWSFF = Teuchos::null
00157     );
00158   // ToDo: To be more general we would have to define a z_index for each
00159   // *models[i] object and we would need parameter index maps to map from the
00160   // parameter subvectors in *models[i] to the a "global" list of parameter
00161   // subvectors.  This could be added as a different initialization function
00162   // for the more general use case.
00163   
00165 
00168 
00170   int Np() const;
00172   int Ng() const;
00174   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > get_x_space() const;
00176   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > get_f_space() const;
00178   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > get_p_space(int l) const;
00180   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > get_g_space(int j) const;
00182   ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
00184   ModelEvaluatorBase::InArgs<Scalar> getLowerBounds() const;
00186   ModelEvaluatorBase::InArgs<Scalar> getUpperBounds() const;
00188   Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> > create_W() const;
00190   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_W_op() const;
00192   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_DfDp_op(int l) const;
00194   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_DgDx_op(int j) const;
00196   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_DgDp_op( int j, int l ) const;
00198   ModelEvaluatorBase::InArgs<Scalar> createInArgs() const;
00200   ModelEvaluatorBase::OutArgs<Scalar> createOutArgs() const;
00202   void evalModel(
00203     const ModelEvaluatorBase::InArgs<Scalar>       &inArgs
00204     ,const ModelEvaluatorBase::OutArgs<Scalar>     &outArgs
00205     ) const;
00207   void reportFinalPoint(
00208     const ModelEvaluatorBase::InArgs<Scalar>      &finalPoint
00209     ,const bool                                   wasSolved
00210     );
00211 
00213 
00214 private:
00215 
00216   // //////////////////////////
00217   // Private types
00218 
00219   typedef std::vector<Teuchos::RefCountPtr<ModelEvaluator<Scalar> > >    models_t;
00220   typedef std::vector<Scalar>                                            weights_t;
00221   typedef std::vector<Teuchos::RefCountPtr<const VectorBase<Scalar> > >  z_t;
00222 
00223   // /////////////////////////
00224   // Private data members
00225 
00226   models_t                                               models_;  // size == N
00227   weights_t                                              weights_; // size == N
00228   z_t                                                    z_;       // size == N
00229   int                                                    z_index_;
00230   Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  x_bar_space_;
00231   Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  f_bar_space_;
00232   
00233 };
00234 
00235 // /////////////////////////////////
00236 // Implementations
00237 
00238 // Constructors/Intializers/Accessors
00239 
00240 template<class Scalar>
00241 DefaultMultiPeriodModelEvaluator<Scalar>::DefaultMultiPeriodModelEvaluator()
00242   :z_index_(-1)
00243 {}
00244 
00245 template<class Scalar>
00246 DefaultMultiPeriodModelEvaluator<Scalar>::DefaultMultiPeriodModelEvaluator(
00247   const int                                                     N
00248   ,const Teuchos::RefCountPtr<ModelEvaluator<Scalar> >          models[]
00249   ,const Scalar                                                 weights[]
00250   ,const Teuchos::RefCountPtr<const VectorBase<Scalar> >        z[]
00251   ,const int                                                    z_index
00252   ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &x_bar_space
00253   ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &f_bar_space
00254   //,const AbstractFactory<BlockLinearOpWithSolveBase<Scalar> >   &blockLOWSFF
00255   )
00256 {
00257   initialize(N,models,weights,z,z_index,x_bar_space,f_bar_space);
00258 }
00259 
00260 template<class Scalar>
00261 void DefaultMultiPeriodModelEvaluator<Scalar>::initialize(
00262   const int                                                     N
00263   ,const Teuchos::RefCountPtr<ModelEvaluator<Scalar> >          models[]
00264   ,const Scalar                                                 weights[]
00265   ,const Teuchos::RefCountPtr<const VectorBase<Scalar> >        z[]
00266   ,const int                                                    z_index
00267   ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &x_bar_space
00268   ,const Teuchos::RefCountPtr<ProductVectorSpaceBase<Scalar> >  &f_bar_space
00269   //,const AbstractFactory<BlockLinearOpWithSolveBase<Scalar> >   &blockLOWSFF
00270   )
00271 {
00272   typedef Teuchos::ScalarTraits<Scalar> ST;
00273   TEST_FOR_EXCEPT(!(N>0));
00274   TEST_FOR_EXCEPT(!(models));
00275   TEST_FOR_EXCEPT(!((z_index>=0&&z!=NULL)||(z_index==0&&z==NULL)));
00276   models_.resize(N);
00277   weights_.resize(N);
00278   z_.resize(N);
00279   z_index_ = z_index;
00280   for( int i = 0; i < N; ++i ) {
00281     models_[i] = models[i].assert_not_null();
00282     weights_[i] = ( weights ? weights[i] : ST::one() );
00283     if( z && z[i].get() )
00284       z_[i] = z[i];
00285     else
00286       z_[i] = Teuchos::null;
00287   }
00288   if( x_bar_space.get() ) {
00289     TEST_FOR_EXCEPT(!(x_bar_space->numBlocks()==N));
00290     // ToDo: Check the constituent spaces more carefully against models[]->get_x_space().
00291     x_bar_space_ = x_bar_space;
00292   }
00293   else {
00294     TEST_FOR_EXCEPT(true); // ToDo: Create our own product space!
00295   }
00296   if( f_bar_space.get() ) {
00297     TEST_FOR_EXCEPT(!(f_bar_space->numBlocks()==N));
00298     // ToDo: Check the constituent spaces more carefully against models[]->get_f_space().
00299     f_bar_space_ = f_bar_space;
00300   }
00301   else {
00302     TEST_FOR_EXCEPT(true); // ToDo: Create our own product space!
00303   }
00304 }
00305 
00306 // Public functions overridden from ModelEvaulator
00307 
00308 template<class Scalar>
00309 int DefaultMultiPeriodModelEvaluator<Scalar>::Np() const
00310 {
00311   TEST_FOR_EXCEPT(true);
00312   return 0;
00313 }
00314 
00315 template<class Scalar>
00316 int DefaultMultiPeriodModelEvaluator<Scalar>::Ng() const
00317 {
00318   TEST_FOR_EXCEPT(true);
00319   return 0;
00320 }
00321 
00322 template<class Scalar>
00323 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00324 DefaultMultiPeriodModelEvaluator<Scalar>::get_x_space() const
00325 {
00326   TEST_FOR_EXCEPT(true);
00327   return Teuchos::null;
00328 }
00329 
00330 template<class Scalar>
00331 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00332 DefaultMultiPeriodModelEvaluator<Scalar>::get_f_space() const
00333 {
00334   TEST_FOR_EXCEPT(true);
00335   return Teuchos::null;
00336 }
00337 
00338 template<class Scalar>
00339 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00340 DefaultMultiPeriodModelEvaluator<Scalar>::get_p_space(int l) const
00341 {
00342   TEST_FOR_EXCEPT(true);
00343   return Teuchos::null;
00344 }
00345 
00346 template<class Scalar>
00347 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00348 DefaultMultiPeriodModelEvaluator<Scalar>::get_g_space(int j) const
00349 {
00350   TEST_FOR_EXCEPT(true);
00351   return Teuchos::null;
00352 }
00353 
00354 template<class Scalar>
00355 ModelEvaluatorBase::InArgs<Scalar>
00356 DefaultMultiPeriodModelEvaluator<Scalar>::getNominalValues() const
00357 {
00358   TEST_FOR_EXCEPT(true);
00359   return ModelEvaluatorBase::InArgs<Scalar>();
00360 }
00361 
00362 template<class Scalar>
00363 ModelEvaluatorBase::InArgs<Scalar>
00364 DefaultMultiPeriodModelEvaluator<Scalar>::getLowerBounds() const
00365 {
00366   TEST_FOR_EXCEPT(true);
00367   return ModelEvaluatorBase::InArgs<Scalar>();
00368 }
00369 
00370 template<class Scalar>
00371 ModelEvaluatorBase::InArgs<Scalar>
00372 DefaultMultiPeriodModelEvaluator<Scalar>::getUpperBounds() const
00373 {
00374   TEST_FOR_EXCEPT(true);
00375   return ModelEvaluatorBase::InArgs<Scalar>();
00376 }
00377 
00378 template<class Scalar>
00379 Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00380 DefaultMultiPeriodModelEvaluator<Scalar>::create_W() const
00381 {
00382   TEST_FOR_EXCEPT(true);
00383   return Teuchos::null; // Should never be called!
00384 }
00385 
00386 template<class Scalar>
00387 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00388 DefaultMultiPeriodModelEvaluator<Scalar>::create_W_op() const
00389 {
00390   TEST_FOR_EXCEPT(true);
00391   return Teuchos::null; // Should never be called!
00392 }
00393 
00394 template<class Scalar>
00395 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00396 DefaultMultiPeriodModelEvaluator<Scalar>::create_DfDp_op(int l) const
00397 {
00398   TEST_FOR_EXCEPT(true);
00399   return Teuchos::null;
00400 }
00401 
00402 template<class Scalar>
00403 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00404 DefaultMultiPeriodModelEvaluator<Scalar>::create_DgDx_op(int j) const
00405 {
00406   TEST_FOR_EXCEPT(true);
00407   return Teuchos::null;
00408 }
00409 
00410 template<class Scalar>
00411 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00412 DefaultMultiPeriodModelEvaluator<Scalar>::create_DgDp_op( int j, int l ) const
00413 {
00414   TEST_FOR_EXCEPT(true);
00415   return Teuchos::null;
00416 }
00417 
00418 template<class Scalar>
00419 ModelEvaluatorBase::InArgs<Scalar>
00420 DefaultMultiPeriodModelEvaluator<Scalar>::createInArgs() const
00421 {
00422   ModelEvaluatorBase::InArgsSetup<Scalar> inArgs;
00423   TEST_FOR_EXCEPT(true);
00424   inArgs.setModelEvalDescription(this->description());
00425   return inArgs;
00426 }
00427 
00428 template<class Scalar>
00429 ModelEvaluatorBase::OutArgs<Scalar>
00430 DefaultMultiPeriodModelEvaluator<Scalar>::createOutArgs() const
00431 {
00432   ModelEvaluatorBase::OutArgsSetup<Scalar> outArgs;
00433   TEST_FOR_EXCEPT(true);
00434   outArgs.setModelEvalDescription(this->description());
00435   return outArgs;
00436 }
00437 
00438 template<class Scalar>
00439 void DefaultMultiPeriodModelEvaluator<Scalar>::evalModel(
00440   const ModelEvaluatorBase::InArgs<Scalar>       &inArgs
00441   ,const ModelEvaluatorBase::OutArgs<Scalar>     &outArgs
00442   ) const
00443 {
00444   TEST_FOR_EXCEPT(true);
00445 }
00446 
00447 template<class Scalar>
00448 void DefaultMultiPeriodModelEvaluator<Scalar>::reportFinalPoint(
00449   const ModelEvaluatorBase::InArgs<Scalar>      &finalPoint
00450   ,const bool                                   wasSolved
00451   )
00452 {
00453   TEST_FOR_EXCEPT(true);
00454 }
00455 
00456 } // namespace Thyra
00457 
00458 #endif // THYRA_DEFAULT_MULTI_PERIOD_MODEL_EVALUATOR_HPP

Generated on Thu Sep 18 12:33:02 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1