42 #ifndef EPETRAEXT_MMHELPERS_H 
   43 #define EPETRAEXT_MMHELPERS_H 
   63 class LightweightCrsMatrix;
 
  115   virtual bool Filled() = 0;
 
  117 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  118   virtual int InsertGlobalValues(
int GlobalRow, 
int NumEntries, 
double* Values, 
int* Indices) = 0;
 
  120   virtual int SumIntoGlobalValues(
int GlobalRow, 
int NumEntries, 
double* Values, 
int* Indices) = 0;
 
  123 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  124   virtual int InsertGlobalValues(
long long GlobalRow, 
int NumEntries, 
double* Values, 
long long* Indices) = 0;
 
  126   virtual int SumIntoGlobalValues(
long long GlobalRow, 
int NumEntries, 
double* Values, 
long long* Indices) = 0;
 
  140 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  145 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  146   int InsertGlobalValues(
long long GlobalRow, 
int NumEntries, 
double* Values, 
long long* Indices);
 
  147   int SumIntoGlobalValues(
long long GlobalRow, 
int NumEntries, 
double* Values, 
long long* Indices);
 
  155 template<
typename int_type>
 
  165   int InsertGlobalValues(int_type GlobalRow, 
int NumEntries, 
double* Values, int_type* Indices);
 
  166   int SumIntoGlobalValues(int_type GlobalRow, 
int NumEntries, 
double* Values, int_type* Indices);
 
  168   std::map<int_type,std::set<int_type>*>& 
get_graph();
 
  173   std::map<int_type,std::set<int_type>*> 
graph_;
 
  179 template<
typename int_type>
 
  183 template<
typename int_type>
 
  185                         const std::vector<int_type>& proc_col_ranges,
 
  186                         std::vector<int_type>& send_rows,
 
  187                         std::vector<int>& rows_per_send_proc);
 
  189 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  191                         const std::vector<int>& proc_col_ranges,
 
  192                         std::vector<int>& send_rows,
 
  193                         std::vector<int>& rows_per_send_proc);
 
  196 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  198                         const std::vector<long long>& proc_col_ranges,
 
  199                         std::vector<long long>& send_rows,
 
  200                         std::vector<int>& rows_per_send_proc);
 
  203 template<
typename int_type>
 
  206 template<
typename int_type>
 
  216 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  220 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  233 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  236 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  237   LightweightMap(
long long NumGlobalElements,
int NumMyElements, 
const long long * MyGlobalElements, 
int IndexBase, 
bool GenerateHash=
true);
 
  238   LightweightMap(
long long NumGlobalElements,
int NumMyElements, 
const long long * MyGlobalElements, 
long long IndexBase, 
bool GenerateHash=
true);
 
  245 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  247   int GID(
int LID) 
const;      
 
  250 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  251   int  LID(
long long GID) 
const;
 
  253   long long GID64(
int LID) 
const;
 
  256 #if defined(EPETRA_NO_32BIT_GLOBAL_INDICES) && defined(EPETRA_NO_64BIT_GLOBAL_INDICES) 
  259   int  LID(
long long GID)
 const { 
return -1; }
 
  262 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  267     throw "EpetraExt::LightweightMap::IndexBase: IndexBase cannot fit an int.";
 
  272 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  290 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  291   void Construct_int(
int NumGlobalElements,
int NumMyElements, 
const int * MyGlobalElements, 
long long IndexBase, 
bool GenerateHash=
true);
 
  293 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  294   void Construct_LL(
long long NumGlobalElements,
int NumMyElements, 
const long long * MyGlobalElements, 
long long IndexBase, 
bool GenerateHash=
true);
 
  354 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  376   template <
typename ImportType, 
typename int_type>
 
  381     int MakeColMapAndReindex(std::vector<int> owningPIDs,std::vector<GO> Gcolind,
bool SortGhosts=
false, 
const char * label=0);
 
  383   template<
typename int_type>
 
  386   template<
typename ImportType, 
typename int_type>
 
  388         std::vector<int> &ReverseSendSizes, std::vector<int_type> &ReverseSendBuffer);
 
  390   template<
