Thyra_StateFuncModelEvaluatorBase.hpp

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_STATE_FUNC_MODEL_EVALUATOR_BASE_HPP
00030 #define THYRA_STATE_FUNC_MODEL_EVALUATOR_BASE_HPP
00031 
00032 #include "Thyra_ModelEvaluator.hpp"
00033 
00034 namespace Thyra {
00035 
00044 template<class Scalar>
00045 class StateFuncModelEvaluatorBase : virtual public ModelEvaluator<Scalar> {
00046 public:
00047 
00050 
00052   int Np() const;
00054   int Ng() const;
00056   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > get_p_space(int l) const;
00058   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > get_g_space(int j) const;
00060   ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
00062   ModelEvaluatorBase::InArgs<Scalar> getLowerBounds() const;
00064   ModelEvaluatorBase::InArgs<Scalar> getUpperBounds() const;
00066   Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> > create_W() const;
00068   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_W_op() const;
00070   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_DfDp_op(int l) const;
00072   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_DgDx_op(int j) const;
00074   Teuchos::RefCountPtr<LinearOpBase<Scalar> > create_DgDp_op( int j, int l ) const;
00076   void reportFinalPoint(
00077     const ModelEvaluatorBase::InArgs<Scalar>      &finalPoint
00078     ,const bool                                   wasSolved
00079     );
00080 
00082   
00083 };
00084 
00085 // /////////////////////////////////
00086 // Implementations
00087 
00088 // Public functions overridden from ModelEvaulator
00089 
00090 template<class Scalar>
00091 int StateFuncModelEvaluatorBase<Scalar>::Np() const
00092 { return 0; }
00093 
00094 template<class Scalar>
00095 int StateFuncModelEvaluatorBase<Scalar>::Ng() const
00096 { return 0; }
00097 
00098 template<class Scalar>
00099 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00100 StateFuncModelEvaluatorBase<Scalar>::get_p_space(int l) const
00101 {
00102   TEST_FOR_EXCEPTION(
00103     true,std::logic_error
00104     ,"ModelEvaluator<"<<Teuchos::ScalarTraits<Scalar>::name()<<">::get_p_space(l): "
00105     "Error, this function was not overridden in *this = \'"<<this->description()<<"\'!"
00106     );
00107   return Teuchos::null;
00108 }
00109 
00110 template<class Scalar>
00111 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00112 StateFuncModelEvaluatorBase<Scalar>::get_g_space(int j) const
00113 {
00114   TEST_FOR_EXCEPTION(
00115     true,std::logic_error
00116     ,"ModelEvaluator<"<<Teuchos::ScalarTraits<Scalar>::name()<<">::get_g_space(j): "
00117     " Error, this function was not overridden in \'"
00118     <<this->description()<<"\'!"
00119     );
00120   return Teuchos::null;
00121 }
00122 
00123 template<class Scalar>
00124 ModelEvaluatorBase::InArgs<Scalar>
00125 StateFuncModelEvaluatorBase<Scalar>::getNominalValues() const
00126 { return this->createInArgs(); }
00127 
00128 template<class Scalar>
00129 ModelEvaluatorBase::InArgs<Scalar>
00130 StateFuncModelEvaluatorBase<Scalar>::getLowerBounds() const
00131 { return this->createInArgs(); }
00132 
00133 template<class Scalar>
00134 ModelEvaluatorBase::InArgs<Scalar>
00135 StateFuncModelEvaluatorBase<Scalar>::getUpperBounds() const
00136 { return this->createInArgs(); }
00137 
00138 template<class Scalar>
00139 Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00140 StateFuncModelEvaluatorBase<Scalar>::create_W() const
00141 {
00142   TEST_FOR_EXCEPTION(
00143     true, std::logic_error
00144     ,"Error, if \'W\' is supported by the ModelEvaluator subclass then"
00145     " this function create_W() must be overridden by the subclass to return"
00146     " a non-null object!"
00147     );
00148   return Teuchos::null; // Should never be called!
00149 }
00150 
00151 template<class Scalar>
00152 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00153 StateFuncModelEvaluatorBase<Scalar>::create_W_op() const
00154 {
00155   TEST_FOR_EXCEPTION(
00156     true, std::logic_error
00157     ,"Error, if \'W\' is supported by the ModelEvaluator subclass then"
00158     " this function create_W() must be overridden by the subclass "
00159     <<this->description()<<" to return a non-null object!"
00160     );
00161   return Teuchos::null; // Should never be called!
00162 }
00163 
00164 template<class Scalar>
00165 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00166 StateFuncModelEvaluatorBase<Scalar>::create_DfDp_op(int l) const
00167 {
00168   typedef ModelEvaluatorBase MEB;
00169   MEB::OutArgs<Scalar> outArgs = this->createOutArgs();
00170   TEST_FOR_EXCEPTION(
00171     outArgs.supports(MEB::OUT_ARG_DfDp,l).supports(MEB::DERIV_LINEAR_OP), std::logic_error
00172     ,"Error, The ModelEvaluator subclass "<<this->description()<<" says that it"
00173     " supports the LinearOpBae form of DfDp("<<l<<") (as determined from its OutArgs object created by createOutArgs())"
00174     " but this function create_DfDp_op(...) has not been overriden to create such an object!"
00175     );
00176   return Teuchos::null;
00177 }
00178 
00179 template<class Scalar>
00180 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00181 StateFuncModelEvaluatorBase<Scalar>::create_DgDx_op(int j) const
00182 {
00183   typedef ModelEvaluatorBase MEB;
00184   MEB::OutArgs<Scalar> outArgs = this->createOutArgs();
00185   TEST_FOR_EXCEPTION(
00186     outArgs.supports(MEB::OUT_ARG_DgDx,j).supports(MEB::DERIV_LINEAR_OP), std::logic_error
00187     ,"Error, The ModelEvaluator subclass "<<this->description()<<" says that it"
00188     " supports the LinearOpBae form of DgDx("<<j<<") (as determined from its OutArgs object created by createOutArgs())"
00189     " but this function create_DgDx_op(...) has not been overriden to create such an object!"
00190     );
00191   return Teuchos::null;
00192 }
00193 
00194 template<class Scalar>
00195 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00196 StateFuncModelEvaluatorBase<Scalar>::create_DgDp_op( int j, int l ) const
00197 {
00198   typedef ModelEvaluatorBase MEB;
00199   MEB::OutArgs<Scalar> outArgs = this->createOutArgs();
00200   TEST_FOR_EXCEPTION(
00201     outArgs.supports(MEB::OUT_ARG_DgDp,j,l).supports(MEB::DERIV_LINEAR_OP), std::logic_error
00202     ,"Error, The ModelEvaluator subclass "<<this->description()<<" says that it"
00203     " supports the LinearOpBae form of DgDp("<<j<<","<<l<<") (as determined from its OutArgs object created by createOutArgs())"
00204     " but this function create_DgDp_op(...) has not been overriden to create such an object!"
00205     );
00206   return Teuchos::null;
00207 }
00208 
00209 template<class Scalar>
00210 void StateFuncModelEvaluatorBase<Scalar>::reportFinalPoint(
00211   const ModelEvaluatorBase::InArgs<Scalar>      &finalPoint
00212   ,const bool                                   wasSolved
00213   )
00214 {
00215   // This final point is just ignored by default!
00216 }
00217 
00218 } // namespace Thyra
00219 
00220 #endif // THYRA_STATE_FUNC_MODEL_EVALUATOR_BASE_HPP

Generated on Thu Sep 18 12:32:48 2008 for Thyra Nonlinear Model Evaluator Support by doxygen 1.3.9.1