Amesos Package Browser (Single Doxygen Collection) Development
Amesos_CSparse.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 #ifndef AMESOS_CSPARSE_H
00030 #define AMESOS_CSPARSE_H
00031 
00032 #include "Amesos_ConfigDefs.h"
00033 #include "Amesos_BaseSolver.h"
00034 #include "Amesos_NoCopiable.h"
00035 #include "Amesos_Utils.h"
00036 #include "Amesos_Time.h"
00037 #include "Amesos_Status.h"
00038 #include "Amesos_Control.h"
00039 #include "Amesos_Support.h"
00040 #include "Epetra_LinearProblem.h"
00041 #include "Epetra_Time.h"
00042 #include "Epetra_Map.h"
00043 #include "Epetra_Import.h"
00044 #include "Epetra_Comm.h"
00045 #include "Epetra_RowMatrix.h"
00046 #include "Epetra_CrsMatrix.h"
00047 #include "Teuchos_ParameterList.hpp"
00048 #include "Teuchos_RCP.hpp"
00049 
00050 #ifdef HAVE_AMESOS_CSPARSE
00051 #include "cs.h"
00052 #endif
00053 
00055 
00062 class Amesos_CSparse: public Amesos_BaseSolver, 
00063                       private Amesos_Time, 
00064                       private Amesos_NoCopiable, 
00065                       private Amesos_Utils, 
00066                       private Amesos_Control, 
00067                       private Amesos_Status { 
00068 
00069 public: 
00070 
00072 
00073   Amesos_CSparse(const Epetra_LinearProblem& LinearProblem );
00074 
00076   ~Amesos_CSparse();
00078 
00080 
00082   int SymbolicFactorization() ;
00083 
00085   int NumericFactorization() ;
00086 
00088   int Solve();
00090   
00092 
00094   const Epetra_LinearProblem* GetProblem() const { return(Problem_); }
00095 
00097 
00100   bool MatrixShapeOK() const;
00101 
00103 
00107   int SetUseTranspose(bool UseTranspose) { UseTranspose_ = UseTranspose; return(0); }
00108 
00110   bool UseTranspose() const { return(UseTranspose_); }
00111 
00113   const Epetra_Comm& Comm() const { return(GetProblem()->GetOperator()->Comm()); }
00114 
00116   int SetParameters( Teuchos::ParameterList &ParameterList );
00117 
00119   int NumSymbolicFact() const { return( Amesos_Status::NumSymbolicFact_ ); }
00120 
00122   int NumNumericFact() const { return( Amesos_Status::NumNumericFact_ ); }
00123 
00125   int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
00126 
00128   void PrintTiming() const;
00129   
00131   void PrintStatus() const;
00132 
00134   void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
00135  
00137 
00138 private:  
00139   
00140   int CheckError(const int error) const;
00141 
00142   inline const Epetra_Map& Map() const
00143   {
00144     return(Matrix_->RowMatrixRowMap());
00145   }
00146   
00147   inline const Epetra_RowMatrix& Matrix() const
00148   {
00149     return(*Matrix_);
00150   }
00151 
00152   inline Epetra_Map& SerialMap() 
00153   {
00154     return(*(SerialMap_.get()));
00155   }
00156   
00157   inline Epetra_RowMatrix& SerialMatrix()
00158   {
00159     return(*(SerialMatrix_.get()));
00160   }
00161 
00162   inline Epetra_CrsMatrix& SerialCrsMatrix()
00163   {
00164     return(*(SerialCrsMatrix_.get()));
00165   }
00166 
00167   inline Epetra_Import& Importer()
00168   {
00169     return(*(Importer_.get()));
00170   }
00171   
00172   int ConvertToSerial();
00173   int ConvertToCSparse();
00174   int PerformSymbolicFactorization();
00175   int PerformNumericFactorization(); 
00176 
00177   Teuchos::RCP<Epetra_Map> SerialMap_;
00178   Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrix_;
00179   Teuchos::RCP<Epetra_RowMatrix> SerialMatrix_;
00180   Teuchos::RCP<Epetra_Import> Importer_;
00181   Teuchos::RCP<Amesos_StandardIndex> StdIndex_; 
00182   Teuchos::RCP<Amesos_StandardIndex> StdIndexRange_; 
00183   Teuchos::RCP<Amesos_StandardIndex> StdIndexDomain_; 
00184 
00185   const Epetra_Map* Map_;
00186   const Epetra_RowMatrix* Matrix_;
00187 
00189   bool UseTranspose_;
00191   const Epetra_LinearProblem* Problem_;
00192 
00194   int MtxConvTime_, MtxRedistTime_, VecRedistTime_;
00195   int SymFactTime_, NumFactTime_, SolveTime_;
00196 
00197   // Data for CSparse
00198   cs csMatrix;
00199   cs *csTranMatrix;
00200   css *csSymbolic;
00201   csn *csNumeric;
00202 
00203   //int mtype_;
00204   //void* pt_[64];
00205 
00206   //int iparm_[64];
00207   //int maxfct_; // Maximal number of factors with idential nonzero pattern (always 1)
00208   //int mnum_; //! Actual matrix for solution phase (always 1)
00209   //int msglvl_; //! Output level
00210   //int nrhs_; // Number of RHS
00211 
00212 };  // class Amesos_CSparse  
00213 #endif // AMESOS_CSPARSE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines