59 #include "../epetra_test_err.h"
66 int main(
int argc,
char *argv[]) {
73 MPI_Init( &argc, &argv );
95 cout <<
"Usage: " << argv[0] <<
" [-v [nx [ny]]]" << endl;
101 if(argv[loc][0]==
'-' && argv[loc][1]==
'v')
102 { verbose =
true; ++loc; }
104 if (loc < argc) nx = atoi( argv[loc++] );
105 if( loc < argc) ny = atoi( argv[loc] );
114 int MyPID = Comm.
MyPID();
117 bool verbose1 =
false;
118 if(verbose) verbose1 = (MyPID==0);
125 if(verbose) cout << Comm << endl << flush;
128 long long NumGlobalElements = nx * ny;
129 if( NumGlobalElements < NumProc )
131 cout <<
"NumGlobalElements = " << NumGlobalElements <<
132 " cannot be < number of processors = " << NumProc;
137 Epetra_Map Map( NumGlobalElements, IndexBase, Comm );
141 std::vector<long long> MyGlobalElements( NumMyElements );
143 if( verbose ) cout << Map;
147 std::vector<int> NumNz( NumMyElements, 5 );
150 for (
int i = 0; i < NumMyElements; ++i)
152 global_j = MyGlobalElements[i] / nx;
153 global_i = MyGlobalElements[i] - global_j * nx;
154 if (global_i == 0) NumNz[i] -= 1;
155 if (global_i == nx-1) NumNz[i] -= 1;
156 if (global_j == 0) NumNz[i] -= 1;
157 if (global_j == ny-1) NumNz[i] -= 1;
161 cout << endl <<
"NumNz: ";
162 for (
int i = 0; i < NumMyElements; i++) cout << NumNz[i] <<
" ";
169 std::vector<long long> Indices(5);
172 for (
int i = 0; i < NumMyElements; ++i )
174 global_j = MyGlobalElements[i] / nx;
175 global_i = MyGlobalElements[i] - global_j * nx;
178 if (global_j > 0 && ny > 1)
179 Indices[NumEntries++] = global_i + (global_j-1)*nx;
182 Indices[NumEntries++] = global_i-1 + global_j *nx;
184 Indices[NumEntries++] = MyGlobalElements[i];
187 Indices[NumEntries++] = global_i+1 + global_j *nx;
189 if (global_j < ny-1 && ny > 1)
190 Indices[NumEntries++] = global_i + (global_j+1)*nx;
236 if( verbose ) cout <<
"Parallel Map Coloring 1!\n";
243 if( verbose ) cout <<
"Parallel Map Coloring 2!\n";
265 vector<Epetra_LongLongVector> & ColIndices = MapColoringIndexTransform( *A );
271 cout <<
"***************************************\n";
272 cout <<
"Column Indexing by Color:\n";
273 cout <<
"***************************************\n";
275 for(
int i = 0; i < NumColors; ++i )
277 cout <<
"COLOR: " << ListOfColors[i] << endl;
278 cout << ColIndices[i];
int MyGlobalElements(int *MyGlobalElementList) const
std::string EpetraExt_Version()
int InsertGlobalIndices(int_type GlobalRow, int NumIndices, int_type *Indices)
int main(int argc, char **argv)
int NumMyElements() const
int * ListOfColors() const
void printColoring(const Epetra_MapColoring &ColorMap, Epetra_CrsGraph *A, bool verbose)
Map Coloring of independent columns in a Graph.