00001 
00002 
00003  
00004 
00005 #ifndef PLAYA_EPETRAMATRIX_HPP
00006 #define PLAYA_EPETRAMATRIX_HPP
00007 
00008 #include "PlayaLoadableMatrix.hpp"
00009 #include "PlayaLinearOperatorDecl.hpp"
00010 #include "PlayaLinearOpWithSpacesDecl.hpp"
00011 #include "PlayaRowAccessibleOp.hpp"
00012 #include "PlayaPrintable.hpp"
00013 #include "PlayaILUFactorizableOp.hpp"
00014 #include "Epetra_CrsMatrix.h"
00015 #include "PlayaLinearOpWithSpacesDecl.hpp"
00016 
00017 namespace Playa
00018 {
00019 using namespace Teuchos;
00020 
00021 
00022 
00023 
00024 class EpetraMatrix : public LinearOpWithSpaces<double>,
00025                      public LoadableMatrix<double>,
00026                      public RowAccessibleOp<double>,
00027                      public Printable,
00028                      public ILUFactorizableOp<double>
00029 {
00030 public:
00031 
00032 
00033 
00034   EpetraMatrix(const Epetra_CrsGraph& graph,
00035     const VectorSpace<double>& domain,
00036     const VectorSpace<double>& range);
00037 
00038 
00039   EpetraMatrix(const RCP<Epetra_CrsMatrix>& mat,
00040     const VectorSpace<double>& domain,
00041     const VectorSpace<double>& range);
00042 
00043 
00044   virtual void apply(
00045     Teuchos::ETransp applyType,
00046     const Vector<double>& in,
00047     Vector<double> out) const ;
00048   
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064   virtual void addToRow(int globalRowIndex,
00065     int nElemsToInsert,
00066     const int* globalColumnIndices,
00067     const double* elementValues) ;
00068 
00069 
00070 
00071 
00072 
00073   virtual void addToElementBatch(int numRows, 
00074     int rowBlockSize,
00075     const int* globalRowIndices,
00076     int numColumnsPerRow,
00077     const int* globalColumnIndices,
00078     const double* values,
00079     const int* skipRow);
00080 
00081 
00082   virtual void zero() ;
00083   
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100   virtual void getILUKPreconditioner(int fillLevels,
00101     int overlapFill,
00102     double relaxationValue,
00103     double relativeThreshold,
00104     double absoluteThreshold,
00105     LeftOrRight leftOrRight,
00106     Preconditioner<double>& rtn) const ;
00107 
00108 
00109   
00110 
00111 
00112 
00113   void getRow(const int& row, 
00114     Teuchos::Array<int>& indices, 
00115     Teuchos::Array<double>& values) const;
00116 
00117   
00118 
00119 
00120 
00121 
00122   virtual void print(std::ostream& os) const ;
00123 
00124 
00125 
00126   std::ostream& describe(
00127     std::ostream                         &out
00128     ,const Teuchos::EVerbosityLevel      verbLevel
00129     ,const std::string                   leadingIndent
00130     , const std::string                   indentSpacer
00131     ) const 
00132     {
00133       out << leadingIndent << indentSpacer << this->description() << std::endl;
00134       return out;
00135     }
00136 
00137   std::string description() const ;
00138 
00139 
00140 
00141   static Epetra_CrsMatrix& getConcrete(const LinearOperator<double>& A);
00142 
00143 
00144   static RCP<const Epetra_CrsMatrix> getConcretePtr(const LinearOperator<double>& A);
00145 
00146 
00147 
00148 
00149   const Epetra_CrsMatrix* crsMatrix() const ;
00150 
00151 private:
00152 
00153   Epetra_CrsMatrix* crsMatrix();
00154 
00155   RCP<Epetra_CrsMatrix> matrix_;
00156 
00157   const Epetra_Map& getRangeMap() const;
00158   const Epetra_Map& getDomainMap() const;
00159 };
00160 
00161   
00162 
00163 }
00164 
00165 #endif