52 const int defaultColor)
54 DefaultColor_(defaultColor),
63 ListsAreGenerated_(false),
70 const int defaultColor)
72 DefaultColor_(defaultColor),
81 ListsAreGenerated_(false),
89 DefaultColor_(Source.DefaultColor_),
98 ListsAreGenerated_(false),
140 for (
int i=0; i< NumMyElements; i++)
ElementColors_[i] = elementColors[i*Increment];
148 if (NumMyElements==0)
return(0);
180 {
for (
int i=0; i<NumMyElements; i++) {
191 bool ColorFound =
false;
194 while (!ColorFound && NextColor!=0) {
195 CurColor = NextColor;
197 if (ColorValue==CurColor->
ItemValue) ColorFound =
true;
210 if (arrayIndex>-1)
return(
ColorCount_[arrayIndex]);
219 if (arrayIndex>-1)
return(
ColorLists_[arrayIndex]);
223 template<
typename int_type>
231 int * ColorElementLIDs = 0;
232 int_type * ColorElementGIDs =0;
233 if (arrayIndex>-1) NumElements =
ColorCount_[arrayIndex];
236 ColorElementGIDs =
new int_type[NumElements];
237 for (
int i=0; i<NumElements; i++) ColorElementGIDs[i] = (int_type)
Map().
GID64(ColorElementLIDs[i]);
240 (int_type)
Map().IndexBase64(),
Map().
Comm());
241 if (ColorElementGIDs!=0)
delete [] ColorElementGIDs;
246 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
247 if(
Map().GlobalIndicesInt()) {
248 return TGenerateMap<int>(Color);
252 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
254 return TGenerateMap<long long>(Color);
258 throw "Epetra_MapColoring::GenerateMap: GlobalIndices type unknown";
262 template<
typename int_type>
270 int * ColorElementLIDs = 0;
271 int * ColorElementSizes = 0;
272 int_type * ColorElementGIDs = 0;
273 if (arrayIndex>-1) NumElements =
ColorCount_[arrayIndex];
276 ColorElementSizes =
new int[NumElements];
277 ColorElementGIDs =
new int_type[NumElements];
278 for (
int i=0; i<NumElements; i++) ColorElementGIDs[i] = (int_type)
Map().
GID64(ColorElementLIDs[i]);
282 {
for (
int i=0; i<NumElements; i++)
283 ColorElementSizes[i] = MapElementSizes[ColorElementLIDs[i]];}
287 (int_type)
Map().IndexBase64(),
Map().
Comm());
289 if (ColorElementGIDs!=0)
delete [] ColorElementGIDs;
290 if (ColorElementSizes!=0)
delete [] ColorElementSizes;
296 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
297 if(
Map().GlobalIndicesInt()) {
298 return TGenerateBlockMap<int>(Color);
302 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
304 return TGenerateBlockMap<long long>(Color);
308 throw "Epetra_MapColoring::GenerateBlockMap: GlobalIndices type unknown";
318 <<
" *****************************************" << std::endl
319 <<
" Coloring information arranged map element" << std::endl
320 <<
" *****************************************" << std::endl
322 for (
int iproc=0; iproc < NumProc; iproc++) {
324 int NumMyElements1 =
Map(). NumMyElements();
328 os <<
" MyPID"; os <<
" ";
335 for (
int i=0; i < NumMyElements1; i++) {
337 os << MyPID; os <<
" ";
340 if(
Map().GlobalIndicesInt()) {
341 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
343 os << MyGlobalElements1[i] <<
" ";
345 throw ReportError(
"Epetra_MapColoring::Print: ERROR, GlobalIndicesInt but no API for it.",-1);
348 else if(
Map().GlobalIndicesLongLong())
350 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
352 os << MyGlobalElements1[i] <<
" ";
354 throw ReportError(
"Epetra_MapColoring::Print: ERROR, GlobalIndicesLongLong but no API for it.",-1);
358 throw ReportError(
"Epetra_MapColoring::Print: ERROR, Don't know map global index type.",-1);
375 <<
" **************************************" << std::endl
376 <<
" Coloring information arranged by color" << std::endl
377 <<
" **************************************" << std::endl
379 {
for (
int iproc=0; iproc < NumProc; iproc++) {
381 if (
NumColors()==0) os <<
" No colored elements on processor " << MyPID << std::endl;
383 os <<
"Number of colors in map = " <<
NumColors() << std::endl
384 <<
"Default color = " <<
DefaultColor() << std::endl << std::endl;
387 os <<
" MyPID"; os <<
" ";
396 int CV = ColorValues[ii];
401 for (
int i=0; i < ColorCount; i++) {
403 os << MyPID; os <<
" ";
405 os << LIDList[i] <<
" ";
440 int *PermuteFromLIDs,
454 for (
int j=0; j<NumSameIDs; j++) To[j] += From[j];
456 for (
int j=0; j<NumSameIDs; j++) To[j] = From[j];
459 if (NumPermuteIDs>0) {
461 for (
int j=0; j<NumPermuteIDs; j++) To[PermuteToLIDs[j]] += From[PermuteFromLIDs[j]];
463 for (
int j=0; j<NumPermuteIDs; j++) To[PermuteToLIDs[j]] = From[PermuteFromLIDs[j]];
486 int * IntExports = 0;
488 SizeOfPacket = (int)
sizeof(
int);
490 if (NumExportIDs*SizeOfPacket>LenExports) {
491 if (LenExports>0)
delete [] Exports;
492 LenExports = NumExportIDs*SizeOfPacket;
493 IntExports =
new int[LenExports];
494 Exports = (
char *) IntExports;
499 if (NumExportIDs>0) {
500 ptr = (
int *) Exports;
501 for (
int j=0; j<NumExportIDs; j++) ptr[j] = From[ExportLIDs[j]];
526 if( CombineMode !=
Add
527 && CombineMode !=
Zero
529 && CombineMode !=
AbsMax )
532 if (NumImportIDs<=0)
return(0);
539 ptr = (
int *) Imports;
541 if (CombineMode==
Add)
542 for (j=0; j<NumImportIDs; j++) To[ImportLIDs[j]] += ptr[j];
543 else if(CombineMode==
Insert)
544 for (j=0; j<NumImportIDs; j++) To[ImportLIDs[j]] = ptr[j];
545 else if(CombineMode==
AbsMax) {
546 for (j=0; j<NumImportIDs; j++) To[ImportLIDs[j]] = 0;
547 for (j=0; j<NumImportIDs; j++) To[ImportLIDs[j]] =
EPETRA_MAX( To[ImportLIDs[j]],std::abs(ptr[j]));
Epetra_Map: A class for partitioning vectors and matrices.
Epetra_MapColoring: A class for coloring Epetra_Map and Epetra_BlockMap objects.
int MaxNumColors() const
Returns maximum over all processors of the number of colors.
Epetra_HashTable< int > * ColorIDs_
const Epetra_Comm & Comm() const
Returns the address of the Epetra_Comm for this multi-vector.
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)
Perform ID copies and permutations that are on processor.
Epetra_BlockMap * GenerateBlockMap(int Color) const
Generates an Epetra_BlockMap of the GIDs associated with the specified color.
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
Epetra_MapColoring(const Epetra_BlockMap &Map, const int DefaultColor=0)
Epetra_MapColoring basic constructor.
value_type Get(const long long key)
Epetra_BlockMap * TGenerateBlockMap(int Color) const
#define EPETRA_CHK_ERR(a)
int * ElementSizeList() const
List of the element sizes corresponding to the array MyGlobalElements().
virtual void Barrier() const =0
Epetra_Comm Barrier function.
virtual int MyPID() const =0
Return my process ID.
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.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
Epetra_Util: The Epetra Util Wrapper Class.
int NumMyElements() const
Number of elements on the calling processor.
long long GID64(int LID) const
virtual void Print(std::ostream &os) const
Print method.
bool InItemList(int ColorValue) const
int * ListOfColors() const
Array of length NumColors() containing List of color values used in this coloring.
int * ElementColors() const
Returns pointer to array of the colors associated with the LIDs on the calling processor.
int GenerateLists() const
int CheckSizes(const Epetra_SrcDistObject &A)
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int Allocate(int *ElementColors, int Increment)
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
int NumColors() const
Returns number of colors on the calling processor.
Epetra_Map * GenerateMap(int Color) const
Generates an Epetra_Map of the GIDs associated with the specified color.
virtual int NumProc() const =0
Returns total number of processes.
int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)
Perform any packing or preparation required for call to DoTransfer().
static void EPETRA_LIB_DLL_EXPORT Sort(bool SortAscending, int NumKeys, T *Keys, int NumDoubleCompanions, double **DoubleCompanions, int NumIntCompanions, int **IntCompanions, int NumLongLongCompanions, long long **LongLongCompanions)
Epetra_Util Sort Routine (Shell sort)
Epetra_Map * TGenerateMap(int Color) const
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
long long * MyGlobalElements64() const
virtual ~Epetra_MapColoring()
Epetra_MapColoring destructor.
int UnpackAndCombine(const Epetra_SrcDistObject &Source, int NumImportIDs, int *ImportLIDs, int LenImports, char *Imports, int &SizeOfPacket, Epetra_Distributor &Distor, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor)
Perform any unpacking and combining after call to DoTransfer().
void Add(const long long key, const value_type value)
Epetra_DistObject: A class for constructing and using dense multi-vectors, vectors and matrices in pa...
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.