• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

AAdapt_ThyraAdaptiveModelEvaluator.hpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #ifndef AADAPT_THYRA_EPETRA_MODEL_EVALUATOR_HPP
00008 #define AADAPT_THYRA_EPETRA_MODEL_EVALUATOR_HPP
00009 
00010 #include "Thyra_EpetraModelEvaluator.hpp"
00011 
00012 namespace AAdapt {
00013 
00024 class ThyraAdaptiveModelEvaluator
00025   : public Thyra::EpetraModelEvaluator
00026 {
00027 public:
00028 
00031 
00033   ThyraAdaptiveModelEvaluator();
00034 
00036   ThyraAdaptiveModelEvaluator(
00037     const Teuchos::RCP<const EpetraExt::ModelEvaluator> &epetraModel,
00038     const Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > &W_factory
00039     );
00040 
00042   void initialize(
00043     const Teuchos::RCP<const EpetraExt::ModelEvaluator> &epetraModel,
00044     const Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > &W_factory
00045     );
00046 
00048   Teuchos::RCP<const EpetraExt::ModelEvaluator> getEpetraModel() const;
00049 
00055   void setNominalValues( const Thyra::ModelEvaluatorBase::InArgs<double>& nominalValues );
00056   
00064   void setStateVariableScalingVec(
00065     const Teuchos::RCP<const Epetra_Vector> &stateVariableScalingVec
00066     );
00067   
00070   Teuchos::RCP<const Epetra_Vector>
00071   getStateVariableInvScalingVec() const;
00072   
00075   Teuchos::RCP<const Epetra_Vector>
00076   getStateVariableScalingVec() const;
00077   
00080   void setStateFunctionScalingVec(
00081     const Teuchos::RCP<const Epetra_Vector> &stateFunctionScalingVec
00082     );
00083   
00086   Teuchos::RCP<const Epetra_Vector>
00087   getStateFunctionScalingVec() const;
00088 
00090   void uninitialize(
00091     Teuchos::RCP<const EpetraExt::ModelEvaluator> *epetraModel = NULL,
00092     Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > *W_factory = NULL
00093     );
00094   
00096   const Thyra::ModelEvaluatorBase::InArgs<double>& getFinalPoint() const;
00097 
00099   bool finalPointWasSolved() const;
00100 
00102   const Teuchos::RCP<Thyra::VectorBase<double> >
00103     resize_g_space(int index, Teuchos::RCP<const Epetra_Map> map);
00104 
00106 
00109 
00111   std::string description() const;
00112 
00114 
00117 
00119   void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const& paramList);
00121   Teuchos::RCP<Teuchos::ParameterList> getNonconstParameterList();
00123   Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
00125   Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
00127   Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
00128 
00130 
00133 
00135   int Np() const;
00137   int Ng() const;
00139   Teuchos::RCP<const Thyra::VectorSpaceBase<double> > get_x_space() const;
00141   Teuchos::RCP<const Thyra::VectorSpaceBase<double> > get_f_space() const;
00143   Teuchos::RCP<const Thyra::VectorSpaceBase<double> > get_p_space(int l) const;
00145   Teuchos::RCP<const Teuchos::Array<std::string> > get_p_names(int l) const;
00147   Teuchos::RCP<const Thyra::VectorSpaceBase<double> > get_g_space(int j) const;
00149   Thyra::ModelEvaluatorBase::InArgs<double> getNominalValues() const;
00151   Thyra::ModelEvaluatorBase::InArgs<double> getLowerBounds() const;
00153   Thyra::ModelEvaluatorBase::InArgs<double> getUpperBounds() const;
00155   Teuchos::RCP<Thyra::LinearOpBase<double> > create_W_op() const;
00157   Teuchos::RCP<Thyra::PreconditionerBase<double> > create_W_prec() const;
00159   Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<double> > get_W_factory() const;
00161   Thyra::ModelEvaluatorBase::InArgs<double> createInArgs() const;
00163   void reportFinalPoint(
00164     const Thyra::ModelEvaluatorBase::InArgs<double>      &finalPoint
00165     ,const bool                                   wasSolved
00166     );
00167 
00169 
00170   // Made public to simplify implementation but this is harmless to be public.
00171   // Clients should not deal with this type.
00172   enum EStateFunctionScaling { STATE_FUNC_SCALING_NONE, STATE_FUNC_SCALING_ROW_SUM };
00173 
00174 private:
00175 
00178 
00180   Teuchos::RCP<Thyra::LinearOpBase<double> > create_DfDp_op_impl(int l) const;
00182   Teuchos::RCP<Thyra::LinearOpBase<double> > create_DgDx_dot_op_impl(int j) const;
00184   Teuchos::RCP<Thyra::LinearOpBase<double> > create_DgDx_op_impl(int j) const;
00186   Teuchos::RCP<Thyra::LinearOpBase<double> > create_DgDp_op_impl(int j, int l) const;
00188   Thyra::ModelEvaluatorBase::OutArgs<double> createOutArgsImpl() const;
00190   void evalModelImpl(
00191     const Thyra::ModelEvaluatorBase::InArgs<double> &inArgs,
00192     const Thyra::ModelEvaluatorBase::OutArgs<double> &outArgs
00193     ) const;
00194 
00196 
00197 private:
00198 
00199   // ////////////////////
00200   // Private types
00201 
00202   typedef Teuchos::Array<Teuchos::RCP<const Epetra_Map> > p_map_t;
00203   typedef Teuchos::Array<Teuchos::RCP<const Epetra_Map> > g_map_t;
00204   typedef std::vector<bool> p_map_is_local_t;
00205   typedef std::vector<bool> g_map_is_local_t;
00206 
00207   typedef Teuchos::Array<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > >
00208   p_space_t;
00209   typedef Teuchos::Array<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > >
00210   g_space_t;
00211 
00212   // /////////////////////
00213   // Private data members
00214 
00215   Teuchos::RCP<const EpetraExt::ModelEvaluator> epetraModel_;
00216 
00217   Teuchos::RCP<Teuchos::ParameterList> paramList_;
00218 
00219   Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > W_factory_;
00220 
00221   Teuchos::RCP<const Epetra_Map> x_map_;
00222   p_map_t p_map_;
00223   g_map_t g_map_;
00224   p_map_is_local_t p_map_is_local_;
00225   p_map_is_local_t g_map_is_local_;
00226   Teuchos::RCP<const Epetra_Map> f_map_;
00227 
00228   Teuchos::RCP<const Thyra::VectorSpaceBase<double> > x_space_;
00229   p_space_t p_space_;
00230   Teuchos::RCP<const Thyra::VectorSpaceBase<double> > f_space_;
00231   g_space_t g_space_;
00232 
00233   mutable Thyra::ModelEvaluatorBase::InArgs<double> nominalValues_;
00234   mutable Thyra::ModelEvaluatorBase::InArgs<double> lowerBounds_;
00235   mutable Thyra::ModelEvaluatorBase::InArgs<double> upperBounds_;
00236   mutable bool nominalValuesAndBoundsAreUpdated_;
00237 
00238   Thyra::ModelEvaluatorBase::InArgs<double> finalPoint_;
00239 
00240   EStateFunctionScaling stateFunctionScaling_;
00241   mutable Teuchos::RCP<const Epetra_Vector> stateFunctionScalingVec_;
00242 
00243   Teuchos::RCP<const Epetra_Vector> stateVariableScalingVec_; // S_x
00244   mutable Teuchos::RCP<const Epetra_Vector> invStateVariableScalingVec_; // inv(S_x)
00245   mutable EpetraExt::ModelEvaluator::InArgs epetraInArgsScaling_;
00246   mutable EpetraExt::ModelEvaluator::OutArgs epetraOutArgsScaling_;
00247   
00248   mutable Teuchos::RCP<Epetra_Vector> x_unscaled_;
00249   mutable Teuchos::RCP<Epetra_Vector> x_dot_unscaled_;
00250 
00251   mutable Thyra::ModelEvaluatorBase::InArgs<double> prototypeInArgs_;
00252   mutable Thyra::ModelEvaluatorBase::OutArgs<double> prototypeOutArgs_;
00253   mutable bool currentInArgsOutArgs_;
00254 
00255   bool finalPointWasSolved_;
00256 
00257   // Share the outArgs between the resize and evaluate functions
00258   mutable EpetraExt::ModelEvaluator::OutArgs evaluated_epetraUnscaledOutArgs;
00259 
00260   // //////////////////////////
00261   // Private member functions
00262 
00264   void convertInArgsFromEpetraToThyra(
00265     const EpetraExt::ModelEvaluator::InArgs &epetraInArgs,
00266     Thyra::ModelEvaluatorBase::InArgs<double> *inArgs
00267     ) const;
00268 
00270   void convertInArgsFromThyraToEpetra(
00271     const Thyra::ModelEvaluatorBase::InArgs<double> &inArgs,
00272     EpetraExt::ModelEvaluator::InArgs *epetraInArgs
00273     ) const;
00274 
00276   void convertOutArgsFromThyraToEpetra(
00277     // Thyra form of the outArgs
00278     const Thyra::ModelEvaluatorBase::OutArgs<double> &outArgs,
00279     // Epetra form of the unscaled output arguments 
00280     EpetraExt::ModelEvaluator::OutArgs *epetraUnscaledOutArgs,
00281     // The passed-in form of W
00282     Teuchos::RCP<Thyra::LinearOpBase<double> > *W_op,
00283     Teuchos::RCP<Thyra::EpetraLinearOp> *efwdW,
00284     // The actual Epetra object passed to the underylying EpetraExt::ModelEvaluator
00285     Teuchos::RCP<Epetra_Operator> *eW
00286     ) const;
00287 
00289   void preEvalScalingSetup(
00290     EpetraExt::ModelEvaluator::InArgs *epetraInArgs,
00291     EpetraExt::ModelEvaluator::OutArgs *epetraUnscaledOutArgs,
00292     const Teuchos::RCP<Teuchos::FancyOStream> &out,
00293     const Teuchos::EVerbosityLevel verbLevel
00294     ) const;
00295 
00297   void postEvalScalingSetup(
00298     const EpetraExt::ModelEvaluator::OutArgs &epetraUnscaledOutArgs,
00299     const Teuchos::RCP<Teuchos::FancyOStream> &out,
00300     const Teuchos::EVerbosityLevel verbLevel
00301     ) const;
00302 
00304   void finishConvertingOutArgsFromEpetraToThyra(
00305     const EpetraExt::ModelEvaluator::OutArgs &epetraOutArgs,
00306     Teuchos::RCP<Thyra::LinearOpBase<double> > &W_op,
00307     Teuchos::RCP<Thyra::EpetraLinearOp> &efwdW,
00308     Teuchos::RCP<Epetra_Operator> &eW,
00309     const Thyra::ModelEvaluatorBase::OutArgs<double> &outArgs // Output!
00310     ) const;
00311   // 2007/08/03: rabartl: Above, I pass many of the RCP objects by non-const
00312   // reference since I don't want the compiler to perform any implicit
00313   // conversions on this RCP objects.
00314 
00316   void updateNominalValuesAndBounds() const;
00317 
00319   void updateInArgsOutArgs() const;
00320 
00322   Teuchos::RCP<Thyra::EpetraLinearOp> create_epetra_W_op() const;
00323   
00324 };
00325 
00326 
00327 
00328 } // namespace AAdapt
00329 
00330 
00331 #endif // THYRA_ADAPTIVE_MODEL_EVALUATOR_HPP

Generated on Wed Mar 26 2014 18:36:35 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1