54 #include "../epetra_test_err.h"
60 int main(
int argc,
char *argv[]) {
62 int ierr=0, returnierr=0;
65 MPI_Init(&argc,&argv);
74 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
80 int MyPID = Comm.
MyPID();
83 if (verbose && MyPID==0)
86 if (verbose) cout << Comm << endl;
88 bool verbose1 = verbose;
89 if (verbose) verbose = (MyPID==0);
91 int NumMyElements = 10000;
92 int NumMyElements1 = NumMyElements;
93 int NumGlobalElements = NumMyElements*NumProc+
EPETRA_MIN(NumProc,3);
94 if (MyPID < 3) NumMyElements++;
96 bool DistributedGlobal = (NumGlobalElements>NumMyElements);
103 cout <<
"*******************************************************************************************" << endl
104 <<
" Testing Exceptions (Expect error messages if EPETRA_NO_ERROR_REPORTS is not defined" << endl
105 <<
"*******************************************************************************************" << endl
109 if (verbose) cout <<
"Checking Epetra_Map(-2, IndexBase, Comm)" << endl;
116 if (verbose) cout <<
"Error code should be -1" << endl;
119 cout <<
"Error code = " << Error <<
"Should be -1" << endl;
123 else if (verbose) cout <<
"Checked OK\n\n" << endl;
127 if (verbose) cout <<
"Checking Epetra_Map(2, 3, IndexBase, Comm)" << endl;
134 if (verbose) cout <<
"Error code should be -4" << endl;
137 cout <<
"Error code = " << Error <<
"Should be -4" << endl;
141 else if (verbose) cout <<
"Checked OK\n\n" << endl;
144 if (verbose) cerr << flush;
145 if (verbose) cout << flush;
149 <<
"*******************************************************************************************" << endl
150 <<
" Testing valid constructor now......................................................" << endl
151 <<
"*******************************************************************************************" << endl
155 Map =
new Epetra_Map(NumGlobalElements, IndexBase, Comm);
156 if (verbose) cout <<
"Checking Epetra_Map(NumGlobalElements, IndexBase, Comm)" << endl;
157 ierr =
checkmap(*Map, NumGlobalElements, NumMyElements, 0,
158 IndexBase, Comm, DistributedGlobal);
161 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
166 Map =
new Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm);
168 if (verbose) cout <<
"Checking Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm)" << endl;
169 ierr =
checkmap(*Map, NumGlobalElements, NumMyElements, 0,
170 IndexBase, Comm, DistributedGlobal);
173 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
179 int * MyGlobalElements =
new int[NumMyElements];
180 int MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
181 if (Comm.
MyPID()>2) MaxMyGID+=3;
182 for (
int i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
184 Map =
new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements,
186 if (verbose) cout <<
"Checking Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements, IndexBase, Comm)" << endl;
187 ierr =
checkmap(*Map, NumGlobalElements, NumMyElements, MyGlobalElements,
188 IndexBase, Comm, DistributedGlobal);
191 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
196 bool same = Map1->
SameAs(*Map);
200 same = Map2->
SameAs(*Map);
206 Map2 =
new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements, IndexBase-1, Comm);
207 same = Map2->
SameAs(*Map);
212 if (verbose) cout <<
"Checking Epetra_Map(*Map)" << endl;
213 ierr =
checkmap(*Map1, NumGlobalElements, NumMyElements, MyGlobalElements,
214 IndexBase, Comm, DistributedGlobal);
217 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
224 SmallMap =
new Epetra_Map(-1, MyLen, MyEls, IndBase, Comm);
227 delete [] MyGlobalElements;
232 if (verbose) cout <<
"Checking Epetra_Map reference counting" << endl;
235 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
239 if (verbose) cout <<
"Checking Epetra_LocalMap(NumMyElements1, IndexBase, Comm)" << endl;
240 ierr =
checkmap(*LocalMap, NumMyElements1, NumMyElements1, 0, IndexBase, Comm,
false);
243 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
246 if (verbose) cout <<
"Checking Epetra_LocalMap(*LocalMap)" << endl;
247 ierr =
checkmap(*LocalMap1, NumMyElements1, NumMyElements1, 0, IndexBase, Comm,
false);
250 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
255 if (verbose) cout <<
"Checking Epetra_LocalMap reference counting" << endl;
258 if (verbose && ierr==0) cout <<
"Checked OK\n\n" <<endl;
262 if (verbose) cout <<
"Test ostream << operator" << endl << flush;
276 int NumGlobalElements = 1000;
279 Epetra_Map m1(NumGlobalElements, IndexBase, Comm);
283 if(verbose) cout <<
"Default constructor. \nm1= " << m1count <<
" " << m1addr << endl;
288 int m1countold = m1count;
290 EPETRA_TEST_ERR(!(m2count==m1count && m1count==(m1countold+1)),returnierr);
292 if(verbose) cout <<
"Copy constructor. \nm1= " << m1count <<
" " << m1addr
293 <<
"\nm2= " << m2count <<
" " << m2addr << endl;
296 m1countold = m1count;
300 if(verbose) cout <<
"m2 destroyed. \nm1= " << m1count <<
" " << m1addr << endl;
303 if(verbose) cout <<
"Assignment operator, post construction" << endl;
304 Epetra_Map m3(NumGlobalElements, IndexBase+1, Comm);
309 if(verbose) cout <<
"Prior to assignment: \nm1= " << m1count <<
" " << m1addr
310 <<
"\nm3= " << m3count <<
" " << m3addr << endl;
314 m1countold = m1count;
316 EPETRA_TEST_ERR(!(m3count==m1count && m1count==m1countold+1),returnierr);
318 if(verbose) cout <<
"After assignment: \nm1= " << m1count <<
" " << m1addr
319 <<
"\nm3= " << m3count <<
" " << m3addr << endl;
321 m1countold = m1count;
325 if(verbose) cout <<
"m3 destroyed. \nm1= " << m1count <<
" " << m1addr << endl;
332 int NumMyElements = 100;
339 if(verbose) cout <<
"Default constructor. \nm1= " << m1count <<
" " << m1addr << endl;
344 int m1countold = m1count;
346 EPETRA_TEST_ERR(!(m2count==m1count && m1count==(m1countold+1)),returnierr);
348 if(verbose) cout <<
"Copy constructor. \nm1= " << m1count <<
" " << m1addr
349 <<
"\nm2= " << m2count <<
" " << m2addr << endl;
352 m1countold = m1count;
356 if(verbose) cout <<
"m2 destroyed. \nm1= " << m1count <<
" " << m1addr << endl;
359 if(verbose) cout <<
"Assignment operator, post construction" << endl;
365 if(verbose) cout <<
"Prior to assignment: \nm1= " << m1count <<
" " << m1addr
366 <<
"\nm3= " << m3count <<
" " << m3addr << endl;
370 m1countold = m1count;
372 EPETRA_TEST_ERR(!(m3count==m1count && m1count==m1countold+1),returnierr);
374 if(verbose) cout <<
"After assignment: \nm1= " << m1count <<
" " << m1addr
375 <<
"\nm3= " << m3count <<
" " << m3addr << endl;
377 m1countold = m1count;
381 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)
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
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 IndexBase() const
Index base for this map.
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_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[])
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.