|
EpetraExt Development
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // EpetraExt: Epetra Extended - Linear Algebra Services Package 00005 // Copyright (2001) 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 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 //struct that holds views of the contents of a CrsMatrix. These 00042 //contents may be a mixture of local and remote rows of the 00043 //actual matrix. 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 }//namespace EpetraExt 00123 00124 #endif 00125
1.7.4