60 int main(
int argc,
char *argv[]) {
66 MPI_Init(&argc,&argv);
75 bool veryVerbose =
false;
78 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
81 if (argc>2)
if (argv[2][0]==
'-' && argv[2][1]==
'v') veryVerbose =
true;
83 if (verbose && Comm.
MyPID()==0)
88 if (verbose) std::cout << Comm << std::endl << std::flush;
90 bool verbose1 = verbose;
91 if (verbose) verbose = (Comm.
MyPID()==0);
93 bool veryVerbose1 = veryVerbose;
94 if (veryVerbose) veryVerbose = (Comm.
MyPID()==0);
96 int NumMyElements = 100;
97 if (veryVerbose1) NumMyElements = 10;
98 NumMyElements += Comm.
MyPID();
99 int MaxNumMyElements = NumMyElements+Comm.
NumProc()-1;
100 int * ElementSizeList =
new int[NumMyElements];
101 long long * MyGlobalElements =
new long long[NumMyElements];
103 for (i = 0; i<NumMyElements; i++) {
104 MyGlobalElements[i] = (
long long)(Comm.
MyPID()*MaxNumMyElements+i)*2;
105 ElementSizeList[i] = i%6 + 2;
109 -1LL, NumMyElements, MyGlobalElements, ElementSizeList,
113 delete [] ElementSizeList;
114 delete [] MyGlobalElements;
118 int * elementColors =
new int[NumMyElements];
121 int * colorCount =
new int[maxcolor];
122 int ** colorLIDs =
new int*[maxcolor];
123 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
124 for (i=0; i<maxcolor; i++) colorLIDs[i] = 0;
128 assert(C0[i]==defaultColor);
129 assert(C0(Map.
GID64(i))==defaultColor);
130 if (i%2==0) C0[i] = i%6+5+i%14;
131 else C0(Map.
GID64(i)) = i%5+1;
132 elementColors[i] = C0[i];
137 std::cout <<
"Original Map Coloring using element-by-element definitions" << std::endl;
139 std::cout << C0 << std::endl;
142 for (i=0; i<maxcolor; i++)
143 if (colorCount[i]>0) {
145 colorLIDs[i] =
new int[colorCount[i]];
147 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
148 for (i=0; i<Map.
NumMyElements(); i++) colorLIDs[C0[i]][colorCount[C0[i]]++] = i;
152 int newDefaultColor = -1;
155 std::cout <<
"Same Map Coloring using one-time construction" << std::endl;
157 std::cout << C1 << std::endl;
163 std::cout <<
"Same Map Coloring using copy constructor" << std::endl;
165 std::cout << C1 << std::endl;
171 for (i=0; i<maxcolor; i++) {
173 assert(colorCount[i]==curNumElementsWithColor);
175 if (curNumElementsWithColor==0) {
176 assert(curColorLIDList==0);
179 for (
int j=0; j<curNumElementsWithColor; j++) assert(curColorLIDList[j]==colorLIDs[i][j]);
189 assert(Map1->
GID64(i)==Map.
GID64(colorLIDs[curColor][i]));
190 assert(Map2->
GID64(i)==Map.
GID64(colorLIDs[curColor][i]));
204 long long NumMyElements0 = 0;
213 elementColorValues0.
Import(elementColorValues, importer,
Insert);
216 -1LL,NumMyElements0, elementIDs0.
Values(),
224 for (i=0; i<MapOnPE0.NumMyElements(); i++)
225 assert(ColoringOnPE0[i]==elementColorValues0[i]);
228 std::cout <<
"Same Map Coloring on PE 0 only" << std::endl;
230 std::cout << ColoringOnPE0 << std::endl;
235 std::cout <<
"Same Map Coloring after Import/Export exercise" << std::endl;
237 std::cout << ColoringOnPE0 << std::endl;
240 if (verbose) std::cout <<
"Checked OK\n\n" << std::endl;
243 if (verbose) std::cout <<
"Test ostream << operator" << std::endl << std::flush;
244 std::cout << C0 << std::endl;
248 delete [] elementColors;
249 for (i=0; i<maxcolor; i++)
if (colorLIDs[i]!=0)
delete [] colorLIDs[i];
251 delete [] colorCount;
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_MapColoring: A class for coloring Epetra_Map and Epetra_BlockMap objects.
int ElementSize() const
Returns the size of elements in the map; only valid if map has constant element size.
Epetra_LongLongVector: A class for constructing and using dense integer vectors on a parallel compute...
Epetra_BlockMap * GenerateBlockMap(int Color) const
Generates an Epetra_BlockMap of the GIDs associated with the specified color.
long long IndexBase64() const
Epetra_IntVector: A class for constructing and using dense integer vectors on a parallel computer...
long long NumGlobalElements64() const
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
int * ElementSizeList() const
List of the element sizes corresponding to the array MyGlobalElements().
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
int * Values() const
Returns a pointer to an array containing the values of this vector.
int NumElementsWithColor(int Color) const
Returns number of map elements on calling processor having specified Color.
int * ColorLIDList(int Color) const
Returns pointer to array of Map LIDs associated with the specified color.
int DefaultColor() const
Returns default color.
int NumMyElements() const
Number of elements on the calling processor.
long long GID64(int LID) const
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Exports an Epetra_DistObject using the Epetra_Import object.
int * ElementColors() const
Returns pointer to array of the colors associated with the LIDs on the calling processor.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
int NumColors() const
Returns number of colors on the calling processor.
Epetra_SerialComm: The Epetra Serial Communication Class.
Epetra_Map * GenerateMap(int Color) const
Generates an Epetra_Map of the GIDs associated with the specified color.
int main(int argc, char *argv[])
long long * MyGlobalElements64() const
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Imports an Epetra_DistObject using the Epetra_Import object.
long long * Values() const
Returns a pointer to an array containing the values of this vector.