Amesos Package Browser (Single Doxygen Collection) Development
Amesos_Umfpack.h
Go to the documentation of this file.
00001 
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 //                Amesos: Direct Sparse Solver Package
00006 //                 Copyright (2004) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 
00040 #ifndef AMESOS_UMFPACK_H
00041 #define AMESOS_UMFPACK_H
00042 
00043 #include "Amesos_ConfigDefs.h"
00044 #include "Amesos_BaseSolver.h"
00045 #include "Amesos_BaseSolver.h"
00046 #include "Amesos_NoCopiable.h"
00047 #include "Amesos_Utils.h"
00048 #include "Amesos_Time.h"
00049 #include "Amesos_Status.h"
00050 #include "Amesos_Control.h"
00051 #include "Epetra_CrsMatrix.h"
00052 #include "Epetra_LinearProblem.h"
00053 #include "Epetra_Time.h"
00054 #include "Epetra_Import.h"
00055 #include "Teuchos_RCP.hpp"
00056 #ifdef EPETRA_MPI
00057 #include "Epetra_MpiComm.h"
00058 #else
00059 #include "Epetra_Comm.h"
00060 #endif
00061 
00063 
00070 class Amesos_Umfpack: public Amesos_BaseSolver,  
00071                       private Amesos_Time, 
00072                       private Amesos_NoCopiable, 
00073                       private Amesos_Utils, 
00074                       private Amesos_Control, 
00075                       private Amesos_Status 
00076 { 
00077 public: 
00078 
00080 
00081 
00088   Amesos_Umfpack( const Epetra_LinearProblem& LinearProblem );
00089 
00091 
00093   ~Amesos_Umfpack(void);
00094 
00096 
00097 
00098   int SymbolicFactorization();
00099 
00100   int NumericFactorization();
00101 
00102   int Solve();
00103 
00105 
00106 
00107   const Epetra_LinearProblem *GetProblem() const { return(Problem_); };
00108 
00110 
00113   bool MatrixShapeOK() const ;
00114 
00115   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00116 
00117   bool UseTranspose() const {return(UseTranspose_);};
00118 
00119   const Epetra_Comm & Comm() const {return(GetProblem()->GetOperator()->Comm());};
00120 
00122   /*  Rcond is an estimate of the reciprocal of the condition number of the 
00123       matrix at the time of the most recent call to NumericFactorization()
00124       Rcond = min(abs(diag))/max(abs(diag)) see Umfpack documentatoin
00125       for details.  
00126    */
00127   double GetRcond() const ; 
00128 
00129   int SetParameters( Teuchos::ParameterList &ParameterList ) ;
00130 
00132   int NumSymbolicFact() const { return( Amesos_Status::NumSymbolicFact_ ); }
00133 
00135   int NumNumericFact() const { return( Amesos_Status::NumNumericFact_ ); }
00136 
00138   int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
00139 
00141   void PrintTiming() const;
00142   
00144   void PrintStatus() const;
00145 
00147   void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
00148 
00149 private:  
00150   
00152 
00153   
00155   Epetra_RowMatrix* Matrix()
00156   {
00157     return(dynamic_cast<Epetra_RowMatrix *>(Problem_->GetOperator()));
00158   }
00159 
00161   int ConvertToSerial(const bool FirstTime);
00162 
00163   /*
00164     ConvertToUmfpackCRS - Convert matirx to form expected by Umfpack: Ai, Ap, Aval
00165     Preconditions:
00166       numentries_, NumGloalElements_ and SerialMatrix_ must be set.
00167     Postconditions:
00168       Ai, Ap, and Aval are resized and populated with a compresses row storage 
00169       version of the input matrix A.
00170   */
00171   int ConvertToUmfpackCRS();     
00172 
00173   /*
00174     PerformSymbolicFactorization - Call Umfpack to perform symbolic factorization
00175     Preconditions:
00176       IsLocal must be set to 1 if the input matrix is entirely stored on process 0
00177       Ap, Ai and Aval are a compressed row storage version of the input matrix A.
00178     Postconditions:
00179       Symbolic points to an UMFPACK internal opaque object containing the
00180         symbolic factorization and accompanying information.  
00181       SymbolicFactorizationOK_ = true; 
00182     Note:  All action is performed on process 0
00183   */
00184       
00185   int PerformSymbolicFactorization(); 
00186 
00187   /*
00188     PerformNumericFactorization - Call Umfpack to perform numeric factorization
00189     Preconditions:
00190       IsLocal must be set 
00191       Ap, Ai and Aval are a compressed row storage version of the input matrix A.
00192       Symbolic must be set
00193     Postconditions:
00194       Numeric points to an UMFPACK internal opaque object containing the
00195         numeric factorization and accompanying information.  
00196       NumericFactorizationOK_ = true; 
00197     Note:  All action is performed on process 0
00198   */
00199   int PerformNumericFactorization(); 
00200 
00201   inline const Epetra_Import& Importer() const
00202   {
00203     return(*(ImportToSerial_.get()));
00204   }
00205 
00206   inline const Epetra_Map& SerialMap() const
00207   {
00208     return(*(SerialMap_.get()));
00209   }
00210 
00211   inline const Epetra_CrsMatrix& SerialCrsMatrix() const
00212   {
00213     return(*(SerialCrsMatrixA_.get()));
00214   }
00215 
00216   inline Epetra_CrsMatrix& SerialCrsMatrix()
00217   {
00218     return(*(SerialCrsMatrixA_.get()));
00219   }
00220 
00221   // @}
00222   
00224   void *Symbolic;
00226   void *Numeric;
00227 
00229   std::vector <int> Ap;
00230   std::vector <int> Ai;
00231   std::vector <double> Aval;
00232 
00234   int IsLocal_;
00236   int numentries_;
00238   int NumGlobalElements_;
00239 
00241   Teuchos::RCP<Epetra_Map> SerialMap_;
00243   /* If IsLocal==1 - Points to the original matrix 
00244    * If  IsLocal==0 - Points to SerialCrsMatrixA
00245    */
00246   Epetra_RowMatrix* SerialMatrix_;
00247 
00248   Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrixA_;
00249 
00251   bool UseTranspose_;
00253   const Epetra_LinearProblem * Problem_;
00255   mutable double Rcond_;
00256   //  True if Rcond_ is the same on all processes
00257   mutable bool RcondValidOnAllProcs_;
00259   Teuchos::RCP<Epetra_Import> ImportToSerial_;
00260 
00262   int MtxConvTime_, MtxRedistTime_, VecRedistTime_;
00263   int SymFactTime_, NumFactTime_, SolveTime_, OverheadTime_;
00264   
00265 };  // class Amesos_Umfpack  
00266 #endif /* AMESOS_UMFPACK_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines