Amesos Package Browser (Single Doxygen Collection) Development
Amesos_Paraklete.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 
00039 #ifndef AMESOS_PARAKLETE_H
00040 #define AMESOS_PARAKLETE_H
00041 
00042 #include "Amesos_ConfigDefs.h"
00043 #include "Amesos_BaseSolver.h"
00044 #include "Amesos_NoCopiable.h"
00045 #include "Amesos_Utils.h"
00046 #include "Amesos_Time.h"
00047 #include "Amesos_Status.h"
00048 #include "Amesos_Control.h"
00049 #include "Epetra_LinearProblem.h"
00050 #include "Epetra_Time.h"
00051 #include "Epetra_Import.h"
00052 #ifdef EPETRA_MPI
00053 #include "Epetra_MpiComm.h"
00054 #else
00055 #include "Epetra_Comm.h"
00056 #endif
00057 #include "Epetra_CrsGraph.h"
00058 #include "Epetra_CrsMatrix.h"
00059 #ifdef HAVE_AMESOS_EPETRAEXT
00060 #include "EpetraExt_Transpose_RowMatrix.h"
00061 #endif
00062 
00063 
00065 
00084 // Amesos_Paraklete_Pimpl contains a pointer to structures defined in 
00085 // paraklete.h.  This prevents Amesos_Paraklete.h 
00086 // from having to include paraklete.h.
00087 //
00088 //  Doxygen does not handle forward class references well.
00089 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00090 class Amesos_Paraklete_Pimpl ; 
00091 class Amesos_StandardIndex ; 
00092 #endif
00093 
00094 class Amesos_Paraklete: public Amesos_BaseSolver,  
00095                   private Amesos_Time, 
00096                   private Amesos_NoCopiable, 
00097                   private Amesos_Utils, 
00098                   private Amesos_Control, 
00099                   private Amesos_Status { 
00100 
00101 public: 
00102 
00104 
00105 
00112   Amesos_Paraklete(const Epetra_LinearProblem& LinearProblem );
00113 
00115   ~Amesos_Paraklete(void);
00116   
00118 
00119 
00120   int SymbolicFactorization() ;
00121 
00122   int NumericFactorization() ;
00123 
00124   int Solve();
00125 
00127 
00128 
00130   const Epetra_LinearProblem *GetProblem() const { return(Problem_); };
00131 
00133 
00136   bool MatrixShapeOK() const ;
00137 
00139 
00143   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
00144 
00145   bool UseTranspose() const {return(UseTranspose_);};
00146 
00147   const Epetra_Comm & Comm() const {return(GetProblem()->GetOperator()->Comm());};
00148 
00149   int SetParameters( Teuchos::ParameterList &ParameterList );
00150 
00152   int NumSymbolicFact() const { return( Amesos_Status::NumSymbolicFact_ ); }
00153 
00155   int NumNumericFact() const { return( Amesos_Status::NumNumericFact_ ); }
00156 
00158   int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
00159 
00161   void PrintTiming() const;
00162   
00164   void PrintStatus() const;
00165  
00167   void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
00168  
00169 private:  
00170   
00172 
00173 
00174   /*
00175   CreateLocalMatrixAndExporters - Prepare to convert matrix and vectors to serial 
00176     Preconditions:
00177       Problem_ must be set 
00178   
00179     Postconditions:
00180       UseDataInPlace_ is set to 1 if the input matrix can be used in place, i.e.
00181         1)  is entirely stored on process 0
00182         2)  range map and domain map are same as the row map
00183       The following are only set if (! UseDataInPlace_ )"
00184         SerialMap_ 
00185   ImportToSerial_
00186   SerialCrsMatrixA_ 
00187 
00188       SerialMatrix_ 
00189    */
00190   int CreateLocalMatrixAndExporters() ;
00191   /*
00192     ExportToSerial
00193     Preconditions:
00194        UseDataInPlace_ must be set
00195        ImportToSerial and SerialCrsMatrixA_ must be set if UseDataInPlace_ != 1
00196     Postconditions
00197        SerialMatrix_ points to a serial version of the matrix
00198    */
00199   int ExportToSerial() ;
00200   /*
00201     ConvertToParakleteCRS - Convert matrix to form expected by Paraklete: Ai, Ap, Aval
00202     Preconditions:
00203       numentries_, RowMatrixA_, ImportToSerial_, StdIndexMatrix_, Reindex_ 
00204     Postconditions:
00205       SerialCrsMatrixA_
00206   */
00207   int ConvertToParakleteCRS(bool firsttime);     
00208 
00209   /*
00210     PerformSymbolicFactorization - Call Paraklete to perform symbolic factorization
00211     Preconditions:
00212       UseDataInPlace_ must be set to 1 if the input matrix is entirely stored on process 0
00213       Ap, Ai and Aval point to a compressed row storage version of the input matrix A.
00214     Postconditions:
00215       Symbolic points to an PARAKLETE internal opaque object containing the
00216         symbolic factorization and accompanying information.  
00217       SymbolicFactorizationOK_ = true; 
00218     Note:  All action is performed on process 0
00219   */
00220       
00221   int PerformSymbolicFactorization(); 
00222 
00223   /*
00224     PerformNumericFactorization - Call Paraklete to perform numeric factorization
00225     Preconditions:
00226       UseDataInPlace_ must be set 
00227       Ap, Ai and Aval point to a compressed row storage version of the input matrix A.
00228       Symbolic must be set
00229     Postconditions:
00230       Numeric points to an PARAKLETE internal opaque object containing the
00231         numeric factorization and accompanying information.  
00232       NumericFactorizationOK_ = true; 
00233     Note:  All action is performed on process 0
00234   */
00235   int PerformNumericFactorization(); 
00236 
00237   // @}
00238 
00239   bool IamInGroup_;  // True if this process is involved in the computation.  Set by SymbolicFactorization
00240   
00241   int SerialXlda_ ;
00242   //
00243   //  PrivateParakleteData_ contains pointers to data needed by paraklete whose
00244   //  data structures are defined by paraklete.h
00245   //
00246   Teuchos::RCP<Amesos_Paraklete_Pimpl> PrivateParakleteData_; 
00247   Teuchos::RCP<Amesos_StandardIndex> StdIndex_; 
00248   Teuchos::RCP<Amesos_StandardIndex> StdIndexRange_; 
00249   Teuchos::RCP<Amesos_StandardIndex> StdIndexDomain_; 
00250   MPI_Comm ParakleteComm_;
00251 
00256   std::vector <long> Ap;
00257   std::vector <long> Ai;
00258   std::vector <double> VecAval;
00259   double* Aval;
00260 
00262   int UseDataInPlace_;
00264   int numentries_;
00266   int NumGlobalElements_;
00267 
00269   Epetra_RowMatrix* RowMatrixA_;
00271   Epetra_CrsMatrix* CrsMatrixA_;
00272   //
00273   //  transposer_ transposes a CrsMatrix 
00274   //  Created in CreateLocalMatrixAndExporters
00275   //  Used in ExportToSerial()
00276   //
00277 #ifdef HAVE_AMESOS_EPETRAEXT
00278   Teuchos::RCP<EpetraExt::RowMatrix_Transpose> transposer_;
00279 #endif
00280 
00281   Teuchos::RCP<Epetra_Map> SerialMap_;
00283   Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrixA_;
00285   Epetra_RowMatrix* StdIndexMatrix_ ; 
00286   Epetra_MultiVector* StdIndexDomainVector_ ; 
00287   Epetra_MultiVector* StdIndexRangeVector_ ; 
00289   Epetra_RowMatrix* SerialMatrix_ ; 
00290 
00292   //  serially, StorageOptimized, the LHS and RHS are assumed to be available 
00293   //  when SymbolicFactorization is called and not to change (address or number
00294   //  of vectors) thereafter.  
00295   bool TrustMe_;
00297   int NumVectors_; 
00299   double *SerialXBvalues_ ;
00300   double *SerialBvalues_ ;
00302   Epetra_MultiVector* SerialB_ ;
00303   Epetra_MultiVector* SerialX_ ;
00305   Teuchos::RCP<Epetra_MultiVector> SerialXextract_;
00306   Teuchos::RCP<Epetra_MultiVector> SerialBextract_;
00307 
00309   bool UseTranspose_;
00311   const Epetra_LinearProblem * Problem_;
00312 
00314   std::vector<int> ColIndicesV_;
00316   std::vector<double> RowValuesV_;
00318   Teuchos::RCP<Epetra_Import> ImportToSerial_;
00319   Teuchos::RCP<Epetra_Import> ImportRangeToSerial_;
00320   Teuchos::RCP<Epetra_Import> ImportDomainToSerial_;
00321  
00323   int MtxConvTime_, MtxRedistTime_, VecRedistTime_;
00324   int SymFactTime_, NumFactTime_, SolveTime_, OverheadTime_;
00325  
00326 };  // class Amesos_Paraklete  
00327 
00328 #endif /* AMESOS_PARAKLETE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines