55 #include "../epetra_test_err.h" 
   61 int main(
int argc, 
char *argv[]) {
 
   63   int ierr=0, returnierr=0;
 
   66   MPI_Init(&argc,&argv);
 
   75   if (argc>1) 
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose = 
true;
 
   81   int MyPID = Comm.
MyPID();
 
   84   if (verbose && MyPID==0)
 
   87   if (verbose) cout << Comm << endl;
 
   89   bool verbose1 = verbose;
 
   90   if (verbose) verbose = (MyPID==0);
 
   92   int NumMyElements = 10000;
 
   93   int NumMyElements1 = NumMyElements; 
 
   94   long long NumGlobalElements = ((
long long)NumMyElements)*NumProc+
EPETRA_MIN(NumProc,3);
 
   95   if (MyPID < 3) NumMyElements++;
 
   96   long long IndexBase = 0;
 
   97   bool DistributedGlobal = (NumGlobalElements>NumMyElements);
 
  104     cout << 
"*******************************************************************************************" << endl
 
  105    << 
"        Testing Exceptions (Expect error messages if EPETRA_NO_ERROR_REPORTS is not defined" << endl
 
  106    << 
"*******************************************************************************************" << endl
 
  110     if (verbose) cout << 
"Checking Epetra_Map(-2, IndexBase, Comm)" << endl;
 
  111     Map = 
new Epetra_Map((
long long)-2, IndexBase, Comm);
 
  117   if (verbose) cout << 
"Error code should be -1" << endl;
 
  120   cout << 
"Error code = " << Error << 
"Should be -1" << endl;
 
  124     else if (verbose) cout << 
"Checked OK\n\n" << endl;
 
  128     if (verbose) cout << 
"Checking Epetra_Map(2, 3, IndexBase, Comm)" << endl;
 
  129     Map = 
new Epetra_Map((
long long)2, 3, IndexBase, Comm);
 
  135   if (verbose) cout << 
"Error code should be -4" << endl;
 
  138   cout << 
"Error code = " << Error << 
"Should be -4" << endl;
 
  142     else if (verbose) cout << 
"Checked OK\n\n" << endl;
 
  145   if (verbose) cerr << flush;
 
  146   if (verbose) cout << flush;
 
  150       << 
"*******************************************************************************************" << endl
 
  151       << 
"        Testing valid constructor now......................................................" << endl
 
  152       << 
"*******************************************************************************************" << endl
 
  156   Map = 
new Epetra_Map(NumGlobalElements, IndexBase, Comm);
 
  157   if (verbose) cout << 
"Checking Epetra_Map(NumGlobalElements, IndexBase, Comm)" << endl;
 
  158   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, 0,
 
  159       IndexBase, Comm, DistributedGlobal);
 
  162   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  167   Map = 
new Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm);
 
  169   if (verbose) cout << 
"Checking Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm)" << endl;
 
  170   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, 0,
 
  171       IndexBase, Comm, DistributedGlobal);
 
  174   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  180   long long * MyGlobalElements = 
new long long[NumMyElements];
 
  181   long long MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
 
  182   if (Comm.
MyPID()>2) MaxMyGID+=3;
 
  183   for (
int i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
 
  185   Map = 
new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements,
 
  187   if (verbose) cout << 
"Checking Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements,  IndexBase, Comm)" << endl;
 
  188   ierr = 
checkmap(*Map, NumGlobalElements, NumMyElements, MyGlobalElements,
 
  189                   IndexBase, Comm, DistributedGlobal);
 
  192   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  197   bool same = Map1->
SameAs(*Map);
 
  201   same = Map2->
SameAs(*Map);
 
  207   Map2 =  
new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements, IndexBase-1, Comm);
 
  208   same = Map2->
SameAs(*Map);
 
  213   if (verbose) cout << 
"Checking Epetra_Map(*Map)" << endl;
 
  214   ierr = 
checkmap(*Map1, NumGlobalElements, NumMyElements, MyGlobalElements,
 
  215       IndexBase, Comm, DistributedGlobal);
 
  218   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  225     SmallMap = 
new Epetra_Map((
long long)-1, MyLen, MyEls, IndBase, Comm);
 
  228   delete [] MyGlobalElements;
 
  233   if (verbose) cout << 
"Checking Epetra_Map reference counting" << endl;
 
  236   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  240   if (verbose) cout << 
"Checking Epetra_LocalMap(NumMyElements1, IndexBase, Comm)" << endl;
 
  241   ierr = 
checkmap(*LocalMap, NumMyElements1, NumMyElements1, 0, IndexBase, Comm, 
false);
 
  244   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  247   if (verbose) cout << 
