53 #include "../epetra_test_err.h" 
   56 int main(
int argc, 
char *argv[]) {
 
   60     if ((argv[1][0] == 
'-') && (argv[1][1] == 
'v'))
 
   70   MPI_Init(&argc,&argv);
 
   79   int MyPID = Comm.
MyPID();
 
   82   int verbose_int = verbose ? 1 : 0;
 
   84   verbose = verbose_int==1 ? 
true : 
false;
 
   86   if (verbose && MyPID==0)
 
   89   if (verbose) cout << Comm << endl << flush;
 
   91   bool verbose1 = verbose;
 
   92   if (verbose) verbose = (MyPID==0);
 
   94   int NumMyElements = 10000;
 
   95   long long NumGlobalElements = NumMyElements*NumProc+
EPETRA_MIN(NumProc,3);
 
   96   if (MyPID < 3) NumMyElements++;
 
   97   long long IndexBase = 0;
 
   99   bool DistributedGlobal = (NumGlobalElements>NumMyElements);
 
  100   bool IsOneToOne = 
true;
 
  106     cout << 
"*******************************************************************************************" << endl
 
  107    << 
"        Testing Exceptions (Expect error messages if EPETRA_NO_ERROR_REPORTS is not defined" << endl
 
  108    << 
"*******************************************************************************************" << endl
 
  112     if (verbose) cout << 
"Checking Epetra_BlockMap(-2, ElementSize, IndexBase, Comm)" << endl;
 
  119         if (verbose) cout << 
"Error code should be -1" << endl;
 
  122         cout << 
"Error code = " << Error << 
"Should be -1" << endl;
 
  126     else if (verbose) cout << 
"Checked OK\n\n" << endl;
 
  130     if (verbose) cout << 
"Checking Epetra_BlockMap(2, 3, ElementSize, IndexBase, Comm)" << endl;
 
  137         if (verbose) cout << 
"Error code should be -4" << endl;
 
  140         cout << 
"Error code = " << Error << 
"Should be -4" << endl;
 
  144     else if (verbose) cout << 
"Checked OK\n\n" << endl;
 
  147   if (verbose) cerr << flush;
 
  148   if (verbose) cout << flush;
 
  152          << 
"*******************************************************************************************" << endl
 
  153          << 
"        Testing valid constructor now......................................................" << endl
 
  154          << 
"*******************************************************************************************" << endl
 
  157   Map = 
new Epetra_BlockMap(NumGlobalElements, ElementSize, IndexBase, Comm);
 
  158   if (verbose) cout << 
"Checking Epetra_BlockMap(NumGlobalElements, ElementSize, IndexBase, Comm)" << endl;
 
  159   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, 0, ElementSize, 0,
 
  160       NumGlobalElements*ElementSize, NumMyElements*ElementSize,
 
  161       IndexBase, Comm, DistributedGlobal,IsOneToOne);
 
  164   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  169   Map = 
new Epetra_BlockMap(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm);
 
  171   if (verbose) cout << 
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm)" << endl;
 
  172   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, 0, ElementSize, 0,
 
  173                    NumGlobalElements*ElementSize, NumMyElements*ElementSize,
 
  174       IndexBase, Comm, DistributedGlobal,IsOneToOne);
 
  177   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  184   long long NumGlobalElems = (Comm.
NumProc()+1)*NumMyElems;
 
  185   long long myFirstElem = Comm.
MyPID()*NumMyElems;
 
  186   if (Comm.
MyPID() == 0) NumMyElems *= 2;
 
  188   long long* myElems = 
new long long[NumMyElems];
 
  189   for(
int ii=0; ii<NumMyElems; ++ii) {
 
  190     myElems[ii] = myFirstElem + ii;
 
  193   Map = 
new Epetra_BlockMap(NumGlobalElems, NumMyElems, myElems, 1, 0, Comm);
 
  195   if (verbose) cout << 
"Checking non-oneToOne Epetra_BlockMap(...)"<<endl;
 
  203   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  211   long long * MyGlobalElements = 
new long long[NumMyElements];
 
  212   long long MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
 
  215   for (i = 0; i<NumMyElements; i++)
 
  216     MyGlobalElements[i] = MaxMyGID-i;
 
  218   Map = 
new Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize,
 
  221   if (verbose) cout << 
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements,  ElementSize, IndexBase, Comm)" << endl;
 
  222   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize, 0,
 
  223                   NumGlobalElements*ElementSize, NumMyElements*ElementSize,
 
  224                   IndexBase, Comm, DistributedGlobal,IsOneToOne);
 
  227   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  233   int * ElementSizeList = 
new int[NumMyElements];
 
  234   int NumMyEquations = 0;
 
  235   int NumGlobalEquations = 0;
 
  236   for (i = 0; i<NumMyElements; i++) {
 
  237     ElementSizeList[i] = i%6 + 2; 
 
  238     NumMyEquations += ElementSizeList[i];
 
  241   NumGlobalEquations = Comm.
NumProc()*NumMyEquations;
 
  246       NumGlobalEquations += 3*((NumMyElements)%6+2);
 
  248       NumGlobalEquations -= (Comm.
NumProc()-3)*((NumMyElements-1)%6+2);
 
  250   Map = 
new Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSizeList,
 
  252   if (verbose) cout << 
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements,  ElementSizeList, IndexBase, Comm)" << endl;
 
  253   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize, ElementSizeList,
 
  254       NumGlobalEquations, NumMyEquations,
 
  255       IndexBase, Comm, DistributedGlobal,IsOneToOne);
 
  258   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  264   bool same = Map1->
SameAs(*Map);
 
  268   same = Map2->
SameAs(*Map);
 
  274   Map2 = 
