Amesos Package Browser (Single Doxygen Collection) Development
Amesos_Superlu.h
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                Amesos: Direct Sparse Solver Package
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 //
00030 //  Coding tasks:
00031 //  1)  Create the dense matrices in Solve()   DONE 
00032 //  2)  Make the call to dgsvx() in Factor() dONE 
00033 //  3)  Make the call to dgsvx() in Solve()  DONE
00034 //
00035 //  Later coding tasks:
00036 //  0)  Factor called twice
00037 //  1)  Refactor()
00038 //  2)  Parameter list
00039 //  3)  Transpose  - DONE 
00040 //  4)  Destructor - In particular, need to call the SuperLU_FREE routines.
00041 //  5)  Coments - especially in Amesos_Superlu.h
00042 //
00043 //  SymbolicFactorization() performs no action other than making sure that Factorization 
00044 //    s performed
00045 //  NumericFactorization() performs the factorization but no solve (right hand side is
00046 //    is set to 0 vectors) reuses factors only if ReuseFactorization_ is set. 
00047 //    If FactorizationOK_() && ReuseSymbolic_ 
00048 //       ReFactor()
00049 //    else
00050 //       Factor() 
00051 //
00052 //  Solve() 
00053 //
00054 //  Factor() does everything from scratch:
00055 //    Redistributes the data if necessary
00056 //      Deletes any data structures left over from the previous call to Factor()
00057 //    Copies the data into the format that SuperLU wants it
00058 //    Calls dgssvx to factor the matrix with factor set to true
00059 //  ReFactor()
00060 //    Redistributes the data if necessary
00061 //      - Attempting to check to make sure that the non-zero structure is unchanged
00062 //    Copies the data into the format that SuperLU already has it
00063 //       FIRST PASS - assert( false ) 
00064 //    
00065 
00066 #ifndef AMESOS_SUPERLU_H
00067 #define AMESOS_SUPERLU_H
00068 
00069 #include "Amesos_ConfigDefs.h"
00070 #include "Amesos_BaseSolver.h"
00071 #include "Amesos_NoCopiable.h"
00072 #include "Amesos_Utils.h"
00073 #include "Amesos_Time.h"
00074 #include "Amesos_Status.h"
00075 #include "Amesos_Control.h"
00076 #include "Teuchos_RCP.hpp"
00077 
00078 class SLUData;
00079 class Epetra_Comm;
00080 class Epetra_CrsMatrix;
00081 class Epetra_LinearProblem;
00082 
00084 
00092 class Amesos_Superlu: public Amesos_BaseSolver, 
00093                       private Amesos_Time, 
00094                       private Amesos_NoCopiable, 
00095                       private Amesos_Utils, 
00096                       private Amesos_Control, 
00097                       private Amesos_Status { 
00098 
00099 public: 
00100 
00102 
00103 
00110   Amesos_Superlu(const Epetra_LinearProblem& LinearProblem );
00111 
00113   ~Amesos_Superlu();
00114 
00116 
00117 
00118   int SymbolicFactorization();
00119 
00120   int NumericFactorization();
00121 
00122   int Solve();
00123 
00125 
00126 
00127   const Epetra_LinearProblem *GetProblem() const { return(Problem_); };
00128 
00129   bool MatrixShapeOK() const ;
00130 
00131   int SetUseTranspose(bool UseTranspose) {
00132     UseTranspose_ = UseTranspose; return(0);
00133   }
00134 
00135   bool UseTranspose() const {return(UseTranspose_);};
00136 
00137   const Epetra_Comm& Comm() const {return(GetProblem()->GetOperator()->Comm());};
00138 
00139   int SetParameters( Teuchos::ParameterList &ParameterList )  ;
00140 
00142   int NumSymbolicFact() const { return( Amesos_Status::NumSymbolicFact_ ); }
00143 
00145   int NumNumericFact() const { return( Amesos_Status::NumNumericFact_ ); }
00146 
00148   int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
00149 
00151   void PrintTiming() const;
00152 
00154   void PrintStatus() const;
00155 
00157   void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
00158 
00159 private:  
00160 
00162 
00163 
00165   // Note: this method is delicate!
00166   const Epetra_Map& SerialMap() const
00167   {
00168     return(*(SerialMap_.get()));
00169   }
00170 
00172   // Note: this method is delicate!
00173   const Epetra_Import& ImportToSerial() const
00174   {
00175     return(*(ImportToSerial_.get()));
00176   }
00177 
00179   int Factor();
00181   int ReFactor();
00182 
00184   int ConvertToSerial();
00185 
00187   // Note:  All action is performed on process 0
00188   int PerformNumericFactorization(); 
00189 
00191 
00193   SLUData* data_;
00194   std::vector<double> berr_;
00195   std::vector<double> ferr_;
00196   std::vector<int> perm_r_;
00197   std::vector<int> perm_c_;
00198   std::vector<int> etree_;
00199   std::vector<double> R_;
00200   std::vector<double> C_;
00201   char equed_;
00202   // no idea of the following.
00203   double* DummyArray;
00204 
00206   std::vector <int> Ap_;
00208   std::vector <int> Ai_;
00210   std::vector <double> Aval_; 
00212   int NumGlobalRows_; 
00214   int NumGlobalNonzeros_; 
00216   bool UseTranspose_;      
00218   bool FactorizationOK_; 
00219   bool FactorizationDone_; 
00220   bool ReuseSymbolic_;
00222   int iam_;
00224   int MtxConvTime_, MtxRedistTime_, VecRedistTime_;
00225   int NumFactTime_, SolveTime_, OverheadTime_;
00227   Teuchos::RCP<Epetra_Map> SerialMap_;
00229   Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrixA_;
00231   Teuchos::RCP<Epetra_Import> ImportToSerial_;
00233   Epetra_RowMatrix* SerialMatrix_ ;
00235   const Epetra_LinearProblem* Problem_;
00237   Epetra_RowMatrix* RowMatrixA_;
00238 
00239 };  // End of  class Amesos_Superlu  
00240 #endif /* AMESOS_SUPERLU_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines