EpetraExt_DiagonalTransientModel.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00005 //                 Copyright (2001) 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 EPETRA_EXT_DIAGONAL_TRANSIENT_MODEL_HPP
00030 #define EPETRA_EXT_DIAGONAL_TRANSIENT_MODEL_HPP
00031 
00032 
00033 #include "EpetraExt_ModelEvaluator.h"
00034 #include "Teuchos_VerboseObject.hpp"
00035 #include "Teuchos_ParameterListAcceptor.hpp"
00036 #include "Teuchos_Array.hpp"
00037 
00038 
00039 class Epetra_Comm;
00040 class Epetra_CrsGraph;
00041 
00042 
00043 namespace EpetraExt {
00044 
00045 
00050 class DiagonalTransientModel
00051   : public ::EpetraExt::ModelEvaluator,
00052     public Teuchos::VerboseObject<DiagonalTransientModel>,
00053     public Teuchos::ParameterListAcceptor
00054 {
00055 public:
00056 
00059 
00061   DiagonalTransientModel(
00062     Teuchos::RefCountPtr<Epetra_Comm> const& epetra_comm
00063     );
00064 
00066   Teuchos::RefCountPtr<const Epetra_Vector>
00067   getExactSolution(
00068     const double t, const Epetra_Vector *coeff_s_p = 0
00069     ) const;
00070 
00072   Teuchos::RefCountPtr<const Epetra_MultiVector>
00073   getExactSensSolution(
00074     const double t, const Epetra_Vector *coeff_s_p = 0
00075     ) const;
00076 
00078 
00081 
00083   void setParameterList(Teuchos::RefCountPtr<Teuchos::ParameterList> const& paramList);
00085   Teuchos::RefCountPtr<Teuchos::ParameterList> getParameterList();
00087   Teuchos::RefCountPtr<Teuchos::ParameterList> unsetParameterList();
00089   Teuchos::RefCountPtr<const Teuchos::ParameterList> getParameterList() const;
00091   Teuchos::RefCountPtr<const Teuchos::ParameterList> getValidParameters() const;
00092 
00094 
00097 
00099   Teuchos::RefCountPtr<const Epetra_Map> get_x_map() const;
00101   Teuchos::RefCountPtr<const Epetra_Map> get_f_map() const;
00103   Teuchos::RefCountPtr<const Epetra_Map> get_p_map(int l) const;
00105   Teuchos::RefCountPtr<const Teuchos::Array<std::string> > get_p_names(int l) const;
00107   Teuchos::RefCountPtr<const Epetra_Map> get_g_map(int j) const;
00109   Teuchos::RefCountPtr<const Epetra_Vector> get_x_init() const;
00111   Teuchos::RefCountPtr<const Epetra_Vector> get_x_dot_init() const;
00113   Teuchos::RefCountPtr<const Epetra_Vector> get_p_init(int l) const;
00115   Teuchos::RefCountPtr<Epetra_Operator> create_W() const;
00117   InArgs createInArgs() const;
00119   OutArgs createOutArgs() const;
00121   void evalModel( const InArgs& inArgs, const OutArgs& outArgs ) const;
00122 
00124 
00125 public:
00126 
00127   enum ELambdaFit { LAMBDA_FIT_LINEAR, LAMBDA_FIT_RANDOM };
00128 
00129 private:
00130 
00131   // /////////////////////////////////////
00132   // Private types
00133 
00134   typedef Teuchos::Array<double> coeff_s_t;
00135   typedef Teuchos::Array<int> coeff_s_idx_t;
00136   typedef Teuchos::Array<Teuchos::RefCountPtr<const Epetra_Map> >  RCP_Eptra_Map_Array_t;
00137   typedef Teuchos::Array<Teuchos::RefCountPtr<Epetra_Vector> > RCP_Eptra_Vector_Array_t;
00138   typedef Teuchos::Array<Teuchos::RefCountPtr<Teuchos::Array<std::string> > > RCP_Array_String_Array_t;
00139   
00140 
00141   // /////////////////////////////////////
00142   // Private member data
00143 
00144   Teuchos::RefCountPtr<Teuchos::ParameterList> paramList_;
00145   Teuchos::RefCountPtr<Epetra_Comm> epetra_comm_;
00146   Teuchos::RefCountPtr<Epetra_Map> epetra_map_;
00147   bool implicit_;
00148   int numElements_;
00149   double lambda_min_;
00150   double lambda_max_;
00151   coeff_s_t coeff_s_;
00152   coeff_s_idx_t coeff_s_idx_;
00153   ELambdaFit lambda_fit_;
00154   double x0_;
00155   bool exactSolutionAsResponse_;
00156   Teuchos::RefCountPtr<Epetra_Vector> lambda_;
00157   Teuchos::RefCountPtr<Epetra_CrsGraph> W_graph_;
00158   int Np_;
00159   int np_;
00160   int Ng_;
00161   RCP_Eptra_Map_Array_t map_p_;
00162   RCP_Array_String_Array_t names_p_;
00163   RCP_Eptra_Map_Array_t map_g_;
00164   RCP_Eptra_Vector_Array_t p_init_;
00165   Teuchos::RefCountPtr<Epetra_Vector> x_init_;
00166   Teuchos::RefCountPtr<Epetra_Vector> x_dot_init_;
00167 
00168   mutable Teuchos::RefCountPtr<const Epetra_Vector> coeff_s_p_;
00169 
00170   bool isIntialized_;
00171 
00172   // /////////////////////////////////////
00173   // Private member functions
00174 
00175   void initialize();
00176 
00177   void set_coeff_s_p( 
00178     const Teuchos::RefCountPtr<const Epetra_Vector> &coeff_s_p
00179     ) const;
00180 
00181   void unset_coeff_s_p() const;
00182 
00183   int coeff_s_idx(int i) const
00184     {
00185       return coeff_s_idx_[i];
00186     }
00187 
00188   double coeff_s(int i) const
00189     {
00190       return (*coeff_s_p_)[coeff_s_idx(i)];
00191     }
00192 
00193 };
00194 
00195 
00200 Teuchos::RefCountPtr<DiagonalTransientModel>
00201 diagonalTransientModel(
00202   Teuchos::RefCountPtr<Epetra_Comm> const& epetra_comm,
00203   Teuchos::RefCountPtr<Teuchos::ParameterList> const& paramList = Teuchos::null
00204   );
00205 
00206 
00207 } // namespace EpetraExt
00208 
00209 
00210 // RAB: Note, I wrapped this example code in a namespace mainly to make the
00211 // later definition of the nonmember functions safe (see the Thyra
00212 // Coding Guildelines document).
00213 
00214 
00215 #endif // EPETRA_EXT_DIAGONAL_TRANSIENT_MODEL_HPP

Generated on Tue Oct 20 12:46:07 2009 for Rythmos - Transient Integration for Differential Equations by doxygen 1.4.7