59 int 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;
125 assert(C0[i]==defaultColor);
126 assert(C0(Map.
GID(i))==defaultColor);
127 if (i%2==0) C0[i] = i%6+5+i%14;
128 else C0(Map.
GID(i)) = i%5+1;
129 elementColors[i] = C0[i];
134 std::cout <<
"Original Map Coloring using element-by-element definitions" << std::endl;
136 std::cout << C0 << std::endl;
139 for (i=0; i<maxcolor; i++)
140 if (colorCount[i]>0) {
142 colorLIDs[i] =
new int[colorCount[i]];
144 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
145 for (i=0; i<Map.
NumMyElements(); i++) colorLIDs[C0[i]][colorCount[C0[i]]++] = i;
149 int newDefaultColor = -1;
152 std::cout <<
"Same Map Coloring using one-time construction" << std::endl;
154 std::cout << C1 << std::endl;
160 std::cout <<
"Same Map Coloring using copy constructor" << std::endl;
162 std::cout << C1 << std::endl;
168 for (i=0; i<maxcolor; i++) {
170 assert(colorCount[i]==curNumElementsWithColor);
172 if (curNumElementsWithColor==0) {
173 assert(curColorLIDList==0);
176 for (
int j=0; j<curNumElementsWithColor; j++) assert(curColorLIDList[j]==colorLIDs[i][j]);
186 assert(Map1->
GID(i)==Map.
GID(colorLIDs[curColor][i]));
187 assert(Map2->
GID(i)==Map.
GID(colorLIDs[curColor][i]));
201 int NumMyElements0 = 0;
210 elementColorValues0.
Import(elementColorValues, importer,
Insert);
219 for (i=0; i<MapOnPE0.NumMyElements(); i++)
220 assert(ColoringOnPE0[i]==elementColorValues0[i]);
223 std::cout <<
"Same Map Coloring on PE 0 only" << std::endl;
225 std::cout << ColoringOnPE0 << std::endl;
230 std::cout <<
"Same Map Coloring after Import/Export exercise" << std::endl;
232 std::cout << ColoringOnPE0 << std::endl;
235 if (verbose) std::cout <<
"Checked OK\n\n" << std::endl;
238 if (verbose) std::cout <<
"Test ostream << operator" << std::endl << std::flush;
239 std::cout << C0 << std::endl;
243 delete [] elementColors;
244 for (i=0; i<maxcolor; i++)
if (colorLIDs[i]!=0)
delete [] colorLIDs[i];
246 delete [] colorCount;
int NumGlobalElements() const
Number of elements across all processors.
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_BlockMap * GenerateBlockMap(int Color) const
Generates an Epetra_BlockMap of the GIDs associated with the specified color.
Epetra_IntVector: A class for constructing and using dense integer vectors on a parallel computer...
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
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 IndexBase() const
Index base for this map.
int NumMyElements() const
Number of elements on the calling processor.
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.
int GID(int LID) const
Returns global ID of local ID, return IndexBase-1 if not found on this 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[])
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.