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) {
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);
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);
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.