59int main(
int argc,
char *argv[]) {
65 MPI_Init(&argc,&argv);
74 bool veryVerbose =
false;
77 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
80 if (argc>2)
if (argv[2][0]==
'-' && argv[2][1]==
'v') veryVerbose =
true;
82 if (verbose && Comm.
MyPID()==0)
87 if (verbose) std::cout << Comm << std::endl << std::flush;
89 bool verbose1 = verbose;
90 if (verbose) verbose = (Comm.
MyPID()==0);
92 bool veryVerbose1 = veryVerbose;
93 if (veryVerbose) veryVerbose = (Comm.
MyPID()==0);
95 int NumMyElements = 100;
96 if (veryVerbose1) NumMyElements = 10;
97 NumMyElements += Comm.
MyPID();
98 int MaxNumMyElements = NumMyElements+Comm.
NumProc()-1;
99 int * ElementSizeList =
new int[NumMyElements];
100 int * MyGlobalElements =
new int[NumMyElements];
102 for (i = 0; i<NumMyElements; i++) {
103 MyGlobalElements[i] = (Comm.
MyPID()*MaxNumMyElements+i)*2;
104 ElementSizeList[i] = i%6 + 2;
107 Epetra_BlockMap Map(-1, NumMyElements, MyGlobalElements, ElementSizeList,
110 delete [] ElementSizeList;
111 delete [] MyGlobalElements;
115 int * elementColors =
new int[NumMyElements];
118 int * colorCount =
new int[maxcolor];
119 int ** colorLIDs =
new int*[maxcolor];
120 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
121 for (i=0; i<maxcolor; i++) colorLIDs[i] = 0;
126 if (i%2==0) C0[i] = i%6+5+i%14;
127 else C0(Map.
GID(i)) = i%5+1;
128 elementColors[i] = C0[i];
133 std::cout <<
"Original Map Coloring using element-by-element definitions" << std::endl;
135 std::cout << C0 << std::endl;
138 for (i=0; i<maxcolor; i++)
139 if (colorCount[i]>0) {
141 colorLIDs[i] =
new int[colorCount[i]];
143 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
144 for (i=0; i<Map.
NumMyElements(); i++) colorLIDs[C0[i]][colorCount[C0[i]]++] = i;
148 int newDefaultColor = -1;
151 std::cout <<
"Same Map Coloring using one-time construction" << std::endl;
153 std::cout << C1 << std::endl;
159 std::cout <<
"Same Map Coloring using copy constructor" << std::endl;
161 std::cout << C1 << std::endl;
167 for (i=0; i<maxcolor; i++) {
169 assert(colorCount[i]==curNumElementsWithColor);
170 if (curNumElementsWithColor==0) {
174 for (
int j=0; j<curNumElementsWithColor; j++) assert(C2.
ColorLIDList(i)[j]==colorLIDs[i][j]);
184 assert(Map1->
GID(i)==Map.
GID(colorLIDs[curColor][i]));
185 assert(Map2->
GID(i)==Map.
GID(colorLIDs[curColor][i]));
199 int NumMyElements0 = 0;
208 elementColorValues0.
Import(elementColorValues, importer,
Insert);
218 assert(ColoringOnPE0[i]==elementColorValues0[i]);
221 std::cout <<
"Same Map Coloring on PE 0 only" << std::endl;
223 std::cout << ColoringOnPE0 << std::endl;
228 std::cout <<
"Same Map Coloring after Import/Export exercise" << std::endl;
230 std::cout << ColoringOnPE0 << std::endl;
233 if (verbose) std::cout <<
"Checked OK\n\n" << std::endl;
236 if (verbose) std::cout <<
"Test ostream << operator" << std::endl << std::flush;
237 std::cout << C0 << std::endl;
241 delete [] elementColors;
242 for (i=0; i<maxcolor; i++)
if (colorLIDs[i]!=0)
delete [] colorLIDs[i];
244 delete [] colorCount;
int main(int argc, char *argv[])