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_EPETRA_MODEL_EVALUATOR_HPP 00030 #define THYRA_EPETRA_MODEL_EVALUATOR_HPP 00031 00032 #include "Thyra_ModelEvaluator.hpp" 00033 #include "Thyra_EpetraThyraWrappers.hpp" 00034 #include "Thyra_LinearOpWithSolveFactoryBase.hpp" 00035 #include "EpetraExt_ModelEvaluator.h" 00036 #include "Epetra_Map.h" 00037 00038 namespace Thyra { 00039 00041 class EpetraModelEvaluator : public ModelEvaluator<double> { 00042 public: 00043 00046 00048 EpetraModelEvaluator(); 00049 00051 EpetraModelEvaluator( 00052 const Teuchos::RefCountPtr<const EpetraExt::ModelEvaluator> &epetraModel 00053 ,const Teuchos::RefCountPtr<LinearOpWithSolveFactoryBase<double> > &W_factory 00054 ); 00055 00057 void initialize( 00058 const Teuchos::RefCountPtr<const EpetraExt::ModelEvaluator> &epetraModel 00059 ,const Teuchos::RefCountPtr<LinearOpWithSolveFactoryBase<double> > &W_factory 00060 ); 00061 00063 Teuchos::RefCountPtr<const EpetraExt::ModelEvaluator> getEpetraModel() const; 00064 00066 void setInitialGuess( const ModelEvaluatorBase::InArgs<double>& initialGuess ); 00067 00069 void uninitialize( 00070 Teuchos::RefCountPtr<const EpetraExt::ModelEvaluator> *epetraModel = NULL 00071 ,Teuchos::RefCountPtr<LinearOpWithSolveFactoryBase<double> > *W_factory = NULL 00072 ); 00073 00075 const ModelEvaluatorBase::InArgs<double>& getFinalPoint() const; 00076 00078 bool finalPointWasSolved() const; 00079 00081 00084 00086 int Np() const; 00088 int Ng() const; 00090 Teuchos::RefCountPtr<const VectorSpaceBase<double> > get_x_space() const; 00092 Teuchos::RefCountPtr<const VectorSpaceBase<double> > get_f_space() const; 00094 Teuchos::RefCountPtr<const VectorSpaceBase<double> > get_p_space(int l) const; 00096 Teuchos::RefCountPtr<const VectorSpaceBase<double> > get_g_space(int j) const; 00098 ModelEvaluatorBase::InArgs<double> getNominalValues() const; 00100 ModelEvaluatorBase::InArgs<double> getLowerBounds() const; 00102 ModelEvaluatorBase::InArgs<double> getUpperBounds() const; 00104 Teuchos::RefCountPtr<LinearOpWithSolveBase<double> > create_W() const; 00106 Teuchos::RefCountPtr<LinearOpBase<double> > create_W_op() const; 00108 Teuchos::RefCountPtr<LinearOpBase<double> > create_DfDp_op(int l) const; 00110 Teuchos::RefCountPtr<LinearOpBase<double> > create_DgDx_op(int j) const; 00112 Teuchos::RefCountPtr<LinearOpBase<double> > create_DgDp_op( int j, int l ) const; 00114 ModelEvaluatorBase::InArgs<double> createInArgs() const; 00116 ModelEvaluatorBase::OutArgs<double> createOutArgs() const; 00118 void evalModel( 00119 const ModelEvaluatorBase::InArgs<double> &inArgs 00120 ,const ModelEvaluatorBase::OutArgs<double> &outArgs 00121 ) const; 00123 void reportFinalPoint( 00124 const ModelEvaluatorBase::InArgs<double> &finalPoint 00125 ,const bool wasSolved 00126 ); 00127 00129 00132 00134 std::string description() const; 00135 00137 00138 private: 00139 00140 // //////////////////// 00141 // Private types 00142 00143 typedef std::vector<Teuchos::RefCountPtr<const Epetra_Map> > p_map_t; 00144 typedef std::vector<Teuchos::RefCountPtr<const Epetra_Map> > g_map_t; 00145 00146 typedef std::vector<Teuchos::RefCountPtr<const SpmdVectorSpaceDefaultBase<double> > > p_space_t; 00147 typedef std::vector<Teuchos::RefCountPtr<const SpmdVectorSpaceDefaultBase<double> > > g_space_t; 00148 00149 // //////////////////// 00150 // Private data mebers 00151 00152 Teuchos::RefCountPtr<const EpetraExt::ModelEvaluator> epetraModel_; 00153 Teuchos::RefCountPtr<LinearOpWithSolveFactoryBase<double> > W_factory_; 00154 Teuchos::RefCountPtr<const Epetra_Map> x_map_; 00155 p_map_t p_map_; 00156 g_map_t g_map_; 00157 Teuchos::RefCountPtr<const Epetra_Map> f_map_; 00158 Teuchos::RefCountPtr<const SpmdVectorSpaceDefaultBase<double> > x_space_; 00159 p_space_t p_space_; 00160 Teuchos::RefCountPtr<const SpmdVectorSpaceDefaultBase<double> > f_space_; 00161 g_space_t g_space_; 00162 ModelEvaluatorBase::InArgs<double> initialGuess_; 00163 ModelEvaluatorBase::InArgs<double> lowerBounds_; 00164 ModelEvaluatorBase::InArgs<double> upperBounds_; 00165 ModelEvaluatorBase::InArgs<double> finalPoint_; 00166 bool finalPointWasSolved_; 00167 00168 }; 00169 00170 // 00171 // Utility functions 00172 // 00173 00175 ModelEvaluatorBase::EDerivativeMultiVectorOrientation 00176 convert( const EpetraExt::ModelEvaluator::EDerivativeMultiVectorOrientation &mvOrientation ); 00177 00179 EpetraExt::ModelEvaluator::EDerivativeMultiVectorOrientation 00180 convert( const ModelEvaluatorBase::EDerivativeMultiVectorOrientation &mvOrientation ); 00181 00183 ModelEvaluatorBase::DerivativeProperties 00184 convert( const EpetraExt::ModelEvaluator::DerivativeProperties &derivativeProperties ); 00185 00187 ModelEvaluatorBase::DerivativeSupport 00188 convert( const EpetraExt::ModelEvaluator::DerivativeSupport &derivativeSupport ); 00189 00191 EpetraExt::ModelEvaluator::Derivative 00192 convert( 00193 const ModelEvaluatorBase::Derivative<double> &derivative 00194 ,const Teuchos::RefCountPtr<const Epetra_Map> &fnc_map 00195 ,const Teuchos::RefCountPtr<const Epetra_Map> &var_map 00196 ); 00197 00198 } // namespace Thyra 00199 00200 #endif // THYRA_EPETRA_MODEL_EVALUATOR_HPP
1.3.9.1