42 #ifndef EPETRAEXT_MMHELPERS_H 43 #define EPETRAEXT_MMHELPERS_H 46 #include "Epetra_ConfigDefs.h" 47 #include "Epetra_DistObject.h" 48 #include "Epetra_Map.h" 49 #include "Teuchos_RCP.hpp" 56 class Epetra_CrsMatrix;
58 class Epetra_Distributor;
61 class LightweightCrsMatrix;
108 virtual const Epetra_Map& RowMap()
const = 0;
110 virtual bool Filled() = 0;
112 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 113 virtual int InsertGlobalValues(
int GlobalRow,
int NumEntries,
double* Values,
int* Indices) = 0;
115 virtual int SumIntoGlobalValues(
int GlobalRow,
int NumEntries,
double* Values,
int* Indices) = 0;
118 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 119 virtual int InsertGlobalValues(
long long GlobalRow,
int NumEntries,
double* Values,
long long* Indices) = 0;
121 virtual int SumIntoGlobalValues(
long long GlobalRow,
int NumEntries,
double* Values,
long long* Indices) = 0;
131 const Epetra_Map& RowMap()
const;
135 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 136 int InsertGlobalValues(
int GlobalRow,
int NumEntries,
double* Values,
int* Indices);
137 int SumIntoGlobalValues(
int GlobalRow,
int NumEntries,
double* Values,
int* Indices);
140 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 141 int InsertGlobalValues(
long long GlobalRow,
int NumEntries,
double* Values,
long long* Indices);
142 int SumIntoGlobalValues(
long long GlobalRow,
int NumEntries,
double* Values,
long long* Indices);
146 Epetra_CrsMatrix& ecrsmat_;
150 template<
typename int_type>
156 const Epetra_Map&
RowMap()
const {
return rowmap_; }
160 int InsertGlobalValues(int_type GlobalRow,
int NumEntries,
double* Values, int_type* Indices);
161 int SumIntoGlobalValues(int_type GlobalRow,
int NumEntries,
double* Values, int_type* Indices);
163 std::map<int_type,std::set<int_type>*>& get_graph();
168 std::map<int_type,std::set<int_type>*> graph_;
169 const Epetra_Map& rowmap_;
174 template<
typename int_type>
176 Epetra_CrsMatrix& C);
178 template<
typename int_type>
180 const std::vector<int_type>& proc_col_ranges,
181 std::vector<int_type>& send_rows,
182 std::vector<int>& rows_per_send_proc);
184 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 186 const std::vector<int>& proc_col_ranges,
187 std::vector<int>& send_rows,
188 std::vector<int>& rows_per_send_proc);
191 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 193 const std::vector<long long>& proc_col_ranges,
194 std::vector<long long>& send_rows,
195 std::vector<int>& rows_per_send_proc);
198 template<
typename int_type>
199 std::pair<int_type,int_type>
get_col_range(
const Epetra_Map& emap);
201 template<
typename int_type>
202 std::pair<int_type,int_type>
get_col_range(
const Epetra_CrsMatrix& mtx);
211 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 215 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 228 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 229 LightweightMap(
int NumGlobalElements,
int NumMyElements,
const int * MyGlobalElements,
int IndexBase,
bool GenerateHash=
true);
231 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 232 LightweightMap(
long long NumGlobalElements,
int NumMyElements,
const long long * MyGlobalElements,
int IndexBase,
bool GenerateHash=
true);
233 LightweightMap(
long long NumGlobalElements,
int NumMyElements,
const long long * MyGlobalElements,
long long IndexBase,
bool GenerateHash=
true);
240 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 241 int LID(
int GID)
const;
242 int GID(
int LID)
const;
245 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 246 int LID(
long long GID)
const;
248 long long GID64(
int LID)
const;
249 int NumMyElements()
const;
251 #if defined(EPETRA_NO_32BIT_GLOBAL_INDICES) && defined(EPETRA_NO_64BIT_GLOBAL_INDICES) 254 int LID(
long long GID)
const {
return -1; }
257 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 258 int* MyGlobalElements()
const;
260 if(IndexBase64() == (
long long) static_cast<int>(IndexBase64()))
261 return (
int) IndexBase64();
262 throw "EpetraExt::LightweightMap::IndexBase: IndexBase cannot fit an int.";
264 void MyGlobalElementsPtr(
int *& MyGlobalElementList)
const;
267 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 268 long long* MyGlobalElements64()
const;
269 void MyGlobalElementsPtr(
long long *& MyGlobalElementList)
const;
285 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 286 void Construct_int(
int NumGlobalElements,
int NumMyElements,
const int * MyGlobalElements,
long long IndexBase,
bool GenerateHash=
true);
288 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 289 void Construct_LL(
long long NumGlobalElements,
int NumMyElements,
const long long * MyGlobalElements,
long long IndexBase,
bool GenerateHash=
true);
322 const Epetra_BlockMap &
SourceMap()
const {
return *SourceMap_;}
332 Epetra_Distributor* Distor_;
333 const Epetra_BlockMap* SourceMap_;
349 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 371 template <
typename ImportType,
typename int_type>
372 void Construct(
const Epetra_CrsMatrix & A, ImportType & RowImporter);
376 int MakeColMapAndReindex(std::vector<int> owningPIDs,std::vector<GO> Gcolind);
378 template<
typename int_type>
379 std::vector<int_type>& getcolind();
381 template<
typename ImportType,
typename int_type>
382 int PackAndPrepareReverseComm(
const Epetra_CrsMatrix & SourceMatrix, ImportType & RowImporter,
383 std::vector<int> &ReverseSendSizes, std::vector<int_type> &ReverseSendBuffer);
385 template<
typename ImportType,
typename int_type>
386 int MakeExportLists(
const Epetra_CrsMatrix & SourceMatrix, ImportType & RowImporter,
387 std::vector<int> &ReverseRecvSizes,
const int_type *ReverseRecvBuffer,
388 std::vector<int> & ExportPIDs, std::vector<int> & ExportLIDs);
392 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 393 template<>
inline std::vector<int>& LightweightCrsMatrix::getcolind() {
return colind_; }
395 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 396 template<>
inline std::vector<long long>& LightweightCrsMatrix::getcolind() {
return colind_LL_; }
LightweightCrsMatrix * importMatrix
Epetra_HashTable< long long > * LIDHash_LL_
Epetra_BlockMap * RowMapEP_
std::vector< int > targetMapToOrigRow
LightweightMap * RowMapLW_
void pack_outgoing_rows(const Epetra_CrsMatrix &mtx, const std::vector< int > &proc_col_ranges, std::vector< int > &send_rows, std::vector< int > &rows_per_send_proc)
const Epetra_Map * rowMap
std::vector< int > colind_
std::vector< int > ExportPIDs_
const Epetra_CrsMatrix * origMatrix
const Epetra_Map & RowMap() const
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
const Epetra_Map * origRowMap
std::vector< int > targetMapToImportRow
const Epetra_Map * domainMap
std::vector< double > vals_
std::vector< int > MyGlobalElements_int_
const Epetra_BlockMap & SourceMap() const
long long IndexBase64() const
const LightweightMap & TargetMap() const
void Tpack_outgoing_rows(const Epetra_CrsMatrix &mtx, const std::vector< int_type > &proc_col_ranges, std::vector< int_type > &send_rows, std::vector< int > &rows_per_send_proc)
virtual ~CrsMatrixStruct()
bool GlobalIndicesInt() const
Epetra_HashTable< int > * LIDHash_int_
std::vector< long long > MyGlobalElements_LL_
Epetra_Distributor & Distributor()
std::vector< int > ColMapOwningPIDs_
std::vector< int > ExportLIDs_
std::vector< int > rowptr_
const Epetra_Map * colMap
const Epetra_BlockMap * importColMap
void insert_matrix_locations(CrsWrapper_GraphBuilder< int_type > &graphbuilder, Epetra_CrsMatrix &C)
int dumpCrsMatrixStruct(const CrsMatrixStruct &M)
std::vector< long long > colind_LL_
bool GlobalIndicesLongLong() const
std::pair< int_type, int_type > get_col_range(const Epetra_Map &emap)