41 #include "Epetra_ConfigDefs.h" 
   44 #include "Epetra_Comm.h" 
   45 #include "Epetra_BlockMap.h" 
   46 #include "Epetra_Map.h" 
   47 #include "Epetra_IntVector.h" 
   48 #include "Epetra_LongLongVector.h" 
   49 #include "Epetra_GIDTypeVector.h" 
   50 #include "Epetra_IntSerialDenseVector.h" 
   51 #include "Epetra_LongLongSerialDenseVector.h" 
   52 #include "Epetra_GIDTypeSerialDenseVector.h" 
   53 #include "Epetra_Import.h" 
   55 using namespace EpetraExt;
 
   60          const char *mapDescription, 
 
   62   long long M = map.NumGlobalElements64();
 
   70     handle = fopen(filename,
"w");
 
   71     if (!handle) 
return(-1);
 
   78     if (writeHeader==
true) { 
 
   82       if (mapName!=0) fprintf(handle, 
"%% \n%% %s\n", mapName);
 
   83       if (mapDescription!=0) fprintf(handle, 
"%% %s\n%% \n", mapDescription);
 
   88   if (writeHeader==
true) { 
 
  101     if (v2.Import(v1, lengthImporter, 
Insert)) 
return(-1);
 
  103       fprintf(handle, 
"%s", 
"%Format Version:\n");
 
  106       fprintf(handle, 
"%s", 
"%NumProc: Number of processors:\n");
 
  108       fprintf(handle, 
"%s", 
"%MaxElementSize: Maximum element size:\n");
 
  110       fprintf(handle, 
"%s", 
"%MinElementSize: Minimum element size:\n");
 
  112       fprintf(handle, 
"%s", 
"%IndexBase: Index base of map:\n");
 
  113       fprintf(handle, 
"%% %lld \n", map.IndexBase64());
 
  114       fprintf(handle, 
"%s", 
"%NumGlobalElements: Total number of GIDs in map:\n");
 
  115       fprintf(handle, 
"%% %lld \n", map.NumGlobalElements64());
 
  116       fprintf(handle, 
"%s", 
"%NumMyElements: BlockMap lengths per processor:\n");
 
  117       for ( 
int i=0; i< v2.
MyLength(); i++) fprintf(handle, 
"%% %d\n", v2[i]);
 
  125     if (fclose(handle)) 
return(-1);
 
  129 template<
typename int_type>
 
  137     int_type * myElements = 0;
 
  138   map.MyGlobalElementsPtr(myElements);
 
  139     int * elementSizeList = 0;
 
  141     return(
writeBlockMap(handle, map.NumGlobalElements64(), myElements, elementSizeList, doSizes));
 
  146   Epetra_Map allGidsMap((int_type) -1, numRows, (int_type) 0,comm);
 
  149   for (
int i=0; i<numRows; i++) allGids[i] = (int_type) map.GID64(i);
 
  152   for (
int i=0; i<numRows; i++) allSizes[i] = map.
ElementSize(i);
 
  155   int numChunks = numProc;
 
  156   int stripSize = allGids.GlobalLength64()/numChunks;
 
  157   int remainder = allGids.GlobalLength64()%numChunks;
 
  159   int curStripSize = 0;
 
  162   if (comm.
MyPID()==0) {
 
  163     importGidList.Size(stripSize+1); 
 
  164     if (doSizes) importSizeList.
Size(stripSize+1); 
 
  166   for (
int i=0; i<numChunks; i++) {
 
  167     if (comm.
MyPID()==0) { 
 
  168       curStripSize = stripSize;
 
  169       if (i<remainder) curStripSize++; 
 
  170       for (
int j=0; j<curStripSize; j++) importGidList[j] = j + curStart;
 
  171       curStart += curStripSize;
 
  174     Epetra_Map importGidMap((int_type) -1, curStripSize, importGidList.Values(), 0, comm);
 
  178     if (importGids.Import(allGids, gidImporter, 
Insert)) 
return(-1); 
 
  180     if (doSizes) 
if (importSizes.Import(allSizes, gidImporter, 
Insert)) 
return(-1); 
 
  185     int_type * myElements = importGids.Values();
 
  186     int * elementSizeList = 0;
 
  187     if (doSizes) elementSizeList = importSizes.
Values();
 
  189     writeBlockMap(handle, importGids.MyLength(), myElements, elementSizeList, doSizes);
 
  195 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  197     return TBlockMapToHandle<int>(handle, map);
 
  201 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 
  203     return TBlockMapToHandle<long long>(handle, map);
 
  207     throw "EpetraExt::BlockMapToHandle: GlobalIndices type unknown";
 
  210 int writeBlockMap(FILE * handle, 
long long length, 
const int * v1, 
const int * v2, 
bool doSizes) {
 
  212   for (
long long i=0; i<length; i++) {
 
  213     fprintf(handle, 
"%d", v1[i]);
 
  214     if (doSizes) fprintf(handle, 
" %d", v2[i]);
 
  215     fprintf(handle, 
"%s", 
"\n");
 
  220 int writeBlockMap(FILE * handle, 
long long length, 
const long long * v1, 
const int * v2, 
bool doSizes) {
 
  222   for (
long long i=0; i<length; i++) {
 
  223     fprintf(handle, 
"%lld", v1[i]);
 
  224     if (doSizes) fprintf(handle, 
" %d", v2[i]);
 
  225     fprintf(handle, 
"%s", 
"\n");
 
int writeBlockMap(FILE *handle, long long length, const int *v1, const int *v2, bool doSizes)
 
bool GlobalIndicesLongLong() const 
 
int BlockMapToMatrixMarketFile(const char *filename, const Epetra_BlockMap &map, const char *mapName, const char *mapDescription, bool writeHeader)
Writes an Epetra_BlockMap or Epetra_Map object to a Matrix Market format file. 
 
#define mm_set_matrix(typecode)
 
bool ConstantElementSize() const 
 
int mm_write_banner(FILE *f, MM_typecode matcode)
 
#define mm_set_integer(typecode)
 
bool GlobalIndicesInt() const 
 
virtual int MyPID() const =0
 
int NumMyElements() const 
 
int * ElementSizeList() const 
 
int BlockMapToHandle(FILE *handle, const Epetra_BlockMap &map)
 
const Epetra_Comm & Comm() const 
 
virtual int NumProc() const =0
 
int TBlockMapToHandle(FILE *handle, const Epetra_BlockMap &map)
 
int MaxElementSize() const 
 
#define mm_set_array(typecode)
 
int mm_write_mtx_array_size(FILE *f, long long M, long long N)
 
#define mm_initialize_typecode(typecode)
 
int MinElementSize() const