typename ImportType, 
typename int_type>
 
  392           std::vector<int> &ReverseRecvSizes, 
const int_type *ReverseRecvBuffer,
 
  393           std::vector<int> & ExportPIDs, std::vector<int> & ExportLIDs);
 
  397 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  400 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  405 template<
typename int_type>
 
  409                 const Epetra_Import * prototypeImporter=0,
bool SortGhosts=
false,
 
  410     const char * label=0)
 
  421 #ifdef ENABLE_MMM_TIMINGS 
  423   if(label) tpref = std::string(label);
 
  436   Mview.
rowMap       = &targetMap;
 
  445   if(Mrowmap.
SameAs(targetMap)) {
 
  451   else if(prototypeImporter && prototypeImporter->SourceMap().SameAs(M.
RowMap()) && prototypeImporter->TargetMap().SameAs(targetMap)){
 
  452     numRemote = prototypeImporter->NumRemoteIDs();
 
  457     const int * PermuteToLIDs   = prototypeImporter->PermuteToLIDs();
 
  458     const int * PermuteFromLIDs = prototypeImporter->PermuteFromLIDs();
 
  459     const int * RemoteLIDs      = prototypeImporter->RemoteLIDs();
 
  461     for(i=0; i<prototypeImporter->NumSameIDs();i++)
 
  465     for(i=0; i<prototypeImporter->NumPermuteIDs();i++)
 
  468     for(i=0; i<prototypeImporter->NumRemoteIDs();i++)
 
  473     throw std::runtime_error(
"import_only: This routine only works if you either have the right map or no prototypeImporter");
 
  477       std::cerr << 
"EpetraExt::MatrixMatrix::Multiply ERROR, numProcs < 2 but " 
  478            << 
"attempting to import remote matrix rows."<<std::endl;
 
  486 #ifdef ENABLE_MMM_TIMINGS 
  487   MM = 
Teuchos::rcp(
new TimeMonitor(*TimeMonitor::getNewTimer(tpref + std::string(
"EpetraExt: MMM Ionly Import-1"))));
 
  489   const int * RemoteLIDs = prototypeImporter->RemoteLIDs();
 
  492   int_type* MremoteRows = numRemote>0 ? 
new int_type[prototypeImporter->NumRemoteIDs()] : 0;
 
  493   for(i=0; i<prototypeImporter->NumRemoteIDs(); i++)
 
  494     MremoteRows[i] = (int_type) targetMap.
GID64(RemoteLIDs[i]);
 
  498 #ifdef ENABLE_MMM_TIMINGS 
  499   MM = 
Teuchos::rcp(
new TimeMonitor(*TimeMonitor::getNewTimer(tpref + std::string(
"EpetraExt: MMM Ionly Import-2"))));
 
  506 #ifdef ENABLE_MMM_TIMINGS 
  507   MM = 
Teuchos::rcp(
new TimeMonitor(*TimeMonitor::getNewTimer(tpref + std::string(
"EpetraExt: MMM Ionly Import-3"))));
 
  512 #ifdef ENABLE_MMM_TIMINGS 
  513   MM = 
Teuchos::rcp(
new TimeMonitor(*TimeMonitor::getNewTimer(tpref + std::string(
"EpetraExt: MMM Ionly Import-4"))));
 
  516 #ifdef ENABLE_MMM_STATISTICS 
  522   delete [] MremoteRows;
 
int SumIntoGlobalValues(int_type GlobalRow, int NumEntries, double *Values, int_type *Indices)
void Construct_int(int NumGlobalElements, int NumMyElements, const int *MyGlobalElements, long long IndexBase, bool GenerateHash=true)
LightweightCrsMatrix * importMatrix
const LightweightMap * TargetMap_
RemoteOnlyImport(const Epetra_Import &Importer, LightweightMap &RemoteOnlyTargetMap)
Epetra_HashTable< long long > * LIDHash_LL_
Epetra_BlockMap * RowMapEP_
std::vector< int > targetMapToOrigRow
long long * MyGlobalElements64() const 
virtual ~CrsWrapper_GraphBuilder()
virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, double *Values, int *Indices)=0
void MyGlobalElementsPtr(int *&MyGlobalElementList) const 
void PrintMultiplicationStatistics(Epetra_Import *Transfer, const std::string &label)
bool SameAs(const Epetra_BlockMap &Map) const 
long long IndexBase64() const 
int MakeColMapAndReindex(std::vector< int > owningPIDs, std::vector< GO > Gcolind, bool SortGhosts=false, const char *label=0)
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)
int PackAndPrepareReverseComm(const Epetra_CrsMatrix &SourceMatrix, ImportType &RowImporter, std::vector< int > &ReverseSendSizes, std::vector< int_type > &ReverseSendBuffer)
Epetra_CrsMatrix & ecrsmat_
const Epetra_Map * rowMap
long long GID64(int LID) const 
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, double *Values, int *Indices)=0
std::vector< int > colind_
void printMultiplicationStatistics(Epetra_Import *Transfer, const std::string &label)
const Epetra_BlockMap * SourceMap_
std::vector< int > ExportPIDs_
const Epetra_Map & ColMap() const 
const Epetra_CrsMatrix * origMatrix
const Epetra_Map & RowMap() const 
const Epetra_Map & rowmap_
const Epetra_Map & RowMap() const 
int NumMyElements() const 
const Epetra_Map * origRowMap
long long GID64(int LID) const 
int InsertGlobalValues(int GlobalRow, int NumEntries, double *Values, int *Indices)
std::vector< int > targetMapToImportRow
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual const Epetra_Map & RowMap() const =0
int NumMyElements() const 
LightweightMap & operator=(const LightweightMap &map)
LightweightMapData * Data_
virtual ~CrsWrapper_Epetra_CrsMatrix()
const Epetra_Map * domainMap
int SumIntoGlobalValues(int GlobalRow, int NumEntries, double *Values, int *Indices)
const Epetra_Map & RowMap() const 
std::vector< double > vals_
CrsWrapper_Epetra_CrsMatrix(Epetra_CrsMatrix &epetracrsmatrix)
const Epetra_Comm & Comm() const 
std::vector< int > MyGlobalElements_int_
const Epetra_BlockMap & SourceMap() const 
long long IndexBase64() const 
int * MyGlobalElements() const 
std::map< int_type, std::set< int_type > * > graph_
virtual int NumProc() const =0
const LightweightMap & TargetMap() const 
void Construct_LL(long long NumGlobalElements, int NumMyElements, const long long *MyGlobalElements, long long IndexBase, bool GenerateHash=true)
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)
CrsWrapper_GraphBuilder(const Epetra_Map &emap)
const Epetra_Map & DomainMap() const 
virtual ~CrsMatrixStruct()
bool GlobalIndicesInt() const 
Epetra_HashTable< int > * LIDHash_int_
std::vector< long long > MyGlobalElements_LL_
LightweightCrsMatrix(const Epetra_CrsMatrix &A, RemoteOnlyImport &RowImporter, bool SortGhosts=false, const char *label=0)
Epetra_Distributor & Distributor()
std::map< int_type, std::set< int_type > * > & get_graph()
std::vector< int > ColMapOwningPIDs_
std::vector< int > ExportLIDs_
std::vector< int > rowptr_
std::vector< int_type > & getcolind()
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)
int import_only(const Epetra_CrsMatrix &M, const Epetra_Map &targetMap, CrsMatrixStruct &Mview, const Epetra_Import *prototypeImporter)
int InsertGlobalValues(int_type GlobalRow, int NumEntries, double *Values, int_type *Indices)
void Construct(const Epetra_CrsMatrix &A, ImportType &RowImporter, bool SortGhosts=false, const char *label=0)
std::vector< long long > colind_LL_
bool GlobalIndicesLongLong() const 
std::pair< int_type, int_type > get_col_range(const Epetra_Map &emap)
int MakeExportLists(const Epetra_CrsMatrix &SourceMatrix, ImportType &RowImporter, std::vector< int > &ReverseRecvSizes, const int_type *ReverseRecvBuffer, std::vector< int > &ExportPIDs, std::vector< int > &ExportLIDs)
Epetra_Distributor * Distor_