Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultFinalPointCaptureModelEvaluator.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_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_HPP
00030 #define THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_HPP
00031 
00032 #include "Thyra_ModelEvaluatorDelegatorBase.hpp"
00033 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
00034 #include "Teuchos_Time.hpp"
00035 
00036 
00037 //#define THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_DUMP_ALL
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00050 template<class Scalar>
00051 class DefaultFinalPointCaptureModelEvaluator
00052   : virtual public ModelEvaluatorDelegatorBase<Scalar>
00053 {
00054 public:
00055 
00057   typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00058 
00061 
00063   DefaultFinalPointCaptureModelEvaluator();
00064 
00066   DefaultFinalPointCaptureModelEvaluator(
00067     const Teuchos::RCP<ModelEvaluator<Scalar> >  &thyraModel
00068     );
00069 
00071   const ModelEvaluatorBase::InArgs<Scalar>& getFinalPoint() const;
00072 
00074   bool finalPointWasSolved() const;
00075 
00077 
00080 
00082   std::string description() const;
00083 
00085 
00088 
00090   void reportFinalPoint(
00091     const ModelEvaluatorBase::InArgs<Scalar> &finalPoint,
00092     const bool wasSolved
00093     );
00094 
00096 
00097 private:
00098 
00101 
00103   void evalModelImpl(
00104     const ModelEvaluatorBase::InArgs<Scalar> &inArgs,
00105     const ModelEvaluatorBase::OutArgs<Scalar> &outArgs
00106     ) const;
00107 
00109 
00110 private:
00111 
00112   ModelEvaluatorBase::InArgs<Scalar> finalPoint_;
00113   bool finalPointWasSolved_;
00114   
00115 };
00116 
00117 
00118 // /////////////////////////////////
00119 // Implementations
00120 
00121 
00122 // Constructors/initializers/accessors/utilities
00123 
00124 
00125 template<class Scalar>
00126 DefaultFinalPointCaptureModelEvaluator<Scalar>::DefaultFinalPointCaptureModelEvaluator()
00127   :finalPointWasSolved_(false)
00128 {}
00129 
00130 
00131 template<class Scalar>
00132 DefaultFinalPointCaptureModelEvaluator<Scalar>::DefaultFinalPointCaptureModelEvaluator(
00133   const Teuchos::RCP<ModelEvaluator<Scalar> >                     &thyraModel
00134   )
00135 {
00136   this->ModelEvaluatorDelegatorBase<Scalar>::initialize(thyraModel);
00137   finalPoint_ = thyraModel->createInArgs();
00138   finalPoint_.setArgs(thyraModel->getNominalValues());
00139   finalPointWasSolved_ = false;
00140 }
00141 
00142 
00143 template<class Scalar>
00144 const ModelEvaluatorBase::InArgs<Scalar>&
00145 DefaultFinalPointCaptureModelEvaluator<Scalar>::getFinalPoint() const
00146 {
00147 #ifdef THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_DUMP_ALL
00148   *Teuchos::VerboseObjectBase::getDefaultOStream()
00149     << "\nDefaultFinalPointCaptureModelEvaluator<Scalar>::getFinalPoint():"
00150     << " finalPoint =\n" << Teuchos::describe(finalPoint_,Teuchos::VERB_EXTREME);
00151 #endif  
00152   return finalPoint_;
00153 }
00154 
00155 
00156 template<class Scalar>
00157 bool DefaultFinalPointCaptureModelEvaluator<Scalar>::finalPointWasSolved() const
00158 {
00159   return finalPointWasSolved_;
00160 }
00161 
00162 
00163 // Public functions overridden from Teuchos::Describable
00164 
00165 
00166 template<class Scalar>
00167 std::string DefaultFinalPointCaptureModelEvaluator<Scalar>::description() const
00168 {
00169   const Teuchos::RCP<const ModelEvaluator<Scalar> >
00170     thyraModel = this->getUnderlyingModel();
00171   std::ostringstream oss;
00172   oss << "Thyra::DefaultFinalPointCaptureModelEvaluator{";
00173   oss << "thyraModel=";
00174   if(thyraModel.get())
00175     oss << "\'"<<thyraModel->description()<<"\'";
00176   else
00177     oss << "NULL";
00178   oss << "}";
00179   return oss.str();
00180 }
00181 
00182 
00183 // Overridden from ModelEvaulator.
00184 
00185 
00186 template<class Scalar>
00187 void DefaultFinalPointCaptureModelEvaluator<Scalar>::reportFinalPoint(
00188   const ModelEvaluatorBase::InArgs<Scalar> &finalPoint,
00189   const bool wasSolved
00190   )
00191 {
00192   finalPoint_.setArgs(finalPoint);
00193   finalPointWasSolved_ = wasSolved;
00194   if(!this->isUnderlyingModelConst())
00195     this->getNonconstUnderlyingModel()->reportFinalPoint(finalPoint,wasSolved);
00196 #ifdef THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_DUMP_ALL
00197   *Teuchos::VerboseObjectBase::getDefaultOStream()
00198     << "\nDefaultFinalPointCaptureModelEvaluator<Scalar>::reportFinalPoint(...):"
00199     << " finalPoint =\n" << Teuchos::describe(finalPoint_,Teuchos::VERB_EXTREME);
00200 #endif  
00201 }
00202 
00203 
00204 // Private functions overridden from ModelEvaulatorDefaultBase
00205 
00206 
00207 template<class Scalar>
00208 void DefaultFinalPointCaptureModelEvaluator<Scalar>::evalModelImpl(
00209   const ModelEvaluatorBase::InArgs<Scalar> &inArgs,
00210   const ModelEvaluatorBase::OutArgs<Scalar> &outArgs
00211   ) const
00212 {
00213 
00214   THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(
00215     "Thyra::DefaultFinalPointCaptureModelEvaluator",inArgs,outArgs
00216     );
00217 
00218   thyraModel->evalModel(inArgs,outArgs);
00219 
00220   THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END();
00221 
00222 }
00223 
00224 
00225 } // namespace Thyra
00226 
00227 
00228 #endif // THYRA_DEFAULT_FINAL_POINT_CAPTURE_MODEL_EVALUATOR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines