00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef EPETRAEXT_MMHELPERS_H
00030 #define EPETRAEXT_MMHELPERS_H
00031
00032 #include <EpetraExt_ConfigDefs.h>
00033 #include <set>
00034 #include <map>
00035
00036 class Epetra_Map;
00037 class Epetra_CrsMatrix;
00038
00039 namespace EpetraExt {
00040
00041
00042
00043
00044 class CrsMatrixStruct {
00045 public:
00046 CrsMatrixStruct();
00047
00048 virtual ~CrsMatrixStruct();
00049
00050 void deleteContents();
00051
00052 int numRows;
00053 int* numEntriesPerRow;
00054 int** indices;
00055 double** values;
00056 bool* remote;
00057 int numRemote;
00058 const Epetra_Map* origRowMap;
00059 const Epetra_Map* rowMap;
00060 const Epetra_Map* colMap;
00061 const Epetra_Map* domainMap;
00062 const Epetra_Map* importColMap;
00063 Epetra_CrsMatrix* importMatrix;
00064 };
00065
00066 int dumpCrsMatrixStruct(const CrsMatrixStruct& M);
00067
00068 class CrsWrapper {
00069 public:
00070 virtual ~CrsWrapper(){}
00071
00072 virtual const Epetra_Map& RowMap() const = 0;
00073
00074 virtual bool Filled() = 0;
00075
00076 virtual int InsertGlobalValues(int GlobalRow, int NumEntries, double* Values, int* Indices) = 0;
00077
00078 virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, double* Values, int* Indices) = 0;
00079 };
00080
00081 class CrsWrapper_Epetra_CrsMatrix : public CrsWrapper {
00082 public:
00083 CrsWrapper_Epetra_CrsMatrix(Epetra_CrsMatrix& epetracrsmatrix);
00084 virtual ~CrsWrapper_Epetra_CrsMatrix();
00085
00086 const Epetra_Map& RowMap() const;
00087
00088 bool Filled();
00089
00090 int InsertGlobalValues(int GlobalRow, int NumEntries, double* Values, int* Indices);
00091 int SumIntoGlobalValues(int GlobalRow, int NumEntries, double* Values, int* Indices);
00092
00093 private:
00094 Epetra_CrsMatrix& ecrsmat_;
00095 };
00096
00097 class CrsWrapper_GraphBuilder : public CrsWrapper {
00098 public:
00099 CrsWrapper_GraphBuilder(const Epetra_Map& emap);
00100 virtual ~CrsWrapper_GraphBuilder();
00101
00102 const Epetra_Map& RowMap() const {return rowmap_; }
00103
00104 bool Filled();
00105
00106 int InsertGlobalValues(int GlobalRow, int NumEntries, double* Values, int* Indices);
00107 int SumIntoGlobalValues(int GlobalRow, int NumEntries, double* Values, int* Indices);
00108
00109 std::map<int,std::set<int>*>& get_graph();
00110
00111 int get_max_row_length() { return max_row_length_; }
00112
00113 private:
00114 std::map<int,std::set<int>*> graph_;
00115 const Epetra_Map& rowmap_;
00116 int max_row_length_;
00117 };
00118
00119 void insert_matrix_locations(CrsWrapper_GraphBuilder& graphbuilder,
00120 Epetra_CrsMatrix& C);
00121
00122 }
00123
00124 #endif
00125