49 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
55 UserAllocated_(false),
59 throw ReportError(
"Epetra_LongLongVector::Epetra_LongLongVector: cannot be called with non long long map index type", -1);
68 UserAllocated_(false),
72 throw ReportError(
"Epetra_LongLongVector::Epetra_LongLongVector: cannot be called with non long long map index type", -1);
81 UserAllocated_(false),
85 throw ReportError(
"Epetra_LongLongVector::Epetra_LongLongVector: cannot be called with non long long map index type", -1);
111 Values_ =
new long long[myLength];
124 for (
int i=0; i<iend; i++)
Values_[i] = V[i];
150 for (
int i=0; i<iend; i++) V[i] =
Values_[i];
164 for (
int i=0; i<iend; i++)
Values_[i] = Value;
169 long long result = std::numeric_limits<long long>::min();
171 if (iend>0) result =
Values_[0];
173 long long globalResult;
174 this->
Comm().
MaxAll(&result, &globalResult, 1);
175 return(globalResult);
179 long long result = std::numeric_limits<long long>::max();
181 if (iend>0) result =
Values_[0];
183 long long globalResult;
184 this->
Comm().
MinAll(&result, &globalResult, 1);
185 return(globalResult);
192 throw ReportError(
"Length of LongLongVectors incompatible in Assign. The this LongLongVector has MyLength = " +
toString(
MyLength())
196 for (
int i=0; i<iend; i++)
Values_[i] =V[i];
204 for (
int iproc=0; iproc < NumProc; iproc++) {
206 int NumMyElements1 =
Map(). NumMyElements();
209 int * FirstPointInElementList1=0;
214 os <<
" MyPID"; os <<
" ";
216 if (MaxElementSize1==1)
224 for (
int i=0; i < NumMyElements1; i++) {
228 os << MyPID; os <<
" ";
230 if (MaxElementSize1==1) {
231 os << MyGlobalElements1[i] <<
" ";
235 os << MyGlobalElements1[i]<<
"/" << ii <<
" ";
236 iii = FirstPointInElementList1[i]+ii;
265 int *PermuteFromLIDs,
276 int * ToFirstPointInElementList = 0;
277 int * FromFirstPointInElementList = 0;
278 int * FromElementSizeList = 0;
282 if (!ConstantElementSize) {
295 if (MaxElementSize==1) {
297 NumSameEntries = NumSameIDs;
299 else if (ConstantElementSize) {
301 NumSameEntries = NumSameIDs * MaxElementSize;
305 NumSameEntries = FromFirstPointInElementList[NumSameIDs];
309 if (To==From) NumSameEntries = 0;
315 for (j=0; j<NumSameEntries; j++) To[j] += From[j];
317 for (j=0; j<NumSameEntries; j++) To[j] = From[j];
320 if (NumPermuteIDs>0) {
326 for (j=0; j<NumPermuteIDs; j++) To[PermuteToLIDs[j]] += From[PermuteFromLIDs[j]];
327 else for (j=0; j<NumPermuteIDs; j++) To[PermuteToLIDs[j]] = From[PermuteFromLIDs[j]];
333 for (j=0; j<NumPermuteIDs; j++) {
334 jj = MaxElementSize*PermuteToLIDs[j];
335 jjj = MaxElementSize*PermuteFromLIDs[j];
336 for (k=0; k<MaxElementSize; k++)
337 To[jj+k] += From[jjj+k];
340 for (j=0; j<NumPermuteIDs; j++) {
341 jj = MaxElementSize*PermuteToLIDs[j];
342 jjj = MaxElementSize*PermuteFromLIDs[j];
343 for (k=0; k<MaxElementSize; k++)
344 To[jj+k] = From[jjj+k];
352 for (j=0; j<NumPermuteIDs; j++) {
353 jj = ToFirstPointInElementList[PermuteToLIDs[j]];
354 jjj = FromFirstPointInElementList[PermuteFromLIDs[j]];
355 int ElementSize = FromElementSizeList[PermuteFromLIDs[j]];
356 for (k=0; k<ElementSize; k++)
357 To[jj+k] += From[jjj+k];
360 for (j=0; j<NumPermuteIDs; j++) {
361 jj = ToFirstPointInElementList[PermuteToLIDs[j]];
362 jjj = FromFirstPointInElementList[PermuteFromLIDs[j]];
363 int ElementSize = FromElementSizeList[PermuteFromLIDs[j]];
364 for (k=0; k<ElementSize; k++)
365 To[jj+k] = From[jjj+k];
395 int * FromFirstPointInElementList = 0;
396 int * FromElementSizeList = 0;
398 if (!ConstantElementSize) {
403 SizeOfPacket = MaxElementSize * (int)
sizeof(
long long);
405 if(NumExportIDs*SizeOfPacket>LenExports) {
406 if (LenExports>0)
delete [] Exports;
407 LenExports = NumExportIDs*SizeOfPacket;
408 Exports =
new char[LenExports];
413 if (NumExportIDs>0) {
414 ptr = (
long long *) Exports;
417 if (MaxElementSize==1)
for (j=0; j<NumExportIDs; j++) *ptr++ = From[ExportLIDs[j]];
420 else if (ConstantElementSize) {
422 for (j=0; j<NumExportIDs; j++) {
423 jj = MaxElementSize*ExportLIDs[j];
424 for (k=0; k<MaxElementSize; k++)
432 int thisSizeOfPacket = MaxElementSize;
433 for (j=0; j<NumExportIDs; j++) {
434 ptr = (
long long *) Exports + j*thisSizeOfPacket;
435 jj = FromFirstPointInElementList[ExportLIDs[j]];
436 int ElementSize = FromElementSizeList[ExportLIDs[j]];
437 for (k=0; k<ElementSize; k++)
464 if( CombineMode !=
Add
465 && CombineMode !=
Zero
468 && CombineMode !=
AbsMax )
471 if (NumImportIDs<=0)
return(0);
477 int * ToFirstPointInElementList = 0;
478 int * ToElementSizeList = 0;
480 if (!ConstantElementSize) {
488 ptr = (
long long *) Imports;
491 if (MaxElementSize==1) {
493 if (CombineMode==
Add)
494 for (j=0; j<NumImportIDs; j++) To[ImportLIDs[j]] += *ptr++;
495 else if(CombineMode==
Insert)
496 for (j=0; j<NumImportIDs; j++) To[ImportLIDs[j]] = *ptr++;
497 else if(CombineMode==
AbsMax)
498 for (j=0; j<NumImportIDs; j++) {
499 To[ImportLIDs[j]] =
EPETRA_MAX( To[ImportLIDs[j]],(*ptr > 0 ? *ptr : -*ptr));
505 for (j=0; j<NumImportIDs; j++) {To[ImportLIDs[j]] += *ptr++; To[ImportLIDs[j]] /= 2;}
510 else if (ConstantElementSize) {
512 if (CombineMode==
Add) {
513 for (j=0; j<NumImportIDs; j++) {
514 jj = MaxElementSize*ImportLIDs[j];
515 for (k=0; k<MaxElementSize; k++)
519 else if(CombineMode==
Insert) {
520 for (j=0; j<NumImportIDs; j++) {
521 jj = MaxElementSize*ImportLIDs[j];
522 for (k=0; k<MaxElementSize; k++)
526 else if(CombineMode==
AbsMax) {
527 for (j=0; j<NumImportIDs; j++) {
528 jj = MaxElementSize*ImportLIDs[j];
529 for (k=0; k<MaxElementSize; k++) {
530 To[jj+k] =
EPETRA_MAX( To[jj+k], (*ptr > 0 ? *ptr : -*ptr));
537 else if(CombineMode==
Average) {
538 for (j=0; j<NumImportIDs; j++) {
539 jj = MaxElementSize*ImportLIDs[j];
540 for (k=0; k<MaxElementSize; k++)
541 { To[jj+k] += *ptr++; To[jj+k] /= 2;}
550 int thisSizeOfPacket = MaxElementSize;
552 if (CombineMode==
Add) {
553 for (j=0; j<NumImportIDs; j++) {
554 ptr = (
long long *) Imports + j*thisSizeOfPacket;
555 jj = ToFirstPointInElementList[ImportLIDs[j]];
556 int ElementSize = ToElementSizeList[ImportLIDs[j]];
557 for (k=0; k<ElementSize; k++)
561 else if(CombineMode==
Insert){
562 for (j=0; j<NumImportIDs; j++) {
563 ptr = (
long long *) Imports + j*thisSizeOfPacket;
564 jj = ToFirstPointInElementList[ImportLIDs[j]];
565 int ElementSize = ToElementSizeList[ImportLIDs[j]];
566 for (k=0; k<ElementSize; k++)
570 else if(CombineMode==
AbsMax){
571 for (j=0; j<NumImportIDs; j++) {
572 ptr = (
long long *) Imports + j*thisSizeOfPacket;
573 jj = ToFirstPointInElementList[ImportLIDs[j]];
574 int ElementSize = ToElementSizeList[ImportLIDs[j]];
575 for (k=0; k<ElementSize; k++) {
576 To[jj+k] =
EPETRA_MAX( To[jj+k], (*ptr > 0 ? *ptr : -*ptr));
583 else if(CombineMode==
Average) {
584 for (j=0; j<NumImportIDs; j++) {
585 ptr = (
long long *) Imports + j*thisSizeOfPacket;
586 jj = ToFirstPointInElementList[ImportLIDs[j]];
587 int ElementSize = ToElementSizeList[ImportLIDs[j]];
588 for (k=0; k<ElementSize; k++)
589 { To[jj+k] += *ptr++; To[jj+k] /= 2;}
597 #endif // EPETRA_NO_64BIT_GLOBAL_INDICES
int * FirstPointInElementList() const
Pointer to internal array containing a mapping between the local elements and the first local point n...
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...
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.
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
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().
bool ConstantElementSize() const
Returns true if map has constant element size.
#define EPETRA_CHK_ERR(a)
int * ElementSizeList() const
List of the element sizes corresponding to the array MyGlobalElements().
long long MinValue()
Find minimum value.
int ExtractView(long long **V) const
Set user-provided address of V.
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.
int CheckSizes(const Epetra_SrcDistObject &A)
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
virtual int MinAll(double *PartialMins, double *GlobalMins, int Count) const =0
Epetra_Comm Global Min function.
virtual void Barrier() const =0
Epetra_Comm Barrier function.
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().
virtual int MyPID() const =0
Return my process ID.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
int ExtractCopy(long long *V) const
Put vector values into user-provided array.
std::string toString(const int &x) const
long long MaxValue()
Find maximum value.
Epetra_LongLongVector & operator=(const Epetra_LongLongVector &Source)
= Operator.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int PutValue(long long Value)
Set all elements of the vector to Value.
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
Epetra_LongLongVector(const Epetra_BlockMap &Map, bool zeroOut=true)
Basic Epetra_LongLongVector constuctor.
virtual int NumProc() const =0
Returns total number of processes.
int MaxElementSize() const
Maximum element size across all processors.
virtual ~Epetra_LongLongVector()
Epetra_LongLongVector destructor.
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 void Print(std::ostream &os) const
Print method.
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.