TSFAztecSolver.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 /* ***********************************************************************
00003 // 
00004 //           TSFExtended: Trilinos Solver Framework Extended
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 TSFAZTECSOLVER_HPP
00030 #define TSFAZTECSOLVER_HPP
00031 
00032 #include "SundanceDefs.hpp"
00033 #include "TSFLinearSolverBaseDecl.hpp"
00034 #include "SundanceHandleable.hpp"
00035 #include "SundancePrintable.hpp"
00036 #include "Teuchos_Describable.hpp"
00037 
00038 #include "Teuchos_Array.hpp"
00039 #include "Teuchos_RefCountPtr.hpp"
00040 #include "Teuchos_ParameterList.hpp"
00041 #include <map>
00042 
00043 #include "AztecOO.h"
00044 
00045 #define AZ_recursive_iterate 10001
00046 
00047 #define HAVE_ML
00048 
00049 
00050 namespace TSFExtended
00051 {
00052   using namespace Teuchos;
00053 
00054   /**
00055    *
00056    */
00057   class AztecSolver : public LinearSolverBase<double>,
00058                       public Sundance::Handleable<LinearSolverBase<double> >,
00059                       public Printable,
00060                       public Describable
00061   {
00062   public:
00063     /** */
00064     AztecSolver(const Teuchos::map<int, int>& aztecOptions,
00065                 const Teuchos::map<int, double>& aztecParameters);
00066 
00067     /** */
00068     AztecSolver(const Teuchos::ParameterList& params);
00069 
00070     /** */
00071     virtual ~AztecSolver(){;}
00072 
00073     /** Change the convergence tolerance. */
00074     virtual void updateTolerance(const double& tol);
00075 
00076 
00077     /** Set the preconditioning operator */
00078     void setUserPrec(const LinearOperator<double>& P,
00079          const LinearSolver<double>& pSolver);
00080 
00081     /** \name Printable interface */
00082     //@{
00083     /** Write to a stream  */
00084     void print(std::ostream& os) const 
00085     {
00086       os << description() << std::endl;
00087     }
00088     //@}
00089     
00090     /** \name Describable interface */
00091     //@{
00092     /** Write a brief description */
00093     std::string description() const {return "AztecSolver";}
00094     //@}
00095 
00096     
00097 
00098     /** */
00099     virtual SolverState<double> solve(const LinearOperator<double>& op,
00100                                       const Vector<double>& rhs,
00101                                       Vector<double>& soln) const ;
00102 
00103     /** \name Handleable interface */
00104     //@{
00105     /** Return a ref count pointer to a newly created object */
00106     virtual RCP<LinearSolverBase<double> > getRcp() 
00107     {return rcp(this);}
00108     //@}
00109 
00110 
00111   protected:
00112 
00113   private:
00114     
00115     void setupML(Epetra_RowMatrix* A) const ;
00116 
00117     /** Aztec options */
00118     mutable Array<int> options_;
00119 
00120     /** Aztec parameters */
00121     mutable Array<double> parameters_;
00122 
00123     /** Flag indicating whether we are using ML preconditioning */
00124     bool useML_;
00125 
00126     /** Flag indicating whether we are using Ifpack preconditioning */
00127     bool useIfpack_;
00128 
00129     /** Flag indicating whether we are using a user-defined preconditioner */
00130     bool useUserPrec_;
00131 
00132     /** Flag indicating whether we are doing a recursive solve
00133      *  with aztec (i.e., using recursiveIterate) */
00134     bool aztec_recursive_iterate_;
00135 
00136     /** Parameter list for preconditioner */
00137     mutable ParameterList precParams_;
00138 
00139     /** User-defined preconditioner object */
00140     mutable RCP<Epetra_Operator> userPrec_;
00141 
00142     /** Aztec status */
00143     mutable Array<double> aztec_status;
00144 
00145     /** Aztec proc_config */
00146     mutable Array<int> aztec_proc_config;
00147 
00148 
00149     /** Map from parameter name to AZTEC parameter identifier */
00150     static Teuchos::map<string,int>& paramMap() 
00151     {static Teuchos::map<string,int> rtn; return rtn;}
00152     
00153     /** Initialize the map from parameter names to AZTEC parameter ID codes */
00154     static void initParamMap();
00155 
00156     
00157   };
00158   
00159 }
00160 
00161 #endif

Site Contact