"Checking Epetra_LocalMap(*LocalMap)" << endl;
 
  248   ierr = 
checkmap(*LocalMap1, NumMyElements1, NumMyElements1, 0, IndexBase, Comm, 
false);
 
  251   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  256   if (verbose) cout << 
"Checking Epetra_LocalMap reference counting" << endl;
 
  259   if (verbose && ierr==0) cout << 
"Checked OK\n\n" <<endl;
 
  263     if (verbose) cout << 
"Test ostream << operator" << endl << flush;
 
  277   long long NumGlobalElements = 1000;
 
  278   long long IndexBase = 0;
 
  280   Epetra_Map m1(NumGlobalElements, IndexBase, Comm);
 
  281   int m1count = m1.ReferenceCount();
 
  284   if(verbose) cout << 
"Default constructor. \nm1= " << m1count << 
"  " << m1addr << endl;
 
  289   int m1countold = m1count;
 
  291   EPETRA_TEST_ERR(!(m2count==m1count && m1count==(m1countold+1)),returnierr); 
 
  293   if(verbose) cout << 
"Copy constructor. \nm1= " << m1count << 
"  " << m1addr
 
  294                    << 
"\nm2= " << m2count << 
"  " << m2addr << endl;
 
  297   m1countold = m1count;
 
  301   if(verbose) cout << 
"m2 destroyed. \nm1= " << m1count << 
"  " << m1addr << endl;
 
  304     if(verbose) cout << 
"Assignment operator, post construction" << endl;
 
  305     Epetra_Map m3(NumGlobalElements, IndexBase+1, Comm);
 
  306     int m3count = m3.ReferenceCount();
 
  310     if(verbose) cout << 
"Prior to assignment: \nm1= " << m1count << 
"  " << m1addr
 
  311                      << 
"\nm3= " << m3count << 
"  " << m3addr << endl;
 
  314     m3addr = m3.DataPtr();
 
  315     m1countold = m1count;
 
  317     EPETRA_TEST_ERR(!(m3count==m1count && m1count==m1countold+1),returnierr); 
 
  319     if(verbose) cout << 
"After assignment: \nm1= " << m1count << 
"  " << m1addr
 
  320                      << 
"\nm3= " << m3count << 
"  " << m3addr << endl;
 
  322   m1countold = m1count;
 
  326   if(verbose) cout << 
"m3 destroyed. \nm1= " << m1count << 
"  " << m1addr << endl;
 
  333   long long NumMyElements = 100;
 
  334   long long IndexBase = 0;
 
  337   int m1count = m1.ReferenceCount();
 
  340   if(verbose) cout << 
"Default constructor. \nm1= " << m1count << 
"  " << m1addr << endl;
 
  345   int m1countold = m1count;
 
  347   EPETRA_TEST_ERR(!(m2count==m1count && m1count==(m1countold+1)),returnierr); 
 
  349   if(verbose) cout << 
"Copy constructor. \nm1= " << m1count << 
"  " << m1addr
 
  350                    << 
"\nm2= " << m2count << 
"  " << m2addr << endl;
 
  353   m1countold = m1count;
 
  357   if(verbose) cout << 
"m2 destroyed. \nm1= " << m1count << 
"  " << m1addr << endl;
 
  360     if(verbose) cout << 
"Assignment operator, post construction" << endl;
 
  362     int m3count = m3.ReferenceCount();
 
  366     if(verbose) cout << 
"Prior to assignment: \nm1= " << m1count << 
"  " << m1addr
 
  367                      << 
"\nm3= " << m3count << 
"  " << m3addr << endl;
 
  370     m3addr = m3.DataPtr(); 
 
  371     m1countold = m1count;
 
  373     EPETRA_TEST_ERR(!(m3count==m1count && m1count==m1countold+1),returnierr); 
 
  375     if(verbose) cout << 
"After assignment: \nm1= " << m1count << 
"  " << m1addr
 
  376                      << 
"\nm3= " << m3count << 
"  " << m3addr << endl;
 
  378   m1countold = m1count;
 
  382   if(verbose) cout << 
"m3 destroyed. \nm1= " << m1count << 
"  " << m1addr << endl;
 
Epetra_BlockMapData: The Epetra BlockMap Data Class. 
 
Epetra_Map: A class for partitioning vectors and matrices. 
 
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 MyPID() const 
Return my process ID. 
 
int checkMapDataClass(Epetra_Comm &Comm, int verbose)
 
Epetra_MpiComm: The Epetra MPI Communication Class. 
 
int checkLocalMapDataClass(Epetra_Comm &Comm, int verbose)
 
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)
 
int ReferenceCount() const 
Get reference count. 
 
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_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[])
 
long long * MyGlobalElements64() const 
 
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.