56 #include "../epetra_test_err.h"
60 int main(
int argc,
char *argv[]) {
68 MPI_Init(&argc,&argv);
71 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
85 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
92 int MyPID = Comm.
MyPID();
95 if (verbose && MyPID==0)
98 if (verbose) cout << Comm <<endl;
100 bool verbose1 = verbose;
103 if (verbose && rank!=0) verbose =
false;
105 int NumMyElements = 10000;
106 int NumMyElements1 = NumMyElements;
107 int NumGlobalElements = NumMyElements*NumProc+
EPETRA_MIN(NumProc,3);
108 if (MyPID < 3) NumMyElements++;
116 if (verbose) cout <<
"\n*********************************************************" << endl;
117 if (verbose) cout <<
"Checking Epetra_LocalMap(NumMyElements1, IndexBase, Comm)" << endl;
118 if (verbose) cout <<
" and Epetra_BlockMap(NumGlobalElements, ElementSize, IndexBase, Comm)" << endl;
119 if (verbose) cout <<
"*********************************************************" << endl;
133 if (verbose) cout <<
"\n*********************************************************" << endl;
134 if (verbose) cout <<
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm)" << endl;
135 if (verbose) cout <<
"*********************************************************" << endl;
137 BlockMap =
new Epetra_BlockMap(NumGlobalElements, NumMyElements, ElementSize, IndexBase, Comm);
148 int * MyGlobalElements =
new int[NumMyElements];
149 int MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
150 if (Comm.
MyPID()>2) MaxMyGID+=3;
151 for (i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
153 if (verbose) cout <<
"\n*********************************************************" << endl;
154 if (verbose) cout <<
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize, IndexBase, Comm)" << endl;
155 if (verbose) cout <<
"*********************************************************" << endl;
157 BlockMap =
new Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSize,
165 int * ElementSizeList =
new int[NumMyElements];
166 int NumMyEquations = 0;
167 int NumGlobalEquations = 0;
168 for (i = 0; i<NumMyElements; i++)
170 ElementSizeList[i] = i%6+2;
171 NumMyEquations += ElementSizeList[i];
174 NumGlobalEquations = Comm.
NumProc()*NumMyEquations;
180 NumGlobalEquations += 3*((NumMyElements)%6+2);
182 NumGlobalEquations -= (Comm.
NumProc()-3)*((NumMyElements-1)%6+2);
185 if (verbose) cout <<
"\n*********************************************************" << endl;
186 if (verbose) cout <<
"Checking Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSizeList, IndexBase, Comm)" << endl;
187 if (verbose) cout <<
"*********************************************************" << endl;
189 BlockMap =
new Epetra_BlockMap(NumGlobalElements, NumMyElements, MyGlobalElements, ElementSizeList,
197 if (verbose) cout <<
"\n*********************************************************" << endl;
198 if (verbose) cout <<
"Checking Epetra_BlockMap(*BlockMap)" << endl;
199 if (verbose) cout <<
"*********************************************************" << endl;
207 delete [] ElementSizeList;
208 delete [] MyGlobalElements;
215 if (verbose) cout <<
"\n*********************************************************" << endl;
216 if (verbose) cout <<
"Checking Epetra_Map(NumGlobalElements, IndexBase, Comm)" << endl;
217 if (verbose) cout <<
"*********************************************************" << endl;
228 if (verbose) cout <<
"\n*********************************************************" << endl;
229 if (verbose) cout <<
"Checking Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm)" << endl;
230 if (verbose) cout <<
"*********************************************************" << endl;
232 Map =
new Epetra_Map(NumGlobalElements, NumMyElements, IndexBase, Comm);
243 MyGlobalElements =
new int[NumMyElements];
244 MaxMyGID = (Comm.
MyPID()+1)*NumMyElements-1+IndexBase;
245 if (Comm.
MyPID()>2) MaxMyGID+=3;
246 for (i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
248 if (verbose) cout <<
"\n*********************************************************" << endl;
249 if (verbose) cout <<
"Checking Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements, IndexBase, Comm)" << endl;
250 if (verbose) cout <<
"*********************************************************" << endl;
252 Map =
new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements,
260 if (verbose) cout <<
"\n*********************************************************" << endl;
261 if (verbose) cout <<
"Checking Epetra_Map(*Map)" << endl;
262 if (verbose) cout <<
"*********************************************************" << endl;
270 delete [] MyGlobalElements;
287 if (verbose) cout <<
"Testing Assignment operator" << endl;
289 double tmp1 = 1.00001* (double) (MyPID+1);
293 cout <<
"On PE "<< MyPID <<
" A[1][1] should equal = " << tmp1;
294 if (tmp1==tmp2) cout <<
" and it does!" << endl;
295 else cout <<
" but it equals " << tmp2;
299 if (verbose) cout <<
"Testing MFLOPs" << endl;
303 C.
Multiply(
'T',
'N', 0.5, A, B, 0.0);
305 double Multiply_flops = C.
Flops();
306 if (verbose) cout <<
"\n\nTotal FLOPs = " << Multiply_flops << endl;
307 if (verbose) cout <<
"Total Time = " << Multiply_time << endl;
308 if (verbose) cout <<
"MFLOPs = " << Multiply_flops/Multiply_time/1000000.0 << endl;
316 double * Dp =
new double[200];
318 for (i=0; i<100; i++)
319 Dp[i+j*100] = i+j*100;
322 if (verbose) cout <<
"\n\nTesting ostream operator: Multivector should be 100-by-2 and print i,j indices"
328 if (verbose) cout <<
"\n\nTesting ostream operator: Same Multivector as before except using BlockMap of 25x4"
332 if (verbose) cout <<
"Traceback Mode value = " << D.
GetTracebackMode() << endl;
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
void SetFlopCounter(const Epetra_Flops &FlopCounter_in)
Set the internal Epetra_Flops() pointer.
Epetra_Map: A class for partitioning vectors and matrices.
int Random()
Set multi-vector values to random numbers.
#define EPETRA_TEST_ERR(a, b)
double ElapsedTime(void) const
Epetra_Time elapsed time function.
static void SetTracebackMode(int TracebackModeValue)
Set the value of the Epetra_Object error traceback report mode.
int MatrixTests(const Epetra_BlockMap &Map, const Epetra_LocalMap &LocalMap, int NumVectors, bool verbose)
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
Epetra_Time: The Epetra Timing Class.
int MultiVectorTests(const Epetra_Map &Map, int NumVectors, bool verbose)
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.
Epetra_Flops: The Epetra Floating Point Operations Class.
int Multiply(char TransA, char TransB, double ScalarAB, const Epetra_MultiVector &A, const Epetra_MultiVector &B, double ScalarThis)
Matrix-Matrix multiplication, this = ScalarThis*this + ScalarAB*A*B.
void Barrier() const
Epetra_SerialComm Barrier function.
static int GetTracebackMode()
Get the value of the Epetra_Object error report mode.
double Flops() const
Returns the number of floating point operations with this multi-vector.
int main(int argc, char *argv[])
Epetra_LocalMap: A class for replicating vectors and matrices across multiple processors.