PlayaAztecSolver.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 //   
00003 /* @HEADER@ */
00004 
00005 #ifndef PLAYA_AZTECSOLVER_HPP
00006 #define PLAYA_AZTECSOLVER_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 #include "PlayaLinearSolverBaseDecl.hpp"
00010 #include "PlayaHandleable.hpp"
00011 #include "PlayaPrintable.hpp"
00012 #include "Teuchos_Describable.hpp"
00013 
00014 #include "Teuchos_Array.hpp"
00015 #include "Teuchos_RefCountPtr.hpp"
00016 #include "Teuchos_ParameterList.hpp"
00017 #include <map>
00018 
00019 #include "AztecOO.h"
00020 
00021 #define AZ_recursive_iterate 10001
00022 
00023 #define HAVE_ML
00024 
00025 
00026 namespace Playa
00027 {
00028   using namespace Teuchos;
00029 
00030   /**
00031    *
00032    */
00033   class AztecSolver : public LinearSolverBase<double>,
00034                       public Playa::Handleable<LinearSolverBase<double> >,
00035                       public Printable,
00036                       public Describable
00037   {
00038   public:
00039     /** */
00040     AztecSolver(const Teuchos::map<int, int>& aztecOptions,
00041                 const Teuchos::map<int, double>& aztecParameters);
00042 
00043     /** */
00044     AztecSolver(const Teuchos::ParameterList& params);
00045 
00046     /** */
00047     virtual ~AztecSolver(){;}
00048 
00049     /** Change the convergence tolerance. */
00050     virtual void updateTolerance(const double& tol);
00051 
00052 
00053     /** Set the preconditioning operator */
00054     void setUserPrec(const LinearOperator<double>& P,
00055          const LinearSolver<double>& pSolver);
00056 
00057     /** \name Printable interface */
00058     //@{
00059     /** Write to a stream  */
00060     void print(std::ostream& os) const 
00061     {
00062       os << description() << std::endl;
00063     }
00064     //@}
00065     
00066     /** \name Describable interface */
00067     //@{
00068     /** Write a brief description */
00069     std::string description() const {return "AztecSolver";}
00070     //@}
00071 
00072     
00073 
00074     /** */
00075     virtual SolverState<double> solve(const LinearOperator<double>& op,
00076                                       const Vector<double>& rhs,
00077                                       Vector<double>& soln) const ;
00078 
00079     /** \name Handleable interface */
00080     //@{
00081     /** Return a ref count pointer to a newly created object */
00082     virtual RCP<LinearSolverBase<double> > getRcp() 
00083     {return rcp(this);}
00084     //@}
00085 
00086 
00087   protected:
00088 
00089   private:
00090     
00091     void setupML(Epetra_RowMatrix* A) const ;
00092 
00093     /** Aztec options */
00094     mutable Array<int> options_;
00095 
00096     /** Aztec parameters */
00097     mutable Array<double> parameters_;
00098 
00099     /** Flag indicating whether we are using ML preconditioning */
00100     bool useML_;
00101 
00102     /** Flag indicating whether we are using Ifpack preconditioning */
00103     bool useIfpack_;
00104 
00105     /** Flag indicating whether we are using a user-defined preconditioner */
00106     bool useUserPrec_;
00107 
00108     /** Flag indicating whether we are doing a recursive solve
00109      *  with aztec (i.e., using recursiveIterate) */
00110     bool aztec_recursive_iterate_;
00111 
00112     /** Parameter list for preconditioner */
00113     mutable ParameterList precParams_;
00114 
00115     /** User-defined preconditioner object */
00116     mutable RCP<Epetra_Operator> userPrec_;
00117 
00118     /** Aztec status */
00119     mutable Array<double> aztec_status;
00120 
00121     /** Aztec proc_config */
00122     mutable Array<int> aztec_proc_config;
00123 
00124 
00125     /** Map from parameter name to AZTEC parameter identifier */
00126     static Teuchos::map<string,int>& paramMap() 
00127     {static Teuchos::map<string,int> rtn; return rtn;}
00128     
00129     /** Initialize the map from parameter names to AZTEC parameter ID codes */
00130     static void initParamMap();
00131 
00132     
00133   };
00134   
00135 }
00136 
00137 #endif

Site Contact