new Epetra_BlockMap(NumGlobalElements,NumMyElements,MyGlobalElements,ElementSizeList,IndexBase-1,Comm);
 
  275   same = Map2->
SameAs(*Map);
 
  279   int *ElementSizeList1 = 
new int[NumMyElements];
 
  280   for (i=0; i<NumMyElements; i++)
 
  281     ElementSizeList1[i] = i%5 + 2; 
 
  282   Map2 = 
new Epetra_BlockMap(NumGlobalElements,NumMyElements,MyGlobalElements,ElementSizeList1,IndexBase,Comm);
 
  283   same = Map2->
SameAs(*Map);
 
  285   delete [] ElementSizeList1;
 
  288   same = Map3->
SameAs(*Map);
 
  293   if (verbose) cout << 
"Checking Epetra_BlockMap(*Map)" << endl;
 
  294   ierr = 
checkmap(*Map1, NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize, ElementSizeList,
 
  295       NumGlobalEquations, NumMyEquations,
 
  296       IndexBase, Comm, DistributedGlobal,IsOneToOne);
 
  299   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  302     if (verbose) cout << 
"Test ostream << operator" << endl << flush;
 
  323     Map1 = 
new Epetra_BlockMap(-1, 0, (
long long*)0, (
int*)0, IndexBase, Comm);
 
  326     Map1 = 
new Epetra_BlockMap(-1, NumMyElements, MyGlobalElements, ElementSizeList, IndexBase, Comm);
 
  337   delete[] ElementSizeList;
 
  338   delete[] MyGlobalElements;
 
  346    << 
"*******************************************************************************************" << endl
 
  347    << 
"        Testing reference counting now....................................................." << endl
 
  348    << 
"*******************************************************************************************" << endl << endl;
 
  350   Epetra_BlockMap b1(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm);
 
  354   if(verbose) cout << 
"Default constructor. \nb1= " << b1count << 
"  " << b1addr << endl;
 
  359   int b1countold = b1count;
 
  363   if(verbose) cout << 
"Copy constructor. \nb1= " << b1count << 
"  " << b1addr << 
"\nb2= " << b2count << 
"  " << b2addr << endl;
 
  366   b1countold = b1count;
 
  370   if(verbose) cout << 
"b2 destroyed. \nb1= " << b1count << 
"  " << b1addr << endl;
 
  373     if(verbose) cout << 
"Assignment operator, post construction" << endl;
 
  374     Epetra_BlockMap b3(NumGlobalElements, NumMyElements, ElementSize, IndexBase-1, Comm);
 
  379     if(verbose) cout << 
"Prior to assignment: \nb1= " << b1count << 
"  " << b1addr << 
"\nb3= " << b3count << 
"  " << b3addr << endl;
 
  383     b1countold = b1count;
 
  387     if(verbose) cout << 
"After assignment: \nb1= " << b1count << 
"  " << b1addr << 
"\nb3= " << b3count << 
"  " << b3addr << endl;
 
  389   b1countold = b1count;
 
  393   if (verbose) cout << 
"b3 destroyed. \nb1= " << b1count << 
"  " << b1addr << endl;
 
  396   if (verbose && (ierr == 0)) cout << 
"Checked OK\n\n" <<endl;
 
  404    << 
"*******************************************************************************************" << endl
 
  405    << 
"        Testing subcommunicators now......................................................." << endl
 
  406    << 
"*******************************************************************************************" << endl << endl;
 
  413     Map1 = 
new Epetra_BlockMap((
long long)-1, NumMyElements, 1, IndexBase, Comm);
 
  427   delete Map1; 
delete Map2; 
delete Map3;
 
long long MinMyGID64() const 
 
Epetra_BlockMapData: The Epetra BlockMap Data Class. 
 
bool SameAs(const Epetra_BlockMap &Map) const 
Returns true if this and Map are identical maps. 
 
#define EPETRA_TEST_ERR(a, b)
 
long long IndexBase64() const 
 
int ReferenceCount() const 
Returns the reference count of BlockMapData. 
 
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(). 
 
Epetra_BlockMap * RemoveEmptyProcesses() const 
Return a new BlockMap with processes with zero elements removed. 
 
int MyPID() const 
Return my process ID. 
 
Epetra_MpiComm: The Epetra MPI Communication Class. 
 
std::string Epetra_Version()
 
int NumMyElements() const 
Number of elements on the calling processor. 
 
Epetra_Comm: The Epetra Communication Abstract Base Class. 
 
int checkmap(Epetra_BlockMap &Map, int NumGlobalElements, int NumMyElements, int *MyGlobalElements, int ElementSize, int *ElementSizeList, int NumGlobalPoints, int NumMyPoints, int IndexBase, Epetra_Comm &Comm, bool DistributedGlobal, bool IsOneToOne)
 
Epetra_BlockMap: A class for partitioning block element vectors and matrices. 
 
int NumProc() const 
Returns total number of processes (always returns 1 for SerialComm). 
 
Epetra_BlockMap * ReplaceCommWithSubset(const Epetra_Comm *Comm) const 
Replace this BlockMap's communicator with a subset communicator. 
 
const Epetra_Comm & Comm() const 
Access function for Epetra_Comm communicator. 
 
Epetra_SerialComm: The Epetra Serial Communication Class. 
 
void Barrier() const 
Epetra_SerialComm Barrier function. 
 
const Epetra_BlockMapData * DataPtr() const 
Returns a pointer to the BlockMapData instance this BlockMap uses. 
 
int main(int argc, char *argv[])
 
int Broadcast(double *MyVals, int Count, int Root) const 
Epetra_SerialComm Broadcast function. 
 
long long * MyGlobalElements64() const 
 
long long MaxMyGID64() const